@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
|
@@ -0,0 +1,7 @@
|
|
|
1
|
+
import type { AlgorithmIdentifier } from '../../../types/index.js';
|
|
2
|
+
/**
|
|
3
|
+
* Use SubtleCrypto.supports() to understand if the runtime supports using the given key algorithm
|
|
4
|
+
* for signature verification.
|
|
5
|
+
*/
|
|
6
|
+
export declare function runtimeSupportsWebCryptoKeyAlg(alg: AlgorithmIdentifier): boolean;
|
|
7
|
+
//# sourceMappingURL=runtimeSupportsWebCryptoKeyAlg.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"runtimeSupportsWebCryptoKeyAlg.d.ts","sourceRoot":"","sources":["../../../../src/helpers/iso/isoCrypto/runtimeSupportsWebCryptoKeyAlg.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,mBAAmB,EAAsB,MAAM,yBAAyB,CAAC;AAEvF;;;GAGG;AACH,wBAAgB,8BAA8B,CAAC,GAAG,EAAE,mBAAmB,GAAG,OAAO,CAYhF"}
|
|
@@ -0,0 +1,16 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Use SubtleCrypto.supports() to understand if the runtime supports using the given key algorithm
|
|
3
|
+
* for signature verification.
|
|
4
|
+
*/
|
|
5
|
+
export function runtimeSupportsWebCryptoKeyAlg(alg) {
|
|
6
|
+
const globalSubtleCrypto = globalThis.SubtleCrypto;
|
|
7
|
+
if (typeof globalSubtleCrypto.supports !== 'function') {
|
|
8
|
+
return false;
|
|
9
|
+
}
|
|
10
|
+
try {
|
|
11
|
+
return globalSubtleCrypto.supports('verify', alg);
|
|
12
|
+
}
|
|
13
|
+
catch (_err) {
|
|
14
|
+
return false;
|
|
15
|
+
}
|
|
16
|
+
}
|
|
@@ -1,4 +1,4 @@
|
|
|
1
1
|
export type SubtleCryptoAlg = 'SHA-1' | 'SHA-256' | 'SHA-384' | 'SHA-512';
|
|
2
2
|
export type SubtleCryptoCrv = 'P-256' | 'P-384' | 'P-521' | 'Ed25519';
|
|
3
|
-
export type SubtleCryptoKeyAlgName = 'ECDSA' | 'Ed25519' | 'RSASSA-PKCS1-v1_5' | 'RSA-PSS';
|
|
3
|
+
export type SubtleCryptoKeyAlgName = 'ECDSA' | 'Ed25519' | 'ML-DSA-44' | 'ML-DSA-65' | 'ML-DSA-87' | 'RSASSA-PKCS1-v1_5' | 'RSA-PSS';
|
|
4
4
|
//# sourceMappingURL=structs.d.ts.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"structs.d.ts","sourceRoot":"","sources":["../../../../src/helpers/iso/isoCrypto/structs.ts"],"names":[],"mappings":"AAAA,MAAM,MAAM,eAAe,GAAG,OAAO,GAAG,SAAS,GAAG,SAAS,GAAG,SAAS,CAAC;AAC1E,MAAM,MAAM,eAAe,GAAG,OAAO,GAAG,OAAO,GAAG,OAAO,GAAG,SAAS,CAAC;AACtE,MAAM,MAAM,sBAAsB,GAC9B,OAAO,GACP,SAAS,GACT,mBAAmB,GACnB,SAAS,CAAC"}
|
|
1
|
+
{"version":3,"file":"structs.d.ts","sourceRoot":"","sources":["../../../../src/helpers/iso/isoCrypto/structs.ts"],"names":[],"mappings":"AAAA,MAAM,MAAM,eAAe,GAAG,OAAO,GAAG,SAAS,GAAG,SAAS,GAAG,SAAS,CAAC;AAC1E,MAAM,MAAM,eAAe,GAAG,OAAO,GAAG,OAAO,GAAG,OAAO,GAAG,SAAS,CAAC;AACtE,MAAM,MAAM,sBAAsB,GAC9B,OAAO,GACP,SAAS,GACT,WAAW,GACX,WAAW,GACX,WAAW,GACX,mBAAmB,GACnB,SAAS,CAAC"}
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"verify.d.ts","sourceRoot":"","sources":["../../../../src/helpers/iso/isoCrypto/verify.ts"],"names":[],"mappings":"AAAA,OAAO,EACL,KAAK,OAAO,EAEZ,KAAK,aAAa,
|
|
1
|
+
{"version":3,"file":"verify.d.ts","sourceRoot":"","sources":["../../../../src/helpers/iso/isoCrypto/verify.ts"],"names":[],"mappings":"AAAA,OAAO,EACL,KAAK,OAAO,EAEZ,KAAK,aAAa,EAMnB,MAAM,eAAe,CAAC;AAMvB,OAAO,KAAK,EAAE,WAAW,EAAE,MAAM,yBAAyB,CAAC;AAE3D;;GAEG;AACH,wBAAgB,MAAM,CAAC,IAAI,EAAE;IAC3B,aAAa,EAAE,aAAa,CAAC;IAC7B,SAAS,EAAE,WAAW,CAAC;IACvB,IAAI,EAAE,WAAW,CAAC;IAClB,eAAe,CAAC,EAAE,OAAO,CAAC;CAC3B,GAAG,OAAO,CAAC,OAAO,CAAC,CA2BnB"}
|
|
@@ -1,4 +1,5 @@
|
|
|
1
|
-
import { COSEKEYS, isCOSECrv, isCOSEPublicKeyEC2, isCOSEPublicKeyOKP, isCOSEPublicKeyRSA, } from '../../cose.js';
|
|
1
|
+
import { COSEKEYS, isCOSECrv, isCOSEPublicKeyAKP, isCOSEPublicKeyEC2, isCOSEPublicKeyOKP, isCOSEPublicKeyRSA, } from '../../cose.js';
|
|
2
|
+
import { verifyAKP } from './verifyAKP.js';
|
|
2
3
|
import { verifyEC2 } from './verifyEC2.js';
|
|
3
4
|
import { verifyRSA } from './verifyRSA.js';
|
|
4
5
|
import { verifyOKP } from './verifyOKP.js';
|
|
@@ -27,6 +28,9 @@ export function verify(opts) {
|
|
|
27
28
|
else if (isCOSEPublicKeyOKP(cosePublicKey)) {
|
|
28
29
|
return verifyOKP({ cosePublicKey, signature, data });
|
|
29
30
|
}
|
|
31
|
+
else if (isCOSEPublicKeyAKP(cosePublicKey)) {
|
|
32
|
+
return verifyAKP({ cosePublicKey, signature, data });
|
|
33
|
+
}
|
|
30
34
|
const kty = cosePublicKey.get(COSEKEYS.kty);
|
|
31
35
|
throw new Error(`Signature verification with public key of kty ${kty} is not supported by this method`);
|
|
32
36
|
}
|
|
@@ -0,0 +1,9 @@
|
|
|
1
|
+
import { type COSEPublicKeyAKP } from '../../cose.js';
|
|
2
|
+
import type { Uint8Array_ } from '../../../types/index.js';
|
|
3
|
+
/** AKP, a.k.a ML-DSA */
|
|
4
|
+
export declare function verifyAKP(opts: {
|
|
5
|
+
cosePublicKey: COSEPublicKeyAKP;
|
|
6
|
+
signature: Uint8Array_;
|
|
7
|
+
data: Uint8Array_;
|
|
8
|
+
}): Promise<boolean>;
|
|
9
|
+
//# sourceMappingURL=verifyAKP.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"verifyAKP.d.ts","sourceRoot":"","sources":["../../../../src/helpers/iso/isoCrypto/verifyAKP.ts"],"names":[],"mappings":"AAAA,OAAO,EAAY,KAAK,gBAAgB,EAAa,MAAM,eAAe,CAAC;AAM3E,OAAO,KAAK,EAAmB,WAAW,EAAE,MAAM,yBAAyB,CAAC;AAE5E,wBAAwB;AACxB,wBAAsB,SAAS,CAAC,IAAI,EAAE;IACpC,aAAa,EAAE,gBAAgB,CAAC;IAChC,SAAS,EAAE,WAAW,CAAC;IACvB,IAAI,EAAE,WAAW,CAAC;CACnB,GAAG,OAAO,CAAC,OAAO,CAAC,CA+CnB"}
|
|
@@ -0,0 +1,48 @@
|
|
|
1
|
+
import { COSEKEYS, isCOSEAlg } from '../../cose.js';
|
|
2
|
+
import { isoBase64URL } from '../../index.js';
|
|
3
|
+
import { importJWKKey } from './importJWKKey.js';
|
|
4
|
+
import { getWebCrypto } from './getWebCrypto.js';
|
|
5
|
+
import { mapCoseAlgToWebCryptoKeyAlgName } from './mapCoseAlgToWebCryptoKeyAlgName.js';
|
|
6
|
+
import { PQCNotSupportedError } from '../../../errors/index.js';
|
|
7
|
+
/** AKP, a.k.a ML-DSA */
|
|
8
|
+
export async function verifyAKP(opts) {
|
|
9
|
+
const { cosePublicKey, signature, data } = opts;
|
|
10
|
+
const WebCrypto = await getWebCrypto();
|
|
11
|
+
const alg = cosePublicKey.get(COSEKEYS.alg);
|
|
12
|
+
const pub = cosePublicKey.get(COSEKEYS.pub);
|
|
13
|
+
if (!alg) {
|
|
14
|
+
throw new Error('Public key was missing alg (AKP)');
|
|
15
|
+
}
|
|
16
|
+
if (!isCOSEAlg(alg)) {
|
|
17
|
+
throw new Error(`Public key had invalid alg ${alg} (AKP)`);
|
|
18
|
+
}
|
|
19
|
+
if (!pub) {
|
|
20
|
+
throw new Error('Public key was missing pub (AKP)');
|
|
21
|
+
}
|
|
22
|
+
const webCryptoAlg = mapCoseAlgToWebCryptoKeyAlgName(alg);
|
|
23
|
+
// See https://wicg.github.io/webcrypto-modern-algos/#ml-dsa-operations-import-key -> "jwk"
|
|
24
|
+
const keyData = {
|
|
25
|
+
kty: 'AKP',
|
|
26
|
+
alg: webCryptoAlg,
|
|
27
|
+
pub: isoBase64URL.fromBuffer(pub),
|
|
28
|
+
ext: false,
|
|
29
|
+
};
|
|
30
|
+
/**
|
|
31
|
+
* ML-DSA support is pretty cutting edge, so take some steps to help RP's understand this instead
|
|
32
|
+
* of them getting a `NotSupportedError: Unrecognized algorithm name` and trying to interpret it.
|
|
33
|
+
*/
|
|
34
|
+
let key;
|
|
35
|
+
try {
|
|
36
|
+
key = await importJWKKey({ keyData, algorithm: webCryptoAlg });
|
|
37
|
+
}
|
|
38
|
+
catch (err) {
|
|
39
|
+
const _err = err;
|
|
40
|
+
if (_err.name === 'NotSupportedError') {
|
|
41
|
+
throw new PQCNotSupportedError(alg);
|
|
42
|
+
}
|
|
43
|
+
else {
|
|
44
|
+
throw err;
|
|
45
|
+
}
|
|
46
|
+
}
|
|
47
|
+
return WebCrypto.subtle.verify(webCryptoAlg, key, signature, data);
|
|
48
|
+
}
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"verifyEC2.d.ts","sourceRoot":"","sources":["../../../../src/helpers/iso/isoCrypto/verifyEC2.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,KAAK,OAAO,EAAqB,KAAK,gBAAgB,EAAE,MAAM,eAAe,CAAC;AAMvF,OAAO,KAAK,EAAE,WAAW,EAAE,MAAM,yBAAyB,CAAC;AAE3D;;GAEG;AACH,wBAAsB,SAAS,CAAC,IAAI,EAAE;IACpC,aAAa,EAAE,gBAAgB,CAAC;IAChC,SAAS,EAAE,WAAW,CAAC;IACvB,IAAI,EAAE,WAAW,CAAC;IAClB,eAAe,CAAC,EAAE,OAAO,CAAC;CAC3B,GAAG,OAAO,CAAC,OAAO,CAAC,
|
|
1
|
+
{"version":3,"file":"verifyEC2.d.ts","sourceRoot":"","sources":["../../../../src/helpers/iso/isoCrypto/verifyEC2.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,KAAK,OAAO,EAAqB,KAAK,gBAAgB,EAAE,MAAM,eAAe,CAAC;AAMvF,OAAO,KAAK,EAAE,WAAW,EAAE,MAAM,yBAAyB,CAAC;AAE3D;;GAEG;AACH,wBAAsB,SAAS,CAAC,IAAI,EAAE;IACpC,aAAa,EAAE,gBAAgB,CAAC;IAChC,SAAS,EAAE,WAAW,CAAC;IACvB,IAAI,EAAE,WAAW,CAAC;IAClB,eAAe,CAAC,EAAE,OAAO,CAAC;CAC3B,GAAG,OAAO,CAAC,OAAO,CAAC,CAuEnB"}
|
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
import { COSECRV, COSEKEYS } 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 { getWebCrypto } from './getWebCrypto.js';
|
|
6
6
|
/**
|
|
@@ -56,14 +56,11 @@ export async function verifyEC2(opts) {
|
|
|
56
56
|
name: 'ECDSA',
|
|
57
57
|
namedCurve: _crv,
|
|
58
58
|
};
|
|
59
|
-
const key = await
|
|
60
|
-
keyData,
|
|
61
|
-
algorithm: keyAlgorithm,
|
|
62
|
-
});
|
|
59
|
+
const key = await importJWKKey({ keyData, algorithm: keyAlgorithm });
|
|
63
60
|
// Determine which SHA algorithm to use for signature verification
|
|
64
|
-
let subtleAlg =
|
|
61
|
+
let subtleAlg = mapCoseAlgToWebCryptoHashAlgName(alg);
|
|
65
62
|
if (shaHashOverride) {
|
|
66
|
-
subtleAlg =
|
|
63
|
+
subtleAlg = mapCoseAlgToWebCryptoHashAlgName(shaHashOverride);
|
|
67
64
|
}
|
|
68
65
|
const verifyAlgorithm = {
|
|
69
66
|
name: 'ECDSA',
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"verifyOKP.d.ts","sourceRoot":"","sources":["../../../../src/helpers/iso/isoCrypto/verifyOKP.ts"],"names":[],"mappings":"AAAA,OAAO,EAAqB,KAAK,gBAAgB,EAAa,MAAM,eAAe,CAAC;AAKpF,OAAO,KAAK,EAAE,WAAW,EAAE,MAAM,yBAAyB,CAAC;AAE3D,wBAAsB,SAAS,CAAC,IAAI,EAAE;IACpC,aAAa,EAAE,gBAAgB,CAAC;IAChC,SAAS,EAAE,WAAW,CAAC;IACvB,IAAI,EAAE,WAAW,CAAC;CACnB,GAAG,OAAO,CAAC,OAAO,CAAC,
|
|
1
|
+
{"version":3,"file":"verifyOKP.d.ts","sourceRoot":"","sources":["../../../../src/helpers/iso/isoCrypto/verifyOKP.ts"],"names":[],"mappings":"AAAA,OAAO,EAAqB,KAAK,gBAAgB,EAAa,MAAM,eAAe,CAAC;AAKpF,OAAO,KAAK,EAAE,WAAW,EAAE,MAAM,yBAAyB,CAAC;AAE3D,wBAAsB,SAAS,CAAC,IAAI,EAAE;IACpC,aAAa,EAAE,gBAAgB,CAAC;IAChC,SAAS,EAAE,WAAW,CAAC;IACvB,IAAI,EAAE,WAAW,CAAC;CACnB,GAAG,OAAO,CAAC,OAAO,CAAC,CAsDnB"}
|
|
@@ -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,9 +1,6 @@
|
|
|
1
1
|
import { COSEALG } from './cose.js';
|
|
2
2
|
/**
|
|
3
3
|
* Map X.509 signature algorithm OIDs to COSE algorithm IDs
|
|
4
|
-
*
|
|
5
|
-
* - EC2 OIDs: https://oidref.com/1.2.840.10045.4.3
|
|
6
|
-
* - RSA OIDs: https://oidref.com/1.2.840.113549.1.1
|
|
7
4
|
*/
|
|
8
5
|
export declare function mapX509SignatureAlgToCOSEAlg(signatureAlgorithm: string): COSEALG;
|
|
9
6
|
//# sourceMappingURL=mapX509SignatureAlgToCOSEAlg.d.ts.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"mapX509SignatureAlgToCOSEAlg.d.ts","sourceRoot":"","sources":["../../src/helpers/mapX509SignatureAlgToCOSEAlg.ts"],"names":[],"mappings":"
|
|
1
|
+
{"version":3,"file":"mapX509SignatureAlgToCOSEAlg.d.ts","sourceRoot":"","sources":["../../src/helpers/mapX509SignatureAlgToCOSEAlg.ts"],"names":[],"mappings":"AAQA,OAAO,EAAE,OAAO,EAAE,MAAM,WAAW,CAAC;AAEpC;;GAEG;AACH,wBAAgB,4BAA4B,CAC1C,kBAAkB,EAAE,MAAM,GACzB,OAAO,CA8BT"}
|
|
@@ -1,33 +1,42 @@
|
|
|
1
|
+
import { id_ecdsaWithSHA256, id_ecdsaWithSHA384, id_ecdsaWithSHA512 } from '@peculiar/asn1-ecc';
|
|
2
|
+
import { id_sha1WithRSAEncryption, id_sha256WithRSAEncryption, id_sha384WithRSAEncryption, id_sha512WithRSAEncryption, } from '@peculiar/asn1-rsa';
|
|
3
|
+
import { id_ml_dsa_44, id_ml_dsa_65, id_ml_dsa_87 } from '@peculiar/asn1-x509-post-quantum';
|
|
1
4
|
import { COSEALG } from './cose.js';
|
|
2
5
|
/**
|
|
3
6
|
* Map X.509 signature algorithm OIDs to COSE algorithm IDs
|
|
4
|
-
*
|
|
5
|
-
* - EC2 OIDs: https://oidref.com/1.2.840.10045.4.3
|
|
6
|
-
* - RSA OIDs: https://oidref.com/1.2.840.113549.1.1
|
|
7
7
|
*/
|
|
8
8
|
export function mapX509SignatureAlgToCOSEAlg(signatureAlgorithm) {
|
|
9
9
|
let alg;
|
|
10
|
-
if (signatureAlgorithm ===
|
|
10
|
+
if (signatureAlgorithm === id_ecdsaWithSHA256) {
|
|
11
11
|
alg = COSEALG.ES256;
|
|
12
12
|
}
|
|
13
|
-
else if (signatureAlgorithm ===
|
|
13
|
+
else if (signatureAlgorithm === id_ecdsaWithSHA384) {
|
|
14
14
|
alg = COSEALG.ES384;
|
|
15
15
|
}
|
|
16
|
-
else if (signatureAlgorithm ===
|
|
16
|
+
else if (signatureAlgorithm === id_ecdsaWithSHA512) {
|
|
17
17
|
alg = COSEALG.ES512;
|
|
18
18
|
}
|
|
19
|
-
else if (signatureAlgorithm ===
|
|
19
|
+
else if (signatureAlgorithm === id_sha256WithRSAEncryption) {
|
|
20
20
|
alg = COSEALG.RS256;
|
|
21
21
|
}
|
|
22
|
-
else if (signatureAlgorithm ===
|
|
22
|
+
else if (signatureAlgorithm === id_sha384WithRSAEncryption) {
|
|
23
23
|
alg = COSEALG.RS384;
|
|
24
24
|
}
|
|
25
|
-
else if (signatureAlgorithm ===
|
|
25
|
+
else if (signatureAlgorithm === id_sha512WithRSAEncryption) {
|
|
26
26
|
alg = COSEALG.RS512;
|
|
27
27
|
}
|
|
28
|
-
else if (signatureAlgorithm ===
|
|
28
|
+
else if (signatureAlgorithm === id_sha1WithRSAEncryption) {
|
|
29
29
|
alg = COSEALG.RS1;
|
|
30
30
|
}
|
|
31
|
+
else if (signatureAlgorithm === id_ml_dsa_44) {
|
|
32
|
+
alg = COSEALG.ML_DSA_44;
|
|
33
|
+
}
|
|
34
|
+
else if (signatureAlgorithm === id_ml_dsa_65) {
|
|
35
|
+
alg = COSEALG.ML_DSA_65;
|
|
36
|
+
}
|
|
37
|
+
else if (signatureAlgorithm === id_ml_dsa_87) {
|
|
38
|
+
alg = COSEALG.ML_DSA_87;
|
|
39
|
+
}
|
|
31
40
|
else {
|
|
32
41
|
throw new Error(`Unable to map X.509 signature algorithm ${signatureAlgorithm} to a COSE algorithm`);
|
|
33
42
|
}
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"validateCertificatePath.d.ts","sourceRoot":"","sources":["../../src/helpers/validateCertificatePath.ts"],"names":[],"mappings":"
|
|
1
|
+
{"version":3,"file":"validateCertificatePath.d.ts","sourceRoot":"","sources":["../../src/helpers/validateCertificatePath.ts"],"names":[],"mappings":"AAAA,OAAO,kBAAkB,CAAC;AAK1B;;;;GAIG;AACH,wBAAsB,uBAAuB,CAC3C,WAAW,EAAE,MAAM,EAAE,EACrB,eAAe,GAAE,MAAM,EAAO,GAC7B,OAAO,CAAC,OAAO,CAAC,CAqIlB"}
|
|
@@ -1,3 +1,4 @@
|
|
|
1
|
+
import 'reflect-metadata';
|
|
1
2
|
import { X509Certificate, X509ChainBuilder } from '@peculiar/x509';
|
|
2
3
|
import { isCertRevoked } from './isCertRevoked.js';
|
|
3
4
|
/**
|
|
@@ -79,15 +80,33 @@ export async function validateCertificatePath(x5cCertsPEM, trustAnchorsPEM = [])
|
|
|
79
80
|
}
|
|
80
81
|
// Order of certs doesn't matter here but for readability
|
|
81
82
|
const chainBuilder = new X509ChainBuilder({ certificates: [...x5cIntermediates, anchor] });
|
|
82
|
-
//
|
|
83
|
+
// Attempt to build a certificate path
|
|
83
84
|
const chain = await chainBuilder.build(x5cLeafCert);
|
|
84
|
-
|
|
85
|
-
|
|
86
|
-
|
|
87
|
-
|
|
85
|
+
/**
|
|
86
|
+
* The cert chain must chain to the anchor. Usually this is as simple as asserting that the
|
|
87
|
+
* final cert in the chain is the anchor cert. However there's an odd scenario where an
|
|
88
|
+
* intermediate certificate can chain to an anchor cert's public key, but not actually to the
|
|
89
|
+
* anchor cert because e.g. the chain builder stopped at a cross-signed cert for the anchor
|
|
90
|
+
* and not the anchor cert itself.
|
|
91
|
+
*
|
|
92
|
+
* So here we're going to check for that. In the simplest case we'll be fine with the last
|
|
93
|
+
* cert in the chain being byte-equivalent to the current anchor cert. If not, then move a
|
|
94
|
+
* cert up the chain and explicitly check that it was signed by the anchor cert. This also
|
|
95
|
+
* future-proofs this logic from the internals of whatever future X.509 library might be used
|
|
96
|
+
* to build the cert path.
|
|
97
|
+
*/
|
|
98
|
+
const lastCert = chain[chain.length - 1];
|
|
99
|
+
const lastCertEqualsAnchor = lastCert.equal(anchor);
|
|
100
|
+
let certBeforeLastSignedByAnchor = false;
|
|
101
|
+
if (!lastCertEqualsAnchor && chain.length > 1) {
|
|
102
|
+
const certBeforeLast = chain[chain.length - 2];
|
|
103
|
+
certBeforeLastSignedByAnchor = await certBeforeLast.verify({
|
|
104
|
+
publicKey: anchor.publicKey,
|
|
105
|
+
signatureOnly: true,
|
|
106
|
+
});
|
|
88
107
|
}
|
|
89
|
-
|
|
90
|
-
if (
|
|
108
|
+
const chainReachesAnchor = lastCertEqualsAnchor || certBeforeLastSignedByAnchor;
|
|
109
|
+
if (!chainReachesAnchor) {
|
|
91
110
|
// Invalid cert chain, try the next trust anchor
|
|
92
111
|
continue;
|
|
93
112
|
}
|
package/esm/index.d.ts
CHANGED
package/esm/index.d.ts.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../src/index.ts"],"names":[],"mappings":"AAAA,cAAc,+CAA+C,CAAC;AAC9D,cAAc,8CAA8C,CAAC;AAC7D,cAAc,mDAAmD,CAAC;AAClE,cAAc,kDAAkD,CAAC;AACjE,cAAc,+BAA+B,CAAC;AAC9C,cAAc,+BAA+B,CAAC;AAC9C,cAAc,wBAAwB,CAAC;AACvC,cAAc,kBAAkB,CAAC"}
|
|
1
|
+
{"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../src/index.ts"],"names":[],"mappings":"AAAA,cAAc,+CAA+C,CAAC;AAC9D,cAAc,8CAA8C,CAAC;AAC7D,cAAc,mDAAmD,CAAC;AAClE,cAAc,kDAAkD,CAAC;AACjE,cAAc,+BAA+B,CAAC;AAC9C,cAAc,+BAA+B,CAAC;AAC9C,cAAc,wBAAwB,CAAC;AACvC,cAAc,kBAAkB,CAAC;AACjC,cAAc,mBAAmB,CAAC"}
|
package/esm/index.js
CHANGED
|
@@ -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"}
|