| 210 | * @since 4.0.0 |
| 211 | */ |
| 212 | const 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. |