@simplewebauthn/server 13.3.2 → 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/mapJWSAlgToCOSEAlg.d.ts +8 -0
- package/esm/helpers/mapJWSAlgToCOSEAlg.d.ts.map +1 -0
- package/esm/helpers/mapJWSAlgToCOSEAlg.js +31 -0
- package/esm/helpers/validateCertificatePath.d.ts.map +1 -1
- package/esm/helpers/validateCertificatePath.js +25 -7
- package/esm/metadata/verifyJWT.d.ts.map +1 -1
- package/esm/metadata/verifyJWT.js +7 -2
- 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/defaultRootCerts/mds.d.ts +11 -0
- package/esm/services/defaultRootCerts/mds.d.ts.map +1 -1
- package/esm/services/defaultRootCerts/mds.js +42 -0
- 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 +17 -2
- 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/mapJWSAlgToCOSEAlg.d.ts +8 -0
- package/script/helpers/mapJWSAlgToCOSEAlg.d.ts.map +1 -0
- package/script/helpers/mapJWSAlgToCOSEAlg.js +34 -0
- package/script/helpers/validateCertificatePath.d.ts.map +1 -1
- package/script/helpers/validateCertificatePath.js +25 -7
- package/script/metadata/verifyJWT.d.ts.map +1 -1
- package/script/metadata/verifyJWT.js +6 -1
- 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/defaultRootCerts/mds.d.ts +11 -0
- package/script/services/defaultRootCerts/mds.d.ts.map +1 -1
- package/script/services/defaultRootCerts/mds.js +43 -1
- 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 +16 -1
- 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
|
}
|
|
@@ -0,0 +1,8 @@
|
|
|
1
|
+
import { COSEALG } from './cose.js';
|
|
2
|
+
/**
|
|
3
|
+
* Map JWS algorithms to COSE algorithm IDs
|
|
4
|
+
*
|
|
5
|
+
* See https://www.rfc-editor.org/rfc/rfc7518.html#section-3.1 for possible values
|
|
6
|
+
*/
|
|
7
|
+
export declare function mapJWSAlgToCOSEAlg(alg: string): COSEALG;
|
|
8
|
+
//# sourceMappingURL=mapJWSAlgToCOSEAlg.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"mapJWSAlgToCOSEAlg.d.ts","sourceRoot":"","sources":["../../src/helpers/mapJWSAlgToCOSEAlg.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,OAAO,EAAE,MAAM,WAAW,CAAC;AAEpC;;;;GAIG;AACH,wBAAgB,kBAAkB,CAAC,GAAG,EAAE,MAAM,GAAG,OAAO,CAoBvD"}
|
|
@@ -0,0 +1,31 @@
|
|
|
1
|
+
import { COSEALG } from './cose.js';
|
|
2
|
+
/**
|
|
3
|
+
* Map JWS algorithms to COSE algorithm IDs
|
|
4
|
+
*
|
|
5
|
+
* See https://www.rfc-editor.org/rfc/rfc7518.html#section-3.1 for possible values
|
|
6
|
+
*/
|
|
7
|
+
export function mapJWSAlgToCOSEAlg(alg) {
|
|
8
|
+
let algCOSE;
|
|
9
|
+
if (alg === 'ES256') {
|
|
10
|
+
algCOSE = COSEALG.ES256;
|
|
11
|
+
}
|
|
12
|
+
else if (alg === 'ES384') {
|
|
13
|
+
algCOSE = COSEALG.ES384;
|
|
14
|
+
}
|
|
15
|
+
else if (alg === 'ES512') {
|
|
16
|
+
algCOSE = COSEALG.ES512;
|
|
17
|
+
}
|
|
18
|
+
else if (alg === 'RS256') {
|
|
19
|
+
algCOSE = COSEALG.RS256;
|
|
20
|
+
}
|
|
21
|
+
else if (alg === 'RS384') {
|
|
22
|
+
algCOSE = COSEALG.RS384;
|
|
23
|
+
}
|
|
24
|
+
else if (alg === 'RS512') {
|
|
25
|
+
algCOSE = COSEALG.RS512;
|
|
26
|
+
}
|
|
27
|
+
else {
|
|
28
|
+
throw new Error(`Unable to map JWS algorithm "${alg}" to a COSE algorithm`);
|
|
29
|
+
}
|
|
30
|
+
return algCOSE;
|
|
31
|
+
}
|
|
@@ -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 +1 @@
|
|
|
1
|
-
{"version":3,"file":"verifyJWT.d.ts","sourceRoot":"","sources":["../../src/metadata/verifyJWT.ts"],"names":[],"mappings":"
|
|
1
|
+
{"version":3,"file":"verifyJWT.d.ts","sourceRoot":"","sources":["../../src/metadata/verifyJWT.ts"],"names":[],"mappings":"AAMA,OAAO,KAAK,EAAE,WAAW,EAAE,MAAM,mBAAmB,CAAC;AAErD;;;;;;;;GAQG;AACH,wBAAgB,SAAS,CAAC,GAAG,EAAE,MAAM,EAAE,QAAQ,EAAE,WAAW,GAAG,OAAO,CAAC,OAAO,CAAC,CAgC9E"}
|
|
@@ -1,6 +1,7 @@
|
|
|
1
1
|
import { convertX509PublicKeyToCOSE } from '../helpers/convertX509PublicKeyToCOSE.js';
|
|
2
2
|
import { isoBase64URL, isoUint8Array } from '../helpers/iso/index.js';
|
|
3
|
-
import {
|
|
3
|
+
import { COSEKEYS, isCOSEPublicKeyEC2, isCOSEPublicKeyRSA } from '../helpers/cose.js';
|
|
4
|
+
import { mapJWSAlgToCOSEAlg } from '../helpers/mapJWSAlgToCOSEAlg.js';
|
|
4
5
|
import { verifyEC2 } from '../helpers/iso/isoCrypto/verifyEC2.js';
|
|
5
6
|
import { verifyRSA } from '../helpers/iso/isoCrypto/verifyRSA.js';
|
|
6
7
|
/**
|
|
@@ -17,12 +18,15 @@ export function verifyJWT(jwt, leafCert) {
|
|
|
17
18
|
const certCOSE = convertX509PublicKeyToCOSE(leafCert);
|
|
18
19
|
const data = isoUint8Array.fromUTF8String(`${header}.${payload}`);
|
|
19
20
|
const signatureBytes = isoBase64URL.toBuffer(signature);
|
|
21
|
+
// We just need the `alg` from the header, so only partially define the shape of it
|
|
22
|
+
const headerJSON = JSON.parse(isoBase64URL.toUTF8String(header));
|
|
23
|
+
const jwtHeaderHashAlgCOSE = mapJWSAlgToCOSEAlg(headerJSON.alg);
|
|
20
24
|
if (isCOSEPublicKeyEC2(certCOSE)) {
|
|
21
25
|
return verifyEC2({
|
|
22
26
|
data,
|
|
23
27
|
signature: signatureBytes,
|
|
24
28
|
cosePublicKey: certCOSE,
|
|
25
|
-
shaHashOverride:
|
|
29
|
+
shaHashOverride: jwtHeaderHashAlgCOSE,
|
|
26
30
|
});
|
|
27
31
|
}
|
|
28
32
|
else if (isCOSEPublicKeyRSA(certCOSE)) {
|
|
@@ -30,6 +34,7 @@ export function verifyJWT(jwt, leafCert) {
|
|
|
30
34
|
data,
|
|
31
35
|
signature: signatureBytes,
|
|
32
36
|
cosePublicKey: certCOSE,
|
|
37
|
+
shaHashOverride: jwtHeaderHashAlgCOSE,
|
|
33
38
|
});
|
|
34
39
|
}
|
|
35
40
|
const kty = certCOSE.get(COSEKEYS.kty);
|
|
@@ -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":"verifyRegist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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) {
|
|
@@ -9,4 +9,15 @@
|
|
|
9
9
|
* CB:B5:22:D7:B7:F1:27:AD:6A:01:13:86:5B:DF:1C:D4:10:2E:7D:07:59:AF:63:5A:7C:F4:72:0D:C9:63:C5:3B
|
|
10
10
|
*/
|
|
11
11
|
export declare const GlobalSign_Root_CA_R3 = "-----BEGIN CERTIFICATE-----\nMIIDXzCCAkegAwIBAgILBAAAAAABIVhTCKIw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JrlAGomecs\nMx86OyXShkDOOyyGeMlhLxS67ttVb9+E7gUJTb0o2HLO02JQZR7rkpeDMdmztcpH\nWD9f\n-----END CERTIFICATE-----\n ";
|
|
12
|
+
/**
|
|
13
|
+
* GlobalSign Root R46
|
|
14
|
+
*
|
|
15
|
+
* Downloaded from https://valid.r46.roots.globalsign.com/
|
|
16
|
+
*
|
|
17
|
+
* Valid until 2046-03-20 @ 00:00 PST
|
|
18
|
+
*
|
|
19
|
+
* SHA256 Fingerprint
|
|
20
|
+
* 4F:A3:12:6D:8D:3A:11:D1:C4:85:5A:4F:80:7C:BA:D6:CF:91:9D:3A:5A:88:B0:3B:EA:2C:63:72:D9:3C:40:C9
|
|
21
|
+
*/
|
|
22
|
+
export declare const GlobalSign_Root_R46 = "-----BEGIN CERTIFICATE-----\nMIIFWjCCA0KgAwIBAgISEdK7udcjGJ5AXwqdLdDfJWfRMA0GCSqGSIb3DQEBDAUA\nMEYxCzAJBgNVBAYTAkJFMRkwFwYDVQQKExBHbG9iYWxTaWduIG52LXNhMRwwGgYD\nVQQDExNHbG9iYWxTaWduIFJvb3QgUjQ2MB4XDTE5MDMyMDAwMDAwMFoXDTQ2MDMy\nMDAwMDAwMFowRjELMAkGA1UEBhMCQkUxGTAXBgNVBAoTEEdsb2JhbFNpZ24gbnYt\nc2ExHDAaBgNVBAMTE0dsb2JhbFNpZ24gUm9vdCBSNDYwggIiMA0GCSqGSIb3DQEB\nAQUAA4ICDwAwggIKAoICAQCsrHQy6LNl5brtQyYdpokNRbopiLKkHWPd08EsCVeJ\nOaFV6Wc0dwxu5FUdUiXSE2te4R2pt32JMl8Nnp8semNgQB+msLZ4j5lUlghYruQG\nvGIFAha/r6gjA7aUD7xubMLL1aa7DOn2wQL7Id5m3RerdELv8HQvJfTqa1VbkNud\n316HCkD7rRlr+/fKYIje2sGP1q7Vf9Q8g+7XFkyDRTNrJ9CG0Bwta/OrffGFqfUo\n0q3v84RLHIf8E6M6cqJaESvWJ3En7YEtbWaB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Mbfc2hIkCwU9D9SGuTSyxTDYWnP\n4vkYxboznxSjBF25cfe1lNj2M8FawTSLfJvdkzrnE6JwYZ+vj+vYxXX4M2bUdGc6\nN3ec592kD3ZDZopD8p/7DEJ4Y9HiD2971KE9dJeFt0g5QdYg/NA6s/rob8SKunE3\nvouXsXgxT7PntgMTzlSdriVZzH81Xwj3QEUxeCp6\n-----END CERTIFICATE-----\n";
|
|
12
23
|
//# sourceMappingURL=mds.d.ts.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"mds.d.ts","sourceRoot":"","sources":["../../../src/services/defaultRootCerts/mds.ts"],"names":[],"mappings":"AAAA;;;;;;;;;GASG;AACH,eAAO,MAAM,qBAAqB,wuCAqBhC,CAAC"}
|
|
1
|
+
{"version":3,"file":"mds.d.ts","sourceRoot":"","sources":["../../../src/services/defaultRootCerts/mds.ts"],"names":[],"mappings":"AAAA;;;;;;;;;GASG;AACH,eAAO,MAAM,qBAAqB,wuCAqBhC,CAAC;AAEH;;;;;;;;;GASG;AACH,eAAO,MAAM,mBAAmB,+5DA+B/B,CAAC"}
|