@simplewebauthn/server 13.3.3 → 14.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.
- package/README.md +8 -4
- package/esm/authentication/generateAuthenticationOptions.d.ts +2 -2
- package/esm/authentication/generateAuthenticationOptions.d.ts.map +1 -1
- package/esm/authentication/verifyAuthenticationResponse.d.ts +1 -0
- package/esm/authentication/verifyAuthenticationResponse.d.ts.map +1 -1
- package/esm/authentication/verifyAuthenticationResponse.js +40 -2
- package/esm/helpers/cose.d.ts +18 -2
- package/esm/helpers/cose.d.ts.map +1 -1
- package/esm/helpers/cose.js +12 -0
- package/esm/helpers/decodeClientDataJSON.d.ts +1 -0
- package/esm/helpers/decodeClientDataJSON.d.ts.map +1 -1
- package/esm/helpers/index.d.ts +2 -0
- package/esm/helpers/index.d.ts.map +1 -1
- package/esm/helpers/index.js +2 -0
- package/esm/helpers/iso/isoCrypto/digest.js +2 -2
- package/esm/helpers/iso/isoCrypto/getWebCrypto.d.ts.map +1 -1
- package/esm/helpers/iso/isoCrypto/getWebCrypto.js +12 -0
- package/esm/helpers/iso/isoCrypto/importJWKKey.d.ts +9 -0
- package/esm/helpers/iso/isoCrypto/importJWKKey.d.ts.map +1 -0
- package/esm/helpers/iso/isoCrypto/{importKey.js → importJWKKey.js} +6 -4
- package/esm/helpers/iso/isoCrypto/mapCoseAlgToWebCryptoHashAlgName.d.ts +10 -0
- package/esm/helpers/iso/isoCrypto/mapCoseAlgToWebCryptoHashAlgName.d.ts.map +1 -0
- package/esm/helpers/iso/isoCrypto/{mapCoseAlgToWebCryptoAlg.js → mapCoseAlgToWebCryptoHashAlgName.js} +6 -3
- package/esm/helpers/iso/isoCrypto/mapCoseAlgToWebCryptoKeyAlgName.d.ts +4 -1
- package/esm/helpers/iso/isoCrypto/mapCoseAlgToWebCryptoKeyAlgName.d.ts.map +1 -1
- package/esm/helpers/iso/isoCrypto/mapCoseAlgToWebCryptoKeyAlgName.js +15 -0
- package/esm/helpers/iso/isoCrypto/runtimeSupportsWebCryptoKeyAlg.d.ts +7 -0
- package/esm/helpers/iso/isoCrypto/runtimeSupportsWebCryptoKeyAlg.d.ts.map +1 -0
- package/esm/helpers/iso/isoCrypto/runtimeSupportsWebCryptoKeyAlg.js +16 -0
- package/esm/helpers/iso/isoCrypto/structs.d.ts +1 -1
- package/esm/helpers/iso/isoCrypto/structs.d.ts.map +1 -1
- package/esm/helpers/iso/isoCrypto/verify.d.ts.map +1 -1
- package/esm/helpers/iso/isoCrypto/verify.js +5 -1
- package/esm/helpers/iso/isoCrypto/verifyAKP.d.ts +9 -0
- package/esm/helpers/iso/isoCrypto/verifyAKP.d.ts.map +1 -0
- package/esm/helpers/iso/isoCrypto/verifyAKP.js +47 -0
- package/esm/helpers/iso/isoCrypto/verifyEC2.d.ts.map +1 -1
- package/esm/helpers/iso/isoCrypto/verifyEC2.js +5 -8
- package/esm/helpers/iso/isoCrypto/verifyOKP.d.ts.map +1 -1
- package/esm/helpers/iso/isoCrypto/verifyOKP.js +2 -5
- package/esm/helpers/iso/isoCrypto/verifyRSA.d.ts.map +1 -1
- package/esm/helpers/iso/isoCrypto/verifyRSA.js +5 -8
- package/esm/helpers/logging.d.ts +28 -10
- package/esm/helpers/logging.d.ts.map +1 -1
- package/esm/helpers/logging.js +27 -16
- package/esm/helpers/validateCertificatePath.d.ts.map +1 -1
- package/esm/helpers/validateCertificatePath.js +25 -7
- package/esm/registration/generateRegistrationOptions.d.ts +10 -8
- package/esm/registration/generateRegistrationOptions.d.ts.map +1 -1
- package/esm/registration/generateRegistrationOptions.js +11 -29
- package/esm/registration/verifications/tpm/constants.d.ts +1 -2
- package/esm/registration/verifications/tpm/constants.d.ts.map +1 -1
- package/esm/registration/verifications/tpm/constants.js +1 -2
- package/esm/registration/verifications/tpm/isValidTPMManufacturerID.d.ts +3 -0
- package/esm/registration/verifications/tpm/isValidTPMManufacturerID.d.ts.map +1 -0
- package/esm/registration/verifications/tpm/isValidTPMManufacturerID.js +6 -0
- package/esm/registration/verifications/tpm/verifyAttestationTPM.d.ts.map +1 -1
- package/esm/registration/verifications/tpm/verifyAttestationTPM.js +3 -2
- package/esm/registration/verifyRegistrationResponse.d.ts +3 -3
- package/esm/registration/verifyRegistrationResponse.d.ts.map +1 -1
- package/esm/registration/verifyRegistrationResponse.js +3 -3
- package/esm/services/metadataService.d.ts +4 -0
- package/esm/services/metadataService.d.ts.map +1 -1
- package/esm/services/metadataService.js +16 -10
- package/esm/services/settingsService.d.ts +4 -0
- package/esm/services/settingsService.d.ts.map +1 -1
- package/esm/services/settingsService.js +12 -0
- package/esm/types/dom.d.ts +236 -3
- package/esm/types/dom.d.ts.map +1 -1
- package/esm/types/index.d.ts +158 -44
- package/esm/types/index.d.ts.map +1 -1
- package/package.json +1 -1
- package/script/authentication/generateAuthenticationOptions.d.ts +2 -2
- package/script/authentication/generateAuthenticationOptions.d.ts.map +1 -1
- package/script/authentication/verifyAuthenticationResponse.d.ts +1 -0
- package/script/authentication/verifyAuthenticationResponse.d.ts.map +1 -1
- package/script/authentication/verifyAuthenticationResponse.js +40 -2
- package/script/helpers/cose.d.ts +18 -2
- package/script/helpers/cose.d.ts.map +1 -1
- package/script/helpers/cose.js +13 -0
- package/script/helpers/decodeClientDataJSON.d.ts +1 -0
- package/script/helpers/decodeClientDataJSON.d.ts.map +1 -1
- package/script/helpers/index.d.ts +2 -0
- package/script/helpers/index.d.ts.map +1 -1
- package/script/helpers/index.js +4 -1
- package/script/helpers/iso/isoCrypto/digest.js +2 -2
- package/script/helpers/iso/isoCrypto/getWebCrypto.d.ts.map +1 -1
- package/script/helpers/iso/isoCrypto/getWebCrypto.js +12 -0
- package/script/helpers/iso/isoCrypto/importJWKKey.d.ts +9 -0
- package/script/helpers/iso/isoCrypto/importJWKKey.d.ts.map +1 -0
- package/script/helpers/iso/isoCrypto/{importKey.js → importJWKKey.js} +7 -5
- package/script/helpers/iso/isoCrypto/mapCoseAlgToWebCryptoHashAlgName.d.ts +10 -0
- package/script/helpers/iso/isoCrypto/mapCoseAlgToWebCryptoHashAlgName.d.ts.map +1 -0
- package/script/helpers/iso/isoCrypto/{mapCoseAlgToWebCryptoAlg.js → mapCoseAlgToWebCryptoHashAlgName.js} +7 -4
- package/script/helpers/iso/isoCrypto/mapCoseAlgToWebCryptoKeyAlgName.d.ts +4 -1
- package/script/helpers/iso/isoCrypto/mapCoseAlgToWebCryptoKeyAlgName.d.ts.map +1 -1
- package/script/helpers/iso/isoCrypto/mapCoseAlgToWebCryptoKeyAlgName.js +15 -0
- package/script/helpers/iso/isoCrypto/runtimeSupportsWebCryptoKeyAlg.d.ts +7 -0
- package/script/helpers/iso/isoCrypto/runtimeSupportsWebCryptoKeyAlg.d.ts.map +1 -0
- package/script/helpers/iso/isoCrypto/runtimeSupportsWebCryptoKeyAlg.js +19 -0
- package/script/helpers/iso/isoCrypto/structs.d.ts +1 -1
- package/script/helpers/iso/isoCrypto/structs.d.ts.map +1 -1
- package/script/helpers/iso/isoCrypto/verify.d.ts.map +1 -1
- package/script/helpers/iso/isoCrypto/verify.js +4 -0
- package/script/helpers/iso/isoCrypto/verifyAKP.d.ts +9 -0
- package/script/helpers/iso/isoCrypto/verifyAKP.d.ts.map +1 -0
- package/script/helpers/iso/isoCrypto/verifyAKP.js +50 -0
- package/script/helpers/iso/isoCrypto/verifyEC2.d.ts.map +1 -1
- package/script/helpers/iso/isoCrypto/verifyEC2.js +5 -8
- package/script/helpers/iso/isoCrypto/verifyOKP.d.ts.map +1 -1
- package/script/helpers/iso/isoCrypto/verifyOKP.js +2 -5
- package/script/helpers/iso/isoCrypto/verifyRSA.d.ts.map +1 -1
- package/script/helpers/iso/isoCrypto/verifyRSA.js +5 -8
- package/script/helpers/logging.d.ts +28 -10
- package/script/helpers/logging.d.ts.map +1 -1
- package/script/helpers/logging.js +29 -17
- package/script/helpers/validateCertificatePath.d.ts.map +1 -1
- package/script/helpers/validateCertificatePath.js +25 -7
- package/script/registration/generateRegistrationOptions.d.ts +10 -8
- package/script/registration/generateRegistrationOptions.d.ts.map +1 -1
- package/script/registration/generateRegistrationOptions.js +13 -31
- package/script/registration/verifications/tpm/constants.d.ts +1 -2
- package/script/registration/verifications/tpm/constants.d.ts.map +1 -1
- package/script/registration/verifications/tpm/constants.js +1 -2
- package/script/registration/verifications/tpm/isValidTPMManufacturerID.d.ts +3 -0
- package/script/registration/verifications/tpm/isValidTPMManufacturerID.d.ts.map +1 -0
- package/script/registration/verifications/tpm/isValidTPMManufacturerID.js +9 -0
- package/script/registration/verifications/tpm/verifyAttestationTPM.d.ts.map +1 -1
- package/script/registration/verifications/tpm/verifyAttestationTPM.js +2 -1
- package/script/registration/verifyRegistrationResponse.d.ts +3 -3
- package/script/registration/verifyRegistrationResponse.d.ts.map +1 -1
- package/script/registration/verifyRegistrationResponse.js +2 -2
- package/script/services/metadataService.d.ts +4 -0
- package/script/services/metadataService.d.ts.map +1 -1
- package/script/services/metadataService.js +15 -9
- package/script/services/settingsService.d.ts +4 -0
- package/script/services/settingsService.d.ts.map +1 -1
- package/script/services/settingsService.js +12 -0
- package/script/types/dom.d.ts +236 -3
- package/script/types/dom.d.ts.map +1 -1
- package/script/types/index.d.ts +158 -44
- package/script/types/index.d.ts.map +1 -1
- package/esm/helpers/iso/isoCrypto/importKey.d.ts +0 -5
- package/esm/helpers/iso/isoCrypto/importKey.d.ts.map +0 -1
- package/esm/helpers/iso/isoCrypto/mapCoseAlgToWebCryptoAlg.d.ts +0 -7
- package/esm/helpers/iso/isoCrypto/mapCoseAlgToWebCryptoAlg.d.ts.map +0 -1
- package/script/helpers/iso/isoCrypto/importKey.d.ts +0 -5
- package/script/helpers/iso/isoCrypto/importKey.d.ts.map +0 -1
- package/script/helpers/iso/isoCrypto/mapCoseAlgToWebCryptoAlg.d.ts +0 -7
- package/script/helpers/iso/isoCrypto/mapCoseAlgToWebCryptoAlg.d.ts.map +0 -1
|
@@ -1,11 +1,13 @@
|
|
|
1
1
|
"use strict";
|
|
2
2
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
-
exports.
|
|
3
|
+
exports.importJWKKey = importJWKKey;
|
|
4
4
|
const getWebCrypto_js_1 = require("./getWebCrypto.js");
|
|
5
|
-
|
|
5
|
+
/**
|
|
6
|
+
* Convert a JWK-formatted public key into a WebCrypto CryptoKey that can be used for
|
|
7
|
+
* signature verification
|
|
8
|
+
*/
|
|
9
|
+
async function importJWKKey(opts) {
|
|
6
10
|
const WebCrypto = await (0, getWebCrypto_js_1.getWebCrypto)();
|
|
7
11
|
const { keyData, algorithm } = opts;
|
|
8
|
-
return WebCrypto.subtle.importKey('jwk', keyData, algorithm, false, [
|
|
9
|
-
'verify',
|
|
10
|
-
]);
|
|
12
|
+
return WebCrypto.subtle.importKey('jwk', keyData, algorithm, false, ['verify']);
|
|
11
13
|
}
|
|
@@ -0,0 +1,10 @@
|
|
|
1
|
+
import type { SubtleCryptoAlg } from './structs.js';
|
|
2
|
+
import { COSEALG } from '../../cose.js';
|
|
3
|
+
/**
|
|
4
|
+
* Convert a COSE alg ID into a corresponding hash algorithm string value that WebCrypto APIs expect
|
|
5
|
+
*
|
|
6
|
+
* Unless otherwise specified, mappings were referenced from
|
|
7
|
+
* https://w3c.github.io/webcrypto/#jwk-mapping-alg
|
|
8
|
+
*/
|
|
9
|
+
export declare function mapCoseAlgToWebCryptoHashAlgName(alg: COSEALG): SubtleCryptoAlg;
|
|
10
|
+
//# sourceMappingURL=mapCoseAlgToWebCryptoHashAlgName.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"mapCoseAlgToWebCryptoHashAlgName.d.ts","sourceRoot":"","sources":["../../../../src/helpers/iso/isoCrypto/mapCoseAlgToWebCryptoHashAlgName.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,eAAe,EAAE,MAAM,cAAc,CAAC;AACpD,OAAO,EAAE,OAAO,EAAE,MAAM,eAAe,CAAC;AAExC;;;;;GAKG;AACH,wBAAgB,gCAAgC,CAAC,GAAG,EAAE,OAAO,GAAG,eAAe,CAe9E"}
|
|
@@ -1,11 +1,14 @@
|
|
|
1
1
|
"use strict";
|
|
2
2
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
-
exports.
|
|
3
|
+
exports.mapCoseAlgToWebCryptoHashAlgName = mapCoseAlgToWebCryptoHashAlgName;
|
|
4
4
|
const cose_js_1 = require("../../cose.js");
|
|
5
5
|
/**
|
|
6
|
-
* Convert a COSE alg ID into a corresponding string value that WebCrypto APIs expect
|
|
6
|
+
* Convert a COSE alg ID into a corresponding hash algorithm string value that WebCrypto APIs expect
|
|
7
|
+
*
|
|
8
|
+
* Unless otherwise specified, mappings were referenced from
|
|
9
|
+
* https://w3c.github.io/webcrypto/#jwk-mapping-alg
|
|
7
10
|
*/
|
|
8
|
-
function
|
|
11
|
+
function mapCoseAlgToWebCryptoHashAlgName(alg) {
|
|
9
12
|
if ([cose_js_1.COSEALG.RS1].indexOf(alg) >= 0) {
|
|
10
13
|
return 'SHA-1';
|
|
11
14
|
}
|
|
@@ -19,5 +22,5 @@ function mapCoseAlgToWebCryptoAlg(alg) {
|
|
|
19
22
|
0) {
|
|
20
23
|
return 'SHA-512';
|
|
21
24
|
}
|
|
22
|
-
throw new Error(`Could not map COSE alg value of ${alg} to a WebCrypto alg`);
|
|
25
|
+
throw new Error(`Could not map COSE alg value of ${alg} to a WebCrypto hash alg name`);
|
|
23
26
|
}
|
|
@@ -1,7 +1,10 @@
|
|
|
1
1
|
import { COSEALG } from '../../cose.js';
|
|
2
|
-
import { SubtleCryptoKeyAlgName } from './structs.js';
|
|
2
|
+
import type { SubtleCryptoKeyAlgName } from './structs.js';
|
|
3
3
|
/**
|
|
4
4
|
* Convert a COSE alg ID into a corresponding key algorithm string value that WebCrypto APIs expect
|
|
5
|
+
*
|
|
6
|
+
* Unless otherwise specified, mappings were referenced from
|
|
7
|
+
* https://w3c.github.io/webcrypto/#jwk-mapping-alg
|
|
5
8
|
*/
|
|
6
9
|
export declare function mapCoseAlgToWebCryptoKeyAlgName(alg: COSEALG): SubtleCryptoKeyAlgName;
|
|
7
10
|
//# sourceMappingURL=mapCoseAlgToWebCryptoKeyAlgName.d.ts.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"mapCoseAlgToWebCryptoKeyAlgName.d.ts","sourceRoot":"","sources":["../../../../src/helpers/iso/isoCrypto/mapCoseAlgToWebCryptoKeyAlgName.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,OAAO,EAAE,MAAM,eAAe,CAAC;AACxC,OAAO,EAAE,sBAAsB,EAAE,MAAM,cAAc,CAAC;
|
|
1
|
+
{"version":3,"file":"mapCoseAlgToWebCryptoKeyAlgName.d.ts","sourceRoot":"","sources":["../../../../src/helpers/iso/isoCrypto/mapCoseAlgToWebCryptoKeyAlgName.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,OAAO,EAAE,MAAM,eAAe,CAAC;AACxC,OAAO,KAAK,EAAE,sBAAsB,EAAE,MAAM,cAAc,CAAC;AAE3D;;;;;GAKG;AACH,wBAAgB,+BAA+B,CAC7C,GAAG,EAAE,OAAO,GACX,sBAAsB,CAuBxB"}
|
|
@@ -4,6 +4,9 @@ exports.mapCoseAlgToWebCryptoKeyAlgName = mapCoseAlgToWebCryptoKeyAlgName;
|
|
|
4
4
|
const cose_js_1 = require("../../cose.js");
|
|
5
5
|
/**
|
|
6
6
|
* Convert a COSE alg ID into a corresponding key algorithm string value that WebCrypto APIs expect
|
|
7
|
+
*
|
|
8
|
+
* Unless otherwise specified, mappings were referenced from
|
|
9
|
+
* https://w3c.github.io/webcrypto/#jwk-mapping-alg
|
|
7
10
|
*/
|
|
8
11
|
function mapCoseAlgToWebCryptoKeyAlgName(alg) {
|
|
9
12
|
if ([cose_js_1.COSEALG.EdDSA].indexOf(alg) >= 0) {
|
|
@@ -18,5 +21,17 @@ function mapCoseAlgToWebCryptoKeyAlgName(alg) {
|
|
|
18
21
|
else if ([cose_js_1.COSEALG.PS256, cose_js_1.COSEALG.PS384, cose_js_1.COSEALG.PS512].indexOf(alg) >= 0) {
|
|
19
22
|
return 'RSA-PSS';
|
|
20
23
|
}
|
|
24
|
+
else if ([cose_js_1.COSEALG.ML_DSA_44].indexOf(alg) >= 0) {
|
|
25
|
+
// https://wicg.github.io/webcrypto-modern-algos/#ml-dsa-registration
|
|
26
|
+
return 'ML-DSA-44';
|
|
27
|
+
}
|
|
28
|
+
else if ([cose_js_1.COSEALG.ML_DSA_65].indexOf(alg) >= 0) {
|
|
29
|
+
// https://wicg.github.io/webcrypto-modern-algos/#ml-dsa-registration
|
|
30
|
+
return 'ML-DSA-65';
|
|
31
|
+
}
|
|
32
|
+
else if ([cose_js_1.COSEALG.ML_DSA_87].indexOf(alg) >= 0) {
|
|
33
|
+
// https://wicg.github.io/webcrypto-modern-algos/#ml-dsa-registration
|
|
34
|
+
return 'ML-DSA-87';
|
|
35
|
+
}
|
|
21
36
|
throw new Error(`Could not map COSE alg value of ${alg} to a WebCrypto key alg name`);
|
|
22
37
|
}
|
|
@@ -0,0 +1,7 @@
|
|
|
1
|
+
import type { AlgorithmIdentifier } from '../../../types/index.js';
|
|
2
|
+
/**
|
|
3
|
+
* Use SubtleCrypto.supports() to understand if the runtime supports using the given key algorithm
|
|
4
|
+
* for signature verification.
|
|
5
|
+
*/
|
|
6
|
+
export declare function runtimeSupportsWebCryptoKeyAlg(alg: AlgorithmIdentifier): boolean;
|
|
7
|
+
//# sourceMappingURL=runtimeSupportsWebCryptoKeyAlg.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"runtimeSupportsWebCryptoKeyAlg.d.ts","sourceRoot":"","sources":["../../../../src/helpers/iso/isoCrypto/runtimeSupportsWebCryptoKeyAlg.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,mBAAmB,EAAsB,MAAM,yBAAyB,CAAC;AAEvF;;;GAGG;AACH,wBAAgB,8BAA8B,CAAC,GAAG,EAAE,mBAAmB,GAAG,OAAO,CAYhF"}
|
|
@@ -0,0 +1,19 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
+
exports.runtimeSupportsWebCryptoKeyAlg = runtimeSupportsWebCryptoKeyAlg;
|
|
4
|
+
/**
|
|
5
|
+
* Use SubtleCrypto.supports() to understand if the runtime supports using the given key algorithm
|
|
6
|
+
* for signature verification.
|
|
7
|
+
*/
|
|
8
|
+
function runtimeSupportsWebCryptoKeyAlg(alg) {
|
|
9
|
+
const globalSubtleCrypto = globalThis.SubtleCrypto;
|
|
10
|
+
if (typeof globalSubtleCrypto.supports !== 'function') {
|
|
11
|
+
return false;
|
|
12
|
+
}
|
|
13
|
+
try {
|
|
14
|
+
return globalSubtleCrypto.supports('verify', alg);
|
|
15
|
+
}
|
|
16
|
+
catch (_err) {
|
|
17
|
+
return false;
|
|
18
|
+
}
|
|
19
|
+
}
|
|
@@ -1,4 +1,4 @@
|
|
|
1
1
|
export type SubtleCryptoAlg = 'SHA-1' | 'SHA-256' | 'SHA-384' | 'SHA-512';
|
|
2
2
|
export type SubtleCryptoCrv = 'P-256' | 'P-384' | 'P-521' | 'Ed25519';
|
|
3
|
-
export type SubtleCryptoKeyAlgName = 'ECDSA' | 'Ed25519' | 'RSASSA-PKCS1-v1_5' | 'RSA-PSS';
|
|
3
|
+
export type SubtleCryptoKeyAlgName = 'ECDSA' | 'Ed25519' | 'ML-DSA-44' | 'ML-DSA-65' | 'ML-DSA-87' | 'RSASSA-PKCS1-v1_5' | 'RSA-PSS';
|
|
4
4
|
//# sourceMappingURL=structs.d.ts.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"structs.d.ts","sourceRoot":"","sources":["../../../../src/helpers/iso/isoCrypto/structs.ts"],"names":[],"mappings":"AAAA,MAAM,MAAM,eAAe,GAAG,OAAO,GAAG,SAAS,GAAG,SAAS,GAAG,SAAS,CAAC;AAC1E,MAAM,MAAM,eAAe,GAAG,OAAO,GAAG,OAAO,GAAG,OAAO,GAAG,SAAS,CAAC;AACtE,MAAM,MAAM,sBAAsB,GAC9B,OAAO,GACP,SAAS,GACT,mBAAmB,GACnB,SAAS,CAAC"}
|
|
1
|
+
{"version":3,"file":"structs.d.ts","sourceRoot":"","sources":["../../../../src/helpers/iso/isoCrypto/structs.ts"],"names":[],"mappings":"AAAA,MAAM,MAAM,eAAe,GAAG,OAAO,GAAG,SAAS,GAAG,SAAS,GAAG,SAAS,CAAC;AAC1E,MAAM,MAAM,eAAe,GAAG,OAAO,GAAG,OAAO,GAAG,OAAO,GAAG,SAAS,CAAC;AACtE,MAAM,MAAM,sBAAsB,GAC9B,OAAO,GACP,SAAS,GACT,WAAW,GACX,WAAW,GACX,WAAW,GACX,mBAAmB,GACnB,SAAS,CAAC"}
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"verify.d.ts","sourceRoot":"","sources":["../../../../src/helpers/iso/isoCrypto/verify.ts"],"names":[],"mappings":"AAAA,OAAO,EACL,KAAK,OAAO,EAEZ,KAAK,aAAa,
|
|
1
|
+
{"version":3,"file":"verify.d.ts","sourceRoot":"","sources":["../../../../src/helpers/iso/isoCrypto/verify.ts"],"names":[],"mappings":"AAAA,OAAO,EACL,KAAK,OAAO,EAEZ,KAAK,aAAa,EAMnB,MAAM,eAAe,CAAC;AAMvB,OAAO,KAAK,EAAE,WAAW,EAAE,MAAM,yBAAyB,CAAC;AAE3D;;GAEG;AACH,wBAAgB,MAAM,CAAC,IAAI,EAAE;IAC3B,aAAa,EAAE,aAAa,CAAC;IAC7B,SAAS,EAAE,WAAW,CAAC;IACvB,IAAI,EAAE,WAAW,CAAC;IAClB,eAAe,CAAC,EAAE,OAAO,CAAC;CAC3B,GAAG,OAAO,CAAC,OAAO,CAAC,CA2BnB"}
|
|
@@ -2,6 +2,7 @@
|
|
|
2
2
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
3
|
exports.verify = verify;
|
|
4
4
|
const cose_js_1 = require("../../cose.js");
|
|
5
|
+
const verifyAKP_js_1 = require("./verifyAKP.js");
|
|
5
6
|
const verifyEC2_js_1 = require("./verifyEC2.js");
|
|
6
7
|
const verifyRSA_js_1 = require("./verifyRSA.js");
|
|
7
8
|
const verifyOKP_js_1 = require("./verifyOKP.js");
|
|
@@ -30,6 +31,9 @@ function verify(opts) {
|
|
|
30
31
|
else if ((0, cose_js_1.isCOSEPublicKeyOKP)(cosePublicKey)) {
|
|
31
32
|
return (0, verifyOKP_js_1.verifyOKP)({ cosePublicKey, signature, data });
|
|
32
33
|
}
|
|
34
|
+
else if ((0, cose_js_1.isCOSEPublicKeyAKP)(cosePublicKey)) {
|
|
35
|
+
return (0, verifyAKP_js_1.verifyAKP)({ cosePublicKey, signature, data });
|
|
36
|
+
}
|
|
33
37
|
const kty = cosePublicKey.get(cose_js_1.COSEKEYS.kty);
|
|
34
38
|
throw new Error(`Signature verification with public key of kty ${kty} is not supported by this method`);
|
|
35
39
|
}
|
|
@@ -0,0 +1,9 @@
|
|
|
1
|
+
import { type COSEPublicKeyAKP } from '../../cose.js';
|
|
2
|
+
import type { Uint8Array_ } from '../../../types/index.js';
|
|
3
|
+
/** AKP, a.k.a ML-DSA */
|
|
4
|
+
export declare function verifyAKP(opts: {
|
|
5
|
+
cosePublicKey: COSEPublicKeyAKP;
|
|
6
|
+
signature: Uint8Array_;
|
|
7
|
+
data: Uint8Array_;
|
|
8
|
+
}): Promise<boolean>;
|
|
9
|
+
//# sourceMappingURL=verifyAKP.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"verifyAKP.d.ts","sourceRoot":"","sources":["../../../../src/helpers/iso/isoCrypto/verifyAKP.ts"],"names":[],"mappings":"AAAA,OAAO,EAAY,KAAK,gBAAgB,EAAa,MAAM,eAAe,CAAC;AAK3E,OAAO,KAAK,EAAmB,WAAW,EAAE,MAAM,yBAAyB,CAAC;AAE5E,wBAAwB;AACxB,wBAAsB,SAAS,CAAC,IAAI,EAAE;IACpC,aAAa,EAAE,gBAAgB,CAAC;IAChC,SAAS,EAAE,WAAW,CAAC;IACvB,IAAI,EAAE,WAAW,CAAC;CACnB,GAAG,OAAO,CAAC,OAAO,CAAC,CAkDnB"}
|
|
@@ -0,0 +1,50 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
+
exports.verifyAKP = verifyAKP;
|
|
4
|
+
const cose_js_1 = require("../../cose.js");
|
|
5
|
+
const index_js_1 = require("../../index.js");
|
|
6
|
+
const importJWKKey_js_1 = require("./importJWKKey.js");
|
|
7
|
+
const getWebCrypto_js_1 = require("./getWebCrypto.js");
|
|
8
|
+
const mapCoseAlgToWebCryptoKeyAlgName_js_1 = require("./mapCoseAlgToWebCryptoKeyAlgName.js");
|
|
9
|
+
/** AKP, a.k.a ML-DSA */
|
|
10
|
+
async function verifyAKP(opts) {
|
|
11
|
+
const { cosePublicKey, signature, data } = opts;
|
|
12
|
+
const WebCrypto = await (0, getWebCrypto_js_1.getWebCrypto)();
|
|
13
|
+
const alg = cosePublicKey.get(cose_js_1.COSEKEYS.alg);
|
|
14
|
+
const pub = cosePublicKey.get(cose_js_1.COSEKEYS.pub);
|
|
15
|
+
if (!alg) {
|
|
16
|
+
throw new Error('Public key was missing alg (AKP)');
|
|
17
|
+
}
|
|
18
|
+
if (!(0, cose_js_1.isCOSEAlg)(alg)) {
|
|
19
|
+
throw new Error(`Public key had invalid alg ${alg} (AKP)`);
|
|
20
|
+
}
|
|
21
|
+
if (!pub) {
|
|
22
|
+
throw new Error('Public key was missing pub (AKP)');
|
|
23
|
+
}
|
|
24
|
+
const webCryptoAlg = (0, mapCoseAlgToWebCryptoKeyAlgName_js_1.mapCoseAlgToWebCryptoKeyAlgName)(alg);
|
|
25
|
+
// See https://wicg.github.io/webcrypto-modern-algos/#ml-dsa-operations-import-key -> "jwk"
|
|
26
|
+
const keyData = {
|
|
27
|
+
kty: 'AKP',
|
|
28
|
+
alg: webCryptoAlg,
|
|
29
|
+
pub: index_js_1.isoBase64URL.fromBuffer(pub),
|
|
30
|
+
ext: false,
|
|
31
|
+
};
|
|
32
|
+
/**
|
|
33
|
+
* ML-DSA support is pretty cutting edge, so take some steps to help RP's understand this instead
|
|
34
|
+
* of them getting a `NotSupportedError: Unrecognized algorithm name` and trying to interpret it.
|
|
35
|
+
*/
|
|
36
|
+
let key;
|
|
37
|
+
try {
|
|
38
|
+
key = await (0, importJWKKey_js_1.importJWKKey)({ keyData, algorithm: webCryptoAlg });
|
|
39
|
+
}
|
|
40
|
+
catch (err) {
|
|
41
|
+
const _err = err;
|
|
42
|
+
if (_err.name === 'NotSupportedError') {
|
|
43
|
+
throw new Error(`This runtime's WebCrypto.subtle does not support use of ${webCryptoAlg}. See the \`cause\` property of this error for more info`, { cause: err });
|
|
44
|
+
}
|
|
45
|
+
else {
|
|
46
|
+
throw err;
|
|
47
|
+
}
|
|
48
|
+
}
|
|
49
|
+
return WebCrypto.subtle.verify(webCryptoAlg, key, signature, data);
|
|
50
|
+
}
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"verifyEC2.d.ts","sourceRoot":"","sources":["../../../../src/helpers/iso/isoCrypto/verifyEC2.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,KAAK,OAAO,EAAqB,KAAK,gBAAgB,EAAE,MAAM,eAAe,CAAC;AAMvF,OAAO,KAAK,EAAE,WAAW,EAAE,MAAM,yBAAyB,CAAC;AAE3D;;GAEG;AACH,wBAAsB,SAAS,CAAC,IAAI,EAAE;IACpC,aAAa,EAAE,gBAAgB,CAAC;IAChC,SAAS,EAAE,WAAW,CAAC;IACvB,IAAI,EAAE,WAAW,CAAC;IAClB,eAAe,CAAC,EAAE,OAAO,CAAC;CAC3B,GAAG,OAAO,CAAC,OAAO,CAAC,
|
|
1
|
+
{"version":3,"file":"verifyEC2.d.ts","sourceRoot":"","sources":["../../../../src/helpers/iso/isoCrypto/verifyEC2.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,KAAK,OAAO,EAAqB,KAAK,gBAAgB,EAAE,MAAM,eAAe,CAAC;AAMvF,OAAO,KAAK,EAAE,WAAW,EAAE,MAAM,yBAAyB,CAAC;AAE3D;;GAEG;AACH,wBAAsB,SAAS,CAAC,IAAI,EAAE;IACpC,aAAa,EAAE,gBAAgB,CAAC;IAChC,SAAS,EAAE,WAAW,CAAC;IACvB,IAAI,EAAE,WAAW,CAAC;IAClB,eAAe,CAAC,EAAE,OAAO,CAAC;CAC3B,GAAG,OAAO,CAAC,OAAO,CAAC,CAuEnB"}
|
|
@@ -2,8 +2,8 @@
|
|
|
2
2
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
3
|
exports.verifyEC2 = verifyEC2;
|
|
4
4
|
const cose_js_1 = require("../../cose.js");
|
|
5
|
-
const
|
|
6
|
-
const
|
|
5
|
+
const mapCoseAlgToWebCryptoHashAlgName_js_1 = require("./mapCoseAlgToWebCryptoHashAlgName.js");
|
|
6
|
+
const importJWKKey_js_1 = require("./importJWKKey.js");
|
|
7
7
|
const index_js_1 = require("../index.js");
|
|
8
8
|
const getWebCrypto_js_1 = require("./getWebCrypto.js");
|
|
9
9
|
/**
|
|
@@ -59,14 +59,11 @@ async function verifyEC2(opts) {
|
|
|
59
59
|
name: 'ECDSA',
|
|
60
60
|
namedCurve: _crv,
|
|
61
61
|
};
|
|
62
|
-
const key = await (0,
|
|
63
|
-
keyData,
|
|
64
|
-
algorithm: keyAlgorithm,
|
|
65
|
-
});
|
|
62
|
+
const key = await (0, importJWKKey_js_1.importJWKKey)({ keyData, algorithm: keyAlgorithm });
|
|
66
63
|
// Determine which SHA algorithm to use for signature verification
|
|
67
|
-
let subtleAlg = (0,
|
|
64
|
+
let subtleAlg = (0, mapCoseAlgToWebCryptoHashAlgName_js_1.mapCoseAlgToWebCryptoHashAlgName)(alg);
|
|
68
65
|
if (shaHashOverride) {
|
|
69
|
-
subtleAlg = (0,
|
|
66
|
+
subtleAlg = (0, mapCoseAlgToWebCryptoHashAlgName_js_1.mapCoseAlgToWebCryptoHashAlgName)(shaHashOverride);
|
|
70
67
|
}
|
|
71
68
|
const verifyAlgorithm = {
|
|
72
69
|
name: 'ECDSA',
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"verifyOKP.d.ts","sourceRoot":"","sources":["../../../../src/helpers/iso/isoCrypto/verifyOKP.ts"],"names":[],"mappings":"AAAA,OAAO,EAAqB,KAAK,gBAAgB,EAAa,MAAM,eAAe,CAAC;AAKpF,OAAO,KAAK,EAAE,WAAW,EAAE,MAAM,yBAAyB,CAAC;AAE3D,wBAAsB,SAAS,CAAC,IAAI,EAAE;IACpC,aAAa,EAAE,gBAAgB,CAAC;IAChC,SAAS,EAAE,WAAW,CAAC;IACvB,IAAI,EAAE,WAAW,CAAC;CACnB,GAAG,OAAO,CAAC,OAAO,CAAC,
|
|
1
|
+
{"version":3,"file":"verifyOKP.d.ts","sourceRoot":"","sources":["../../../../src/helpers/iso/isoCrypto/verifyOKP.ts"],"names":[],"mappings":"AAAA,OAAO,EAAqB,KAAK,gBAAgB,EAAa,MAAM,eAAe,CAAC;AAKpF,OAAO,KAAK,EAAE,WAAW,EAAE,MAAM,yBAAyB,CAAC;AAE3D,wBAAsB,SAAS,CAAC,IAAI,EAAE;IACpC,aAAa,EAAE,gBAAgB,CAAC;IAChC,SAAS,EAAE,WAAW,CAAC;IACvB,IAAI,EAAE,WAAW,CAAC;CACnB,GAAG,OAAO,CAAC,OAAO,CAAC,CAsDnB"}
|
|
@@ -3,7 +3,7 @@ Object.defineProperty(exports, "__esModule", { value: true });
|
|
|
3
3
|
exports.verifyOKP = verifyOKP;
|
|
4
4
|
const cose_js_1 = require("../../cose.js");
|
|
5
5
|
const index_js_1 = require("../../index.js");
|
|
6
|
-
const
|
|
6
|
+
const importJWKKey_js_1 = require("./importJWKKey.js");
|
|
7
7
|
const getWebCrypto_js_1 = require("./getWebCrypto.js");
|
|
8
8
|
async function verifyOKP(opts) {
|
|
9
9
|
const { cosePublicKey, signature, data } = opts;
|
|
@@ -43,10 +43,7 @@ async function verifyOKP(opts) {
|
|
|
43
43
|
name: _crv,
|
|
44
44
|
namedCurve: _crv,
|
|
45
45
|
};
|
|
46
|
-
const key = await (0,
|
|
47
|
-
keyData,
|
|
48
|
-
algorithm: keyAlgorithm,
|
|
49
|
-
});
|
|
46
|
+
const key = await (0, importJWKKey_js_1.importJWKKey)({ keyData, algorithm: keyAlgorithm });
|
|
50
47
|
const verifyAlgorithm = {
|
|
51
48
|
name: _crv,
|
|
52
49
|
};
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"verifyRSA.d.ts","sourceRoot":"","sources":["../../../../src/helpers/iso/isoCrypto/verifyRSA.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,KAAK,OAAO,EAAY,KAAK,gBAAgB,EAAa,MAAM,eAAe,CAAC;AAMzF,OAAO,KAAK,EAAE,WAAW,EAAE,MAAM,yBAAyB,CAAC;AAE3D;;GAEG;AACH,wBAAsB,SAAS,CAAC,IAAI,EAAE;IACpC,aAAa,EAAE,gBAAgB,CAAC;IAChC,SAAS,EAAE,WAAW,CAAC;IACvB,IAAI,EAAE,WAAW,CAAC;IAClB,eAAe,CAAC,EAAE,OAAO,CAAC;CAC3B,GAAG,OAAO,CAAC,OAAO,CAAC,
|
|
1
|
+
{"version":3,"file":"verifyRSA.d.ts","sourceRoot":"","sources":["../../../../src/helpers/iso/isoCrypto/verifyRSA.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,KAAK,OAAO,EAAY,KAAK,gBAAgB,EAAa,MAAM,eAAe,CAAC;AAMzF,OAAO,KAAK,EAAE,WAAW,EAAE,MAAM,yBAAyB,CAAC;AAE3D;;GAEG;AACH,wBAAsB,SAAS,CAAC,IAAI,EAAE;IACpC,aAAa,EAAE,gBAAgB,CAAC;IAChC,SAAS,EAAE,WAAW,CAAC;IACvB,IAAI,EAAE,WAAW,CAAC;IAClB,eAAe,CAAC,EAAE,OAAO,CAAC;CAC3B,GAAG,OAAO,CAAC,OAAO,CAAC,CAwFnB"}
|
|
@@ -2,8 +2,8 @@
|
|
|
2
2
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
3
|
exports.verifyRSA = verifyRSA;
|
|
4
4
|
const cose_js_1 = require("../../cose.js");
|
|
5
|
-
const
|
|
6
|
-
const
|
|
5
|
+
const mapCoseAlgToWebCryptoHashAlgName_js_1 = require("./mapCoseAlgToWebCryptoHashAlgName.js");
|
|
6
|
+
const importJWKKey_js_1 = require("./importJWKKey.js");
|
|
7
7
|
const index_js_1 = require("../index.js");
|
|
8
8
|
const mapCoseAlgToWebCryptoKeyAlgName_js_1 = require("./mapCoseAlgToWebCryptoKeyAlgName.js");
|
|
9
9
|
const getWebCrypto_js_1 = require("./getWebCrypto.js");
|
|
@@ -37,13 +37,13 @@ async function verifyRSA(opts) {
|
|
|
37
37
|
};
|
|
38
38
|
const keyAlgorithm = {
|
|
39
39
|
name: (0, mapCoseAlgToWebCryptoKeyAlgName_js_1.mapCoseAlgToWebCryptoKeyAlgName)(alg),
|
|
40
|
-
hash: { name: (0,
|
|
40
|
+
hash: { name: (0, mapCoseAlgToWebCryptoHashAlgName_js_1.mapCoseAlgToWebCryptoHashAlgName)(alg) },
|
|
41
41
|
};
|
|
42
42
|
const verifyAlgorithm = {
|
|
43
43
|
name: (0, mapCoseAlgToWebCryptoKeyAlgName_js_1.mapCoseAlgToWebCryptoKeyAlgName)(alg),
|
|
44
44
|
};
|
|
45
45
|
if (shaHashOverride) {
|
|
46
|
-
keyAlgorithm.hash.name = (0,
|
|
46
|
+
keyAlgorithm.hash.name = (0, mapCoseAlgToWebCryptoHashAlgName_js_1.mapCoseAlgToWebCryptoHashAlgName)(shaHashOverride);
|
|
47
47
|
}
|
|
48
48
|
if (keyAlgorithm.name === 'RSASSA-PKCS1-v1_5') {
|
|
49
49
|
if (keyAlgorithm.hash.name === 'SHA-256') {
|
|
@@ -86,9 +86,6 @@ async function verifyRSA(opts) {
|
|
|
86
86
|
else {
|
|
87
87
|
throw new Error(`Unexpected RSA key algorithm ${alg} (${keyAlgorithm.name})`);
|
|
88
88
|
}
|
|
89
|
-
const key = await (0,
|
|
90
|
-
keyData,
|
|
91
|
-
algorithm: keyAlgorithm,
|
|
92
|
-
});
|
|
89
|
+
const key = await (0, importJWKKey_js_1.importJWKKey)({ keyData, algorithm: keyAlgorithm });
|
|
93
90
|
return WebCrypto.subtle.verify(verifyAlgorithm, key, signature, data);
|
|
94
91
|
}
|
|
@@ -1,16 +1,34 @@
|
|
|
1
1
|
/**
|
|
2
|
-
*
|
|
3
|
-
*
|
|
2
|
+
* A basic logging interface that enables projects to capture logging output from SimpleWebAuthn
|
|
3
|
+
* using whatever logging method is appropriate for the project. Logging levels can be defined
|
|
4
|
+
* independently to only capture desired levels.
|
|
4
5
|
*
|
|
5
|
-
*
|
|
6
|
-
*
|
|
6
|
+
* For example, a project using `console` statements to capture logs can use the following
|
|
7
|
+
* implementation of this interface:
|
|
7
8
|
*
|
|
8
|
-
*
|
|
9
|
-
*
|
|
10
|
-
*
|
|
11
|
-
*
|
|
12
|
-
*
|
|
9
|
+
* ```ts
|
|
10
|
+
* const ConsoleLogger: SimpleWebAuthnLogger = {
|
|
11
|
+
* // debug(message: string, ...args: unknown[]) { console.debug(message, ...args); },
|
|
12
|
+
* info(message: string, ...args: unknown[]) { console.info(message, ...args); },
|
|
13
|
+
* warn(message: string, ...args: unknown[]) { console.warn(message, ...args); },
|
|
14
|
+
* error(message: string, ...args: unknown[]) { console.error(message, ...args); },
|
|
15
|
+
* };
|
|
13
16
|
* ```
|
|
14
17
|
*/
|
|
15
|
-
export
|
|
18
|
+
export interface SimpleWebAuthnLogger {
|
|
19
|
+
debug?: (message: string, ...args: unknown[]) => void;
|
|
20
|
+
info?: (message: string, ...args: unknown[]) => void;
|
|
21
|
+
warn?: (message: string, ...args: unknown[]) => void;
|
|
22
|
+
error?: (message: string, ...args: unknown[]) => void;
|
|
23
|
+
}
|
|
24
|
+
/**
|
|
25
|
+
* A logger instance that doesn't do anything. Useful as a default argument when no custom instance
|
|
26
|
+
* of the `SimpleWebAuthnLogger` interface is specified.
|
|
27
|
+
*/
|
|
28
|
+
export declare const DefaultNoopLogger: Required<SimpleWebAuthnLogger>;
|
|
29
|
+
/**
|
|
30
|
+
* Generate an instance of SimpleWebAuthnLogger that defines all methods. Any logging method not
|
|
31
|
+
* defined on `logger` will be a no-op.
|
|
32
|
+
*/
|
|
33
|
+
export declare function buildLoggerAllMethods(logger: SimpleWebAuthnLogger): Required<SimpleWebAuthnLogger>;
|
|
16
34
|
//# sourceMappingURL=logging.d.ts.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"logging.d.ts","sourceRoot":"","sources":["../../src/helpers/logging.ts"],"names":[],"mappings":"
|
|
1
|
+
{"version":3,"file":"logging.d.ts","sourceRoot":"","sources":["../../src/helpers/logging.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;;;;;;;GAgBG;AACH,MAAM,WAAW,oBAAoB;IACnC,KAAK,CAAC,EAAE,CAAC,OAAO,EAAE,MAAM,EAAE,GAAG,IAAI,EAAE,OAAO,EAAE,KAAK,IAAI,CAAC;IACtD,IAAI,CAAC,EAAE,CAAC,OAAO,EAAE,MAAM,EAAE,GAAG,IAAI,EAAE,OAAO,EAAE,KAAK,IAAI,CAAC;IACrD,IAAI,CAAC,EAAE,CAAC,OAAO,EAAE,MAAM,EAAE,GAAG,IAAI,EAAE,OAAO,EAAE,KAAK,IAAI,CAAC;IACrD,KAAK,CAAC,EAAE,CAAC,OAAO,EAAE,MAAM,EAAE,GAAG,IAAI,EAAE,OAAO,EAAE,KAAK,IAAI,CAAC;CACvD;AAED;;;GAGG;AACH,eAAO,MAAM,iBAAiB,EAAE,QAAQ,CAAC,oBAAoB,CAK5D,CAAC;AAEF;;;GAGG;AACH,wBAAgB,qBAAqB,CACnC,MAAM,EAAE,oBAAoB,GAC3B,QAAQ,CAAC,oBAAoB,CAAC,CAoBhC"}
|
|
@@ -1,22 +1,34 @@
|
|
|
1
1
|
"use strict";
|
|
2
|
-
// const defaultLogger = debug('SimpleWebAuthn');
|
|
3
2
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
4
|
-
exports.
|
|
3
|
+
exports.DefaultNoopLogger = void 0;
|
|
4
|
+
exports.buildLoggerAllMethods = buildLoggerAllMethods;
|
|
5
5
|
/**
|
|
6
|
-
*
|
|
7
|
-
*
|
|
8
|
-
*
|
|
9
|
-
* See https://www.npmjs.com/package/debug for information on how to control logging output when
|
|
10
|
-
* using @simplewebauthn/server
|
|
11
|
-
*
|
|
12
|
-
* Example:
|
|
13
|
-
*
|
|
14
|
-
* ```
|
|
15
|
-
* const log = getLogger('mds');
|
|
16
|
-
* log('hello'); // simplewebauthn:mds hello +0ms
|
|
17
|
-
* ```
|
|
6
|
+
* A logger instance that doesn't do anything. Useful as a default argument when no custom instance
|
|
7
|
+
* of the `SimpleWebAuthnLogger` interface is specified.
|
|
18
8
|
*/
|
|
19
|
-
|
|
20
|
-
|
|
21
|
-
|
|
9
|
+
exports.DefaultNoopLogger = {
|
|
10
|
+
debug() { },
|
|
11
|
+
info() { },
|
|
12
|
+
warn() { },
|
|
13
|
+
error() { },
|
|
14
|
+
};
|
|
15
|
+
/**
|
|
16
|
+
* Generate an instance of SimpleWebAuthnLogger that defines all methods. Any logging method not
|
|
17
|
+
* defined on `logger` will be a no-op.
|
|
18
|
+
*/
|
|
19
|
+
function buildLoggerAllMethods(logger) {
|
|
20
|
+
const toReturn = { ...exports.DefaultNoopLogger };
|
|
21
|
+
if (logger.debug) {
|
|
22
|
+
toReturn.debug = logger.debug;
|
|
23
|
+
}
|
|
24
|
+
if (logger.info) {
|
|
25
|
+
toReturn.info = logger.info;
|
|
26
|
+
}
|
|
27
|
+
if (logger.warn) {
|
|
28
|
+
toReturn.warn = logger.warn;
|
|
29
|
+
}
|
|
30
|
+
if (logger.error) {
|
|
31
|
+
toReturn.error = logger.error;
|
|
32
|
+
}
|
|
33
|
+
return toReturn;
|
|
22
34
|
}
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"validateCertificatePath.d.ts","sourceRoot":"","sources":["../../src/helpers/validateCertificatePath.ts"],"names":[],"mappings":"AAIA;;;;GAIG;AACH,wBAAsB,uBAAuB,CAC3C,WAAW,EAAE,MAAM,EAAE,EACrB,eAAe,GAAE,MAAM,EAAO,GAC7B,OAAO,CAAC,OAAO,CAAC,
|
|
1
|
+
{"version":3,"file":"validateCertificatePath.d.ts","sourceRoot":"","sources":["../../src/helpers/validateCertificatePath.ts"],"names":[],"mappings":"AAIA;;;;GAIG;AACH,wBAAsB,uBAAuB,CAC3C,WAAW,EAAE,MAAM,EAAE,EACrB,eAAe,GAAE,MAAM,EAAO,GAC7B,OAAO,CAAC,OAAO,CAAC,CAqIlB"}
|
|
@@ -82,15 +82,33 @@ async function validateCertificatePath(x5cCertsPEM, trustAnchorsPEM = []) {
|
|
|
82
82
|
}
|
|
83
83
|
// Order of certs doesn't matter here but for readability
|
|
84
84
|
const chainBuilder = new x509_1.X509ChainBuilder({ certificates: [...x5cIntermediates, anchor] });
|
|
85
|
-
//
|
|
85
|
+
// Attempt to build a certificate path
|
|
86
86
|
const chain = await chainBuilder.build(x5cLeafCert);
|
|
87
|
-
|
|
88
|
-
|
|
89
|
-
|
|
90
|
-
|
|
87
|
+
/**
|
|
88
|
+
* The cert chain must chain to the anchor. Usually this is as simple as asserting that the
|
|
89
|
+
* final cert in the chain is the anchor cert. However there's an odd scenario where an
|
|
90
|
+
* intermediate certificate can chain to an anchor cert's public key, but not actually to the
|
|
91
|
+
* anchor cert because e.g. the chain builder stopped at a cross-signed cert for the anchor
|
|
92
|
+
* and not the anchor cert itself.
|
|
93
|
+
*
|
|
94
|
+
* So here we're going to check for that. In the simplest case we'll be fine with the last
|
|
95
|
+
* cert in the chain being byte-equivalent to the current anchor cert. If not, then move a
|
|
96
|
+
* cert up the chain and explicitly check that it was signed by the anchor cert. This also
|
|
97
|
+
* future-proofs this logic from the internals of whatever future X.509 library might be used
|
|
98
|
+
* to build the cert path.
|
|
99
|
+
*/
|
|
100
|
+
const lastCert = chain[chain.length - 1];
|
|
101
|
+
const lastCertEqualsAnchor = lastCert.equal(anchor);
|
|
102
|
+
let certBeforeLastSignedByAnchor = false;
|
|
103
|
+
if (!lastCertEqualsAnchor && chain.length > 1) {
|
|
104
|
+
const certBeforeLast = chain[chain.length - 2];
|
|
105
|
+
certBeforeLastSignedByAnchor = await certBeforeLast.verify({
|
|
106
|
+
publicKey: anchor.publicKey,
|
|
107
|
+
signatureOnly: true,
|
|
108
|
+
});
|
|
91
109
|
}
|
|
92
|
-
|
|
93
|
-
if (
|
|
110
|
+
const chainReachesAnchor = lastCertEqualsAnchor || certBeforeLastSignedByAnchor;
|
|
111
|
+
if (!chainReachesAnchor) {
|
|
94
112
|
// Invalid cert chain, try the next trust anchor
|
|
95
113
|
continue;
|
|
96
114
|
}
|
|
@@ -1,11 +1,13 @@
|
|
|
1
|
-
import type { AuthenticationExtensionsClientInputs, AuthenticatorSelectionCriteria,
|
|
1
|
+
import type { AuthenticationExtensionsClientInputs, AuthenticatorSelectionCriteria, Base64URLString, PublicKeyCredentialCreationOptionsJSON, Uint8Array_ } from '../types/index.js';
|
|
2
|
+
import { COSEALG } from '../helpers/cose.js';
|
|
2
3
|
export type GenerateRegistrationOptionsOpts = Parameters<typeof generateRegistrationOptions>[0];
|
|
3
4
|
/**
|
|
4
|
-
*
|
|
5
|
-
* See
|
|
6
|
-
*
|
|
5
|
+
* Use the most commonly-supported algorithms
|
|
6
|
+
* See the following:
|
|
7
|
+
* - https://www.iana.org/assignments/cose/cose.xhtml#algorithms
|
|
8
|
+
* - https://w3c.github.io/webauthn/#dom-publickeycredentialcreationoptions-pubkeycredparams
|
|
7
9
|
*/
|
|
8
|
-
export declare
|
|
10
|
+
export declare let defaultSupportedAlgorithmIDs: COSEALG[];
|
|
9
11
|
/**
|
|
10
12
|
* Prepare a value to pass into navigator.credentials.create(...) for authenticator registration
|
|
11
13
|
*
|
|
@@ -22,7 +24,7 @@ export declare const supportedCOSEAlgorithmIdentifiers: COSEAlgorithmIdentifier[
|
|
|
22
24
|
* @param excludeCredentials **(Optional)** - Authenticators registered by the user so the user can't register the same credential multiple times. Defaults to `[]`
|
|
23
25
|
* @param authenticatorSelection **(Optional)** - Advanced criteria for restricting the types of authenticators that may be used. Defaults to `{ residentKey: 'preferred', userVerification: 'preferred' }`
|
|
24
26
|
* @param extensions **(Optional)** - Additional plugins the authenticator or browser should use during attestation
|
|
25
|
-
* @param supportedAlgorithmIDs **(Optional)** - Array of numeric COSE algorithm identifiers supported
|
|
27
|
+
* @param supportedAlgorithmIDs **(Optional)** - Array of numeric COSE algorithm identifiers indicating supported public key algorithms. Import `COSEALG` from \@simplewebauthn/server/helpers for suitable values. Defaults to `[COSEALG.EdDSA, COSEALG.ES256, COSEALG.RS256]`
|
|
26
28
|
* @param preferredAuthenticatorType **(Optional)** - Encourage the browser to prompt the user to register a specific type of authenticator
|
|
27
29
|
*/
|
|
28
30
|
export declare function generateRegistrationOptions(options: {
|
|
@@ -36,11 +38,11 @@ export declare function generateRegistrationOptions(options: {
|
|
|
36
38
|
attestationType?: 'direct' | 'enterprise' | 'none';
|
|
37
39
|
excludeCredentials?: {
|
|
38
40
|
id: Base64URLString;
|
|
39
|
-
transports?:
|
|
41
|
+
transports?: string[];
|
|
40
42
|
}[];
|
|
41
43
|
authenticatorSelection?: AuthenticatorSelectionCriteria;
|
|
42
44
|
extensions?: AuthenticationExtensionsClientInputs;
|
|
43
|
-
supportedAlgorithmIDs?:
|
|
45
|
+
supportedAlgorithmIDs?: number[];
|
|
44
46
|
preferredAuthenticatorType?: 'securityKey' | 'localDevice' | 'remoteDevice';
|
|
45
47
|
}): Promise<PublicKeyCredentialCreationOptionsJSON>;
|
|
46
48
|
//# sourceMappingURL=generateRegistrationOptions.d.ts.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"generateRegistrationOptions.d.ts","sourceRoot":"","sources":["../../src/registration/generateRegistrationOptions.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EACV,oCAAoC,EACpC,8BAA8B,EAC9B,
|
|
1
|
+
{"version":3,"file":"generateRegistrationOptions.d.ts","sourceRoot":"","sources":["../../src/registration/generateRegistrationOptions.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EACV,oCAAoC,EACpC,8BAA8B,EAC9B,eAAe,EACf,sCAAsC,EAGtC,WAAW,EACZ,MAAM,mBAAmB,CAAC;AAK3B,OAAO,EAAE,OAAO,EAAE,MAAM,oBAAoB,CAAC;AAE7C,MAAM,MAAM,+BAA+B,GAAG,UAAU,CAAC,OAAO,2BAA2B,CAAC,CAAC,CAAC,CAAC,CAAC;AAchG;;;;;GAKG;AACH,eAAO,IAAI,4BAA4B,EAAE,OAAO,EAI/C,CAAC;AAMF;;;;;;;;;;;;;;;;;;GAkBG;AACH,wBAAsB,2BAA2B,CAC/C,OAAO,EAAE;IACP,MAAM,EAAE,MAAM,CAAC;IACf,IAAI,EAAE,MAAM,CAAC;IACb,QAAQ,EAAE,MAAM,CAAC;IACjB,MAAM,CAAC,EAAE,WAAW,CAAC;IACrB,SAAS,CAAC,EAAE,MAAM,GAAG,WAAW,CAAC;IACjC,eAAe,CAAC,EAAE,MAAM,CAAC;IACzB,OAAO,CAAC,EAAE,MAAM,CAAC;IACjB,eAAe,CAAC,EAAE,QAAQ,GAAG,YAAY,GAAG,MAAM,CAAC;IACnD,kBAAkB,CAAC,EAAE;QACnB,EAAE,EAAE,eAAe,CAAC;QACpB,UAAU,CAAC,EAAE,MAAM,EAAE,CAAC;KACvB,EAAE,CAAC;IACJ,sBAAsB,CAAC,EAAE,8BAA8B,CAAC;IACxD,UAAU,CAAC,EAAE,oCAAoC,CAAC;IAClD,qBAAqB,CAAC,EAAE,MAAM,EAAE,CAAC;IACjC,0BAA0B,CAAC,EAAE,aAAa,GAAG,aAAa,GAAG,cAAc,CAAC;CAC7E,GACA,OAAO,CAAC,sCAAsC,CAAC,CAqIjD"}
|