@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,6 +1,6 @@
|
|
|
1
1
|
import { COSECRV, COSEKEYS, isCOSEAlg } from '../../cose.js';
|
|
2
2
|
import { isoBase64URL } from '../../index.js';
|
|
3
|
-
import {
|
|
3
|
+
import { importJWKKey } from './importJWKKey.js';
|
|
4
4
|
import { getWebCrypto } from './getWebCrypto.js';
|
|
5
5
|
export async function verifyOKP(opts) {
|
|
6
6
|
const { cosePublicKey, signature, data } = opts;
|
|
@@ -40,10 +40,7 @@ export async function verifyOKP(opts) {
|
|
|
40
40
|
name: _crv,
|
|
41
41
|
namedCurve: _crv,
|
|
42
42
|
};
|
|
43
|
-
const key = await
|
|
44
|
-
keyData,
|
|
45
|
-
algorithm: keyAlgorithm,
|
|
46
|
-
});
|
|
43
|
+
const key = await importJWKKey({ keyData, algorithm: keyAlgorithm });
|
|
47
44
|
const verifyAlgorithm = {
|
|
48
45
|
name: _crv,
|
|
49
46
|
};
|
|
@@ -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"}
|
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
import { COSEKEYS, isCOSEAlg } from '../../cose.js';
|
|
2
|
-
import {
|
|
3
|
-
import {
|
|
2
|
+
import { mapCoseAlgToWebCryptoHashAlgName } from './mapCoseAlgToWebCryptoHashAlgName.js';
|
|
3
|
+
import { importJWKKey } from './importJWKKey.js';
|
|
4
4
|
import { isoBase64URL } from '../index.js';
|
|
5
5
|
import { mapCoseAlgToWebCryptoKeyAlgName } from './mapCoseAlgToWebCryptoKeyAlgName.js';
|
|
6
6
|
import { getWebCrypto } from './getWebCrypto.js';
|
|
@@ -34,13 +34,13 @@ export async function verifyRSA(opts) {
|
|
|
34
34
|
};
|
|
35
35
|
const keyAlgorithm = {
|
|
36
36
|
name: mapCoseAlgToWebCryptoKeyAlgName(alg),
|
|
37
|
-
hash: { name:
|
|
37
|
+
hash: { name: mapCoseAlgToWebCryptoHashAlgName(alg) },
|
|
38
38
|
};
|
|
39
39
|
const verifyAlgorithm = {
|
|
40
40
|
name: mapCoseAlgToWebCryptoKeyAlgName(alg),
|
|
41
41
|
};
|
|
42
42
|
if (shaHashOverride) {
|
|
43
|
-
keyAlgorithm.hash.name =
|
|
43
|
+
keyAlgorithm.hash.name = mapCoseAlgToWebCryptoHashAlgName(shaHashOverride);
|
|
44
44
|
}
|
|
45
45
|
if (keyAlgorithm.name === 'RSASSA-PKCS1-v1_5') {
|
|
46
46
|
if (keyAlgorithm.hash.name === 'SHA-256') {
|
|
@@ -83,9 +83,6 @@ export async function verifyRSA(opts) {
|
|
|
83
83
|
else {
|
|
84
84
|
throw new Error(`Unexpected RSA key algorithm ${alg} (${keyAlgorithm.name})`);
|
|
85
85
|
}
|
|
86
|
-
const key = await
|
|
87
|
-
keyData,
|
|
88
|
-
algorithm: keyAlgorithm,
|
|
89
|
-
});
|
|
86
|
+
const key = await importJWKKey({ keyData, algorithm: keyAlgorithm });
|
|
90
87
|
return WebCrypto.subtle.verify(verifyAlgorithm, key, signature, data);
|
|
91
88
|
}
|
package/esm/helpers/logging.d.ts
CHANGED
|
@@ -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"}
|
package/esm/helpers/logging.js
CHANGED
|
@@ -1,19 +1,30 @@
|
|
|
1
|
-
// const defaultLogger = debug('SimpleWebAuthn');
|
|
2
1
|
/**
|
|
3
|
-
*
|
|
4
|
-
*
|
|
5
|
-
*
|
|
6
|
-
* See https://www.npmjs.com/package/debug for information on how to control logging output when
|
|
7
|
-
* using @simplewebauthn/server
|
|
8
|
-
*
|
|
9
|
-
* Example:
|
|
10
|
-
*
|
|
11
|
-
* ```
|
|
12
|
-
* const log = getLogger('mds');
|
|
13
|
-
* log('hello'); // simplewebauthn:mds hello +0ms
|
|
14
|
-
* ```
|
|
2
|
+
* A logger instance that doesn't do anything. Useful as a default argument when no custom instance
|
|
3
|
+
* of the `SimpleWebAuthnLogger` interface is specified.
|
|
15
4
|
*/
|
|
16
|
-
export
|
|
17
|
-
|
|
18
|
-
|
|
5
|
+
export const DefaultNoopLogger = {
|
|
6
|
+
debug() { },
|
|
7
|
+
info() { },
|
|
8
|
+
warn() { },
|
|
9
|
+
error() { },
|
|
10
|
+
};
|
|
11
|
+
/**
|
|
12
|
+
* Generate an instance of SimpleWebAuthnLogger that defines all methods. Any logging method not
|
|
13
|
+
* defined on `logger` will be a no-op.
|
|
14
|
+
*/
|
|
15
|
+
export function buildLoggerAllMethods(logger) {
|
|
16
|
+
const toReturn = { ...DefaultNoopLogger };
|
|
17
|
+
if (logger.debug) {
|
|
18
|
+
toReturn.debug = logger.debug;
|
|
19
|
+
}
|
|
20
|
+
if (logger.info) {
|
|
21
|
+
toReturn.info = logger.info;
|
|
22
|
+
}
|
|
23
|
+
if (logger.warn) {
|
|
24
|
+
toReturn.warn = logger.warn;
|
|
25
|
+
}
|
|
26
|
+
if (logger.error) {
|
|
27
|
+
toReturn.error = logger.error;
|
|
28
|
+
}
|
|
29
|
+
return toReturn;
|
|
19
30
|
}
|
|
@@ -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"}
|
|
@@ -79,15 +79,33 @@ export async function validateCertificatePath(x5cCertsPEM, trustAnchorsPEM = [])
|
|
|
79
79
|
}
|
|
80
80
|
// Order of certs doesn't matter here but for readability
|
|
81
81
|
const chainBuilder = new X509ChainBuilder({ certificates: [...x5cIntermediates, anchor] });
|
|
82
|
-
//
|
|
82
|
+
// Attempt to build a certificate path
|
|
83
83
|
const chain = await chainBuilder.build(x5cLeafCert);
|
|
84
|
-
|
|
85
|
-
|
|
86
|
-
|
|
87
|
-
|
|
84
|
+
/**
|
|
85
|
+
* The cert chain must chain to the anchor. Usually this is as simple as asserting that the
|
|
86
|
+
* final cert in the chain is the anchor cert. However there's an odd scenario where an
|
|
87
|
+
* intermediate certificate can chain to an anchor cert's public key, but not actually to the
|
|
88
|
+
* anchor cert because e.g. the chain builder stopped at a cross-signed cert for the anchor
|
|
89
|
+
* and not the anchor cert itself.
|
|
90
|
+
*
|
|
91
|
+
* So here we're going to check for that. In the simplest case we'll be fine with the last
|
|
92
|
+
* cert in the chain being byte-equivalent to the current anchor cert. If not, then move a
|
|
93
|
+
* cert up the chain and explicitly check that it was signed by the anchor cert. This also
|
|
94
|
+
* future-proofs this logic from the internals of whatever future X.509 library might be used
|
|
95
|
+
* to build the cert path.
|
|
96
|
+
*/
|
|
97
|
+
const lastCert = chain[chain.length - 1];
|
|
98
|
+
const lastCertEqualsAnchor = lastCert.equal(anchor);
|
|
99
|
+
let certBeforeLastSignedByAnchor = false;
|
|
100
|
+
if (!lastCertEqualsAnchor && chain.length > 1) {
|
|
101
|
+
const certBeforeLast = chain[chain.length - 2];
|
|
102
|
+
certBeforeLastSignedByAnchor = await certBeforeLast.verify({
|
|
103
|
+
publicKey: anchor.publicKey,
|
|
104
|
+
signatureOnly: true,
|
|
105
|
+
});
|
|
88
106
|
}
|
|
89
|
-
|
|
90
|
-
if (
|
|
107
|
+
const chainReachesAnchor = lastCertEqualsAnchor || certBeforeLastSignedByAnchor;
|
|
108
|
+
if (!chainReachesAnchor) {
|
|
91
109
|
// Invalid cert chain, try the next trust anchor
|
|
92
110
|
continue;
|
|
93
111
|
}
|
|
@@ -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"}
|
|
@@ -1,33 +1,8 @@
|
|
|
1
|
+
import { SettingsService } from '../services/settingsService.js';
|
|
1
2
|
import { generateChallenge } from '../helpers/generateChallenge.js';
|
|
2
3
|
import { generateUserID } from '../helpers/generateUserID.js';
|
|
3
4
|
import { isoBase64URL, isoUint8Array } from '../helpers/iso/index.js';
|
|
4
|
-
|
|
5
|
-
* Supported crypto algo identifiers
|
|
6
|
-
* See https://w3c.github.io/webauthn/#sctn-alg-identifier
|
|
7
|
-
* and https://www.iana.org/assignments/cose/cose.xhtml#algorithms
|
|
8
|
-
*/
|
|
9
|
-
export const supportedCOSEAlgorithmIdentifiers = [
|
|
10
|
-
// EdDSA (In first position to encourage authenticators to use this over ES256)
|
|
11
|
-
-8,
|
|
12
|
-
// ECDSA w/ SHA-256
|
|
13
|
-
-7,
|
|
14
|
-
// ECDSA w/ SHA-512
|
|
15
|
-
-36,
|
|
16
|
-
// RSASSA-PSS w/ SHA-256
|
|
17
|
-
-37,
|
|
18
|
-
// RSASSA-PSS w/ SHA-384
|
|
19
|
-
-38,
|
|
20
|
-
// RSASSA-PSS w/ SHA-512
|
|
21
|
-
-39,
|
|
22
|
-
// RSASSA-PKCS1-v1_5 w/ SHA-256
|
|
23
|
-
-257,
|
|
24
|
-
// RSASSA-PKCS1-v1_5 w/ SHA-384
|
|
25
|
-
-258,
|
|
26
|
-
// RSASSA-PKCS1-v1_5 w/ SHA-512
|
|
27
|
-
-259,
|
|
28
|
-
// RSASSA-PKCS1-v1_5 w/ SHA-1 (Deprecated; here for legacy support)
|
|
29
|
-
-65535,
|
|
30
|
-
];
|
|
5
|
+
import { COSEALG } from '../helpers/cose.js';
|
|
31
6
|
/**
|
|
32
7
|
* Set up some default authenticator selection options as per the latest spec:
|
|
33
8
|
* https://www.w3.org/TR/webauthn-2/#dictdef-authenticatorselectioncriteria
|
|
@@ -45,7 +20,14 @@ const defaultAuthenticatorSelection = {
|
|
|
45
20
|
* - https://www.iana.org/assignments/cose/cose.xhtml#algorithms
|
|
46
21
|
* - https://w3c.github.io/webauthn/#dom-publickeycredentialcreationoptions-pubkeycredparams
|
|
47
22
|
*/
|
|
48
|
-
|
|
23
|
+
export let defaultSupportedAlgorithmIDs = [
|
|
24
|
+
COSEALG.EdDSA,
|
|
25
|
+
COSEALG.ES256,
|
|
26
|
+
COSEALG.RS256,
|
|
27
|
+
];
|
|
28
|
+
if (SettingsService.runtimeSupportsPQC()) {
|
|
29
|
+
defaultSupportedAlgorithmIDs = [COSEALG.ML_DSA_44, ...defaultSupportedAlgorithmIDs];
|
|
30
|
+
}
|
|
49
31
|
/**
|
|
50
32
|
* Prepare a value to pass into navigator.credentials.create(...) for authenticator registration
|
|
51
33
|
*
|
|
@@ -62,7 +44,7 @@ const defaultSupportedAlgorithmIDs = [-8, -7, -257];
|
|
|
62
44
|
* @param excludeCredentials **(Optional)** - Authenticators registered by the user so the user can't register the same credential multiple times. Defaults to `[]`
|
|
63
45
|
* @param authenticatorSelection **(Optional)** - Advanced criteria for restricting the types of authenticators that may be used. Defaults to `{ residentKey: 'preferred', userVerification: 'preferred' }`
|
|
64
46
|
* @param extensions **(Optional)** - Additional plugins the authenticator or browser should use during attestation
|
|
65
|
-
* @param supportedAlgorithmIDs **(Optional)** - Array of numeric COSE algorithm identifiers supported
|
|
47
|
+
* @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]`
|
|
66
48
|
* @param preferredAuthenticatorType **(Optional)** - Encourage the browser to prompt the user to register a specific type of authenticator
|
|
67
49
|
*/
|
|
68
50
|
export async function generateRegistrationOptions(options) {
|
|
@@ -25,7 +25,7 @@ export declare const TPM_ALG: {
|
|
|
25
25
|
export declare const TPM_ECC_CURVE: {
|
|
26
26
|
[key: number]: string;
|
|
27
27
|
};
|
|
28
|
-
type ManufacturerInfo = {
|
|
28
|
+
export type ManufacturerInfo = {
|
|
29
29
|
name: string;
|
|
30
30
|
id: string;
|
|
31
31
|
};
|
|
@@ -44,5 +44,4 @@ export declare const TPM_MANUFACTURERS: {
|
|
|
44
44
|
export declare const TPM_ECC_CURVE_COSE_CRV_MAP: {
|
|
45
45
|
[key: string]: number;
|
|
46
46
|
};
|
|
47
|
-
export {};
|
|
48
47
|
//# sourceMappingURL=constants.d.ts.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"constants.d.ts","sourceRoot":"","sources":["../../../../src/registration/verifications/tpm/constants.ts"],"names":[],"mappings":"AACA;;;;;;;;GAQG;AAEH;;GAEG;AACH,eAAO,MAAM,MAAM,EAAE;IAAE,CAAC,GAAG,EAAE,MAAM,GAAG,MAAM,CAAA;CAkB3C,CAAC;AAEF;;GAEG;AACH,eAAO,MAAM,OAAO,EAAE;IAAE,CAAC,GAAG,EAAE,MAAM,GAAG,MAAM,CAAA;CAsC5C,CAAC;AAEF;;GAEG;AACH,eAAO,MAAM,aAAa,EAAE;IAAE,CAAC,GAAG,EAAE,MAAM,GAAG,MAAM,CAAA;CAUlD,CAAC;AAEF,
|
|
1
|
+
{"version":3,"file":"constants.d.ts","sourceRoot":"","sources":["../../../../src/registration/verifications/tpm/constants.ts"],"names":[],"mappings":"AACA;;;;;;;;GAQG;AAEH;;GAEG;AACH,eAAO,MAAM,MAAM,EAAE;IAAE,CAAC,GAAG,EAAE,MAAM,GAAG,MAAM,CAAA;CAkB3C,CAAC;AAEF;;GAEG;AACH,eAAO,MAAM,OAAO,EAAE;IAAE,CAAC,GAAG,EAAE,MAAM,GAAG,MAAM,CAAA;CAsC5C,CAAC;AAEF;;GAEG;AACH,eAAO,MAAM,aAAa,EAAE;IAAE,CAAC,GAAG,EAAE,MAAM,GAAG,MAAM,CAAA;CAUlD,CAAC;AAEF,MAAM,MAAM,gBAAgB,GAAG;IAC7B,IAAI,EAAE,MAAM,CAAC;IACb,EAAE,EAAE,MAAM,CAAC;CACZ,CAAC;AAEF;;;;;GAKG;AACH,eAAO,MAAM,iBAAiB,EAAE;IAAE,CAAC,GAAG,EAAE,MAAM,GAAG,gBAAgB,CAAA;CA+BhE,CAAC;AAEF;;GAEG;AACH,eAAO,MAAM,0BAA0B,EAAE;IAAE,CAAC,GAAG,EAAE,MAAM,GAAG,MAAM,CAAA;CAM/D,CAAC"}
|
|
@@ -104,8 +104,7 @@ export const TPM_MANUFACTURERS = {
|
|
|
104
104
|
'id:48504900': { name: 'HPI', id: 'HPI' },
|
|
105
105
|
'id:48504500': { name: 'HPE', id: 'HPE' },
|
|
106
106
|
'id:48495349': { name: 'Huawei', id: 'HISI' },
|
|
107
|
-
'id:
|
|
108
|
-
'id:49424D00': { name: 'IBM', id: 'IBM' }, // Same ID for IBM as above, except the "D" is capitalized as per TPM spec
|
|
107
|
+
'id:49424D00': { name: 'IBM', id: 'IBM' }, // IBM is "id:49424d00" in the TPM spec. It's been normalized here
|
|
109
108
|
'id:49465800': { name: 'Infineon', id: 'IFX' },
|
|
110
109
|
'id:494E5443': { name: 'Intel', id: 'INTC' },
|
|
111
110
|
'id:4C454E00': { name: 'Lenovo', id: 'LEN' },
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"isValidTPMManufacturerID.d.ts","sourceRoot":"","sources":["../../../../src/registration/verifications/tpm/isValidTPMManufacturerID.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,KAAK,gBAAgB,EAAqB,MAAM,gBAAgB,CAAC;AAE1E,wBAAgB,sBAAsB,CAAC,EAAE,EAAE,MAAM,GAAG,gBAAgB,GAAG,SAAS,CAK/E"}
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"verifyAttestationTPM.d.ts","sourceRoot":"","sources":["../../../../src/registration/verifications/tpm/verifyAttestationTPM.ts"],"names":[],"mappings":"AAUA,OAAO,KAAK,EAAE,6BAA6B,EAAE,MAAM,qCAAqC,CAAC;
|
|
1
|
+
{"version":3,"file":"verifyAttestationTPM.d.ts","sourceRoot":"","sources":["../../../../src/registration/verifications/tpm/verifyAttestationTPM.ts"],"names":[],"mappings":"AAUA,OAAO,KAAK,EAAE,6BAA6B,EAAE,MAAM,qCAAqC,CAAC;AAyBzF,wBAAsB,oBAAoB,CACxC,OAAO,EAAE,6BAA6B,GACrC,OAAO,CAAC,OAAO,CAAC,CA+VlB"}
|
|
@@ -11,9 +11,10 @@ import { isoUint8Array } from '../../../helpers/iso/index.js';
|
|
|
11
11
|
import { validateExtFIDOGenCEAAGUID } from '../../../helpers/validateExtFIDOGenCEAAGUID.js';
|
|
12
12
|
import { MetadataService } from '../../../services/metadataService.js';
|
|
13
13
|
import { verifyAttestationWithMetadata } from '../../../metadata/verifyAttestationWithMetadata.js';
|
|
14
|
-
import { TPM_ECC_CURVE_COSE_CRV_MAP
|
|
14
|
+
import { TPM_ECC_CURVE_COSE_CRV_MAP } from './constants.js';
|
|
15
15
|
import { parseCertInfo } from './parseCertInfo.js';
|
|
16
16
|
import { parsePubArea } from './parsePubArea.js';
|
|
17
|
+
import { getTPMManufacturerInfo } from './isValidTPMManufacturerID.js';
|
|
17
18
|
export async function verifyAttestationTPM(options) {
|
|
18
19
|
const { aaguid, attStmt, authData, credentialPublicKey, clientDataHash, rootCertificates, } = options;
|
|
19
20
|
const ver = attStmt.get('ver');
|
|
@@ -200,7 +201,7 @@ export async function verifyAttestationTPM(options) {
|
|
|
200
201
|
throw new Error('Certificate did not contain ExtendedKeyUsage extension (TPM)');
|
|
201
202
|
}
|
|
202
203
|
// Check that tcpaTpmManufacturer (2.23.133.2.1) field is set to a valid manufacturer ID.
|
|
203
|
-
if (!
|
|
204
|
+
if (!getTPMManufacturerInfo(tcgAtTpmManufacturer)) {
|
|
204
205
|
throw new Error(`Could not match TPM manufacturer "${tcgAtTpmManufacturer}" (TPM)`);
|
|
205
206
|
}
|
|
206
207
|
// Check that certificate contains extKeyUsage (2.5.29.37) extension and it must contain
|
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import type {
|
|
1
|
+
import type { CredentialDeviceType, RegistrationResponseJSON, Uint8Array_, WebAuthnCredential } from '../types/index.js';
|
|
2
2
|
import { type AttestationFormat, type AttestationStatement } from '../helpers/decodeAttestationObject.js';
|
|
3
3
|
import type { AuthenticationExtensionsAuthenticatorOutputs } from '../helpers/decodeAuthenticatorExtensions.js';
|
|
4
4
|
/**
|
|
@@ -17,7 +17,7 @@ export type VerifyRegistrationResponseOpts = Parameters<typeof verifyRegistratio
|
|
|
17
17
|
* @param expectedType **(Optional)** - The response type expected ('webauthn.create')
|
|
18
18
|
* @param requireUserPresence **(Optional)** - Enforce user presence by the authenticator (or skip it during auto registration) Defaults to `true`
|
|
19
19
|
* @param requireUserVerification **(Optional)** - Enforce user verification by the authenticator (via PIN, fingerprint, etc...) Defaults to `true`
|
|
20
|
-
* @param supportedAlgorithmIDs **(Optional)** - Array of numeric COSE algorithm identifiers supported
|
|
20
|
+
* @param supportedAlgorithmIDs **(Optional)** - Array of numeric COSE algorithm identifiers indicating supported public key algorithms. Import `COSEALG` from \@simplewebauthn/server/helpers for suitable values. Should be the same value that was specified for this same argument when calling `generateRegistrationOptions()`. Defaults to `[COSEALG.EdDSA, COSEALG.ES256, COSEALG.RS256]`
|
|
21
21
|
* @param attestationSafetyNetEnforceCTSCheck **(Optional)** - Require that an Android device's system integrity has not been tampered with if it uses SafetyNet attestation. Defaults to `true`
|
|
22
22
|
*/
|
|
23
23
|
export declare function verifyRegistrationResponse(options: {
|
|
@@ -28,7 +28,7 @@ export declare function verifyRegistrationResponse(options: {
|
|
|
28
28
|
expectedType?: string | string[];
|
|
29
29
|
requireUserPresence?: boolean;
|
|
30
30
|
requireUserVerification?: boolean;
|
|
31
|
-
supportedAlgorithmIDs?:
|
|
31
|
+
supportedAlgorithmIDs?: number[];
|
|
32
32
|
attestationSafetyNetEnforceCTSCheck?: boolean;
|
|
33
33
|
}): Promise<VerifiedRegistrationResponse>;
|
|
34
34
|
/**
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"verifyRegistrationResponse.d.ts","sourceRoot":"","sources":["../../src/registration/verifyRegistrationResponse.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EACV,
|
|
1
|
+
{"version":3,"file":"verifyRegistrationResponse.d.ts","sourceRoot":"","sources":["../../src/registration/verifyRegistrationResponse.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EACV,oBAAoB,EACpB,wBAAwB,EACxB,WAAW,EACX,kBAAkB,EACnB,MAAM,mBAAmB,CAAC;AAC3B,OAAO,EACL,KAAK,iBAAiB,EACtB,KAAK,oBAAoB,EAE1B,MAAM,uCAAuC,CAAC;AAC/C,OAAO,KAAK,EAAE,4CAA4C,EAAE,MAAM,6CAA6C,CAAC;AAoBhH;;GAEG;AACH,MAAM,MAAM,8BAA8B,GAAG,UAAU,CAAC,OAAO,0BAA0B,CAAC,CAAC,CAAC,CAAC,CAAC;AAE9F;;;;;;;;;;;;;;GAcG;AACH,wBAAsB,0BAA0B,CAC9C,OAAO,EAAE;IACP,QAAQ,EAAE,wBAAwB,CAAC;IACnC,iBAAiB,EAAE,MAAM,GAAG,CAAC,CAAC,SAAS,EAAE,MAAM,KAAK,OAAO,GAAG,OAAO,CAAC,OAAO,CAAC,CAAC,CAAC;IAChF,cAAc,EAAE,MAAM,GAAG,MAAM,EAAE,CAAC;IAClC,YAAY,CAAC,EAAE,MAAM,GAAG,MAAM,EAAE,CAAC;IACjC,YAAY,CAAC,EAAE,MAAM,GAAG,MAAM,EAAE,CAAC;IACjC,mBAAmB,CAAC,EAAE,OAAO,CAAC;IAC9B,uBAAuB,CAAC,EAAE,OAAO,CAAC;IAClC,qBAAqB,CAAC,EAAE,MAAM,EAAE,CAAC;IACjC,mCAAmC,CAAC,EAAE,OAAO,CAAC;CAC/C,GACA,OAAO,CAAC,4BAA4B,CAAC,CAqPvC;AAED;;;;;;;;;;;;;;;;;;;;;;;;;GAyBG;AACH,MAAM,MAAM,4BAA4B,GAAG;IACzC,QAAQ,EAAE,KAAK,CAAC;IAChB,gBAAgB,CAAC,EAAE,KAAK,CAAC;CAC1B,GAAG;IACF,QAAQ,EAAE,IAAI,CAAC;IACf,gBAAgB,EAAE;QAChB,GAAG,EAAE,iBAAiB,CAAC;QACvB,MAAM,EAAE,MAAM,CAAC;QACf,UAAU,EAAE,kBAAkB,CAAC;QAC/B,cAAc,EAAE,YAAY,CAAC;QAC7B,iBAAiB,EAAE,WAAW,CAAC;QAC/B,YAAY,EAAE,OAAO,CAAC;QACtB,oBAAoB,EAAE,oBAAoB,CAAC;QAC3C,kBAAkB,EAAE,OAAO,CAAC;QAC5B,MAAM,EAAE,MAAM,CAAC;QACf,IAAI,CAAC,EAAE,MAAM,CAAC;QACd,6BAA6B,CAAC,EAAE,4CAA4C,CAAC;KAC9E,CAAC;CACH,CAAC;AAEF;;GAEG;AACH,MAAM,MAAM,6BAA6B,GAAG;IAC1C,MAAM,EAAE,WAAW,CAAC;IACpB,OAAO,EAAE,oBAAoB,CAAC;IAC9B,QAAQ,EAAE,WAAW,CAAC;IACtB,cAAc,EAAE,WAAW,CAAC;IAC5B,YAAY,EAAE,WAAW,CAAC;IAC1B,mBAAmB,EAAE,WAAW,CAAC;IACjC,gBAAgB,EAAE,MAAM,EAAE,CAAC;IAC3B,QAAQ,EAAE,WAAW,CAAC;IACtB,iBAAiB,CAAC,EAAE,OAAO,CAAC;IAC5B,mCAAmC,CAAC,EAAE,OAAO,CAAC;CAC/C,CAAC"}
|
|
@@ -9,7 +9,7 @@ import { parseBackupFlags } from '../helpers/parseBackupFlags.js';
|
|
|
9
9
|
import { matchExpectedRPID } from '../helpers/matchExpectedRPID.js';
|
|
10
10
|
import { isoBase64URL } from '../helpers/iso/index.js';
|
|
11
11
|
import { SettingsService } from '../services/settingsService.js';
|
|
12
|
-
import {
|
|
12
|
+
import { defaultSupportedAlgorithmIDs } from './generateRegistrationOptions.js';
|
|
13
13
|
import { verifyAttestationFIDOU2F } from './verifications/verifyAttestationFIDOU2F.js';
|
|
14
14
|
import { verifyAttestationPacked } from './verifications/verifyAttestationPacked.js';
|
|
15
15
|
import { verifyAttestationAndroidSafetyNet } from './verifications/verifyAttestationAndroidSafetyNet.js';
|
|
@@ -28,11 +28,11 @@ import { verifyAttestationApple } from './verifications/verifyAttestationApple.j
|
|
|
28
28
|
* @param expectedType **(Optional)** - The response type expected ('webauthn.create')
|
|
29
29
|
* @param requireUserPresence **(Optional)** - Enforce user presence by the authenticator (or skip it during auto registration) Defaults to `true`
|
|
30
30
|
* @param requireUserVerification **(Optional)** - Enforce user verification by the authenticator (via PIN, fingerprint, etc...) Defaults to `true`
|
|
31
|
-
* @param supportedAlgorithmIDs **(Optional)** - Array of numeric COSE algorithm identifiers supported
|
|
31
|
+
* @param supportedAlgorithmIDs **(Optional)** - Array of numeric COSE algorithm identifiers indicating supported public key algorithms. Import `COSEALG` from \@simplewebauthn/server/helpers for suitable values. Should be the same value that was specified for this same argument when calling `generateRegistrationOptions()`. Defaults to `[COSEALG.EdDSA, COSEALG.ES256, COSEALG.RS256]`
|
|
32
32
|
* @param attestationSafetyNetEnforceCTSCheck **(Optional)** - Require that an Android device's system integrity has not been tampered with if it uses SafetyNet attestation. Defaults to `true`
|
|
33
33
|
*/
|
|
34
34
|
export async function verifyRegistrationResponse(options) {
|
|
35
|
-
const { response, expectedChallenge, expectedOrigin, expectedRPID, expectedType, requireUserPresence = true, requireUserVerification = true, supportedAlgorithmIDs =
|
|
35
|
+
const { response, expectedChallenge, expectedOrigin, expectedRPID, expectedType, requireUserPresence = true, requireUserVerification = true, supportedAlgorithmIDs = defaultSupportedAlgorithmIDs, attestationSafetyNetEnforceCTSCheck = true, } = options;
|
|
36
36
|
const { id, rawId, type: credentialType, response: attestationResponse } = response;
|
|
37
37
|
// Ensure credential specified an ID
|
|
38
38
|
if (!id) {
|
|
@@ -1,4 +1,5 @@
|
|
|
1
1
|
import type { MetadataStatement } from '../metadata/mdsTypes.js';
|
|
2
|
+
import { type SimpleWebAuthnLogger } from '../helpers/logging.js';
|
|
2
3
|
import type { Uint8Array_ } from '../types/index.js';
|
|
3
4
|
/**
|
|
4
5
|
* Allow MetadataService to accommodate unregistered AAGUIDs (`"permissive"`), or only allow
|
|
@@ -24,6 +25,7 @@ interface MetadataService {
|
|
|
24
25
|
mdsServers?: string[];
|
|
25
26
|
statements?: MetadataStatement[];
|
|
26
27
|
verificationMode?: VerificationMode;
|
|
28
|
+
logger?: SimpleWebAuthnLogger;
|
|
27
29
|
}): Promise<void>;
|
|
28
30
|
/**
|
|
29
31
|
* Get a metadata statement for a given AAGUID.
|
|
@@ -44,10 +46,12 @@ export declare class BaseMetadataService implements MetadataService {
|
|
|
44
46
|
private statementCache;
|
|
45
47
|
private state;
|
|
46
48
|
private verificationMode;
|
|
49
|
+
private logger;
|
|
47
50
|
initialize(opts?: {
|
|
48
51
|
mdsServers?: string[];
|
|
49
52
|
statements?: MetadataStatement[];
|
|
50
53
|
verificationMode?: VerificationMode;
|
|
54
|
+
logger?: SimpleWebAuthnLogger;
|
|
51
55
|
}): Promise<void>;
|
|
52
56
|
getStatement(aaguid: string | Uint8Array_): Promise<MetadataStatement | undefined>;
|
|
53
57
|
/**
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"metadataService.d.ts","sourceRoot":"","sources":["../../src/services/metadataService.ts"],"names":[],"mappings":"AACA,OAAO,KAAK,EAA4B,iBAAiB,EAAE,MAAM,yBAAyB,CAAC;
|
|
1
|
+
{"version":3,"file":"metadataService.d.ts","sourceRoot":"","sources":["../../src/services/metadataService.ts"],"names":[],"mappings":"AACA,OAAO,KAAK,EAA4B,iBAAiB,EAAE,MAAM,yBAAyB,CAAC;AAE3F,OAAO,EAGL,KAAK,oBAAoB,EAC1B,MAAM,uBAAuB,CAAC;AAE/B,OAAO,KAAK,EAAE,WAAW,EAAE,MAAM,mBAAmB,CAAC;AAmCrD;;;GAGG;AACH,MAAM,MAAM,gBAAgB,GAAG,YAAY,GAAG,QAAQ,CAAC;AAEvD,UAAU,eAAe;IACvB;;;;;;;;;;;;;OAaG;IACH,UAAU,CAAC,IAAI,CAAC,EAAE;QAChB,UAAU,CAAC,EAAE,MAAM,EAAE,CAAC;QACtB,UAAU,CAAC,EAAE,iBAAiB,EAAE,CAAC;QACjC,gBAAgB,CAAC,EAAE,gBAAgB,CAAC;QACpC,MAAM,CAAC,EAAE,oBAAoB,CAAC;KAC/B,GAAG,OAAO,CAAC,IAAI,CAAC,CAAC;IAClB;;;;;OAKG;IACH,YAAY,CAAC,MAAM,EAAE,MAAM,GAAG,UAAU,GAAG,OAAO,CAAC,iBAAiB,GAAG,SAAS,CAAC,CAAC;CACnF;AAED;;;;;GAKG;AACH,qBAAa,mBAAoB,YAAW,eAAe;IACzD,OAAO,CAAC,QAAQ,CAAoC;IACpD,OAAO,CAAC,cAAc,CAA6C;IACnE,OAAO,CAAC,KAAK,CAAyC;IACtD,OAAO,CAAC,gBAAgB,CAA8B;IACtD,OAAO,CAAC,MAAM,CAAqD;IAE7D,UAAU,CACd,IAAI,GAAE;QACJ,UAAU,CAAC,EAAE,MAAM,EAAE,CAAC;QACtB,UAAU,CAAC,EAAE,iBAAiB,EAAE,CAAC;QACjC,gBAAgB,CAAC,EAAE,gBAAgB,CAAC;QACpC,MAAM,CAAC,EAAE,oBAAoB,CAAC;KAC1B,GACL,OAAO,CAAC,IAAI,CAAC;IAmFV,YAAY,CAChB,MAAM,EAAE,MAAM,GAAG,WAAW,GAC3B,OAAO,CAAC,iBAAiB,GAAG,SAAS,CAAC;IA8DzC;;OAEG;YACW,YAAY;IAU1B;;OAEG;YACW,UAAU;IA8CxB;;OAEG;IACH,OAAO,CAAC,eAAe;IAgCvB;;OAEG;IACH,OAAO,CAAC,QAAQ;CAWjB;AAED;;;;;GAKG;AACH,eAAO,MAAM,eAAe,EAAE,eAA2C,CAAC"}
|
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
import { convertAAGUIDToString } from '../helpers/convertAAGUIDToString.js';
|
|
2
2
|
import { verifyMDSBlob } from '../metadata/verifyMDSBlob.js';
|
|
3
|
-
import {
|
|
3
|
+
import { buildLoggerAllMethods, DefaultNoopLogger, } from '../helpers/logging.js';
|
|
4
4
|
import { fetch } from '../helpers/fetch.js';
|
|
5
5
|
/**
|
|
6
6
|
* An instance of `CachedMDS` that will not trigger attempts to refresh the associated entry's blob
|
|
@@ -17,7 +17,6 @@ var SERVICE_STATE;
|
|
|
17
17
|
SERVICE_STATE[SERVICE_STATE["REFRESHING"] = 1] = "REFRESHING";
|
|
18
18
|
SERVICE_STATE[SERVICE_STATE["READY"] = 2] = "READY";
|
|
19
19
|
})(SERVICE_STATE || (SERVICE_STATE = {}));
|
|
20
|
-
const log = getLogger('MetadataService');
|
|
21
20
|
/**
|
|
22
21
|
* An implementation of `MetadataService` that can download and parse BLOBs, and support on-demand
|
|
23
22
|
* requesting and caching of individual metadata statements.
|
|
@@ -50,11 +49,18 @@ export class BaseMetadataService {
|
|
|
50
49
|
writable: true,
|
|
51
50
|
value: 'strict'
|
|
52
51
|
});
|
|
52
|
+
Object.defineProperty(this, "logger", {
|
|
53
|
+
enumerable: true,
|
|
54
|
+
configurable: true,
|
|
55
|
+
writable: true,
|
|
56
|
+
value: DefaultNoopLogger
|
|
57
|
+
});
|
|
53
58
|
}
|
|
54
59
|
async initialize(opts = {}) {
|
|
55
60
|
// Reset statement cache
|
|
56
61
|
this.statementCache = {};
|
|
57
|
-
const { mdsServers = [defaultURLMDS], statements, verificationMode } = opts;
|
|
62
|
+
const { mdsServers = [defaultURLMDS], statements, verificationMode, logger = DefaultNoopLogger, } = opts;
|
|
63
|
+
this.logger = buildLoggerAllMethods(logger);
|
|
58
64
|
this.setState(SERVICE_STATE.REFRESHING);
|
|
59
65
|
/**
|
|
60
66
|
* If metadata statements are provided, load them into the cache first. These statements will
|
|
@@ -76,7 +82,7 @@ export class BaseMetadataService {
|
|
|
76
82
|
statementsAdded += 1;
|
|
77
83
|
}
|
|
78
84
|
});
|
|
79
|
-
|
|
85
|
+
this.logger.info(`Cached ${statementsAdded} local statements`);
|
|
80
86
|
}
|
|
81
87
|
/**
|
|
82
88
|
* If MDS servers are provided, then download blobs from them, verify them, and then add their
|
|
@@ -99,14 +105,14 @@ export class BaseMetadataService {
|
|
|
99
105
|
}
|
|
100
106
|
catch (err) {
|
|
101
107
|
// Notify of the error and move on
|
|
102
|
-
|
|
108
|
+
this.logger.error(`Could not download BLOB from ${url}:`, err);
|
|
103
109
|
numServers -= 1;
|
|
104
110
|
}
|
|
105
111
|
}
|
|
106
112
|
// Calculate the difference to get the total number of new statements we successfully added
|
|
107
113
|
const newCacheCount = Object.keys(this.statementCache).length;
|
|
108
114
|
const cacheDiff = newCacheCount - currentCacheCount;
|
|
109
|
-
|
|
115
|
+
this.logger.info(`Cached ${cacheDiff} statements from ${numServers} metadata server(s)`);
|
|
110
116
|
}
|
|
111
117
|
if (verificationMode) {
|
|
112
118
|
this.verificationMode = verificationMode;
|
|
@@ -210,7 +216,7 @@ export class BaseMetadataService {
|
|
|
210
216
|
// TODO (Feb 2026): It'd be more actionable for devs if a specific error was raised here,
|
|
211
217
|
// then this message was logged higher up when it can include the array index of the stale
|
|
212
218
|
// blob.
|
|
213
|
-
|
|
219
|
+
this.logger.warn(`⚠️ This MDS blob (serial: ${payload.no}) contains stale data as of ${parsedNextUpdate.toISOString()}. Please consider re-initializing MetadataService with a newer MDS blob.`);
|
|
214
220
|
}
|
|
215
221
|
}
|
|
216
222
|
}
|
|
@@ -249,13 +255,13 @@ export class BaseMetadataService {
|
|
|
249
255
|
setState(newState) {
|
|
250
256
|
this.state = newState;
|
|
251
257
|
if (newState === SERVICE_STATE.DISABLED) {
|
|
252
|
-
|
|
258
|
+
this.logger.debug('MetadataService is DISABLED');
|
|
253
259
|
}
|
|
254
260
|
else if (newState === SERVICE_STATE.REFRESHING) {
|
|
255
|
-
|
|
261
|
+
this.logger.debug('MetadataService is REFRESHING');
|
|
256
262
|
}
|
|
257
263
|
else if (newState === SERVICE_STATE.READY) {
|
|
258
|
-
|
|
264
|
+
this.logger.debug('MetadataService is READY');
|
|
259
265
|
}
|
|
260
266
|
}
|
|
261
267
|
}
|
|
@@ -19,6 +19,10 @@ interface SettingsService {
|
|
|
19
19
|
getRootCertificates(opts: {
|
|
20
20
|
identifier: RootCertIdentifier;
|
|
21
21
|
}): string[];
|
|
22
|
+
/**
|
|
23
|
+
* Get the runtime's ability to support PQC algorithms by detecting support for ML-DSA-44
|
|
24
|
+
*/
|
|
25
|
+
runtimeSupportsPQC(): boolean;
|
|
22
26
|
}
|
|
23
27
|
/**
|
|
24
28
|
* A basic service for specifying acceptable root certificates for all supported attestation
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"settingsService.d.ts","sourceRoot":"","sources":["../../src/services/settingsService.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,iBAAiB,EAAE,MAAM,uCAAuC,CAAC;AAE/E,OAAO,KAAK,EAAE,WAAW,EAAE,MAAM,mBAAmB,CAAC;
|
|
1
|
+
{"version":3,"file":"settingsService.d.ts","sourceRoot":"","sources":["../../src/services/settingsService.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,iBAAiB,EAAE,MAAM,uCAAuC,CAAC;AAE/E,OAAO,KAAK,EAAE,WAAW,EAAE,MAAM,mBAAmB,CAAC;AAarD,MAAM,MAAM,kBAAkB,GAAG,iBAAiB,GAAG,KAAK,CAAC;AAE3D,UAAU,eAAe;IACvB;;;;;;OAMG;IACH,mBAAmB,CAAC,IAAI,EAAE;QACxB,UAAU,EAAE,kBAAkB,CAAC;QAC/B,YAAY,EAAE,CAAC,WAAW,GAAG,MAAM,CAAC,EAAE,CAAC;KACxC,GAAG,IAAI,CAAC;IAET;;OAEG;IACH,mBAAmB,CAAC,IAAI,EAAE;QAAE,UAAU,EAAE,kBAAkB,CAAA;KAAE,GAAG,MAAM,EAAE,CAAC;IAExE;;OAEG;IACH,kBAAkB,IAAI,OAAO,CAAC;CAC/B;AAyCD;;;;;;;;;;;;;GAaG;AACH,eAAO,MAAM,eAAe,EAAE,eAA2C,CAAC"}
|