MCPcopy Create free account
hub / github.com/Effect-TS/effect / scramInitUnsafe

Function scramInitUnsafe

packages/sql/pg/src/PgAuth.ts:212–229  ·  view source on GitHub ↗
(options: {
  readonly password: string
  readonly nonce: string
})

Source from the content-addressed store, hash-verified

210 * @since 4.0.0
211 */
212const scramInitUnsafe = (options: {
213 readonly password: string
214 readonly nonce: string
215}): { readonly state: ScramFirst; readonly response: Uint8Array } => {
216 if (!/^[\x21-\x2b\x2d-\x7e]+$/.test(options.nonce)) {
217 return fail("SCRAM nonce must contain only printable ASCII characters other than comma")
218 }
219 const clientFirstMessageBare = `n=,r=${options.nonce}`
220 return {
221 state: {
222 _tag: "ScramFirst",
223 password: options.password,
224 clientNonce: options.nonce,
225 clientFirstMessageBare
226 },
227 response: textEncoder.encode(GS2_HEADER + clientFirstMessageBare)
228 }
229}
230
231/**
232 * Creates the first SCRAM-SHA-256 client message.

Callers 1

scramInitFunction · 0.85

Calls 2

encodeMethod · 0.80
failFunction · 0.70

Tested by

no test coverage detected