@simplewebauthn/server 8.3.4 → 8.3.5

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.
@@ -20,8 +20,8 @@ export declare const _getWebCryptoInternals: {
20
20
  default: typeof import("crypto");
21
21
  createHash(algorithm: string, options?: import("crypto").HashOptions | undefined): import("crypto").Hash;
22
22
  createHash(algorithm: string, options?: import("crypto").HashOptions | undefined): import("crypto").Hash;
23
- createHmac(algorithm: string, key: import("crypto").BinaryLike | import("crypto").KeyObject, options?: import("stream").TransformOptions | undefined): import("crypto").Hmac;
24
- createHmac(algorithm: string, key: import("crypto").BinaryLike | import("crypto").KeyObject, 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
+ createHmac(algorithm: string, key: import("crypto").KeyObject | import("crypto").BinaryLike, options?: import("stream").TransformOptions | undefined): import("crypto").Hmac;
25
25
  createCipher(algorithm: import("crypto").CipherCCMTypes, password: import("crypto").BinaryLike, options: import("crypto").CipherCCMOptions): import("crypto").CipherCCM;
26
26
  createCipher(algorithm: import("crypto").CipherGCMTypes, password: import("crypto").BinaryLike, options?: import("crypto").CipherGCMOptions | undefined): import("crypto").CipherGCM;
27
27
  createCipher(algorithm: string, password: import("crypto").BinaryLike, options?: import("stream").TransformOptions | undefined): import("crypto").Cipher;
@@ -243,10 +243,10 @@ export declare const _getWebCryptoInternals: {
243
243
  }): Buffer;
244
244
  getCipherInfo(nameOrNid: string | number, options?: import("crypto").CipherInfoOptions | undefined): import("crypto").CipherInfo | undefined;
245
245
  getCipherInfo(nameOrNid: string | number, options?: import("crypto").CipherInfoOptions | undefined): import("crypto").CipherInfo | undefined;
246
- hkdf(digest: string, irm: import("crypto").BinaryLike | import("crypto").KeyObject, 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").BinaryLike | import("crypto").KeyObject, 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").BinaryLike | import("crypto").KeyObject, salt: import("crypto").BinaryLike, info: import("crypto").BinaryLike, keylen: number): ArrayBuffer;
249
- hkdfSync(digest: string, ikm: import("crypto").BinaryLike | import("crypto").KeyObject, salt: import("crypto").BinaryLike, info: import("crypto").BinaryLike, keylen: number): ArrayBuffer;
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
250
  secureHeapUsed(): import("crypto").SecureHeapUsage;
251
251
  secureHeapUsed(): import("crypto").SecureHeapUsage;
252
252
  randomUUID(options?: import("crypto").RandomUUIDOptions | undefined): `${string}-${string}-${string}-${string}-${string}`;
@@ -294,6 +294,8 @@ export declare const _getWebCryptoInternals: {
294
294
  X509Certificate: typeof import("crypto").X509Certificate;
295
295
  subtle: import("crypto").webcrypto.SubtleCrypto;
296
296
  webcrypto: import("crypto").webcrypto.Crypto;
297
+ } | {
298
+ webcrypto: undefined;
297
299
  }>;
298
300
  stubThisGlobalThisCrypto: () => globalThis.Crypto;
299
301
  setCachedCrypto: (newCrypto: Crypto | undefined) => void;
@@ -11,23 +11,18 @@ export async function getWebCrypto() {
11
11
  * Naively attempt to access Crypto as a global object, which popular alternative run-times
12
12
  * support.
13
13
  */
14
- const _crypto = _getWebCryptoInternals.stubThisGlobalThisCrypto();
15
- if (_crypto) {
16
- webCrypto = _crypto;
14
+ const _globalThisCrypto = _getWebCryptoInternals.stubThisGlobalThisCrypto();
15
+ if (_globalThisCrypto) {
16
+ webCrypto = _globalThisCrypto;
17
17
  return webCrypto;
18
18
  }
19
- try {
20
- /**
21
- * `globalThis.crypto` isn't available, so attempt a Node import...
22
- */
23
- const _crypto = await _getWebCryptoInternals.stubThisImportNodeCrypto();
24
- if (_crypto.webcrypto) {
25
- webCrypto = _crypto.webcrypto;
26
- return webCrypto;
27
- }
28
- }
29
- catch (_err) {
30
- // pass
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;
31
26
  }
32
27
  // We tried to access it both in Node and globally, so bail out
33
28
  throw new MissingWebCrypto();
@@ -41,8 +36,22 @@ export class MissingWebCrypto extends Error {
41
36
  }
42
37
  // Make it possible to stub return values during testing
43
38
  export const _getWebCryptoInternals = {
44
- // dnt-shim-ignore
45
- stubThisImportNodeCrypto: () => import('crypto'),
39
+ stubThisImportNodeCrypto: async () => {
40
+ try {
41
+ // dnt-shim-ignore
42
+ const _nodeCrypto = await import('crypto');
43
+ return _nodeCrypto;
44
+ }
45
+ catch (_err) {
46
+ /**
47
+ * Intentionally declaring webcrypto as undefined because we're assuming the Node import
48
+ * failed due to either:
49
+ * - `import()` isn't supported
50
+ * - `node:crypto` is unavailable.
51
+ */
52
+ return { webcrypto: undefined };
53
+ }
54
+ },
46
55
  stubThisGlobalThisCrypto: () => globalThis.crypto,
47
56
  // Make it possible to reset the `webCrypto` at the top of the file
48
57
  setCachedCrypto: (newCrypto) => {
package/package.json CHANGED
@@ -2,7 +2,7 @@
2
2
  "module": "./esm/index.js",
3
3
  "main": "./script/index.js",
4
4
  "name": "@simplewebauthn/server",
5
- "version": "8.3.4",
5
+ "version": "8.3.5",
6
6
  "description": "SimpleWebAuthn for Servers",
7
7
  "license": "MIT",
8
8
  "author": "Matthew Miller <matthew@millerti.me>",
@@ -20,8 +20,8 @@ export declare const _getWebCryptoInternals: {
20
20
  default: typeof import("crypto");
21
21
  createHash(algorithm: string, options?: import("crypto").HashOptions | undefined): import("crypto").Hash;
22
22
  createHash(algorithm: string, options?: import("crypto").HashOptions | undefined): import("crypto").Hash;
23
- createHmac(algorithm: string, key: import("crypto").BinaryLike | import("crypto").KeyObject, options?: import("stream").TransformOptions | undefined): import("crypto").Hmac;
24
- createHmac(algorithm: string, key: import("crypto").BinaryLike | import("crypto").KeyObject, 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
+ createHmac(algorithm: string, key: import("crypto").KeyObject | import("crypto").BinaryLike, options?: import("stream").TransformOptions | undefined): import("crypto").Hmac;
25
25
  createCipher(algorithm: import("crypto").CipherCCMTypes, password: import("crypto").BinaryLike, options: import("crypto").CipherCCMOptions): import("crypto").CipherCCM;
26
26
  createCipher(algorithm: import("crypto").CipherGCMTypes, password: import("crypto").BinaryLike, options?: import("crypto").CipherGCMOptions | undefined): import("crypto").CipherGCM;
27
27
  createCipher(algorithm: string, password: import("crypto").BinaryLike, options?: import("stream").TransformOptions | undefined): import("crypto").Cipher;
@@ -243,10 +243,10 @@ export declare const _getWebCryptoInternals: {
243
243
  }): Buffer;
244
244
  getCipherInfo(nameOrNid: string | number, options?: import("crypto").CipherInfoOptions | undefined): import("crypto").CipherInfo | undefined;
245
245
  getCipherInfo(nameOrNid: string | number, options?: import("crypto").CipherInfoOptions | undefined): import("crypto").CipherInfo | undefined;
246
- hkdf(digest: string, irm: import("crypto").BinaryLike | import("crypto").KeyObject, 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").BinaryLike | import("crypto").KeyObject, 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").BinaryLike | import("crypto").KeyObject, salt: import("crypto").BinaryLike, info: import("crypto").BinaryLike, keylen: number): ArrayBuffer;
249
- hkdfSync(digest: string, ikm: import("crypto").BinaryLike | import("crypto").KeyObject, salt: import("crypto").BinaryLike, info: import("crypto").BinaryLike, keylen: number): ArrayBuffer;
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
250
  secureHeapUsed(): import("crypto").SecureHeapUsage;
251
251
  secureHeapUsed(): import("crypto").SecureHeapUsage;
252
252
  randomUUID(options?: import("crypto").RandomUUIDOptions | undefined): `${string}-${string}-${string}-${string}-${string}`;
@@ -294,6 +294,8 @@ export declare const _getWebCryptoInternals: {
294
294
  X509Certificate: typeof import("crypto").X509Certificate;
295
295
  subtle: import("crypto").webcrypto.SubtleCrypto;
296
296
  webcrypto: import("crypto").webcrypto.Crypto;
297
+ } | {
298
+ webcrypto: undefined;
297
299
  }>;
298
300
  stubThisGlobalThisCrypto: () => globalThis.Crypto;
299
301
  setCachedCrypto: (newCrypto: Crypto | undefined) => void;
@@ -37,23 +37,18 @@ async function getWebCrypto() {
37
37
  * Naively attempt to access Crypto as a global object, which popular alternative run-times
38
38
  * support.
39
39
  */
40
- const _crypto = exports._getWebCryptoInternals.stubThisGlobalThisCrypto();
41
- if (_crypto) {
42
- webCrypto = _crypto;
40
+ const _globalThisCrypto = exports._getWebCryptoInternals.stubThisGlobalThisCrypto();
41
+ if (_globalThisCrypto) {
42
+ webCrypto = _globalThisCrypto;
43
43
  return webCrypto;
44
44
  }
45
- try {
46
- /**
47
- * `globalThis.crypto` isn't available, so attempt a Node import...
48
- */
49
- const _crypto = await exports._getWebCryptoInternals.stubThisImportNodeCrypto();
50
- if (_crypto.webcrypto) {
51
- webCrypto = _crypto.webcrypto;
52
- return webCrypto;
53
- }
54
- }
55
- catch (_err) {
56
- // pass
45
+ /**
46
+ * `globalThis.crypto` isn't available, so attempt a Node import...
47
+ */
48
+ const _nodeCrypto = await exports._getWebCryptoInternals.stubThisImportNodeCrypto();
49
+ if (_nodeCrypto?.webcrypto) {
50
+ webCrypto = _nodeCrypto.webcrypto;
51
+ return webCrypto;
57
52
  }
58
53
  // We tried to access it both in Node and globally, so bail out
59
54
  throw new MissingWebCrypto();
@@ -69,8 +64,22 @@ class MissingWebCrypto extends Error {
69
64
  exports.MissingWebCrypto = MissingWebCrypto;
70
65
  // Make it possible to stub return values during testing
71
66
  exports._getWebCryptoInternals = {
72
- // dnt-shim-ignore
73
- stubThisImportNodeCrypto: () => Promise.resolve().then(() => __importStar(require('crypto'))),
67
+ stubThisImportNodeCrypto: async () => {
68
+ try {
69
+ // dnt-shim-ignore
70
+ const _nodeCrypto = await Promise.resolve().then(() => __importStar(require('crypto')));
71
+ return _nodeCrypto;
72
+ }
73
+ catch (_err) {
74
+ /**
75
+ * Intentionally declaring webcrypto as undefined because we're assuming the Node import
76
+ * failed due to either:
77
+ * - `import()` isn't supported
78
+ * - `node:crypto` is unavailable.
79
+ */
80
+ return { webcrypto: undefined };
81
+ }
82
+ },
74
83
  stubThisGlobalThisCrypto: () => globalThis.crypto,
75
84
  // Make it possible to reset the `webCrypto` at the top of the file
76
85
  setCachedCrypto: (newCrypto) => {