@simplewebauthn/server 13.3.3 → 14.0.1
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 +52 -2
- package/esm/errors/index.d.ts +17 -0
- package/esm/errors/index.d.ts.map +1 -0
- package/esm/errors/index.js +24 -0
- package/esm/helpers/convertX509PublicKeyToCOSE.d.ts +1 -1
- package/esm/helpers/convertX509PublicKeyToCOSE.d.ts.map +1 -1
- package/esm/helpers/convertX509PublicKeyToCOSE.js +22 -6
- package/esm/helpers/cose.d.ts +19 -2
- package/esm/helpers/cose.d.ts.map +1 -1
- package/esm/helpers/cose.js +15 -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/isCertRevoked.d.ts +1 -0
- package/esm/helpers/isCertRevoked.d.ts.map +1 -1
- package/esm/helpers/isCertRevoked.js +1 -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 +48 -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/mapX509SignatureAlgToCOSEAlg.d.ts +0 -3
- package/esm/helpers/mapX509SignatureAlgToCOSEAlg.d.ts.map +1 -1
- package/esm/helpers/mapX509SignatureAlgToCOSEAlg.js +19 -10
- package/esm/helpers/validateCertificatePath.d.ts +1 -0
- package/esm/helpers/validateCertificatePath.d.ts.map +1 -1
- package/esm/helpers/validateCertificatePath.js +26 -7
- package/esm/index.d.ts +1 -0
- package/esm/index.d.ts.map +1 -1
- package/esm/index.js +1 -0
- 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/verifications/verifyAttestationPacked.js +1 -1
- package/esm/registration/verifyRegistrationResponse.d.ts +3 -3
- package/esm/registration/verifyRegistrationResponse.d.ts.map +1 -1
- package/esm/registration/verifyRegistrationResponse.js +22 -11
- 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 +4 -2
- 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 +52 -2
- package/script/errors/index.d.ts +17 -0
- package/script/errors/index.d.ts.map +1 -0
- package/script/errors/index.js +29 -0
- package/script/helpers/convertX509PublicKeyToCOSE.d.ts +1 -1
- package/script/helpers/convertX509PublicKeyToCOSE.d.ts.map +1 -1
- package/script/helpers/convertX509PublicKeyToCOSE.js +21 -5
- package/script/helpers/cose.d.ts +19 -2
- package/script/helpers/cose.d.ts.map +1 -1
- package/script/helpers/cose.js +17 -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/isCertRevoked.d.ts +1 -0
- package/script/helpers/isCertRevoked.d.ts.map +1 -1
- package/script/helpers/isCertRevoked.js +1 -0
- 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 +51 -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/mapX509SignatureAlgToCOSEAlg.d.ts +0 -3
- package/script/helpers/mapX509SignatureAlgToCOSEAlg.d.ts.map +1 -1
- package/script/helpers/mapX509SignatureAlgToCOSEAlg.js +19 -10
- package/script/helpers/validateCertificatePath.d.ts +1 -0
- package/script/helpers/validateCertificatePath.d.ts.map +1 -1
- package/script/helpers/validateCertificatePath.js +26 -7
- package/script/index.d.ts +1 -0
- package/script/index.d.ts.map +1 -1
- package/script/index.js +1 -0
- 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/verifications/verifyAttestationPacked.js +1 -1
- package/script/registration/verifyRegistrationResponse.d.ts +3 -3
- package/script/registration/verifyRegistrationResponse.d.ts.map +1 -1
- package/script/registration/verifyRegistrationResponse.js +24 -13
- 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
|
@@ -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
|
|
@@ -91,7 +91,7 @@ export async function verifyAttestationPacked(options) {
|
|
|
91
91
|
}
|
|
92
92
|
catch (err) {
|
|
93
93
|
const _err = err;
|
|
94
|
-
throw new Error(`${_err.message} (Packed|Full)
|
|
94
|
+
throw new Error(`${_err.message} (Packed|Full)`, { cause: _err });
|
|
95
95
|
}
|
|
96
96
|
}
|
|
97
97
|
verified = await verifySignature({
|
|
@@ -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;AAE3B,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,CA8PvC;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"}
|
|
@@ -1,15 +1,16 @@
|
|
|
1
|
+
import { PQCNotSupportedError } from '../errors/index.js';
|
|
1
2
|
import { decodeAttestationObject, } from '../helpers/decodeAttestationObject.js';
|
|
2
3
|
import { decodeClientDataJSON } from '../helpers/decodeClientDataJSON.js';
|
|
3
4
|
import { parseAuthenticatorData } from '../helpers/parseAuthenticatorData.js';
|
|
4
5
|
import { toHash } from '../helpers/toHash.js';
|
|
5
6
|
import { decodeCredentialPublicKey } from '../helpers/decodeCredentialPublicKey.js';
|
|
6
|
-
import { COSEKEYS } from '../helpers/cose.js';
|
|
7
|
+
import { COSEKEYS, isPQCCOSEAlg } from '../helpers/cose.js';
|
|
7
8
|
import { convertAAGUIDToString } from '../helpers/convertAAGUIDToString.js';
|
|
8
9
|
import { parseBackupFlags } from '../helpers/parseBackupFlags.js';
|
|
9
10
|
import { matchExpectedRPID } from '../helpers/matchExpectedRPID.js';
|
|
10
11
|
import { isoBase64URL } from '../helpers/iso/index.js';
|
|
11
12
|
import { SettingsService } from '../services/settingsService.js';
|
|
12
|
-
import {
|
|
13
|
+
import { defaultSupportedAlgorithmIDs } from './generateRegistrationOptions.js';
|
|
13
14
|
import { verifyAttestationFIDOU2F } from './verifications/verifyAttestationFIDOU2F.js';
|
|
14
15
|
import { verifyAttestationPacked } from './verifications/verifyAttestationPacked.js';
|
|
15
16
|
import { verifyAttestationAndroidSafetyNet } from './verifications/verifyAttestationAndroidSafetyNet.js';
|
|
@@ -28,11 +29,11 @@ import { verifyAttestationApple } from './verifications/verifyAttestationApple.j
|
|
|
28
29
|
* @param expectedType **(Optional)** - The response type expected ('webauthn.create')
|
|
29
30
|
* @param requireUserPresence **(Optional)** - Enforce user presence by the authenticator (or skip it during auto registration) Defaults to `true`
|
|
30
31
|
* @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
|
|
32
|
+
* @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
33
|
* @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
34
|
*/
|
|
34
35
|
export async function verifyRegistrationResponse(options) {
|
|
35
|
-
const { response, expectedChallenge, expectedOrigin, expectedRPID, expectedType, requireUserPresence = true, requireUserVerification = true, supportedAlgorithmIDs =
|
|
36
|
+
const { response, expectedChallenge, expectedOrigin, expectedRPID, expectedType, requireUserPresence = true, requireUserVerification = true, supportedAlgorithmIDs = defaultSupportedAlgorithmIDs, attestationSafetyNetEnforceCTSCheck = true, } = options;
|
|
36
37
|
const { id, rawId, type: credentialType, response: attestationResponse } = response;
|
|
37
38
|
// Ensure credential specified an ID
|
|
38
39
|
if (!id) {
|
|
@@ -128,19 +129,29 @@ export async function verifyRegistrationResponse(options) {
|
|
|
128
129
|
throw new Error('No AAGUID was present during registration');
|
|
129
130
|
}
|
|
130
131
|
const decodedPublicKey = decodeCredentialPublicKey(credentialPublicKey);
|
|
131
|
-
const
|
|
132
|
-
if (typeof
|
|
132
|
+
const pubKeyAlg = decodedPublicKey.get(COSEKEYS.alg);
|
|
133
|
+
if (typeof pubKeyAlg !== 'number') {
|
|
133
134
|
throw new Error('Credential public key was missing numeric alg');
|
|
134
135
|
}
|
|
135
136
|
// Make sure the key algorithm is one we specified within the registration options
|
|
136
|
-
if (!supportedAlgorithmIDs.includes(
|
|
137
|
+
if (!supportedAlgorithmIDs.includes(pubKeyAlg)) {
|
|
137
138
|
const supported = supportedAlgorithmIDs.join(', ');
|
|
138
|
-
throw new Error(`Unexpected public key alg "${
|
|
139
|
+
throw new Error(`Unexpected public key alg "${pubKeyAlg}", expected one of "${supported}"`);
|
|
140
|
+
}
|
|
141
|
+
/**
|
|
142
|
+
* If the runtime doesn't support PQC passkeys then terminate here at the first sign of a PQC
|
|
143
|
+
* algorithm so that downstream issues that arise due to lack of PQC support won't get masked as
|
|
144
|
+
* unexpected behavior.
|
|
145
|
+
*
|
|
146
|
+
* I'm choosing to raise here even if attestation is "none" because it feels weird to allow an RP
|
|
147
|
+
* to parse a registration response w/o attestation only to encounter failure when trying to auth
|
|
148
|
+
* with the PQC passkey and the runtime doesn't support PQC.
|
|
149
|
+
*/
|
|
150
|
+
if (isPQCCOSEAlg(pubKeyAlg) && !SettingsService.runtimeSupportsPQC()) {
|
|
151
|
+
throw new PQCNotSupportedError(pubKeyAlg);
|
|
139
152
|
}
|
|
140
153
|
const clientDataHash = await toHash(isoBase64URL.toBuffer(attestationResponse.clientDataJSON));
|
|
141
|
-
const rootCertificates = SettingsService.getRootCertificates({
|
|
142
|
-
identifier: fmt,
|
|
143
|
-
});
|
|
154
|
+
const rootCertificates = SettingsService.getRootCertificates({ identifier: fmt });
|
|
144
155
|
// Prepare arguments to pass to the relevant verification method
|
|
145
156
|
const verifierOpts = {
|
|
146
157
|
aaguid,
|
|
@@ -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"}
|
|
@@ -1,4 +1,5 @@
|
|
|
1
1
|
import { convertCertBufferToPEM } from '../helpers/convertCertBufferToPEM.js';
|
|
2
|
+
import { runtimeSupportsWebCryptoKeyAlg } from '../helpers/iso/isoCrypto/runtimeSupportsWebCryptoKeyAlg.js';
|
|
2
3
|
import { GlobalSign_Root_CA } from './defaultRootCerts/android-safetynet.js';
|
|
3
4
|
import { Google_Hardware_Attestation_Root_1, Google_Hardware_Attestation_Root_2, Google_Hardware_Attestation_Root_3, Google_Hardware_Attestation_Root_4, } from './defaultRootCerts/android-key.js';
|
|
4
5
|
import { Apple_WebAuthn_Root_CA } from './defaultRootCerts/apple.js';
|
|
@@ -12,7 +13,15 @@ class BaseSettingsService {
|
|
|
12
13
|
writable: true,
|
|
13
14
|
value: void 0
|
|
14
15
|
});
|
|
16
|
+
// Track whether the runtime supports PQC algorithms
|
|
17
|
+
Object.defineProperty(this, "_runtimeSupportsPQC", {
|
|
18
|
+
enumerable: true,
|
|
19
|
+
configurable: true,
|
|
20
|
+
writable: true,
|
|
21
|
+
value: false
|
|
22
|
+
});
|
|
15
23
|
this.pemCertificates = new Map();
|
|
24
|
+
this._runtimeSupportsPQC = runtimeSupportsWebCryptoKeyAlg('ML-DSA-44');
|
|
16
25
|
}
|
|
17
26
|
setRootCertificates(opts) {
|
|
18
27
|
const { identifier, certificates } = opts;
|
|
@@ -31,6 +40,9 @@ class BaseSettingsService {
|
|
|
31
40
|
const { identifier } = opts;
|
|
32
41
|
return this.pemCertificates.get(identifier) ?? [];
|
|
33
42
|
}
|
|
43
|
+
runtimeSupportsPQC() {
|
|
44
|
+
return this._runtimeSupportsPQC;
|
|
45
|
+
}
|
|
34
46
|
}
|
|
35
47
|
/**
|
|
36
48
|
* A basic service for specifying acceptable root certificates for all supported attestation
|