@simplewebauthn/server 9.0.3 → 10.0.0

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (46) hide show
  1. package/README.md +2 -2
  2. package/esm/authentication/generateAuthenticationOptions.d.ts +16 -14
  3. package/esm/authentication/generateAuthenticationOptions.js +21 -16
  4. package/esm/authentication/verifyAuthenticationResponse.d.ts +13 -18
  5. package/esm/authentication/verifyAuthenticationResponse.js +12 -17
  6. package/esm/deps.d.ts +1 -1
  7. package/esm/helpers/convertCertBufferToPEM.js +1 -1
  8. package/esm/helpers/decodeClientDataJSON.d.ts +2 -1
  9. package/esm/helpers/decodeClientDataJSON.js +1 -1
  10. package/esm/helpers/generateUserID.d.ts +7 -0
  11. package/esm/helpers/generateUserID.js +17 -0
  12. package/esm/helpers/index.d.ts +2 -1
  13. package/esm/helpers/index.js +2 -1
  14. package/esm/helpers/iso/isoBase64URL.d.ts +10 -5
  15. package/esm/helpers/iso/isoBase64URL.js +13 -7
  16. package/esm/helpers/iso/isoCrypto/getWebCrypto.d.ts +0 -289
  17. package/esm/helpers/iso/isoCrypto/getWebCrypto.js +26 -41
  18. package/esm/metadata/parseJWT.js +2 -2
  19. package/esm/registration/generateRegistrationOptions.d.ts +19 -19
  20. package/esm/registration/generateRegistrationOptions.js +40 -22
  21. package/esm/registration/verifications/verifyAttestationAndroidSafetyNet.js +2 -2
  22. package/esm/registration/verifyRegistrationResponse.d.ts +9 -12
  23. package/esm/registration/verifyRegistrationResponse.js +8 -11
  24. package/package.json +3 -3
  25. package/script/authentication/generateAuthenticationOptions.d.ts +16 -14
  26. package/script/authentication/generateAuthenticationOptions.js +21 -16
  27. package/script/authentication/verifyAuthenticationResponse.d.ts +13 -18
  28. package/script/authentication/verifyAuthenticationResponse.js +12 -17
  29. package/script/deps.d.ts +1 -1
  30. package/script/helpers/convertCertBufferToPEM.js +1 -1
  31. package/script/helpers/decodeClientDataJSON.d.ts +2 -1
  32. package/script/helpers/decodeClientDataJSON.js +1 -1
  33. package/script/helpers/generateUserID.d.ts +7 -0
  34. package/script/helpers/generateUserID.js +21 -0
  35. package/script/helpers/index.d.ts +2 -1
  36. package/script/helpers/index.js +3 -1
  37. package/script/helpers/iso/isoBase64URL.d.ts +10 -5
  38. package/script/helpers/iso/isoBase64URL.js +18 -11
  39. package/script/helpers/iso/isoCrypto/getWebCrypto.d.ts +0 -288
  40. package/script/helpers/iso/isoCrypto/getWebCrypto.js +26 -64
  41. package/script/metadata/parseJWT.js +2 -2
  42. package/script/registration/generateRegistrationOptions.d.ts +19 -19
  43. package/script/registration/generateRegistrationOptions.js +40 -22
  44. package/script/registration/verifications/verifyAttestationAndroidSafetyNet.js +2 -2
  45. package/script/registration/verifyRegistrationResponse.d.ts +9 -12
  46. package/script/registration/verifyRegistrationResponse.js +8 -11
@@ -1,11 +1,3 @@
1
- /// <reference types="node" />
2
- /// <reference types="node" />
3
- /// <reference types="node" />
4
- /// <reference types="node" />
5
- /// <reference types="node/crypto.js" />
6
- /// <reference types="node/crypto.js" />
7
- /// <reference types="node/stream.js" />
8
- /// <reference types="node/stream.js" />
9
1
  import type { Crypto } from '../../../deps.js';
10
2
  /**
11
3
  * Try to get an instance of the Crypto API from the current runtime. Should support Node,
@@ -16,287 +8,6 @@ export declare class MissingWebCrypto extends Error {
16
8
  constructor();
17
9
  }
18
10
  export declare const _getWebCryptoInternals: {
19
- stubThisImportNodeCrypto: () => Promise<{
20
- default: typeof import("crypto");
21
- createHash(algorithm: string, options?: import("crypto").HashOptions | undefined): import("crypto").Hash;
22
- createHash(algorithm: string, options?: import("crypto").HashOptions | undefined): import("crypto").Hash;
23
- createHmac(algorithm: string, key: import("crypto").KeyObject | import("crypto").BinaryLike, options?: import("stream").TransformOptions | undefined): import("crypto").Hmac;
24
- createHmac(algorithm: string, key: import("crypto").KeyObject | import("crypto").BinaryLike, options?: import("stream").TransformOptions | undefined): import("crypto").Hmac;
25
- createCipher(algorithm: import("crypto").CipherCCMTypes, password: import("crypto").BinaryLike, options: import("crypto").CipherCCMOptions): import("crypto").CipherCCM;
26
- createCipher(algorithm: import("crypto").CipherGCMTypes, password: import("crypto").BinaryLike, options?: import("crypto").CipherGCMOptions | undefined): import("crypto").CipherGCM;
27
- createCipher(algorithm: string, password: import("crypto").BinaryLike, options?: import("stream").TransformOptions | undefined): import("crypto").Cipher;
28
- createCipher(algorithm: import("crypto").CipherCCMTypes, password: import("crypto").BinaryLike, options: import("crypto").CipherCCMOptions): import("crypto").CipherCCM;
29
- createCipher(algorithm: import("crypto").CipherGCMTypes, password: import("crypto").BinaryLike, options?: import("crypto").CipherGCMOptions | undefined): import("crypto").CipherGCM;
30
- createCipher(algorithm: string, password: import("crypto").BinaryLike, options?: import("stream").TransformOptions | undefined): import("crypto").Cipher;
31
- createCipheriv(algorithm: import("crypto").CipherCCMTypes, key: import("crypto").CipherKey, iv: import("crypto").BinaryLike, options: import("crypto").CipherCCMOptions): import("crypto").CipherCCM;
32
- createCipheriv(algorithm: import("crypto").CipherOCBTypes, key: import("crypto").CipherKey, iv: import("crypto").BinaryLike, options: import("crypto").CipherOCBOptions): import("crypto").CipherOCB;
33
- createCipheriv(algorithm: import("crypto").CipherGCMTypes, key: import("crypto").CipherKey, iv: import("crypto").BinaryLike, options?: import("crypto").CipherGCMOptions | undefined): import("crypto").CipherGCM;
34
- createCipheriv(algorithm: string, key: import("crypto").CipherKey, iv: import("crypto").BinaryLike | null, options?: import("stream").TransformOptions | undefined): import("crypto").Cipher;
35
- createCipheriv(algorithm: import("crypto").CipherCCMTypes, key: import("crypto").CipherKey, iv: import("crypto").BinaryLike, options: import("crypto").CipherCCMOptions): import("crypto").CipherCCM;
36
- createCipheriv(algorithm: import("crypto").CipherOCBTypes, key: import("crypto").CipherKey, iv: import("crypto").BinaryLike, options: import("crypto").CipherOCBOptions): import("crypto").CipherOCB;
37
- createCipheriv(algorithm: import("crypto").CipherGCMTypes, key: import("crypto").CipherKey, iv: import("crypto").BinaryLike, options?: import("crypto").CipherGCMOptions | undefined): import("crypto").CipherGCM;
38
- createCipheriv(algorithm: string, key: import("crypto").CipherKey, iv: import("crypto").BinaryLike | null, options?: import("stream").TransformOptions | undefined): import("crypto").Cipher;
39
- createDecipher(algorithm: import("crypto").CipherCCMTypes, password: import("crypto").BinaryLike, options: import("crypto").CipherCCMOptions): import("crypto").DecipherCCM;
40
- createDecipher(algorithm: import("crypto").CipherGCMTypes, password: import("crypto").BinaryLike, options?: import("crypto").CipherGCMOptions | undefined): import("crypto").DecipherGCM;
41
- createDecipher(algorithm: string, password: import("crypto").BinaryLike, options?: import("stream").TransformOptions | undefined): import("crypto").Decipher;
42
- createDecipher(algorithm: import("crypto").CipherCCMTypes, password: import("crypto").BinaryLike, options: import("crypto").CipherCCMOptions): import("crypto").DecipherCCM;
43
- createDecipher(algorithm: import("crypto").CipherGCMTypes, password: import("crypto").BinaryLike, options?: import("crypto").CipherGCMOptions | undefined): import("crypto").DecipherGCM;
44
- createDecipher(algorithm: string, password: import("crypto").BinaryLike, options?: import("stream").TransformOptions | undefined): import("crypto").Decipher;
45
- createDecipheriv(algorithm: import("crypto").CipherCCMTypes, key: import("crypto").CipherKey, iv: import("crypto").BinaryLike, options: import("crypto").CipherCCMOptions): import("crypto").DecipherCCM;
46
- createDecipheriv(algorithm: import("crypto").CipherOCBTypes, key: import("crypto").CipherKey, iv: import("crypto").BinaryLike, options: import("crypto").CipherOCBOptions): import("crypto").DecipherOCB;
47
- createDecipheriv(algorithm: import("crypto").CipherGCMTypes, key: import("crypto").CipherKey, iv: import("crypto").BinaryLike, options?: import("crypto").CipherGCMOptions | undefined): import("crypto").DecipherGCM;
48
- createDecipheriv(algorithm: string, key: import("crypto").CipherKey, iv: import("crypto").BinaryLike | null, options?: import("stream").TransformOptions | undefined): import("crypto").Decipher;
49
- createDecipheriv(algorithm: import("crypto").CipherCCMTypes, key: import("crypto").CipherKey, iv: import("crypto").BinaryLike, options: import("crypto").CipherCCMOptions): import("crypto").DecipherCCM;
50
- createDecipheriv(algorithm: import("crypto").CipherOCBTypes, key: import("crypto").CipherKey, iv: import("crypto").BinaryLike, options: import("crypto").CipherOCBOptions): import("crypto").DecipherOCB;
51
- createDecipheriv(algorithm: import("crypto").CipherGCMTypes, key: import("crypto").CipherKey, iv: import("crypto").BinaryLike, options?: import("crypto").CipherGCMOptions | undefined): import("crypto").DecipherGCM;
52
- createDecipheriv(algorithm: string, key: import("crypto").CipherKey, iv: import("crypto").BinaryLike | null, options?: import("stream").TransformOptions | undefined): import("crypto").Decipher;
53
- generateKey(type: "hmac" | "aes", options: {
54
- length: number;
55
- }, callback: (err: Error | null, key: import("crypto").KeyObject) => void): void;
56
- generateKey(type: "hmac" | "aes", options: {
57
- length: number;
58
- }, callback: (err: Error | null, key: import("crypto").KeyObject) => void): void;
59
- generateKeySync(type: "hmac" | "aes", options: {
60
- length: number;
61
- }): import("crypto").KeyObject;
62
- generateKeySync(type: "hmac" | "aes", options: {
63
- length: number;
64
- }): import("crypto").KeyObject;
65
- createPrivateKey(key: string | import("crypto").PrivateKeyInput | Buffer | import("crypto").JsonWebKeyInput): import("crypto").KeyObject;
66
- createPrivateKey(key: string | import("crypto").PrivateKeyInput | Buffer | import("crypto").JsonWebKeyInput): import("crypto").KeyObject;
67
- createPublicKey(key: string | import("crypto").KeyObject | Buffer | import("crypto").JsonWebKeyInput | import("crypto").PublicKeyInput): import("crypto").KeyObject;
68
- createPublicKey(key: string | import("crypto").KeyObject | Buffer | import("crypto").JsonWebKeyInput | import("crypto").PublicKeyInput): import("crypto").KeyObject;
69
- createSecretKey(key: NodeJS.ArrayBufferView): import("crypto").KeyObject;
70
- createSecretKey(key: string, encoding: BufferEncoding): import("crypto").KeyObject;
71
- createSecretKey(key: NodeJS.ArrayBufferView): import("crypto").KeyObject;
72
- createSecretKey(key: string, encoding: BufferEncoding): import("crypto").KeyObject;
73
- createSign(algorithm: string, options?: import("stream").WritableOptions | undefined): import("crypto").Sign;
74
- createSign(algorithm: string, options?: import("stream").WritableOptions | undefined): import("crypto").Sign;
75
- createVerify(algorithm: string, options?: import("stream").WritableOptions | undefined): import("crypto").Verify;
76
- createVerify(algorithm: string, options?: import("stream").WritableOptions | undefined): import("crypto").Verify;
77
- createDiffieHellman(primeLength: number, generator?: number | undefined): import("crypto").DiffieHellman;
78
- createDiffieHellman(prime: ArrayBuffer | NodeJS.ArrayBufferView, generator?: number | ArrayBuffer | NodeJS.ArrayBufferView | undefined): import("crypto").DiffieHellman;
79
- createDiffieHellman(prime: ArrayBuffer | NodeJS.ArrayBufferView, generator: string, generatorEncoding: import("crypto").BinaryToTextEncoding): import("crypto").DiffieHellman;
80
- createDiffieHellman(prime: string, primeEncoding: import("crypto").BinaryToTextEncoding, generator?: number | ArrayBuffer | NodeJS.ArrayBufferView | undefined): import("crypto").DiffieHellman;
81
- createDiffieHellman(prime: string, primeEncoding: import("crypto").BinaryToTextEncoding, generator: string, generatorEncoding: import("crypto").BinaryToTextEncoding): import("crypto").DiffieHellman;
82
- createDiffieHellman(primeLength: number, generator?: number | undefined): import("crypto").DiffieHellman;
83
- createDiffieHellman(prime: ArrayBuffer | NodeJS.ArrayBufferView, generator?: number | ArrayBuffer | NodeJS.ArrayBufferView | undefined): import("crypto").DiffieHellman;
84
- createDiffieHellman(prime: ArrayBuffer | NodeJS.ArrayBufferView, generator: string, generatorEncoding: import("crypto").BinaryToTextEncoding): import("crypto").DiffieHellman;
85
- createDiffieHellman(prime: string, primeEncoding: import("crypto").BinaryToTextEncoding, generator?: number | ArrayBuffer | NodeJS.ArrayBufferView | undefined): import("crypto").DiffieHellman;
86
- createDiffieHellman(prime: string, primeEncoding: import("crypto").BinaryToTextEncoding, generator: string, generatorEncoding: import("crypto").BinaryToTextEncoding): import("crypto").DiffieHellman;
87
- getDiffieHellman(groupName: string): import("crypto").DiffieHellmanGroup;
88
- getDiffieHellman(groupName: string): import("crypto").DiffieHellmanGroup;
89
- createDiffieHellmanGroup(name: string): import("crypto").DiffieHellmanGroup;
90
- createDiffieHellmanGroup(name: string): import("crypto").DiffieHellmanGroup;
91
- pbkdf2(password: import("crypto").BinaryLike, salt: import("crypto").BinaryLike, iterations: number, keylen: number, digest: string, callback: (err: Error | null, derivedKey: Buffer) => void): void;
92
- pbkdf2(password: import("crypto").BinaryLike, salt: import("crypto").BinaryLike, iterations: number, keylen: number, digest: string, callback: (err: Error | null, derivedKey: Buffer) => void): void;
93
- pbkdf2Sync(password: import("crypto").BinaryLike, salt: import("crypto").BinaryLike, iterations: number, keylen: number, digest: string): Buffer;
94
- pbkdf2Sync(password: import("crypto").BinaryLike, salt: import("crypto").BinaryLike, iterations: number, keylen: number, digest: string): Buffer;
95
- randomBytes(size: number): Buffer;
96
- randomBytes(size: number, callback: (err: Error | null, buf: Buffer) => void): void;
97
- randomBytes(size: number): Buffer;
98
- randomBytes(size: number, callback: (err: Error | null, buf: Buffer) => void): void;
99
- pseudoRandomBytes(size: number): Buffer;
100
- pseudoRandomBytes(size: number, callback: (err: Error | null, buf: Buffer) => void): void;
101
- pseudoRandomBytes(size: number): Buffer;
102
- pseudoRandomBytes(size: number, callback: (err: Error | null, buf: Buffer) => void): void;
103
- randomInt(max: number): number;
104
- randomInt(min: number, max: number): number;
105
- randomInt(max: number, callback: (err: Error | null, value: number) => void): void;
106
- randomInt(min: number, max: number, callback: (err: Error | null, value: number) => void): void;
107
- randomInt(max: number): number;
108
- randomInt(min: number, max: number): number;
109
- randomInt(max: number, callback: (err: Error | null, value: number) => void): void;
110
- randomInt(min: number, max: number, callback: (err: Error | null, value: number) => void): void;
111
- randomFillSync<T extends NodeJS.ArrayBufferView>(buffer: T, offset?: number | undefined, size?: number | undefined): T;
112
- randomFillSync<T_1 extends NodeJS.ArrayBufferView>(buffer: T_1, offset?: number | undefined, size?: number | undefined): T_1;
113
- randomFill<T_2 extends NodeJS.ArrayBufferView>(buffer: T_2, callback: (err: Error | null, buf: T_2) => void): void;
114
- randomFill<T_3 extends NodeJS.ArrayBufferView>(buffer: T_3, offset: number, callback: (err: Error | null, buf: T_3) => void): void;
115
- randomFill<T_4 extends NodeJS.ArrayBufferView>(buffer: T_4, offset: number, size: number, callback: (err: Error | null, buf: T_4) => void): void;
116
- randomFill<T_5 extends NodeJS.ArrayBufferView>(buffer: T_5, callback: (err: Error | null, buf: T_5) => void): void;
117
- randomFill<T_6 extends NodeJS.ArrayBufferView>(buffer: T_6, offset: number, callback: (err: Error | null, buf: T_6) => void): void;
118
- randomFill<T_7 extends NodeJS.ArrayBufferView>(buffer: T_7, offset: number, size: number, callback: (err: Error | null, buf: T_7) => void): void;
119
- scrypt(password: import("crypto").BinaryLike, salt: import("crypto").BinaryLike, keylen: number, callback: (err: Error | null, derivedKey: Buffer) => void): void;
120
- scrypt(password: import("crypto").BinaryLike, salt: import("crypto").BinaryLike, keylen: number, options: import("crypto").ScryptOptions, callback: (err: Error | null, derivedKey: Buffer) => void): void;
121
- scrypt(password: import("crypto").BinaryLike, salt: import("crypto").BinaryLike, keylen: number, callback: (err: Error | null, derivedKey: Buffer) => void): void;
122
- scrypt(password: import("crypto").BinaryLike, salt: import("crypto").BinaryLike, keylen: number, options: import("crypto").ScryptOptions, callback: (err: Error | null, derivedKey: Buffer) => void): void;
123
- scryptSync(password: import("crypto").BinaryLike, salt: import("crypto").BinaryLike, keylen: number, options?: import("crypto").ScryptOptions | undefined): Buffer;
124
- scryptSync(password: import("crypto").BinaryLike, salt: import("crypto").BinaryLike, keylen: number, options?: import("crypto").ScryptOptions | undefined): Buffer;
125
- publicEncrypt(key: import("crypto").RsaPublicKey | import("crypto").RsaPrivateKey | import("crypto").KeyLike, buffer: NodeJS.ArrayBufferView): Buffer;
126
- publicEncrypt(key: import("crypto").RsaPublicKey | import("crypto").RsaPrivateKey | import("crypto").KeyLike, buffer: NodeJS.ArrayBufferView): Buffer;
127
- publicDecrypt(key: import("crypto").RsaPublicKey | import("crypto").RsaPrivateKey | import("crypto").KeyLike, buffer: NodeJS.ArrayBufferView): Buffer;
128
- publicDecrypt(key: import("crypto").RsaPublicKey | import("crypto").RsaPrivateKey | import("crypto").KeyLike, buffer: NodeJS.ArrayBufferView): Buffer;
129
- privateDecrypt(privateKey: import("crypto").RsaPrivateKey | import("crypto").KeyLike, buffer: NodeJS.ArrayBufferView): Buffer;
130
- privateDecrypt(privateKey: import("crypto").RsaPrivateKey | import("crypto").KeyLike, buffer: NodeJS.ArrayBufferView): Buffer;
131
- privateEncrypt(privateKey: import("crypto").RsaPrivateKey | import("crypto").KeyLike, buffer: NodeJS.ArrayBufferView): Buffer;
132
- privateEncrypt(privateKey: import("crypto").RsaPrivateKey | import("crypto").KeyLike, buffer: NodeJS.ArrayBufferView): Buffer;
133
- getCiphers(): string[];
134
- getCiphers(): string[];
135
- getCurves(): string[];
136
- getCurves(): string[];
137
- getFips(): 0 | 1;
138
- getFips(): 0 | 1;
139
- setFips(bool: boolean): void;
140
- setFips(bool: boolean): void;
141
- getHashes(): string[];
142
- getHashes(): string[];
143
- createECDH(curveName: string): import("crypto").ECDH;
144
- createECDH(curveName: string): import("crypto").ECDH;
145
- timingSafeEqual(a: NodeJS.ArrayBufferView, b: NodeJS.ArrayBufferView): boolean;
146
- timingSafeEqual(a: NodeJS.ArrayBufferView, b: NodeJS.ArrayBufferView): boolean;
147
- generateKeyPairSync(type: "rsa", options: import("crypto").RSAKeyPairOptions<"pem", "pem">): import("crypto").KeyPairSyncResult<string, string>;
148
- generateKeyPairSync(type: "rsa", options: import("crypto").RSAKeyPairOptions<"pem", "der">): import("crypto").KeyPairSyncResult<string, Buffer>;
149
- generateKeyPairSync(type: "rsa", options: import("crypto").RSAKeyPairOptions<"der", "pem">): import("crypto").KeyPairSyncResult<Buffer, string>;
150
- generateKeyPairSync(type: "rsa", options: import("crypto").RSAKeyPairOptions<"der", "der">): import("crypto").KeyPairSyncResult<Buffer, Buffer>;
151
- generateKeyPairSync(type: "rsa", options: import("crypto").RSAKeyPairKeyObjectOptions): import("crypto").KeyPairKeyObjectResult;
152
- generateKeyPairSync(type: "rsa-pss", options: import("crypto").RSAPSSKeyPairOptions<"pem", "pem">): import("crypto").KeyPairSyncResult<string, string>;
153
- generateKeyPairSync(type: "rsa-pss", options: import("crypto").RSAPSSKeyPairOptions<"pem", "der">): import("crypto").KeyPairSyncResult<string, Buffer>;
154
- generateKeyPairSync(type: "rsa-pss", options: import("crypto").RSAPSSKeyPairOptions<"der", "pem">): import("crypto").KeyPairSyncResult<Buffer, string>;
155
- generateKeyPairSync(type: "rsa-pss", options: import("crypto").RSAPSSKeyPairOptions<"der", "der">): import("crypto").KeyPairSyncResult<Buffer, Buffer>;
156
- generateKeyPairSync(type: "rsa-pss", options: import("crypto").RSAPSSKeyPairKeyObjectOptions): import("crypto").KeyPairKeyObjectResult;
157
- generateKeyPairSync(type: "dsa", options: import("crypto").DSAKeyPairOptions<"pem", "pem">): import("crypto").KeyPairSyncResult<string, string>;
158
- generateKeyPairSync(type: "dsa", options: import("crypto").DSAKeyPairOptions<"pem", "der">): import("crypto").KeyPairSyncResult<string, Buffer>;
159
- generateKeyPairSync(type: "dsa", options: import("crypto").DSAKeyPairOptions<"der", "pem">): import("crypto").KeyPairSyncResult<Buffer, string>;
160
- generateKeyPairSync(type: "dsa", options: import("crypto").DSAKeyPairOptions<"der", "der">): import("crypto").KeyPairSyncResult<Buffer, Buffer>;
161
- generateKeyPairSync(type: "dsa", options: import("crypto").DSAKeyPairKeyObjectOptions): import("crypto").KeyPairKeyObjectResult;
162
- generateKeyPairSync(type: "ec", options: import("crypto").ECKeyPairOptions<"pem", "pem">): import("crypto").KeyPairSyncResult<string, string>;
163
- generateKeyPairSync(type: "ec", options: import("crypto").ECKeyPairOptions<"pem", "der">): import("crypto").KeyPairSyncResult<string, Buffer>;
164
- generateKeyPairSync(type: "ec", options: import("crypto").ECKeyPairOptions<"der", "pem">): import("crypto").KeyPairSyncResult<Buffer, string>;
165
- generateKeyPairSync(type: "ec", options: import("crypto").ECKeyPairOptions<"der", "der">): import("crypto").KeyPairSyncResult<Buffer, Buffer>;
166
- generateKeyPairSync(type: "ec", options: import("crypto").ECKeyPairKeyObjectOptions): import("crypto").KeyPairKeyObjectResult;
167
- generateKeyPairSync(type: "ed25519", options: import("crypto").ED25519KeyPairOptions<"pem", "pem">): import("crypto").KeyPairSyncResult<string, string>;
168
- generateKeyPairSync(type: "ed25519", options: import("crypto").ED25519KeyPairOptions<"pem", "der">): import("crypto").KeyPairSyncResult<string, Buffer>;
169
- generateKeyPairSync(type: "ed25519", options: import("crypto").ED25519KeyPairOptions<"der", "pem">): import("crypto").KeyPairSyncResult<Buffer, string>;
170
- generateKeyPairSync(type: "ed25519", options: import("crypto").ED25519KeyPairOptions<"der", "der">): import("crypto").KeyPairSyncResult<Buffer, Buffer>;
171
- generateKeyPairSync(type: "ed25519", options?: import("crypto").ED25519KeyPairKeyObjectOptions | undefined): import("crypto").KeyPairKeyObjectResult;
172
- generateKeyPairSync(type: "ed448", options: import("crypto").ED448KeyPairOptions<"pem", "pem">): import("crypto").KeyPairSyncResult<string, string>;
173
- generateKeyPairSync(type: "ed448", options: import("crypto").ED448KeyPairOptions<"pem", "der">): import("crypto").KeyPairSyncResult<string, Buffer>;
174
- generateKeyPairSync(type: "ed448", options: import("crypto").ED448KeyPairOptions<"der", "pem">): import("crypto").KeyPairSyncResult<Buffer, string>;
175
- generateKeyPairSync(type: "ed448", options: import("crypto").ED448KeyPairOptions<"der", "der">): import("crypto").KeyPairSyncResult<Buffer, Buffer>;
176
- generateKeyPairSync(type: "ed448", options?: import("crypto").ED448KeyPairKeyObjectOptions | undefined): import("crypto").KeyPairKeyObjectResult;
177
- generateKeyPairSync(type: "x25519", options: import("crypto").X25519KeyPairOptions<"pem", "pem">): import("crypto").KeyPairSyncResult<string, string>;
178
- generateKeyPairSync(type: "x25519", options: import("crypto").X25519KeyPairOptions<"pem", "der">): import("crypto").KeyPairSyncResult<string, Buffer>;
179
- generateKeyPairSync(type: "x25519", options: import("crypto").X25519KeyPairOptions<"der", "pem">): import("crypto").KeyPairSyncResult<Buffer, string>;
180
- generateKeyPairSync(type: "x25519", options: import("crypto").X25519KeyPairOptions<"der", "der">): import("crypto").KeyPairSyncResult<Buffer, Buffer>;
181
- generateKeyPairSync(type: "x25519", options?: import("crypto").X25519KeyPairKeyObjectOptions | undefined): import("crypto").KeyPairKeyObjectResult;
182
- generateKeyPairSync(type: "x448", options: import("crypto").X448KeyPairOptions<"pem", "pem">): import("crypto").KeyPairSyncResult<string, string>;
183
- generateKeyPairSync(type: "x448", options: import("crypto").X448KeyPairOptions<"pem", "der">): import("crypto").KeyPairSyncResult<string, Buffer>;
184
- generateKeyPairSync(type: "x448", options: import("crypto").X448KeyPairOptions<"der", "pem">): import("crypto").KeyPairSyncResult<Buffer, string>;
185
- generateKeyPairSync(type: "x448", options: import("crypto").X448KeyPairOptions<"der", "der">): import("crypto").KeyPairSyncResult<Buffer, Buffer>;
186
- generateKeyPairSync(type: "x448", options?: import("crypto").X448KeyPairKeyObjectOptions | undefined): import("crypto").KeyPairKeyObjectResult;
187
- generateKeyPairSync(type: "rsa", options: import("crypto").RSAKeyPairOptions<"pem", "pem">): import("crypto").KeyPairSyncResult<string, string>;
188
- generateKeyPairSync(type: "rsa", options: import("crypto").RSAKeyPairOptions<"pem", "der">): import("crypto").KeyPairSyncResult<string, Buffer>;
189
- generateKeyPairSync(type: "rsa", options: import("crypto").RSAKeyPairOptions<"der", "pem">): import("crypto").KeyPairSyncResult<Buffer, string>;
190
- generateKeyPairSync(type: "rsa", options: import("crypto").RSAKeyPairOptions<"der", "der">): import("crypto").KeyPairSyncResult<Buffer, Buffer>;
191
- generateKeyPairSync(type: "rsa", options: import("crypto").RSAKeyPairKeyObjectOptions): import("crypto").KeyPairKeyObjectResult;
192
- generateKeyPairSync(type: "rsa-pss", options: import("crypto").RSAPSSKeyPairOptions<"pem", "pem">): import("crypto").KeyPairSyncResult<string, string>;
193
- generateKeyPairSync(type: "rsa-pss", options: import("crypto").RSAPSSKeyPairOptions<"pem", "der">): import("crypto").KeyPairSyncResult<string, Buffer>;
194
- generateKeyPairSync(type: "rsa-pss", options: import("crypto").RSAPSSKeyPairOptions<"der", "pem">): import("crypto").KeyPairSyncResult<Buffer, string>;
195
- generateKeyPairSync(type: "rsa-pss", options: import("crypto").RSAPSSKeyPairOptions<"der", "der">): import("crypto").KeyPairSyncResult<Buffer, Buffer>;
196
- generateKeyPairSync(type: "rsa-pss", options: import("crypto").RSAPSSKeyPairKeyObjectOptions): import("crypto").KeyPairKeyObjectResult;
197
- generateKeyPairSync(type: "dsa", options: import("crypto").DSAKeyPairOptions<"pem", "pem">): import("crypto").KeyPairSyncResult<string, string>;
198
- generateKeyPairSync(type: "dsa", options: import("crypto").DSAKeyPairOptions<"pem", "der">): import("crypto").KeyPairSyncResult<string, Buffer>;
199
- generateKeyPairSync(type: "dsa", options: import("crypto").DSAKeyPairOptions<"der", "pem">): import("crypto").KeyPairSyncResult<Buffer, string>;
200
- generateKeyPairSync(type: "dsa", options: import("crypto").DSAKeyPairOptions<"der", "der">): import("crypto").KeyPairSyncResult<Buffer, Buffer>;
201
- generateKeyPairSync(type: "dsa", options: import("crypto").DSAKeyPairKeyObjectOptions): import("crypto").KeyPairKeyObjectResult;
202
- generateKeyPairSync(type: "ec", options: import("crypto").ECKeyPairOptions<"pem", "pem">): import("crypto").KeyPairSyncResult<string, string>;
203
- generateKeyPairSync(type: "ec", options: import("crypto").ECKeyPairOptions<"pem", "der">): import("crypto").KeyPairSyncResult<string, Buffer>;
204
- generateKeyPairSync(type: "ec", options: import("crypto").ECKeyPairOptions<"der", "pem">): import("crypto").KeyPairSyncResult<Buffer, string>;
205
- generateKeyPairSync(type: "ec", options: import("crypto").ECKeyPairOptions<"der", "der">): import("crypto").KeyPairSyncResult<Buffer, Buffer>;
206
- generateKeyPairSync(type: "ec", options: import("crypto").ECKeyPairKeyObjectOptions): import("crypto").KeyPairKeyObjectResult;
207
- generateKeyPairSync(type: "ed25519", options: import("crypto").ED25519KeyPairOptions<"pem", "pem">): import("crypto").KeyPairSyncResult<string, string>;
208
- generateKeyPairSync(type: "ed25519", options: import("crypto").ED25519KeyPairOptions<"pem", "der">): import("crypto").KeyPairSyncResult<string, Buffer>;
209
- generateKeyPairSync(type: "ed25519", options: import("crypto").ED25519KeyPairOptions<"der", "pem">): import("crypto").KeyPairSyncResult<Buffer, string>;
210
- generateKeyPairSync(type: "ed25519", options: import("crypto").ED25519KeyPairOptions<"der", "der">): import("crypto").KeyPairSyncResult<Buffer, Buffer>;
211
- generateKeyPairSync(type: "ed25519", options?: import("crypto").ED25519KeyPairKeyObjectOptions | undefined): import("crypto").KeyPairKeyObjectResult;
212
- generateKeyPairSync(type: "ed448", options: import("crypto").ED448KeyPairOptions<"pem", "pem">): import("crypto").KeyPairSyncResult<string, string>;
213
- generateKeyPairSync(type: "ed448", options: import("crypto").ED448KeyPairOptions<"pem", "der">): import("crypto").KeyPairSyncResult<string, Buffer>;
214
- generateKeyPairSync(type: "ed448", options: import("crypto").ED448KeyPairOptions<"der", "pem">): import("crypto").KeyPairSyncResult<Buffer, string>;
215
- generateKeyPairSync(type: "ed448", options: import("crypto").ED448KeyPairOptions<"der", "der">): import("crypto").KeyPairSyncResult<Buffer, Buffer>;
216
- generateKeyPairSync(type: "ed448", options?: import("crypto").ED448KeyPairKeyObjectOptions | undefined): import("crypto").KeyPairKeyObjectResult;
217
- generateKeyPairSync(type: "x25519", options: import("crypto").X25519KeyPairOptions<"pem", "pem">): import("crypto").KeyPairSyncResult<string, string>;
218
- generateKeyPairSync(type: "x25519", options: import("crypto").X25519KeyPairOptions<"pem", "der">): import("crypto").KeyPairSyncResult<string, Buffer>;
219
- generateKeyPairSync(type: "x25519", options: import("crypto").X25519KeyPairOptions<"der", "pem">): import("crypto").KeyPairSyncResult<Buffer, string>;
220
- generateKeyPairSync(type: "x25519", options: import("crypto").X25519KeyPairOptions<"der", "der">): import("crypto").KeyPairSyncResult<Buffer, Buffer>;
221
- generateKeyPairSync(type: "x25519", options?: import("crypto").X25519KeyPairKeyObjectOptions | undefined): import("crypto").KeyPairKeyObjectResult;
222
- generateKeyPairSync(type: "x448", options: import("crypto").X448KeyPairOptions<"pem", "pem">): import("crypto").KeyPairSyncResult<string, string>;
223
- generateKeyPairSync(type: "x448", options: import("crypto").X448KeyPairOptions<"pem", "der">): import("crypto").KeyPairSyncResult<string, Buffer>;
224
- generateKeyPairSync(type: "x448", options: import("crypto").X448KeyPairOptions<"der", "pem">): import("crypto").KeyPairSyncResult<Buffer, string>;
225
- generateKeyPairSync(type: "x448", options: import("crypto").X448KeyPairOptions<"der", "der">): import("crypto").KeyPairSyncResult<Buffer, Buffer>;
226
- generateKeyPairSync(type: "x448", options?: import("crypto").X448KeyPairKeyObjectOptions | undefined): import("crypto").KeyPairKeyObjectResult;
227
- generateKeyPair: typeof import("crypto").generateKeyPair;
228
- sign(algorithm: string | null | undefined, data: NodeJS.ArrayBufferView, key: import("crypto").KeyLike | import("crypto").SignKeyObjectInput | import("crypto").SignPrivateKeyInput): Buffer;
229
- sign(algorithm: string | null | undefined, data: NodeJS.ArrayBufferView, key: import("crypto").KeyLike | import("crypto").SignKeyObjectInput | import("crypto").SignPrivateKeyInput, callback: (error: Error | null, data: Buffer) => void): void;
230
- sign(algorithm: string | null | undefined, data: NodeJS.ArrayBufferView, key: import("crypto").KeyLike | import("crypto").SignKeyObjectInput | import("crypto").SignPrivateKeyInput): Buffer;
231
- sign(algorithm: string | null | undefined, data: NodeJS.ArrayBufferView, key: import("crypto").KeyLike | import("crypto").SignKeyObjectInput | import("crypto").SignPrivateKeyInput, callback: (error: Error | null, data: Buffer) => void): void;
232
- verify(algorithm: string | null | undefined, data: NodeJS.ArrayBufferView, key: import("crypto").KeyLike | import("crypto").VerifyKeyObjectInput | import("crypto").VerifyPublicKeyInput | import("crypto").VerifyJsonWebKeyInput, signature: NodeJS.ArrayBufferView): boolean;
233
- verify(algorithm: string | null | undefined, data: NodeJS.ArrayBufferView, key: import("crypto").KeyLike | import("crypto").VerifyKeyObjectInput | import("crypto").VerifyPublicKeyInput | import("crypto").VerifyJsonWebKeyInput, signature: NodeJS.ArrayBufferView, callback: (error: Error | null, result: boolean) => void): void;
234
- verify(algorithm: string | null | undefined, data: NodeJS.ArrayBufferView, key: import("crypto").KeyLike | import("crypto").VerifyKeyObjectInput | import("crypto").VerifyPublicKeyInput | import("crypto").VerifyJsonWebKeyInput, signature: NodeJS.ArrayBufferView): boolean;
235
- verify(algorithm: string | null | undefined, data: NodeJS.ArrayBufferView, key: import("crypto").KeyLike | import("crypto").VerifyKeyObjectInput | import("crypto").VerifyPublicKeyInput | import("crypto").VerifyJsonWebKeyInput, signature: NodeJS.ArrayBufferView, callback: (error: Error | null, result: boolean) => void): void;
236
- diffieHellman(options: {
237
- privateKey: import("crypto").KeyObject;
238
- publicKey: import("crypto").KeyObject;
239
- }): Buffer;
240
- diffieHellman(options: {
241
- privateKey: import("crypto").KeyObject;
242
- publicKey: import("crypto").KeyObject;
243
- }): Buffer;
244
- getCipherInfo(nameOrNid: string | number, options?: import("crypto").CipherInfoOptions | undefined): import("crypto").CipherInfo | undefined;
245
- getCipherInfo(nameOrNid: string | number, options?: import("crypto").CipherInfoOptions | undefined): import("crypto").CipherInfo | undefined;
246
- hkdf(digest: string, irm: import("crypto").KeyObject | import("crypto").BinaryLike, salt: import("crypto").BinaryLike, info: import("crypto").BinaryLike, keylen: number, callback: (err: Error | null, derivedKey: ArrayBuffer) => void): void;
247
- hkdf(digest: string, irm: import("crypto").KeyObject | import("crypto").BinaryLike, salt: import("crypto").BinaryLike, info: import("crypto").BinaryLike, keylen: number, callback: (err: Error | null, derivedKey: ArrayBuffer) => void): void;
248
- hkdfSync(digest: string, ikm: import("crypto").KeyObject | import("crypto").BinaryLike, salt: import("crypto").BinaryLike, info: import("crypto").BinaryLike, keylen: number): ArrayBuffer;
249
- hkdfSync(digest: string, ikm: import("crypto").KeyObject | import("crypto").BinaryLike, salt: import("crypto").BinaryLike, info: import("crypto").BinaryLike, keylen: number): ArrayBuffer;
250
- secureHeapUsed(): import("crypto").SecureHeapUsage;
251
- secureHeapUsed(): import("crypto").SecureHeapUsage;
252
- randomUUID(options?: import("crypto").RandomUUIDOptions | undefined): `${string}-${string}-${string}-${string}-${string}`;
253
- randomUUID(options?: import("crypto").RandomUUIDOptions | undefined): `${string}-${string}-${string}-${string}-${string}`;
254
- generatePrime(size: number, callback: (err: Error | null, prime: ArrayBuffer) => void): void;
255
- generatePrime(size: number, options: import("crypto").GeneratePrimeOptionsBigInt, callback: (err: Error | null, prime: bigint) => void): void;
256
- generatePrime(size: number, options: import("crypto").GeneratePrimeOptionsArrayBuffer, callback: (err: Error | null, prime: ArrayBuffer) => void): void;
257
- generatePrime(size: number, options: import("crypto").GeneratePrimeOptions, callback: (err: Error | null, prime: bigint | ArrayBuffer) => void): void;
258
- generatePrime(size: number, callback: (err: Error | null, prime: ArrayBuffer) => void): void;
259
- generatePrime(size: number, options: import("crypto").GeneratePrimeOptionsBigInt, callback: (err: Error | null, prime: bigint) => void): void;
260
- generatePrime(size: number, options: import("crypto").GeneratePrimeOptionsArrayBuffer, callback: (err: Error | null, prime: ArrayBuffer) => void): void;
261
- generatePrime(size: number, options: import("crypto").GeneratePrimeOptions, callback: (err: Error | null, prime: bigint | ArrayBuffer) => void): void;
262
- generatePrimeSync(size: number): ArrayBuffer;
263
- generatePrimeSync(size: number, options: import("crypto").GeneratePrimeOptionsBigInt): bigint;
264
- generatePrimeSync(size: number, options: import("crypto").GeneratePrimeOptionsArrayBuffer): ArrayBuffer;
265
- generatePrimeSync(size: number, options: import("crypto").GeneratePrimeOptions): bigint | ArrayBuffer;
266
- generatePrimeSync(size: number): ArrayBuffer;
267
- generatePrimeSync(size: number, options: import("crypto").GeneratePrimeOptionsBigInt): bigint;
268
- generatePrimeSync(size: number, options: import("crypto").GeneratePrimeOptionsArrayBuffer): ArrayBuffer;
269
- generatePrimeSync(size: number, options: import("crypto").GeneratePrimeOptions): bigint | ArrayBuffer;
270
- checkPrime(value: import("crypto").LargeNumberLike, callback: (err: Error | null, result: boolean) => void): void;
271
- checkPrime(value: import("crypto").LargeNumberLike, options: import("crypto").CheckPrimeOptions, callback: (err: Error | null, result: boolean) => void): void;
272
- checkPrime(value: import("crypto").LargeNumberLike, callback: (err: Error | null, result: boolean) => void): void;
273
- checkPrime(value: import("crypto").LargeNumberLike, options: import("crypto").CheckPrimeOptions, callback: (err: Error | null, result: boolean) => void): void;
274
- checkPrimeSync(candidate: import("crypto").LargeNumberLike, options?: import("crypto").CheckPrimeOptions | undefined): boolean;
275
- checkPrimeSync(candidate: import("crypto").LargeNumberLike, options?: import("crypto").CheckPrimeOptions | undefined): boolean;
276
- setEngine(engine: string, flags?: number | undefined): void;
277
- setEngine(engine: string, flags?: number | undefined): void;
278
- getRandomValues<T_8 extends import("crypto").webcrypto.BufferSource>(typedArray: T_8): T_8;
279
- getRandomValues<T_9 extends import("crypto").webcrypto.BufferSource>(typedArray: T_9): T_9;
280
- Certificate: typeof import("crypto").Certificate;
281
- constants: typeof import("crypto").constants;
282
- fips: boolean;
283
- Hash: typeof import("crypto").Hash;
284
- Hmac: typeof import("crypto").Hmac;
285
- KeyObject: typeof import("crypto").KeyObject;
286
- Cipher: typeof import("crypto").Cipher;
287
- Decipher: typeof import("crypto").Decipher;
288
- Sign: typeof import("crypto").Sign;
289
- Verify: typeof import("crypto").Verify;
290
- DiffieHellman: typeof import("crypto").DiffieHellman;
291
- DiffieHellmanGroup: import("crypto").DiffieHellmanGroupConstructor;
292
- ECDH: typeof import("crypto").ECDH;
293
- DEFAULT_ENCODING: BufferEncoding;
294
- X509Certificate: typeof import("crypto").X509Certificate;
295
- subtle: import("crypto").webcrypto.SubtleCrypto;
296
- webcrypto: import("crypto").webcrypto.Crypto;
297
- } | {
298
- webcrypto: undefined;
299
- }>;
300
11
  stubThisGlobalThisCrypto: () => globalThis.Crypto;
301
12
  setCachedCrypto: (newCrypto: Crypto | undefined) => void;
302
13
  };
@@ -3,29 +3,34 @@ let webCrypto = undefined;
3
3
  * Try to get an instance of the Crypto API from the current runtime. Should support Node,
4
4
  * as well as others, like Deno, that implement Web APIs.
5
5
  */
6
- export async function getWebCrypto() {
7
- if (webCrypto) {
8
- return webCrypto;
9
- }
6
+ export function getWebCrypto() {
10
7
  /**
11
- * Naively attempt to access Crypto as a global object, which popular alternative run-times
12
- * support.
8
+ * Hello there! If you came here wondering why this method is asynchronous when use of
9
+ * `globalThis.crypto` is not, it's to minimize a bunch of refactor related to making this
10
+ * synchronous. For example, `generateRegistrationOptions()` and `generateAuthenticationOptions()`
11
+ * become synchronous if we make this synchronous (since nothing else in that method is async)
12
+ * which represents a breaking API change in this library's core API.
13
+ *
14
+ * TODO: If it's after February 2025 when you read this then consider whether it still makes sense
15
+ * to keep this method asynchronous.
13
16
  */
14
- const _globalThisCrypto = _getWebCryptoInternals.stubThisGlobalThisCrypto();
15
- if (_globalThisCrypto) {
16
- webCrypto = _globalThisCrypto;
17
- return webCrypto;
18
- }
19
- /**
20
- * `globalThis.crypto` isn't available, so attempt a Node import...
21
- */
22
- const _nodeCrypto = await _getWebCryptoInternals.stubThisImportNodeCrypto();
23
- if (_nodeCrypto?.webcrypto) {
24
- webCrypto = _nodeCrypto.webcrypto;
25
- return webCrypto;
26
- }
27
- // We tried to access it both in Node and globally, so bail out
28
- throw new MissingWebCrypto();
17
+ const toResolve = new Promise((resolve, reject) => {
18
+ if (webCrypto) {
19
+ return resolve(webCrypto);
20
+ }
21
+ /**
22
+ * Naively attempt to access Crypto as a global object, which popular ESM-centric run-times
23
+ * support (and Node v20+)
24
+ */
25
+ const _globalThisCrypto = _getWebCryptoInternals.stubThisGlobalThisCrypto();
26
+ if (_globalThisCrypto) {
27
+ webCrypto = _globalThisCrypto;
28
+ return resolve(webCrypto);
29
+ }
30
+ // We tried to access it both in Node and globally, so bail out
31
+ return reject(new MissingWebCrypto());
32
+ });
33
+ return toResolve;
29
34
  }
30
35
  export class MissingWebCrypto extends Error {
31
36
  constructor() {
@@ -36,26 +41,6 @@ export class MissingWebCrypto extends Error {
36
41
  }
37
42
  // Make it possible to stub return values during testing
38
43
  export const _getWebCryptoInternals = {
39
- stubThisImportNodeCrypto: async () => {
40
- try {
41
- // dnt-shim-ignore
42
- /**
43
- * The `webpackIgnore` here is to help support Next.js' Edge runtime.
44
- * See https://github.com/MasterKale/SimpleWebAuthn/issues/517 for more info.
45
- */
46
- const _nodeCrypto = await import(/* webpackIgnore: true */ 'crypto');
47
- return _nodeCrypto;
48
- }
49
- catch (_err) {
50
- /**
51
- * Intentionally declaring webcrypto as undefined because we're assuming the Node import
52
- * failed due to either:
53
- * - `import()` isn't supported
54
- * - `node:crypto` is unavailable.
55
- */
56
- return { webcrypto: undefined };
57
- }
58
- },
59
44
  stubThisGlobalThisCrypto: () => globalThis.crypto,
60
45
  // Make it possible to reset the `webCrypto` at the top of the file
61
46
  setCachedCrypto: (newCrypto) => {
@@ -5,8 +5,8 @@ import { isoBase64URL } from '../helpers/iso/index.js';
5
5
  export function parseJWT(jwt) {
6
6
  const parts = jwt.split('.');
7
7
  return [
8
- JSON.parse(isoBase64URL.toString(parts[0])),
9
- JSON.parse(isoBase64URL.toString(parts[1])),
8
+ JSON.parse(isoBase64URL.toUTF8String(parts[0])),
9
+ JSON.parse(isoBase64URL.toUTF8String(parts[1])),
10
10
  parts[2],
11
11
  ];
12
12
  }
@@ -1,14 +1,17 @@
1
- import type { AttestationConveyancePreference, AuthenticationExtensionsClientInputs, AuthenticatorSelectionCriteria, COSEAlgorithmIdentifier, PublicKeyCredentialCreationOptionsJSON, PublicKeyCredentialDescriptorFuture } from '../deps.js';
1
+ import type { AttestationConveyancePreference, AuthenticationExtensionsClientInputs, AuthenticatorSelectionCriteria, AuthenticatorTransportFuture, Base64URLString, COSEAlgorithmIdentifier, PublicKeyCredentialCreationOptionsJSON } from '../deps.js';
2
2
  export type GenerateRegistrationOptionsOpts = {
3
3
  rpName: string;
4
4
  rpID: string;
5
- userID: string;
6
5
  userName: string;
6
+ userID?: Uint8Array;
7
7
  challenge?: string | Uint8Array;
8
8
  userDisplayName?: string;
9
9
  timeout?: number;
10
10
  attestationType?: AttestationConveyancePreference;
11
- excludeCredentials?: PublicKeyCredentialDescriptorFuture[];
11
+ excludeCredentials?: {
12
+ id: Base64URLString;
13
+ transports?: AuthenticatorTransportFuture[];
14
+ }[];
12
15
  authenticatorSelection?: AuthenticatorSelectionCriteria;
13
16
  extensions?: AuthenticationExtensionsClientInputs;
14
17
  supportedAlgorithmIDs?: COSEAlgorithmIdentifier[];
@@ -20,24 +23,21 @@ export type GenerateRegistrationOptionsOpts = {
20
23
  */
21
24
  export declare const supportedCOSEAlgorithmIdentifiers: COSEAlgorithmIdentifier[];
22
25
  /**
23
- * Prepare a value to pass into navigator.credentials.create(...) for authenticator "registration"
26
+ * Prepare a value to pass into navigator.credentials.create(...) for authenticator registration
24
27
  *
25
28
  * **Options:**
26
29
  *
27
- * @param rpName User-visible, "friendly" website/service name
28
- * @param rpID Valid domain name (after `https://`)
29
- * @param userID User's website-specific unique ID
30
- * @param userName User's website-specific username (email, etc...)
31
- * @param challenge Random value the authenticator needs to sign and pass back
32
- * @param userDisplayName User's actual name
33
- * @param timeout How long (in ms) the user can take to complete attestation
34
- * @param attestationType Specific attestation statement
35
- * @param excludeCredentials Authenticators registered by the user so the user can't register the
36
- * same credential multiple times
37
- * @param authenticatorSelection Advanced criteria for restricting the types of authenticators that
38
- * may be used
39
- * @param extensions Additional plugins the authenticator or browser should use during attestation
40
- * @param supportedAlgorithmIDs Array of numeric COSE algorithm identifiers supported for
41
- * attestation by this RP. See https://www.iana.org/assignments/cose/cose.xhtml#algorithms
30
+ * @param rpName - User-visible, "friendly" website/service name
31
+ * @param rpID - Valid domain name (after `https://`)
32
+ * @param userName - User's website-specific username (email, etc...)
33
+ * @param userID **(Optional)** - User's website-specific unique ID. Defaults to generating a random identifier
34
+ * @param challenge **(Optional)** - Random value the authenticator needs to sign and pass back. Defaults to generating a random value
35
+ * @param userDisplayName **(Optional)** - User's actual name. Defaults to `""`
36
+ * @param timeout **(Optional)** - How long (in ms) the user can take to complete attestation. Defaults to `60000`
37
+ * @param attestationType **(Optional)** - Specific attestation statement. Defaults to `"none"`
38
+ * @param excludeCredentials **(Optional)** - Authenticators registered by the user so the user can't register the same credential multiple times. Defaults to `[]`
39
+ * @param authenticatorSelection **(Optional)** - Advanced criteria for restricting the types of authenticators that may be used. Defaults to `{ residentKey: 'preferred', userVerification: 'preferred' }`
40
+ * @param extensions **(Optional)** - Additional plugins the authenticator or browser should use during attestation
41
+ * @param supportedAlgorithmIDs **(Optional)** - Array of numeric COSE algorithm identifiers supported for attestation by this RP. See https://www.iana.org/assignments/cose/cose.xhtml#algorithms. Defaults to `[-8, -7, -257]`
42
42
  */
43
43
  export declare function generateRegistrationOptions(options: GenerateRegistrationOptionsOpts): Promise<PublicKeyCredentialCreationOptionsJSON>;
@@ -1,4 +1,5 @@
1
1
  import { generateChallenge } from '../helpers/generateChallenge.js';
2
+ import { generateUserID } from '../helpers/generateUserID.js';
2
3
  import { isoBase64URL, isoUint8Array } from '../helpers/iso/index.js';
3
4
  /**
4
5
  * Supported crypto algo identifiers
@@ -46,28 +47,25 @@ const defaultAuthenticatorSelection = {
46
47
  */
47
48
  const defaultSupportedAlgorithmIDs = [-8, -7, -257];
48
49
  /**
49
- * Prepare a value to pass into navigator.credentials.create(...) for authenticator "registration"
50
+ * Prepare a value to pass into navigator.credentials.create(...) for authenticator registration
50
51
  *
51
52
  * **Options:**
52
53
  *
53
- * @param rpName User-visible, "friendly" website/service name
54
- * @param rpID Valid domain name (after `https://`)
55
- * @param userID User's website-specific unique ID
56
- * @param userName User's website-specific username (email, etc...)
57
- * @param challenge Random value the authenticator needs to sign and pass back
58
- * @param userDisplayName User's actual name
59
- * @param timeout How long (in ms) the user can take to complete attestation
60
- * @param attestationType Specific attestation statement
61
- * @param excludeCredentials Authenticators registered by the user so the user can't register the
62
- * same credential multiple times
63
- * @param authenticatorSelection Advanced criteria for restricting the types of authenticators that
64
- * may be used
65
- * @param extensions Additional plugins the authenticator or browser should use during attestation
66
- * @param supportedAlgorithmIDs Array of numeric COSE algorithm identifiers supported for
67
- * attestation by this RP. See https://www.iana.org/assignments/cose/cose.xhtml#algorithms
54
+ * @param rpName - User-visible, "friendly" website/service name
55
+ * @param rpID - Valid domain name (after `https://`)
56
+ * @param userName - User's website-specific username (email, etc...)
57
+ * @param userID **(Optional)** - User's website-specific unique ID. Defaults to generating a random identifier
58
+ * @param challenge **(Optional)** - Random value the authenticator needs to sign and pass back. Defaults to generating a random value
59
+ * @param userDisplayName **(Optional)** - User's actual name. Defaults to `""`
60
+ * @param timeout **(Optional)** - How long (in ms) the user can take to complete attestation. Defaults to `60000`
61
+ * @param attestationType **(Optional)** - Specific attestation statement. Defaults to `"none"`
62
+ * @param excludeCredentials **(Optional)** - Authenticators registered by the user so the user can't register the same credential multiple times. Defaults to `[]`
63
+ * @param authenticatorSelection **(Optional)** - Advanced criteria for restricting the types of authenticators that may be used. Defaults to `{ residentKey: 'preferred', userVerification: 'preferred' }`
64
+ * @param extensions **(Optional)** - Additional plugins the authenticator or browser should use during attestation
65
+ * @param supportedAlgorithmIDs **(Optional)** - Array of numeric COSE algorithm identifiers supported for attestation by this RP. See https://www.iana.org/assignments/cose/cose.xhtml#algorithms. Defaults to `[-8, -7, -257]`
68
66
  */
69
67
  export async function generateRegistrationOptions(options) {
70
- const { rpName, rpID, userID, userName, challenge = await generateChallenge(), userDisplayName = userName, timeout = 60000, attestationType = 'none', excludeCredentials = [], authenticatorSelection = defaultAuthenticatorSelection, extensions, supportedAlgorithmIDs = defaultSupportedAlgorithmIDs, } = options;
68
+ const { rpName, rpID, userName, userID, challenge = await generateChallenge(), userDisplayName = '', timeout = 60000, attestationType = 'none', excludeCredentials = [], authenticatorSelection = defaultAuthenticatorSelection, extensions, supportedAlgorithmIDs = defaultSupportedAlgorithmIDs, } = options;
71
69
  /**
72
70
  * Prepare pubKeyCredParams from the array of algorithm ID's
73
71
  */
@@ -115,6 +113,20 @@ export async function generateRegistrationOptions(options) {
115
113
  if (typeof _challenge === 'string') {
116
114
  _challenge = isoUint8Array.fromUTF8String(_challenge);
117
115
  }
116
+ /**
117
+ * Explicitly disallow use of strings for userID anymore because `isoBase64URL.fromBuffer()` below
118
+ * will return an empty string if one gets through!
119
+ */
120
+ if (typeof userID === 'string') {
121
+ throw new Error(`String values for \`userID\` are no longer supported. See https://simplewebauthn.dev/docs/advanced/server/custom-user-ids`);
122
+ }
123
+ /**
124
+ * Generate a user ID if one is not provided
125
+ */
126
+ let _userID = userID;
127
+ if (!_userID) {
128
+ _userID = await generateUserID();
129
+ }
118
130
  return {
119
131
  challenge: isoBase64URL.fromBuffer(_challenge),
120
132
  rp: {
@@ -122,17 +134,23 @@ export async function generateRegistrationOptions(options) {
122
134
  id: rpID,
123
135
  },
124
136
  user: {
125
- id: userID,
137
+ id: isoBase64URL.fromBuffer(_userID),
126
138
  name: userName,
127
139
  displayName: userDisplayName,
128
140
  },
129
141
  pubKeyCredParams,
130
142
  timeout,
131
143
  attestation: attestationType,
132
- excludeCredentials: excludeCredentials.map((cred) => ({
133
- ...cred,
134
- id: isoBase64URL.fromBuffer(cred.id),
135
- })),
144
+ excludeCredentials: excludeCredentials.map((cred) => {
145
+ if (!isoBase64URL.isBase64URL(cred.id)) {
146
+ throw new Error(`excludeCredential id "${cred.id}" is not a valid base64url string`);
147
+ }
148
+ return {
149
+ ...cred,
150
+ id: isoBase64URL.trimPadding(cred.id),
151
+ type: 'public-key',
152
+ };
153
+ }),
136
154
  authenticatorSelection,
137
155
  extensions: {
138
156
  ...extensions,
@@ -23,8 +23,8 @@ export async function verifyAttestationAndroidSafetyNet(options) {
23
23
  // Prepare to verify a JWT
24
24
  const jwt = isoUint8Array.toUTF8String(response);
25
25
  const jwtParts = jwt.split('.');
26
- const HEADER = JSON.parse(isoBase64URL.toString(jwtParts[0]));
27
- const PAYLOAD = JSON.parse(isoBase64URL.toString(jwtParts[1]));
26
+ const HEADER = JSON.parse(isoBase64URL.toUTF8String(jwtParts[0]));
27
+ const PAYLOAD = JSON.parse(isoBase64URL.toUTF8String(jwtParts[1]));
28
28
  const SIGNATURE = jwtParts[2];
29
29
  /**
30
30
  * START Verify PAYLOAD