@simplewebauthn/server 9.0.2 → 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 (54) 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 +2 -2
  7. package/esm/deps.js +2 -2
  8. package/esm/helpers/convertCertBufferToPEM.js +1 -1
  9. package/esm/helpers/decodeClientDataJSON.d.ts +2 -1
  10. package/esm/helpers/decodeClientDataJSON.js +1 -1
  11. package/esm/helpers/generateUserID.d.ts +7 -0
  12. package/esm/helpers/generateUserID.js +17 -0
  13. package/esm/helpers/index.d.ts +2 -1
  14. package/esm/helpers/index.js +2 -1
  15. package/esm/helpers/iso/isoBase64URL.d.ts +10 -5
  16. package/esm/helpers/iso/isoBase64URL.js +13 -7
  17. package/esm/helpers/iso/isoCBOR.d.ts +12 -1
  18. package/esm/helpers/iso/isoCBOR.js +4 -17
  19. package/esm/helpers/iso/isoCrypto/getWebCrypto.d.ts +0 -289
  20. package/esm/helpers/iso/isoCrypto/getWebCrypto.js +26 -41
  21. package/esm/helpers/parseAuthenticatorData.js +10 -1
  22. package/esm/metadata/parseJWT.js +2 -2
  23. package/esm/registration/generateRegistrationOptions.d.ts +19 -19
  24. package/esm/registration/generateRegistrationOptions.js +40 -22
  25. package/esm/registration/verifications/verifyAttestationAndroidSafetyNet.js +2 -2
  26. package/esm/registration/verifyRegistrationResponse.d.ts +9 -12
  27. package/esm/registration/verifyRegistrationResponse.js +8 -11
  28. package/package.json +4 -4
  29. package/script/authentication/generateAuthenticationOptions.d.ts +16 -14
  30. package/script/authentication/generateAuthenticationOptions.js +21 -16
  31. package/script/authentication/verifyAuthenticationResponse.d.ts +13 -18
  32. package/script/authentication/verifyAuthenticationResponse.js +12 -17
  33. package/script/deps.d.ts +2 -2
  34. package/script/deps.js +3 -3
  35. package/script/helpers/convertCertBufferToPEM.js +1 -1
  36. package/script/helpers/decodeClientDataJSON.d.ts +2 -1
  37. package/script/helpers/decodeClientDataJSON.js +1 -1
  38. package/script/helpers/generateUserID.d.ts +7 -0
  39. package/script/helpers/generateUserID.js +21 -0
  40. package/script/helpers/index.d.ts +2 -1
  41. package/script/helpers/index.js +3 -1
  42. package/script/helpers/iso/isoBase64URL.d.ts +10 -5
  43. package/script/helpers/iso/isoBase64URL.js +18 -11
  44. package/script/helpers/iso/isoCBOR.d.ts +12 -1
  45. package/script/helpers/iso/isoCBOR.js +3 -16
  46. package/script/helpers/iso/isoCrypto/getWebCrypto.d.ts +0 -288
  47. package/script/helpers/iso/isoCrypto/getWebCrypto.js +26 -64
  48. package/script/helpers/parseAuthenticatorData.js +10 -1
  49. package/script/metadata/parseJWT.js +2 -2
  50. package/script/registration/generateRegistrationOptions.d.ts +19 -19
  51. package/script/registration/generateRegistrationOptions.js +40 -22
  52. package/script/registration/verifications/verifyAttestationAndroidSafetyNet.js +2 -2
  53. package/script/registration/verifyRegistrationResponse.d.ts +9 -12
  54. package/script/registration/verifyRegistrationResponse.js +8 -11
@@ -1,10 +1,3 @@
1
- /// <reference types="node" />
2
- /// <reference types="node" />
3
- /// <reference types="node" />
4
- /// <reference types="node/crypto.js" />
5
- /// <reference types=".deno/@types+node@18.16.19/node_modules/@types/node/crypto.js" />
6
- /// <reference types="node/stream.js" />
7
- /// <reference types=".deno/@types+node@18.16.19/node_modules/@types/node/stream.js" />
8
1
  import type { Crypto } from '../../../deps.js';
9
2
  /**
10
3
  * Try to get an instance of the Crypto API from the current runtime. Should support Node,
@@ -15,287 +8,6 @@ export declare class MissingWebCrypto extends Error {
15
8
  constructor();
16
9
  }
17
10
  export declare const _getWebCryptoInternals: {
18
- stubThisImportNodeCrypto: () => Promise<{
19
- default: typeof import("crypto");
20
- createHash(algorithm: string, options?: import("crypto").HashOptions | undefined): import("crypto").Hash;
21
- createHash(algorithm: string, options?: import("crypto").HashOptions | undefined): import("crypto").Hash;
22
- createHmac(algorithm: string, key: import("crypto").KeyObject | import("crypto").BinaryLike, options?: import("stream").TransformOptions | undefined): import("crypto").Hmac;
23
- createHmac(algorithm: string, key: import("crypto").KeyObject | import("crypto").BinaryLike, options?: import("stream").TransformOptions | undefined): import("crypto").Hmac;
24
- createCipher(algorithm: import("crypto").CipherCCMTypes, password: import("crypto").BinaryLike, options: import("crypto").CipherCCMOptions): import("crypto").CipherCCM;
25
- createCipher(algorithm: import("crypto").CipherGCMTypes, password: import("crypto").BinaryLike, options?: import("crypto").CipherGCMOptions | undefined): import("crypto").CipherGCM;
26
- createCipher(algorithm: string, password: import("crypto").BinaryLike, options?: import("stream").TransformOptions | undefined): import("crypto").Cipher;
27
- createCipher(algorithm: import("crypto").CipherCCMTypes, password: import("crypto").BinaryLike, options: import("crypto").CipherCCMOptions): import("crypto").CipherCCM;
28
- createCipher(algorithm: import("crypto").CipherGCMTypes, password: import("crypto").BinaryLike, options?: import("crypto").CipherGCMOptions | undefined): import("crypto").CipherGCM;
29
- createCipher(algorithm: string, password: import("crypto").BinaryLike, options?: import("stream").TransformOptions | undefined): import("crypto").Cipher;
30
- createCipheriv(algorithm: import("crypto").CipherCCMTypes, key: import("crypto").CipherKey, iv: import("crypto").BinaryLike, options: import("crypto").CipherCCMOptions): import("crypto").CipherCCM;
31
- createCipheriv(algorithm: import("crypto").CipherOCBTypes, key: import("crypto").CipherKey, iv: import("crypto").BinaryLike, options: import("crypto").CipherOCBOptions): import("crypto").CipherOCB;
32
- createCipheriv(algorithm: import("crypto").CipherGCMTypes, key: import("crypto").CipherKey, iv: import("crypto").BinaryLike, options?: import("crypto").CipherGCMOptions | undefined): import("crypto").CipherGCM;
33
- createCipheriv(algorithm: string, key: import("crypto").CipherKey, iv: import("crypto").BinaryLike | null, options?: import("stream").TransformOptions | undefined): import("crypto").Cipher;
34
- createCipheriv(algorithm: import("crypto").CipherCCMTypes, key: import("crypto").CipherKey, iv: import("crypto").BinaryLike, options: import("crypto").CipherCCMOptions): import("crypto").CipherCCM;
35
- createCipheriv(algorithm: import("crypto").CipherOCBTypes, key: import("crypto").CipherKey, iv: import("crypto").BinaryLike, options: import("crypto").CipherOCBOptions): import("crypto").CipherOCB;
36
- createCipheriv(algorithm: import("crypto").CipherGCMTypes, key: import("crypto").CipherKey, iv: import("crypto").BinaryLike, options?: import("crypto").CipherGCMOptions | undefined): import("crypto").CipherGCM;
37
- createCipheriv(algorithm: string, key: import("crypto").CipherKey, iv: import("crypto").BinaryLike | null, options?: import("stream").TransformOptions | undefined): import("crypto").Cipher;
38
- createDecipher(algorithm: import("crypto").CipherCCMTypes, password: import("crypto").BinaryLike, options: import("crypto").CipherCCMOptions): import("crypto").DecipherCCM;
39
- createDecipher(algorithm: import("crypto").CipherGCMTypes, password: import("crypto").BinaryLike, options?: import("crypto").CipherGCMOptions | undefined): import("crypto").DecipherGCM;
40
- createDecipher(algorithm: string, password: import("crypto").BinaryLike, options?: import("stream").TransformOptions | undefined): import("crypto").Decipher;
41
- createDecipher(algorithm: import("crypto").CipherCCMTypes, password: import("crypto").BinaryLike, options: import("crypto").CipherCCMOptions): import("crypto").DecipherCCM;
42
- createDecipher(algorithm: import("crypto").CipherGCMTypes, password: import("crypto").BinaryLike, options?: import("crypto").CipherGCMOptions | undefined): import("crypto").DecipherGCM;
43
- createDecipher(algorithm: string, password: import("crypto").BinaryLike, options?: import("stream").TransformOptions | undefined): import("crypto").Decipher;
44
- createDecipheriv(algorithm: import("crypto").CipherCCMTypes, key: import("crypto").CipherKey, iv: import("crypto").BinaryLike, options: import("crypto").CipherCCMOptions): import("crypto").DecipherCCM;
45
- createDecipheriv(algorithm: import("crypto").CipherOCBTypes, key: import("crypto").CipherKey, iv: import("crypto").BinaryLike, options: import("crypto").CipherOCBOptions): import("crypto").DecipherOCB;
46
- createDecipheriv(algorithm: import("crypto").CipherGCMTypes, key: import("crypto").CipherKey, iv: import("crypto").BinaryLike, options?: import("crypto").CipherGCMOptions | undefined): import("crypto").DecipherGCM;
47
- createDecipheriv(algorithm: string, key: import("crypto").CipherKey, iv: import("crypto").BinaryLike | null, options?: import("stream").TransformOptions | undefined): import("crypto").Decipher;
48
- createDecipheriv(algorithm: import("crypto").CipherCCMTypes, key: import("crypto").CipherKey, iv: import("crypto").BinaryLike, options: import("crypto").CipherCCMOptions): import("crypto").DecipherCCM;
49
- createDecipheriv(algorithm: import("crypto").CipherOCBTypes, key: import("crypto").CipherKey, iv: import("crypto").BinaryLike, options: import("crypto").CipherOCBOptions): import("crypto").DecipherOCB;
50
- createDecipheriv(algorithm: import("crypto").CipherGCMTypes, key: import("crypto").CipherKey, iv: import("crypto").BinaryLike, options?: import("crypto").CipherGCMOptions | undefined): import("crypto").DecipherGCM;
51
- createDecipheriv(algorithm: string, key: import("crypto").CipherKey, iv: import("crypto").BinaryLike | null, options?: import("stream").TransformOptions | undefined): import("crypto").Decipher;
52
- generateKey(type: "hmac" | "aes", options: {
53
- length: number;
54
- }, callback: (err: Error | null, key: import("crypto").KeyObject) => void): void;
55
- generateKey(type: "hmac" | "aes", options: {
56
- length: number;
57
- }, callback: (err: Error | null, key: import("crypto").KeyObject) => void): void;
58
- generateKeySync(type: "hmac" | "aes", options: {
59
- length: number;
60
- }): import("crypto").KeyObject;
61
- generateKeySync(type: "hmac" | "aes", options: {
62
- length: number;
63
- }): import("crypto").KeyObject;
64
- createPrivateKey(key: string | import("crypto").PrivateKeyInput | Buffer | import("crypto").JsonWebKeyInput): import("crypto").KeyObject;
65
- createPrivateKey(key: string | import("crypto").PrivateKeyInput | Buffer | import("crypto").JsonWebKeyInput): import("crypto").KeyObject;
66
- createPublicKey(key: string | import("crypto").KeyObject | Buffer | import("crypto").JsonWebKeyInput | import("crypto").PublicKeyInput): import("crypto").KeyObject;
67
- createPublicKey(key: string | import("crypto").KeyObject | Buffer | import("crypto").JsonWebKeyInput | import("crypto").PublicKeyInput): import("crypto").KeyObject;
68
- createSecretKey(key: NodeJS.ArrayBufferView): import("crypto").KeyObject;
69
- createSecretKey(key: string, encoding: BufferEncoding): import("crypto").KeyObject;
70
- createSecretKey(key: NodeJS.ArrayBufferView): import("crypto").KeyObject;
71
- createSecretKey(key: string, encoding: BufferEncoding): import("crypto").KeyObject;
72
- createSign(algorithm: string, options?: import("stream").WritableOptions | undefined): import("crypto").Sign;
73
- createSign(algorithm: string, options?: import("stream").WritableOptions | undefined): import("crypto").Sign;
74
- createVerify(algorithm: string, options?: import("stream").WritableOptions | undefined): import("crypto").Verify;
75
- createVerify(algorithm: string, options?: import("stream").WritableOptions | undefined): import("crypto").Verify;
76
- createDiffieHellman(primeLength: number, generator?: number | undefined): import("crypto").DiffieHellman;
77
- createDiffieHellman(prime: ArrayBuffer | NodeJS.ArrayBufferView, generator?: number | ArrayBuffer | NodeJS.ArrayBufferView | undefined): import("crypto").DiffieHellman;
78
- createDiffieHellman(prime: ArrayBuffer | NodeJS.ArrayBufferView, generator: string, generatorEncoding: import("crypto").BinaryToTextEncoding): import("crypto").DiffieHellman;
79
- createDiffieHellman(prime: string, primeEncoding: import("crypto").BinaryToTextEncoding, generator?: number | ArrayBuffer | NodeJS.ArrayBufferView | undefined): import("crypto").DiffieHellman;
80
- createDiffieHellman(prime: string, primeEncoding: import("crypto").BinaryToTextEncoding, generator: string, generatorEncoding: import("crypto").BinaryToTextEncoding): import("crypto").DiffieHellman;
81
- createDiffieHellman(primeLength: number, generator?: number | undefined): import("crypto").DiffieHellman;
82
- createDiffieHellman(prime: ArrayBuffer | NodeJS.ArrayBufferView, generator?: number | ArrayBuffer | NodeJS.ArrayBufferView | undefined): import("crypto").DiffieHellman;
83
- createDiffieHellman(prime: ArrayBuffer | NodeJS.ArrayBufferView, generator: string, generatorEncoding: import("crypto").BinaryToTextEncoding): import("crypto").DiffieHellman;
84
- createDiffieHellman(prime: string, primeEncoding: import("crypto").BinaryToTextEncoding, generator?: number | ArrayBuffer | NodeJS.ArrayBufferView | undefined): import("crypto").DiffieHellman;
85
- createDiffieHellman(prime: string, primeEncoding: import("crypto").BinaryToTextEncoding, generator: string, generatorEncoding: import("crypto").BinaryToTextEncoding): import("crypto").DiffieHellman;
86
- getDiffieHellman(groupName: string): import("crypto").DiffieHellmanGroup;
87
- getDiffieHellman(groupName: string): import("crypto").DiffieHellmanGroup;
88
- createDiffieHellmanGroup(name: string): import("crypto").DiffieHellmanGroup;
89
- createDiffieHellmanGroup(name: string): import("crypto").DiffieHellmanGroup;
90
- pbkdf2(password: import("crypto").BinaryLike, salt: import("crypto").BinaryLike, iterations: number, keylen: number, digest: string, callback: (err: Error | null, derivedKey: Buffer) => void): void;
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
- pbkdf2Sync(password: import("crypto").BinaryLike, salt: import("crypto").BinaryLike, iterations: number, keylen: number, digest: string): Buffer;
93
- pbkdf2Sync(password: import("crypto").BinaryLike, salt: import("crypto").BinaryLike, iterations: number, keylen: number, digest: string): Buffer;
94
- randomBytes(size: number): Buffer;
95
- randomBytes(size: number, callback: (err: Error | null, buf: Buffer) => void): void;
96
- randomBytes(size: number): Buffer;
97
- randomBytes(size: number, callback: (err: Error | null, buf: Buffer) => void): void;
98
- pseudoRandomBytes(size: number): Buffer;
99
- pseudoRandomBytes(size: number, callback: (err: Error | null, buf: Buffer) => void): void;
100
- pseudoRandomBytes(size: number): Buffer;
101
- pseudoRandomBytes(size: number, callback: (err: Error | null, buf: Buffer) => void): void;
102
- randomInt(max: number): number;
103
- randomInt(min: number, max: number): number;
104
- randomInt(max: number, callback: (err: Error | null, value: number) => void): void;
105
- randomInt(min: number, max: number, callback: (err: Error | null, value: number) => void): void;
106
- randomInt(max: number): number;
107
- randomInt(min: number, max: number): number;
108
- randomInt(max: number, callback: (err: Error | null, value: number) => void): void;
109
- randomInt(min: number, max: number, callback: (err: Error | null, value: number) => void): void;
110
- randomFillSync<T extends NodeJS.ArrayBufferView>(buffer: T, offset?: number | undefined, size?: number | undefined): T;
111
- randomFillSync<T_1 extends NodeJS.ArrayBufferView>(buffer: T_1, offset?: number | undefined, size?: number | undefined): T_1;
112
- randomFill<T_2 extends NodeJS.ArrayBufferView>(buffer: T_2, callback: (err: Error | null, buf: T_2) => void): void;
113
- randomFill<T_3 extends NodeJS.ArrayBufferView>(buffer: T_3, offset: number, callback: (err: Error | null, buf: T_3) => void): void;
114
- randomFill<T_4 extends NodeJS.ArrayBufferView>(buffer: T_4, offset: number, size: number, callback: (err: Error | null, buf: T_4) => void): void;
115
- randomFill<T_5 extends NodeJS.ArrayBufferView>(buffer: T_5, callback: (err: Error | null, buf: T_5) => void): void;
116
- randomFill<T_6 extends NodeJS.ArrayBufferView>(buffer: T_6, offset: number, callback: (err: Error | null, buf: T_6) => void): void;
117
- randomFill<T_7 extends NodeJS.ArrayBufferView>(buffer: T_7, offset: number, size: number, callback: (err: Error | null, buf: T_7) => void): void;
118
- scrypt(password: import("crypto").BinaryLike, salt: import("crypto").BinaryLike, keylen: number, callback: (err: Error | null, derivedKey: Buffer) => void): void;
119
- scrypt(password: import("crypto").BinaryLike, salt: import("crypto").BinaryLike, keylen: number, options: import("crypto").ScryptOptions, callback: (err: Error | null, derivedKey: Buffer) => void): void;
120
- scrypt(password: import("crypto").BinaryLike, salt: import("crypto").BinaryLike, keylen: number, callback: (err: Error | null, derivedKey: Buffer) => void): void;
121
- scrypt(password: import("crypto").BinaryLike, salt: import("crypto").BinaryLike, keylen: number, options: import("crypto").ScryptOptions, callback: (err: Error | null, derivedKey: Buffer) => void): void;
122
- scryptSync(password: import("crypto").BinaryLike, salt: import("crypto").BinaryLike, keylen: number, options?: import("crypto").ScryptOptions | undefined): Buffer;
123
- scryptSync(password: import("crypto").BinaryLike, salt: import("crypto").BinaryLike, keylen: number, options?: import("crypto").ScryptOptions | undefined): Buffer;
124
- publicEncrypt(key: import("crypto").RsaPublicKey | import("crypto").RsaPrivateKey | import("crypto").KeyLike, buffer: NodeJS.ArrayBufferView): Buffer;
125
- publicEncrypt(key: import("crypto").RsaPublicKey | import("crypto").RsaPrivateKey | import("crypto").KeyLike, buffer: NodeJS.ArrayBufferView): Buffer;
126
- publicDecrypt(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
- privateDecrypt(privateKey: import("crypto").RsaPrivateKey | import("crypto").KeyLike, buffer: NodeJS.ArrayBufferView): Buffer;
129
- privateDecrypt(privateKey: import("crypto").RsaPrivateKey | import("crypto").KeyLike, buffer: NodeJS.ArrayBufferView): Buffer;
130
- privateEncrypt(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
- getCiphers(): string[];
133
- getCiphers(): string[];
134
- getCurves(): string[];
135
- getCurves(): string[];
136
- getFips(): 0 | 1;
137
- getFips(): 0 | 1;
138
- setFips(bool: boolean): void;
139
- setFips(bool: boolean): void;
140
- getHashes(): string[];
141
- getHashes(): string[];
142
- createECDH(curveName: string): import("crypto").ECDH;
143
- createECDH(curveName: string): import("crypto").ECDH;
144
- timingSafeEqual(a: NodeJS.ArrayBufferView, b: NodeJS.ArrayBufferView): boolean;
145
- timingSafeEqual(a: NodeJS.ArrayBufferView, b: NodeJS.ArrayBufferView): boolean;
146
- generateKeyPairSync(type: "rsa", options: import("crypto").RSAKeyPairOptions<"pem", "pem">): import("crypto").KeyPairSyncResult<string, string>;
147
- generateKeyPairSync(type: "rsa", options: import("crypto").RSAKeyPairOptions<"pem", "der">): import("crypto").KeyPairSyncResult<string, Buffer>;
148
- generateKeyPairSync(type: "rsa", options: import("crypto").RSAKeyPairOptions<"der", "pem">): import("crypto").KeyPairSyncResult<Buffer, string>;
149
- generateKeyPairSync(type: "rsa", options: import("crypto").RSAKeyPairOptions<"der", "der">): import("crypto").KeyPairSyncResult<Buffer, Buffer>;
150
- generateKeyPairSync(type: "rsa", options: import("crypto").RSAKeyPairKeyObjectOptions): import("crypto").KeyPairKeyObjectResult;
151
- generateKeyPairSync(type: "rsa-pss", options: import("crypto").RSAPSSKeyPairOptions<"pem", "pem">): import("crypto").KeyPairSyncResult<string, string>;
152
- generateKeyPairSync(type: "rsa-pss", options: import("crypto").RSAPSSKeyPairOptions<"pem", "der">): import("crypto").KeyPairSyncResult<string, Buffer>;
153
- generateKeyPairSync(type: "rsa-pss", options: import("crypto").RSAPSSKeyPairOptions<"der", "pem">): import("crypto").KeyPairSyncResult<Buffer, string>;
154
- generateKeyPairSync(type: "rsa-pss", options: import("crypto").RSAPSSKeyPairOptions<"der", "der">): import("crypto").KeyPairSyncResult<Buffer, Buffer>;
155
- generateKeyPairSync(type: "rsa-pss", options: import("crypto").RSAPSSKeyPairKeyObjectOptions): import("crypto").KeyPairKeyObjectResult;
156
- generateKeyPairSync(type: "dsa", options: import("crypto").DSAKeyPairOptions<"pem", "pem">): import("crypto").KeyPairSyncResult<string, string>;
157
- generateKeyPairSync(type: "dsa", options: import("crypto").DSAKeyPairOptions<"pem", "der">): import("crypto").KeyPairSyncResult<string, Buffer>;
158
- generateKeyPairSync(type: "dsa", options: import("crypto").DSAKeyPairOptions<"der", "pem">): import("crypto").KeyPairSyncResult<Buffer, string>;
159
- generateKeyPairSync(type: "dsa", options: import("crypto").DSAKeyPairOptions<"der", "der">): import("crypto").KeyPairSyncResult<Buffer, Buffer>;
160
- generateKeyPairSync(type: "dsa", options: import("crypto").DSAKeyPairKeyObjectOptions): import("crypto").KeyPairKeyObjectResult;
161
- generateKeyPairSync(type: "ec", options: import("crypto").ECKeyPairOptions<"pem", "pem">): import("crypto").KeyPairSyncResult<string, string>;
162
- generateKeyPairSync(type: "ec", options: import("crypto").ECKeyPairOptions<"pem", "der">): import("crypto").KeyPairSyncResult<string, Buffer>;
163
- generateKeyPairSync(type: "ec", options: import("crypto").ECKeyPairOptions<"der", "pem">): import("crypto").KeyPairSyncResult<Buffer, string>;
164
- generateKeyPairSync(type: "ec", options: import("crypto").ECKeyPairOptions<"der", "der">): import("crypto").KeyPairSyncResult<Buffer, Buffer>;
165
- generateKeyPairSync(type: "ec", options: import("crypto").ECKeyPairKeyObjectOptions): import("crypto").KeyPairKeyObjectResult;
166
- generateKeyPairSync(type: "ed25519", options: import("crypto").ED25519KeyPairOptions<"pem", "pem">): import("crypto").KeyPairSyncResult<string, string>;
167
- generateKeyPairSync(type: "ed25519", options: import("crypto").ED25519KeyPairOptions<"pem", "der">): import("crypto").KeyPairSyncResult<string, Buffer>;
168
- generateKeyPairSync(type: "ed25519", options: import("crypto").ED25519KeyPairOptions<"der", "pem">): import("crypto").KeyPairSyncResult<Buffer, string>;
169
- generateKeyPairSync(type: "ed25519", options: import("crypto").ED25519KeyPairOptions<"der", "der">): import("crypto").KeyPairSyncResult<Buffer, Buffer>;
170
- generateKeyPairSync(type: "ed25519", options?: import("crypto").ED25519KeyPairKeyObjectOptions | undefined): import("crypto").KeyPairKeyObjectResult;
171
- generateKeyPairSync(type: "ed448", options: import("crypto").ED448KeyPairOptions<"pem", "pem">): import("crypto").KeyPairSyncResult<string, string>;
172
- generateKeyPairSync(type: "ed448", options: import("crypto").ED448KeyPairOptions<"pem", "der">): import("crypto").KeyPairSyncResult<string, Buffer>;
173
- generateKeyPairSync(type: "ed448", options: import("crypto").ED448KeyPairOptions<"der", "pem">): import("crypto").KeyPairSyncResult<Buffer, string>;
174
- generateKeyPairSync(type: "ed448", options: import("crypto").ED448KeyPairOptions<"der", "der">): import("crypto").KeyPairSyncResult<Buffer, Buffer>;
175
- generateKeyPairSync(type: "ed448", options?: import("crypto").ED448KeyPairKeyObjectOptions | undefined): import("crypto").KeyPairKeyObjectResult;
176
- generateKeyPairSync(type: "x25519", options: import("crypto").X25519KeyPairOptions<"pem", "pem">): import("crypto").KeyPairSyncResult<string, string>;
177
- generateKeyPairSync(type: "x25519", options: import("crypto").X25519KeyPairOptions<"pem", "der">): import("crypto").KeyPairSyncResult<string, Buffer>;
178
- generateKeyPairSync(type: "x25519", options: import("crypto").X25519KeyPairOptions<"der", "pem">): import("crypto").KeyPairSyncResult<Buffer, string>;
179
- generateKeyPairSync(type: "x25519", options: import("crypto").X25519KeyPairOptions<"der", "der">): import("crypto").KeyPairSyncResult<Buffer, Buffer>;
180
- generateKeyPairSync(type: "x25519", options?: import("crypto").X25519KeyPairKeyObjectOptions | undefined): import("crypto").KeyPairKeyObjectResult;
181
- generateKeyPairSync(type: "x448", options: import("crypto").X448KeyPairOptions<"pem", "pem">): import("crypto").KeyPairSyncResult<string, string>;
182
- generateKeyPairSync(type: "x448", options: import("crypto").X448KeyPairOptions<"pem", "der">): import("crypto").KeyPairSyncResult<string, Buffer>;
183
- generateKeyPairSync(type: "x448", options: import("crypto").X448KeyPairOptions<"der", "pem">): import("crypto").KeyPairSyncResult<Buffer, string>;
184
- generateKeyPairSync(type: "x448", options: import("crypto").X448KeyPairOptions<"der", "der">): import("crypto").KeyPairSyncResult<Buffer, Buffer>;
185
- generateKeyPairSync(type: "x448", options?: import("crypto").X448KeyPairKeyObjectOptions | undefined): import("crypto").KeyPairKeyObjectResult;
186
- generateKeyPairSync(type: "rsa", options: import("crypto").RSAKeyPairOptions<"pem", "pem">): import("crypto").KeyPairSyncResult<string, string>;
187
- generateKeyPairSync(type: "rsa", options: import("crypto").RSAKeyPairOptions<"pem", "der">): import("crypto").KeyPairSyncResult<string, Buffer>;
188
- generateKeyPairSync(type: "rsa", options: import("crypto").RSAKeyPairOptions<"der", "pem">): import("crypto").KeyPairSyncResult<Buffer, string>;
189
- generateKeyPairSync(type: "rsa", options: import("crypto").RSAKeyPairOptions<"der", "der">): import("crypto").KeyPairSyncResult<Buffer, Buffer>;
190
- generateKeyPairSync(type: "rsa", options: import("crypto").RSAKeyPairKeyObjectOptions): import("crypto").KeyPairKeyObjectResult;
191
- generateKeyPairSync(type: "rsa-pss", options: import("crypto").RSAPSSKeyPairOptions<"pem", "pem">): import("crypto").KeyPairSyncResult<string, string>;
192
- generateKeyPairSync(type: "rsa-pss", options: import("crypto").RSAPSSKeyPairOptions<"pem", "der">): import("crypto").KeyPairSyncResult<string, Buffer>;
193
- generateKeyPairSync(type: "rsa-pss", options: import("crypto").RSAPSSKeyPairOptions<"der", "pem">): import("crypto").KeyPairSyncResult<Buffer, string>;
194
- generateKeyPairSync(type: "rsa-pss", options: import("crypto").RSAPSSKeyPairOptions<"der", "der">): import("crypto").KeyPairSyncResult<Buffer, Buffer>;
195
- generateKeyPairSync(type: "rsa-pss", options: import("crypto").RSAPSSKeyPairKeyObjectOptions): import("crypto").KeyPairKeyObjectResult;
196
- generateKeyPairSync(type: "dsa", options: import("crypto").DSAKeyPairOptions<"pem", "pem">): import("crypto").KeyPairSyncResult<string, string>;
197
- generateKeyPairSync(type: "dsa", options: import("crypto").DSAKeyPairOptions<"pem", "der">): import("crypto").KeyPairSyncResult<string, Buffer>;
198
- generateKeyPairSync(type: "dsa", options: import("crypto").DSAKeyPairOptions<"der", "pem">): import("crypto").KeyPairSyncResult<Buffer, string>;
199
- generateKeyPairSync(type: "dsa", options: import("crypto").DSAKeyPairOptions<"der", "der">): import("crypto").KeyPairSyncResult<Buffer, Buffer>;
200
- generateKeyPairSync(type: "dsa", options: import("crypto").DSAKeyPairKeyObjectOptions): import("crypto").KeyPairKeyObjectResult;
201
- generateKeyPairSync(type: "ec", options: import("crypto").ECKeyPairOptions<"pem", "pem">): import("crypto").KeyPairSyncResult<string, string>;
202
- generateKeyPairSync(type: "ec", options: import("crypto").ECKeyPairOptions<"pem", "der">): import("crypto").KeyPairSyncResult<string, Buffer>;
203
- generateKeyPairSync(type: "ec", options: import("crypto").ECKeyPairOptions<"der", "pem">): import("crypto").KeyPairSyncResult<Buffer, string>;
204
- generateKeyPairSync(type: "ec", options: import("crypto").ECKeyPairOptions<"der", "der">): import("crypto").KeyPairSyncResult<Buffer, Buffer>;
205
- generateKeyPairSync(type: "ec", options: import("crypto").ECKeyPairKeyObjectOptions): import("crypto").KeyPairKeyObjectResult;
206
- generateKeyPairSync(type: "ed25519", options: import("crypto").ED25519KeyPairOptions<"pem", "pem">): import("crypto").KeyPairSyncResult<string, string>;
207
- generateKeyPairSync(type: "ed25519", options: import("crypto").ED25519KeyPairOptions<"pem", "der">): import("crypto").KeyPairSyncResult<string, Buffer>;
208
- generateKeyPairSync(type: "ed25519", options: import("crypto").ED25519KeyPairOptions<"der", "pem">): import("crypto").KeyPairSyncResult<Buffer, string>;
209
- generateKeyPairSync(type: "ed25519", options: import("crypto").ED25519KeyPairOptions<"der", "der">): import("crypto").KeyPairSyncResult<Buffer, Buffer>;
210
- generateKeyPairSync(type: "ed25519", options?: import("crypto").ED25519KeyPairKeyObjectOptions | undefined): import("crypto").KeyPairKeyObjectResult;
211
- generateKeyPairSync(type: "ed448", options: import("crypto").ED448KeyPairOptions<"pem", "pem">): import("crypto").KeyPairSyncResult<string, string>;
212
- generateKeyPairSync(type: "ed448", options: import("crypto").ED448KeyPairOptions<"pem", "der">): import("crypto").KeyPairSyncResult<string, Buffer>;
213
- generateKeyPairSync(type: "ed448", options: import("crypto").ED448KeyPairOptions<"der", "pem">): import("crypto").KeyPairSyncResult<Buffer, string>;
214
- generateKeyPairSync(type: "ed448", options: import("crypto").ED448KeyPairOptions<"der", "der">): import("crypto").KeyPairSyncResult<Buffer, Buffer>;
215
- generateKeyPairSync(type: "ed448", options?: import("crypto").ED448KeyPairKeyObjectOptions | undefined): import("crypto").KeyPairKeyObjectResult;
216
- generateKeyPairSync(type: "x25519", options: import("crypto").X25519KeyPairOptions<"pem", "pem">): import("crypto").KeyPairSyncResult<string, string>;
217
- generateKeyPairSync(type: "x25519", options: import("crypto").X25519KeyPairOptions<"pem", "der">): import("crypto").KeyPairSyncResult<string, Buffer>;
218
- generateKeyPairSync(type: "x25519", options: import("crypto").X25519KeyPairOptions<"der", "pem">): import("crypto").KeyPairSyncResult<Buffer, string>;
219
- generateKeyPairSync(type: "x25519", options: import("crypto").X25519KeyPairOptions<"der", "der">): import("crypto").KeyPairSyncResult<Buffer, Buffer>;
220
- generateKeyPairSync(type: "x25519", options?: import("crypto").X25519KeyPairKeyObjectOptions | undefined): import("crypto").KeyPairKeyObjectResult;
221
- generateKeyPairSync(type: "x448", options: import("crypto").X448KeyPairOptions<"pem", "pem">): import("crypto").KeyPairSyncResult<string, string>;
222
- generateKeyPairSync(type: "x448", options: import("crypto").X448KeyPairOptions<"pem", "der">): import("crypto").KeyPairSyncResult<string, Buffer>;
223
- generateKeyPairSync(type: "x448", options: import("crypto").X448KeyPairOptions<"der", "pem">): import("crypto").KeyPairSyncResult<Buffer, string>;
224
- generateKeyPairSync(type: "x448", options: import("crypto").X448KeyPairOptions<"der", "der">): import("crypto").KeyPairSyncResult<Buffer, Buffer>;
225
- generateKeyPairSync(type: "x448", options?: import("crypto").X448KeyPairKeyObjectOptions | undefined): import("crypto").KeyPairKeyObjectResult;
226
- generateKeyPair: typeof import("crypto").generateKeyPair;
227
- sign(algorithm: string | null | undefined, data: NodeJS.ArrayBufferView, key: import("crypto").KeyLike | import("crypto").SignKeyObjectInput | import("crypto").SignPrivateKeyInput): Buffer;
228
- 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;
229
- sign(algorithm: string | null | undefined, data: NodeJS.ArrayBufferView, key: import("crypto").KeyLike | import("crypto").SignKeyObjectInput | import("crypto").SignPrivateKeyInput): Buffer;
230
- 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;
231
- 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;
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, callback: (error: Error | null, result: boolean) => void): void;
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): boolean;
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, callback: (error: Error | null, result: boolean) => void): void;
235
- diffieHellman(options: {
236
- privateKey: import("crypto").KeyObject;
237
- publicKey: import("crypto").KeyObject;
238
- }): Buffer;
239
- diffieHellman(options: {
240
- privateKey: import("crypto").KeyObject;
241
- publicKey: import("crypto").KeyObject;
242
- }): Buffer;
243
- getCipherInfo(nameOrNid: string | number, options?: import("crypto").CipherInfoOptions | undefined): import("crypto").CipherInfo | undefined;
244
- getCipherInfo(nameOrNid: string | number, options?: import("crypto").CipherInfoOptions | undefined): import("crypto").CipherInfo | undefined;
245
- 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;
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
- hkdfSync(digest: string, ikm: import("crypto").KeyObject | import("crypto").BinaryLike, salt: import("crypto").BinaryLike, info: import("crypto").BinaryLike, keylen: number): ArrayBuffer;
248
- hkdfSync(digest: string, ikm: import("crypto").KeyObject | import("crypto").BinaryLike, salt: import("crypto").BinaryLike, info: import("crypto").BinaryLike, keylen: number): ArrayBuffer;
249
- secureHeapUsed(): import("crypto").SecureHeapUsage;
250
- secureHeapUsed(): import("crypto").SecureHeapUsage;
251
- randomUUID(options?: import("crypto").RandomUUIDOptions | undefined): `${string}-${string}-${string}-${string}-${string}`;
252
- randomUUID(options?: import("crypto").RandomUUIDOptions | undefined): `${string}-${string}-${string}-${string}-${string}`;
253
- generatePrime(size: number, callback: (err: Error | null, prime: ArrayBuffer) => void): void;
254
- generatePrime(size: number, options: import("crypto").GeneratePrimeOptionsBigInt, callback: (err: Error | null, prime: bigint) => void): void;
255
- generatePrime(size: number, options: import("crypto").GeneratePrimeOptionsArrayBuffer, callback: (err: Error | null, prime: ArrayBuffer) => void): void;
256
- generatePrime(size: number, options: import("crypto").GeneratePrimeOptions, callback: (err: Error | null, prime: bigint | ArrayBuffer) => void): void;
257
- generatePrime(size: number, callback: (err: Error | null, prime: ArrayBuffer) => void): void;
258
- generatePrime(size: number, options: import("crypto").GeneratePrimeOptionsBigInt, callback: (err: Error | null, prime: bigint) => void): void;
259
- generatePrime(size: number, options: import("crypto").GeneratePrimeOptionsArrayBuffer, callback: (err: Error | null, prime: ArrayBuffer) => void): void;
260
- generatePrime(size: number, options: import("crypto").GeneratePrimeOptions, callback: (err: Error | null, prime: bigint | ArrayBuffer) => void): void;
261
- generatePrimeSync(size: number): ArrayBuffer;
262
- generatePrimeSync(size: number, options: import("crypto").GeneratePrimeOptionsBigInt): bigint;
263
- generatePrimeSync(size: number, options: import("crypto").GeneratePrimeOptionsArrayBuffer): ArrayBuffer;
264
- generatePrimeSync(size: number, options: import("crypto").GeneratePrimeOptions): bigint | ArrayBuffer;
265
- generatePrimeSync(size: number): ArrayBuffer;
266
- generatePrimeSync(size: number, options: import("crypto").GeneratePrimeOptionsBigInt): bigint;
267
- generatePrimeSync(size: number, options: import("crypto").GeneratePrimeOptionsArrayBuffer): ArrayBuffer;
268
- generatePrimeSync(size: number, options: import("crypto").GeneratePrimeOptions): bigint | ArrayBuffer;
269
- checkPrime(value: import("crypto").LargeNumberLike, callback: (err: Error | null, result: boolean) => void): void;
270
- checkPrime(value: import("crypto").LargeNumberLike, options: import("crypto").CheckPrimeOptions, callback: (err: Error | null, result: boolean) => void): void;
271
- checkPrime(value: import("crypto").LargeNumberLike, callback: (err: Error | null, result: boolean) => void): void;
272
- checkPrime(value: import("crypto").LargeNumberLike, options: import("crypto").CheckPrimeOptions, callback: (err: Error | null, result: boolean) => void): void;
273
- checkPrimeSync(candidate: import("crypto").LargeNumberLike, options?: import("crypto").CheckPrimeOptions | undefined): boolean;
274
- checkPrimeSync(candidate: import("crypto").LargeNumberLike, options?: import("crypto").CheckPrimeOptions | undefined): boolean;
275
- setEngine(engine: string, flags?: number | undefined): void;
276
- setEngine(engine: string, flags?: number | undefined): void;
277
- getRandomValues<T_8 extends import("crypto").webcrypto.BufferSource>(typedArray: T_8): T_8;
278
- getRandomValues<T_9 extends import("crypto").webcrypto.BufferSource>(typedArray: T_9): T_9;
279
- Certificate: typeof import("crypto").Certificate;
280
- constants: typeof import("crypto").constants;
281
- fips: boolean;
282
- Hash: typeof import("crypto").Hash;
283
- Hmac: typeof import("crypto").Hmac;
284
- KeyObject: typeof import("crypto").KeyObject;
285
- Cipher: typeof import("crypto").Cipher;
286
- Decipher: typeof import("crypto").Decipher;
287
- Sign: typeof import("crypto").Sign;
288
- Verify: typeof import("crypto").Verify;
289
- DiffieHellman: typeof import("crypto").DiffieHellman;
290
- DiffieHellmanGroup: import("crypto").DiffieHellmanGroupConstructor;
291
- ECDH: typeof import("crypto").ECDH;
292
- DEFAULT_ENCODING: BufferEncoding;
293
- X509Certificate: typeof import("crypto").X509Certificate;
294
- subtle: import("crypto").webcrypto.SubtleCrypto;
295
- webcrypto: import("crypto").webcrypto.Crypto;
296
- } | {
297
- webcrypto: undefined;
298
- }>;
299
11
  stubThisGlobalThisCrypto: () => globalThis.Crypto;
300
12
  setCachedCrypto: (newCrypto: Crypto | undefined) => void;
301
13
  };
@@ -1,27 +1,4 @@
1
1
  "use strict";
2
- var __createBinding = (this && this.__createBinding) || (Object.create ? (function(o, m, k, k2) {
3
- if (k2 === undefined) k2 = k;
4
- var desc = Object.getOwnPropertyDescriptor(m, k);
5
- if (!desc || ("get" in desc ? !m.__esModule : desc.writable || desc.configurable)) {
6
- desc = { enumerable: true, get: function() { return m[k]; } };
7
- }
8
- Object.defineProperty(o, k2, desc);
9
- }) : (function(o, m, k, k2) {
10
- if (k2 === undefined) k2 = k;
11
- o[k2] = m[k];
12
- }));
13
- var __setModuleDefault = (this && this.__setModuleDefault) || (Object.create ? (function(o, v) {
14
- Object.defineProperty(o, "default", { enumerable: true, value: v });
15
- }) : function(o, v) {
16
- o["default"] = v;
17
- });
18
- var __importStar = (this && this.__importStar) || function (mod) {
19
- if (mod && mod.__esModule) return mod;
20
- var result = {};
21
- if (mod != null) for (var k in mod) if (k !== "default" && Object.prototype.hasOwnProperty.call(mod, k)) __createBinding(result, mod, k);
22
- __setModuleDefault(result, mod);
23
- return result;
24
- };
25
2
  Object.defineProperty(exports, "__esModule", { value: true });
26
3
  exports._getWebCryptoInternals = exports.MissingWebCrypto = exports.getWebCrypto = void 0;
27
4
  let webCrypto = undefined;
@@ -29,29 +6,34 @@ let webCrypto = undefined;
29
6
  * Try to get an instance of the Crypto API from the current runtime. Should support Node,
30
7
  * as well as others, like Deno, that implement Web APIs.
31
8
  */
32
- async function getWebCrypto() {
33
- if (webCrypto) {
34
- return webCrypto;
35
- }
36
- /**
37
- * Naively attempt to access Crypto as a global object, which popular alternative run-times
38
- * support.
39
- */
40
- const _globalThisCrypto = exports._getWebCryptoInternals.stubThisGlobalThisCrypto();
41
- if (_globalThisCrypto) {
42
- webCrypto = _globalThisCrypto;
43
- return webCrypto;
44
- }
9
+ function getWebCrypto() {
45
10
  /**
46
- * `globalThis.crypto` isn't available, so attempt a Node import...
11
+ * Hello there! If you came here wondering why this method is asynchronous when use of
12
+ * `globalThis.crypto` is not, it's to minimize a bunch of refactor related to making this
13
+ * synchronous. For example, `generateRegistrationOptions()` and `generateAuthenticationOptions()`
14
+ * become synchronous if we make this synchronous (since nothing else in that method is async)
15
+ * which represents a breaking API change in this library's core API.
16
+ *
17
+ * TODO: If it's after February 2025 when you read this then consider whether it still makes sense
18
+ * to keep this method asynchronous.
47
19
  */
48
- const _nodeCrypto = await exports._getWebCryptoInternals.stubThisImportNodeCrypto();
49
- if (_nodeCrypto?.webcrypto) {
50
- webCrypto = _nodeCrypto.webcrypto;
51
- return webCrypto;
52
- }
53
- // We tried to access it both in Node and globally, so bail out
54
- throw new MissingWebCrypto();
20
+ const toResolve = new Promise((resolve, reject) => {
21
+ if (webCrypto) {
22
+ return resolve(webCrypto);
23
+ }
24
+ /**
25
+ * Naively attempt to access Crypto as a global object, which popular ESM-centric run-times
26
+ * support (and Node v20+)
27
+ */
28
+ const _globalThisCrypto = exports._getWebCryptoInternals.stubThisGlobalThisCrypto();
29
+ if (_globalThisCrypto) {
30
+ webCrypto = _globalThisCrypto;
31
+ return resolve(webCrypto);
32
+ }
33
+ // We tried to access it both in Node and globally, so bail out
34
+ return reject(new MissingWebCrypto());
35
+ });
36
+ return toResolve;
55
37
  }
56
38
  exports.getWebCrypto = getWebCrypto;
57
39
  class MissingWebCrypto extends Error {
@@ -64,26 +46,6 @@ class MissingWebCrypto extends Error {
64
46
  exports.MissingWebCrypto = MissingWebCrypto;
65
47
  // Make it possible to stub return values during testing
66
48
  exports._getWebCryptoInternals = {
67
- stubThisImportNodeCrypto: async () => {
68
- try {
69
- // dnt-shim-ignore
70
- /**
71
- * The `webpackIgnore` here is to help support Next.js' Edge runtime.
72
- * See https://github.com/MasterKale/SimpleWebAuthn/issues/517 for more info.
73
- */
74
- const _nodeCrypto = await Promise.resolve().then(() => __importStar(require(/* webpackIgnore: true */ 'crypto')));
75
- return _nodeCrypto;
76
- }
77
- catch (_err) {
78
- /**
79
- * Intentionally declaring webcrypto as undefined because we're assuming the Node import
80
- * failed due to either:
81
- * - `import()` isn't supported
82
- * - `node:crypto` is unavailable.
83
- */
84
- return { webcrypto: undefined };
85
- }
86
- },
87
49
  stubThisGlobalThisCrypto: () => globalThis.crypto,
88
50
  // Make it possible to reset the `webCrypto` at the top of the file
89
51
  setCachedCrypto: (newCrypto) => {
@@ -57,7 +57,16 @@ function parseAuthenticatorData(authData) {
57
57
  }
58
58
  // Decode the next CBOR item in the buffer, then re-encode it back to a Buffer
59
59
  const firstDecoded = index_js_1.isoCBOR.decodeFirst(authData.slice(pointer));
60
- const firstEncoded = Uint8Array.from(index_js_1.isoCBOR.encode(firstDecoded));
60
+ const firstEncoded = Uint8Array.from(
61
+ /**
62
+ * Casting to `Map` via `as unknown` here because TS doesn't make it possible to define Maps
63
+ * with discrete keys and properties with known types per pair, and CBOR libs typically parse
64
+ * CBOR Major Type 5 to `Map` because you can have numbers for keys. A `COSEPublicKey` can be
65
+ * generalized as "a Map with numbers for keys and either numbers or bytes for values" though.
66
+ * If this presumption falls apart then other parts of verification later on will fail so we
67
+ * should be safe doing this here.
68
+ */
69
+ index_js_1.isoCBOR.encode(firstDecoded));
61
70
  if (foundBadCBOR) {
62
71
  // Restore the bit we changed so that `authData` is the same as it came in and won't break
63
72
  // signature verification.
@@ -8,8 +8,8 @@ const index_js_1 = require("../helpers/iso/index.js");
8
8
  function parseJWT(jwt) {
9
9
  const parts = jwt.split('.');
10
10
  return [
11
- JSON.parse(index_js_1.isoBase64URL.toString(parts[0])),
12
- JSON.parse(index_js_1.isoBase64URL.toString(parts[1])),
11
+ JSON.parse(index_js_1.isoBase64URL.toUTF8String(parts[0])),
12
+ JSON.parse(index_js_1.isoBase64URL.toUTF8String(parts[1])),
13
13
  parts[2],
14
14
  ];
15
15
  }
@@ -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>;