@simplewebauthn/server 14.0.0 → 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/esm/authentication/verifyAuthenticationResponse.d.ts.map +1 -1
- package/esm/authentication/verifyAuthenticationResponse.js +12 -0
- 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 +1 -0
- package/esm/helpers/cose.d.ts.map +1 -1
- package/esm/helpers/cose.js +3 -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/verifyAKP.d.ts.map +1 -1
- package/esm/helpers/iso/isoCrypto/verifyAKP.js +2 -1
- 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 +1 -0
- package/esm/index.d.ts +1 -0
- package/esm/index.d.ts.map +1 -1
- package/esm/index.js +1 -0
- package/esm/registration/verifications/verifyAttestationPacked.js +1 -1
- package/esm/registration/verifyRegistrationResponse.d.ts.map +1 -1
- package/esm/registration/verifyRegistrationResponse.js +19 -8
- package/package.json +4 -2
- package/script/authentication/verifyAuthenticationResponse.d.ts.map +1 -1
- package/script/authentication/verifyAuthenticationResponse.js +12 -0
- 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 +1 -0
- package/script/helpers/cose.d.ts.map +1 -1
- package/script/helpers/cose.js +4 -0
- 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/verifyAKP.d.ts.map +1 -1
- package/script/helpers/iso/isoCrypto/verifyAKP.js +2 -1
- 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 +1 -0
- package/script/index.d.ts +1 -0
- package/script/index.d.ts.map +1 -1
- package/script/index.js +1 -0
- package/script/registration/verifications/verifyAttestationPacked.js +1 -1
- package/script/registration/verifyRegistrationResponse.d.ts.map +1 -1
- package/script/registration/verifyRegistrationResponse.js +22 -11
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"verifyAuthenticationResponse.d.ts","sourceRoot":"","sources":["../../src/authentication/verifyAuthenticationResponse.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EACV,0BAA0B,EAC1B,eAAe,EACf,oBAAoB,EACpB,2BAA2B,EAC3B,kBAAkB,EACnB,MAAM,mBAAmB,CAAC;AAM3B,OAAO,KAAK,EAAE,4CAA4C,EAAE,MAAM,6CAA6C,CAAC;
|
|
1
|
+
{"version":3,"file":"verifyAuthenticationResponse.d.ts","sourceRoot":"","sources":["../../src/authentication/verifyAuthenticationResponse.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EACV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EAAE,4CAA4C,CAAC;KAC9E,CAAC;CACH,CAAC"}
|
|
@@ -5,6 +5,10 @@ import { parseAuthenticatorData } from '../helpers/parseAuthenticatorData.js';
|
|
|
5
5
|
import { parseBackupFlags } from '../helpers/parseBackupFlags.js';
|
|
6
6
|
import { matchExpectedRPID } from '../helpers/matchExpectedRPID.js';
|
|
7
7
|
import { isoBase64URL, isoUint8Array } from '../helpers/iso/index.js';
|
|
8
|
+
import { decodeCredentialPublicKey } from '../helpers/decodeCredentialPublicKey.js';
|
|
9
|
+
import { COSEKEYS, isPQCCOSEAlg } from '../helpers/cose.js';
|
|
10
|
+
import { SettingsService } from '../services/settingsService.js';
|
|
11
|
+
import { PQCNotSupportedError } from '../errors/index.js';
|
|
8
12
|
/**
|
|
9
13
|
* Verify that the user has legitimately completed the authentication process
|
|
10
14
|
*
|
|
@@ -187,6 +191,14 @@ export async function verifyAuthenticationResponse(options) {
|
|
|
187
191
|
// on the device without going through this site
|
|
188
192
|
throw new Error(`Response counter value ${counter} was lower than expected ${credential.counter}`);
|
|
189
193
|
}
|
|
194
|
+
const decodedPublicKey = decodeCredentialPublicKey(credential.publicKey);
|
|
195
|
+
const pubKeyAlg = decodedPublicKey.get(COSEKEYS.alg);
|
|
196
|
+
if (typeof pubKeyAlg !== 'number') {
|
|
197
|
+
throw new Error('Credential public key was missing numeric alg');
|
|
198
|
+
}
|
|
199
|
+
if (isPQCCOSEAlg(pubKeyAlg) && !SettingsService.runtimeSupportsPQC()) {
|
|
200
|
+
throw new PQCNotSupportedError(pubKeyAlg);
|
|
201
|
+
}
|
|
190
202
|
const { credentialDeviceType, credentialBackedUp } = parseBackupFlags(flags);
|
|
191
203
|
const toReturn = {
|
|
192
204
|
verified: await verifySignature({
|
|
@@ -0,0 +1,17 @@
|
|
|
1
|
+
import type { COSEALG } from '../helpers/cose.js';
|
|
2
|
+
/**
|
|
3
|
+
* Base error class that helps disambiguate SimpleWebAuthn library errors from other library errors
|
|
4
|
+
*/
|
|
5
|
+
export declare class SimpleWebAuthnError extends Error {
|
|
6
|
+
code: SimpleWebAuthnErrorCode;
|
|
7
|
+
constructor({ message, code, cause }: {
|
|
8
|
+
message: string;
|
|
9
|
+
code: SimpleWebAuthnErrorCode;
|
|
10
|
+
cause?: Error;
|
|
11
|
+
});
|
|
12
|
+
}
|
|
13
|
+
export declare class PQCNotSupportedError extends SimpleWebAuthnError {
|
|
14
|
+
constructor(alg: COSEALG);
|
|
15
|
+
}
|
|
16
|
+
export type SimpleWebAuthnErrorCode = 'RUNTIME_NO_PQC_SUPPORT';
|
|
17
|
+
//# sourceMappingURL=index.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../src/errors/index.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,OAAO,EAAE,MAAM,oBAAoB,CAAC;AAGlD;;GAEG;AACH,qBAAa,mBAAoB,SAAQ,KAAK;IAC5C,IAAI,EAAE,uBAAuB,CAAC;gBAElB,EAAE,OAAO,EAAE,IAAI,EAAE,KAAK,EAAE,EAAE;QACpC,OAAO,EAAE,MAAM,CAAC;QAChB,IAAI,EAAE,uBAAuB,CAAC;QAC9B,KAAK,CAAC,EAAE,KAAK,CAAC;KACf;CAKF;AAED,qBAAa,oBAAqB,SAAQ,mBAAmB;gBAC/C,GAAG,EAAE,OAAO;CAKzB;AAED,MAAM,MAAM,uBAAuB,GAAG,wBAAwB,CAAC"}
|
|
@@ -0,0 +1,24 @@
|
|
|
1
|
+
import { mapCoseAlgToWebCryptoKeyAlgName } from '../helpers/iso/isoCrypto/mapCoseAlgToWebCryptoKeyAlgName.js';
|
|
2
|
+
/**
|
|
3
|
+
* Base error class that helps disambiguate SimpleWebAuthn library errors from other library errors
|
|
4
|
+
*/
|
|
5
|
+
export class SimpleWebAuthnError extends Error {
|
|
6
|
+
constructor({ message, code, cause }) {
|
|
7
|
+
super(message, { cause });
|
|
8
|
+
Object.defineProperty(this, "code", {
|
|
9
|
+
enumerable: true,
|
|
10
|
+
configurable: true,
|
|
11
|
+
writable: true,
|
|
12
|
+
value: void 0
|
|
13
|
+
});
|
|
14
|
+
this.name = 'SimpleWebAuthnError';
|
|
15
|
+
this.code = code;
|
|
16
|
+
}
|
|
17
|
+
}
|
|
18
|
+
export class PQCNotSupportedError extends SimpleWebAuthnError {
|
|
19
|
+
constructor(alg) {
|
|
20
|
+
const webCryptoAlg = mapCoseAlgToWebCryptoKeyAlgName(alg);
|
|
21
|
+
const message = `This runtime's WebCrypto.subtle does not support use of ${webCryptoAlg}`;
|
|
22
|
+
super({ message, code: 'RUNTIME_NO_PQC_SUPPORT' });
|
|
23
|
+
}
|
|
24
|
+
}
|
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import { COSEPublicKey } from './cose.js';
|
|
1
|
+
import { type COSEPublicKey } from './cose.js';
|
|
2
2
|
import type { Uint8Array_ } from '../types/index.js';
|
|
3
3
|
export declare function convertX509PublicKeyToCOSE(x509Certificate: Uint8Array_): COSEPublicKey;
|
|
4
4
|
//# sourceMappingURL=convertX509PublicKeyToCOSE.d.ts.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"convertX509PublicKeyToCOSE.d.ts","sourceRoot":"","sources":["../../src/helpers/convertX509PublicKeyToCOSE.ts"],"names":[],"mappings":"
|
|
1
|
+
{"version":3,"file":"convertX509PublicKeyToCOSE.d.ts","sourceRoot":"","sources":["../../src/helpers/convertX509PublicKeyToCOSE.ts"],"names":[],"mappings":"AAMA,OAAO,EAKL,KAAK,aAAa,EAInB,MAAM,WAAW,CAAC;AAEnB,OAAO,KAAK,EAAE,WAAW,EAAE,MAAM,mBAAmB,CAAC;AAErD,wBAAgB,0BAA0B,CACxC,eAAe,EAAE,WAAW,GAC3B,aAAa,CAsGf"}
|
|
@@ -1,8 +1,9 @@
|
|
|
1
1
|
import { AsnParser } from '@peculiar/asn1-schema';
|
|
2
2
|
import { Certificate } from '@peculiar/asn1-x509';
|
|
3
3
|
import { ECParameters, id_ecPublicKey, id_secp256r1, id_secp384r1 } from '@peculiar/asn1-ecc';
|
|
4
|
+
import { id_ml_dsa_44, id_ml_dsa_65, id_ml_dsa_87 } from '@peculiar/asn1-x509-post-quantum';
|
|
4
5
|
import { id_rsaEncryption, RSAPublicKey } from '@peculiar/asn1-rsa';
|
|
5
|
-
import { COSECRV, COSEKEYS, COSEKTY, } from './cose.js';
|
|
6
|
+
import { COSEALG, COSECRV, COSEKEYS, COSEKTY, } from './cose.js';
|
|
6
7
|
import { mapX509SignatureAlgToCOSEAlg } from './mapX509SignatureAlgToCOSEAlg.js';
|
|
7
8
|
export function convertX509PublicKeyToCOSE(x509Certificate) {
|
|
8
9
|
let cosePublicKey = new Map();
|
|
@@ -11,8 +12,7 @@ export function convertX509PublicKeyToCOSE(x509Certificate) {
|
|
|
11
12
|
*/
|
|
12
13
|
const x509 = AsnParser.parse(x509Certificate, Certificate);
|
|
13
14
|
const { tbsCertificate } = x509;
|
|
14
|
-
const { subjectPublicKeyInfo
|
|
15
|
-
const signatureAlgorithm = _tbsSignature.algorithm;
|
|
15
|
+
const { subjectPublicKeyInfo } = tbsCertificate;
|
|
16
16
|
const publicKeyAlgorithmID = subjectPublicKeyInfo.algorithm.algorithm;
|
|
17
17
|
if (publicKeyAlgorithmID === id_ecPublicKey) {
|
|
18
18
|
/**
|
|
@@ -22,12 +22,15 @@ export function convertX509PublicKeyToCOSE(x509Certificate) {
|
|
|
22
22
|
throw new Error('Certificate public key was missing parameters (EC2)');
|
|
23
23
|
}
|
|
24
24
|
const ecParameters = AsnParser.parse(new Uint8Array(subjectPublicKeyInfo.algorithm.parameters), ECParameters);
|
|
25
|
-
let
|
|
25
|
+
let alg;
|
|
26
|
+
let crv;
|
|
26
27
|
const { namedCurve } = ecParameters;
|
|
27
28
|
if (namedCurve === id_secp256r1) {
|
|
29
|
+
alg = COSEALG.ES256;
|
|
28
30
|
crv = COSECRV.P256;
|
|
29
31
|
}
|
|
30
32
|
else if (namedCurve === id_secp384r1) {
|
|
33
|
+
alg = COSEALG.ES384;
|
|
31
34
|
crv = COSECRV.P384;
|
|
32
35
|
}
|
|
33
36
|
else {
|
|
@@ -48,7 +51,7 @@ export function convertX509PublicKeyToCOSE(x509Certificate) {
|
|
|
48
51
|
}
|
|
49
52
|
const coseEC2PubKey = new Map();
|
|
50
53
|
coseEC2PubKey.set(COSEKEYS.kty, COSEKTY.EC2);
|
|
51
|
-
coseEC2PubKey.set(COSEKEYS.alg,
|
|
54
|
+
coseEC2PubKey.set(COSEKEYS.alg, alg);
|
|
52
55
|
coseEC2PubKey.set(COSEKEYS.crv, crv);
|
|
53
56
|
coseEC2PubKey.set(COSEKEYS.x, x);
|
|
54
57
|
coseEC2PubKey.set(COSEKEYS.y, y);
|
|
@@ -61,11 +64,24 @@ export function convertX509PublicKeyToCOSE(x509Certificate) {
|
|
|
61
64
|
const rsaPublicKey = AsnParser.parse(subjectPublicKeyInfo.subjectPublicKey, RSAPublicKey);
|
|
62
65
|
const coseRSAPubKey = new Map();
|
|
63
66
|
coseRSAPubKey.set(COSEKEYS.kty, COSEKTY.RSA);
|
|
64
|
-
|
|
67
|
+
/**
|
|
68
|
+
* The algorithm ID is too ambiguous to know what this alg should really be. But practically
|
|
69
|
+
* speaking `shaHashOverride` is always specified when verifying signatures with RSA public keys
|
|
70
|
+
* which ultimately overrides this sensible default. Using RS256 also gets the correct WebCrypto
|
|
71
|
+
* alg name later on in verifyRSA.ts
|
|
72
|
+
*/
|
|
73
|
+
coseRSAPubKey.set(COSEKEYS.alg, COSEALG.RS256);
|
|
65
74
|
coseRSAPubKey.set(COSEKEYS.n, new Uint8Array(rsaPublicKey.modulus));
|
|
66
75
|
coseRSAPubKey.set(COSEKEYS.e, new Uint8Array(rsaPublicKey.publicExponent));
|
|
67
76
|
cosePublicKey = coseRSAPubKey;
|
|
68
77
|
}
|
|
78
|
+
else if ([id_ml_dsa_44, id_ml_dsa_65, id_ml_dsa_87].indexOf(publicKeyAlgorithmID) >= 0) {
|
|
79
|
+
const coseAKPPubKey = new Map();
|
|
80
|
+
coseAKPPubKey.set(COSEKEYS.kty, COSEKTY.AKP);
|
|
81
|
+
coseAKPPubKey.set(COSEKEYS.alg, mapX509SignatureAlgToCOSEAlg(publicKeyAlgorithmID));
|
|
82
|
+
coseAKPPubKey.set(COSEKEYS.pub, new Uint8Array(subjectPublicKeyInfo.subjectPublicKey));
|
|
83
|
+
cosePublicKey = coseAKPPubKey;
|
|
84
|
+
}
|
|
69
85
|
else {
|
|
70
86
|
throw new Error(`Certificate public key contained unexpected algorithm ID ${publicKeyAlgorithmID}`);
|
|
71
87
|
}
|
package/esm/helpers/cose.d.ts
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"cose.d.ts","sourceRoot":"","sources":["../../src/helpers/cose.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,WAAW,EAAE,MAAM,mBAAmB,CAAC;AAErD;;;;;;;;;;GAUG;AAEH;;GAEG;AACH,MAAM,MAAM,aAAa,GAAG;IAE1B,GAAG,CAAC,GAAG,EAAE,QAAQ,CAAC,GAAG,GAAG,OAAO,GAAG,SAAS,CAAC;IAC5C,GAAG,CAAC,GAAG,EAAE,QAAQ,CAAC,GAAG,GAAG,OAAO,GAAG,SAAS,CAAC;IAE5C,GAAG,CAAC,GAAG,EAAE,QAAQ,CAAC,GAAG,EAAE,KAAK,EAAE,OAAO,GAAG,IAAI,CAAC;IAC7C,GAAG,CAAC,GAAG,EAAE,QAAQ,CAAC,GAAG,EAAE,KAAK,EAAE,OAAO,GAAG,IAAI,CAAC;CAC9C,CAAC;AAEF;;GAEG;AACH,MAAM,MAAM,gBAAgB,GAAG,aAAa,GAAG;IAE7C,GAAG,CAAC,GAAG,EAAE,QAAQ,CAAC,GAAG,GAAG,MAAM,GAAG,SAAS,CAAC;IAC3C,GAAG,CAAC,GAAG,EAAE,QAAQ,CAAC,CAAC,GAAG,WAAW,GAAG,SAAS,CAAC;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S,MAAM;IACf,KAAK,OAAO;IACZ,KAAK,OAAO;IACZ,KAAK,OAAO;IACZ,GAAG,SAAS;CACb;AAED,wBAAgB,SAAS,CAAC,GAAG,EAAE,MAAM,GAAG,SAAS,GAAG,GAAG,IAAI,OAAO,CAEjE;AAED,wBAAgB,YAAY,CAAC,GAAG,EAAE,OAAO,GAAG,OAAO,CAElD"}
|
package/esm/helpers/cose.js
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"isCertRevoked.d.ts","sourceRoot":"","sources":["../../src/helpers/isCertRevoked.ts"],"names":[],"mappings":"AAAA,OAAO,EAIL,KAAK,eAAe,EAErB,MAAM,gBAAgB,CAAC;AAexB;;;;;GAKG;AACH,wBAAsB,aAAa,CAAC,IAAI,EAAE,eAAe,GAAG,OAAO,CAAC,OAAO,CAAC,CAkG3E"}
|
|
1
|
+
{"version":3,"file":"isCertRevoked.d.ts","sourceRoot":"","sources":["../../src/helpers/isCertRevoked.ts"],"names":[],"mappings":"AAAA,OAAO,kBAAkB,CAAC;AAC1B,OAAO,EAIL,KAAK,eAAe,EAErB,MAAM,gBAAgB,CAAC;AAexB;;;;;GAKG;AACH,wBAAsB,aAAa,CAAC,IAAI,EAAE,eAAe,GAAG,OAAO,CAAC,OAAO,CAAC,CAkG3E"}
|
|
@@ -1 +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;
|
|
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"}
|
|
@@ -3,6 +3,7 @@ import { isoBase64URL } from '../../index.js';
|
|
|
3
3
|
import { importJWKKey } from './importJWKKey.js';
|
|
4
4
|
import { getWebCrypto } from './getWebCrypto.js';
|
|
5
5
|
import { mapCoseAlgToWebCryptoKeyAlgName } from './mapCoseAlgToWebCryptoKeyAlgName.js';
|
|
6
|
+
import { PQCNotSupportedError } from '../../../errors/index.js';
|
|
6
7
|
/** AKP, a.k.a ML-DSA */
|
|
7
8
|
export async function verifyAKP(opts) {
|
|
8
9
|
const { cosePublicKey, signature, data } = opts;
|
|
@@ -37,7 +38,7 @@ export async function verifyAKP(opts) {
|
|
|
37
38
|
catch (err) {
|
|
38
39
|
const _err = err;
|
|
39
40
|
if (_err.name === 'NotSupportedError') {
|
|
40
|
-
throw new
|
|
41
|
+
throw new PQCNotSupportedError(alg);
|
|
41
42
|
}
|
|
42
43
|
else {
|
|
43
44
|
throw err;
|
|
@@ -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"}
|
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
|
@@ -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 +1 @@
|
|
|
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;
|
|
1
|
+
{"version":3,"file":"verifyRegistrationResponse.d.ts","sourceRoot":"","s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AAC;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,9 +1,10 @@
|
|
|
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';
|
|
@@ -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,
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@simplewebauthn/server",
|
|
3
|
-
"version": "14.0.
|
|
3
|
+
"version": "14.0.1",
|
|
4
4
|
"description": "SimpleWebAuthn for Servers",
|
|
5
5
|
"keywords": [
|
|
6
6
|
"typescript",
|
|
@@ -56,7 +56,9 @@
|
|
|
56
56
|
"@peculiar/asn1-rsa": "^2.6.1",
|
|
57
57
|
"@peculiar/asn1-schema": "^2.6.0",
|
|
58
58
|
"@peculiar/asn1-x509": "^2.6.1",
|
|
59
|
-
"@peculiar/x509": "^
|
|
59
|
+
"@peculiar/asn1-x509-post-quantum": "^2.9.4",
|
|
60
|
+
"@peculiar/x509": "^2.1.0",
|
|
61
|
+
"reflect-metadata": "^0.2.2"
|
|
60
62
|
},
|
|
61
63
|
"devDependencies": {
|
|
62
64
|
"@types/node": "^20.9.0"
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"verifyAuthenticationResponse.d.ts","sourceRoot":"","sources":["../../src/authentication/verifyAuthenticationResponse.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EACV,0BAA0B,EAC1B,eAAe,EACf,oBAAoB,EACpB,2BAA2B,EAC3B,kBAAkB,EACnB,MAAM,mBAAmB,CAAC;AAM3B,OAAO,KAAK,EAAE,4CAA4C,EAAE,MAAM,6CAA6C,CAAC;
|
|
1
|
+
{"version":3,"file":"verifyAuthenticationResponse.d.ts","sourceRoot":"","sources":["../../src/authentication/verifyAuthenticationResponse.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EACV,0BAA0B,EAC1B,eAAe,EACf,oBAAoB,EACpB,2BAA2B,EAC3B,kBAAkB,EACnB,MAAM,mBAAmB,CAAC;AAM3B,O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seAuthenticatorData.j
|
|
|
8
8
|
const parseBackupFlags_js_1 = require("../helpers/parseBackupFlags.js");
|
|
9
9
|
const matchExpectedRPID_js_1 = require("../helpers/matchExpectedRPID.js");
|
|
10
10
|
const index_js_1 = require("../helpers/iso/index.js");
|
|
11
|
+
const decodeCredentialPublicKey_js_1 = require("../helpers/decodeCredentialPublicKey.js");
|
|
12
|
+
const cose_js_1 = require("../helpers/cose.js");
|
|
13
|
+
const settingsService_js_1 = require("../services/settingsService.js");
|
|
14
|
+
const index_js_2 = require("../errors/index.js");
|
|
11
15
|
/**
|
|
12
16
|
* Verify that the user has legitimately completed the authentication process
|
|
13
17
|
*
|
|
@@ -190,6 +194,14 @@ async function verifyAuthenticationResponse(options) {
|
|
|
190
194
|
// on the device without going through this site
|
|
191
195
|
throw new Error(`Response counter value ${counter} was lower than expected ${credential.counter}`);
|
|
192
196
|
}
|
|
197
|
+
const decodedPublicKey = (0, decodeCredentialPublicKey_js_1.decodeCredentialPublicKey)(credential.publicKey);
|
|
198
|
+
const pubKeyAlg = decodedPublicKey.get(cose_js_1.COSEKEYS.alg);
|
|
199
|
+
if (typeof pubKeyAlg !== 'number') {
|
|
200
|
+
throw new Error('Credential public key was missing numeric alg');
|
|
201
|
+
}
|
|
202
|
+
if ((0, cose_js_1.isPQCCOSEAlg)(pubKeyAlg) && !settingsService_js_1.SettingsService.runtimeSupportsPQC()) {
|
|
203
|
+
throw new index_js_2.PQCNotSupportedError(pubKeyAlg);
|
|
204
|
+
}
|
|
193
205
|
const { credentialDeviceType, credentialBackedUp } = (0, parseBackupFlags_js_1.parseBackupFlags)(flags);
|
|
194
206
|
const toReturn = {
|
|
195
207
|
verified: await (0, verifySignature_js_1.verifySignature)({
|
|
@@ -0,0 +1,17 @@
|
|
|
1
|
+
import type { COSEALG } from '../helpers/cose.js';
|
|
2
|
+
/**
|
|
3
|
+
* Base error class that helps disambiguate SimpleWebAuthn library errors from other library errors
|
|
4
|
+
*/
|
|
5
|
+
export declare class SimpleWebAuthnError extends Error {
|
|
6
|
+
code: SimpleWebAuthnErrorCode;
|
|
7
|
+
constructor({ message, code, cause }: {
|
|
8
|
+
message: string;
|
|
9
|
+
code: SimpleWebAuthnErrorCode;
|
|
10
|
+
cause?: Error;
|
|
11
|
+
});
|
|
12
|
+
}
|
|
13
|
+
export declare class PQCNotSupportedError extends SimpleWebAuthnError {
|
|
14
|
+
constructor(alg: COSEALG);
|
|
15
|
+
}
|
|
16
|
+
export type SimpleWebAuthnErrorCode = 'RUNTIME_NO_PQC_SUPPORT';
|
|
17
|
+
//# sourceMappingURL=index.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../src/errors/index.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,OAAO,EAAE,MAAM,oBAAoB,CAAC;AAGlD;;GAEG;AACH,qBAAa,mBAAoB,SAAQ,KAAK;IAC5C,IAAI,EAAE,uBAAuB,CAAC;gBAElB,EAAE,OAAO,EAAE,IAAI,EAAE,KAAK,EAAE,EAAE;QACpC,OAAO,EAAE,MAAM,CAAC;QAChB,IAAI,EAAE,uBAAuB,CAAC;QAC9B,KAAK,CAAC,EAAE,KAAK,CAAC;KACf;CAKF;AAED,qBAAa,oBAAqB,SAAQ,mBAAmB;gBAC/C,GAAG,EAAE,OAAO;CAKzB;AAED,MAAM,MAAM,uBAAuB,GAAG,wBAAwB,CAAC"}
|
|
@@ -0,0 +1,29 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
+
exports.PQCNotSupportedError = exports.SimpleWebAuthnError = void 0;
|
|
4
|
+
const mapCoseAlgToWebCryptoKeyAlgName_js_1 = require("../helpers/iso/isoCrypto/mapCoseAlgToWebCryptoKeyAlgName.js");
|
|
5
|
+
/**
|
|
6
|
+
* Base error class that helps disambiguate SimpleWebAuthn library errors from other library errors
|
|
7
|
+
*/
|
|
8
|
+
class SimpleWebAuthnError extends Error {
|
|
9
|
+
constructor({ message, code, cause }) {
|
|
10
|
+
super(message, { cause });
|
|
11
|
+
Object.defineProperty(this, "code", {
|
|
12
|
+
enumerable: true,
|
|
13
|
+
configurable: true,
|
|
14
|
+
writable: true,
|
|
15
|
+
value: void 0
|
|
16
|
+
});
|
|
17
|
+
this.name = 'SimpleWebAuthnError';
|
|
18
|
+
this.code = code;
|
|
19
|
+
}
|
|
20
|
+
}
|
|
21
|
+
exports.SimpleWebAuthnError = SimpleWebAuthnError;
|
|
22
|
+
class PQCNotSupportedError extends SimpleWebAuthnError {
|
|
23
|
+
constructor(alg) {
|
|
24
|
+
const webCryptoAlg = (0, mapCoseAlgToWebCryptoKeyAlgName_js_1.mapCoseAlgToWebCryptoKeyAlgName)(alg);
|
|
25
|
+
const message = `This runtime's WebCrypto.subtle does not support use of ${webCryptoAlg}`;
|
|
26
|
+
super({ message, code: 'RUNTIME_NO_PQC_SUPPORT' });
|
|
27
|
+
}
|
|
28
|
+
}
|
|
29
|
+
exports.PQCNotSupportedError = PQCNotSupportedError;
|
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import { COSEPublicKey } from './cose.js';
|
|
1
|
+
import { type COSEPublicKey } from './cose.js';
|
|
2
2
|
import type { Uint8Array_ } from '../types/index.js';
|
|
3
3
|
export declare function convertX509PublicKeyToCOSE(x509Certificate: Uint8Array_): COSEPublicKey;
|
|
4
4
|
//# sourceMappingURL=convertX509PublicKeyToCOSE.d.ts.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"convertX509PublicKeyToCOSE.d.ts","sourceRoot":"","sources":["../../src/helpers/convertX509PublicKeyToCOSE.ts"],"names":[],"mappings":"
|
|
1
|
+
{"version":3,"file":"convertX509PublicKeyToCOSE.d.ts","sourceRoot":"","sources":["../../src/helpers/convertX509PublicKeyToCOSE.ts"],"names":[],"mappings":"AAMA,OAAO,EAKL,KAAK,aAAa,EAInB,MAAM,WAAW,CAAC;AAEnB,OAAO,KAAK,EAAE,WAAW,EAAE,MAAM,mBAAmB,CAAC;AAErD,wBAAgB,0BAA0B,CACxC,eAAe,EAAE,WAAW,GAC3B,aAAa,CAsGf"}
|
|
@@ -4,6 +4,7 @@ exports.convertX509PublicKeyToCOSE = convertX509PublicKeyToCOSE;
|
|
|
4
4
|
const asn1_schema_1 = require("@peculiar/asn1-schema");
|
|
5
5
|
const asn1_x509_1 = require("@peculiar/asn1-x509");
|
|
6
6
|
const asn1_ecc_1 = require("@peculiar/asn1-ecc");
|
|
7
|
+
const asn1_x509_post_quantum_1 = require("@peculiar/asn1-x509-post-quantum");
|
|
7
8
|
const asn1_rsa_1 = require("@peculiar/asn1-rsa");
|
|
8
9
|
const cose_js_1 = require("./cose.js");
|
|
9
10
|
const mapX509SignatureAlgToCOSEAlg_js_1 = require("./mapX509SignatureAlgToCOSEAlg.js");
|
|
@@ -14,8 +15,7 @@ function convertX509PublicKeyToCOSE(x509Certificate) {
|
|
|
14
15
|
*/
|
|
15
16
|
const x509 = asn1_schema_1.AsnParser.parse(x509Certificate, asn1_x509_1.Certificate);
|
|
16
17
|
const { tbsCertificate } = x509;
|
|
17
|
-
const { subjectPublicKeyInfo
|
|
18
|
-
const signatureAlgorithm = _tbsSignature.algorithm;
|
|
18
|
+
const { subjectPublicKeyInfo } = tbsCertificate;
|
|
19
19
|
const publicKeyAlgorithmID = subjectPublicKeyInfo.algorithm.algorithm;
|
|
20
20
|
if (publicKeyAlgorithmID === asn1_ecc_1.id_ecPublicKey) {
|
|
21
21
|
/**
|
|
@@ -25,12 +25,15 @@ function convertX509PublicKeyToCOSE(x509Certificate) {
|
|
|
25
25
|
throw new Error('Certificate public key was missing parameters (EC2)');
|
|
26
26
|
}
|
|
27
27
|
const ecParameters = asn1_schema_1.AsnParser.parse(new Uint8Array(subjectPublicKeyInfo.algorithm.parameters), asn1_ecc_1.ECParameters);
|
|
28
|
-
let
|
|
28
|
+
let alg;
|
|
29
|
+
let crv;
|
|
29
30
|
const { namedCurve } = ecParameters;
|
|
30
31
|
if (namedCurve === asn1_ecc_1.id_secp256r1) {
|
|
32
|
+
alg = cose_js_1.COSEALG.ES256;
|
|
31
33
|
crv = cose_js_1.COSECRV.P256;
|
|
32
34
|
}
|
|
33
35
|
else if (namedCurve === asn1_ecc_1.id_secp384r1) {
|
|
36
|
+
alg = cose_js_1.COSEALG.ES384;
|
|
34
37
|
crv = cose_js_1.COSECRV.P384;
|
|
35
38
|
}
|
|
36
39
|
else {
|
|
@@ -51,7 +54,7 @@ function convertX509PublicKeyToCOSE(x509Certificate) {
|
|
|
51
54
|
}
|
|
52
55
|
const coseEC2PubKey = new Map();
|
|
53
56
|
coseEC2PubKey.set(cose_js_1.COSEKEYS.kty, cose_js_1.COSEKTY.EC2);
|
|
54
|
-
coseEC2PubKey.set(cose_js_1.COSEKEYS.alg,
|
|
57
|
+
coseEC2PubKey.set(cose_js_1.COSEKEYS.alg, alg);
|
|
55
58
|
coseEC2PubKey.set(cose_js_1.COSEKEYS.crv, crv);
|
|
56
59
|
coseEC2PubKey.set(cose_js_1.COSEKEYS.x, x);
|
|
57
60
|
coseEC2PubKey.set(cose_js_1.COSEKEYS.y, y);
|
|
@@ -64,11 +67,24 @@ function convertX509PublicKeyToCOSE(x509Certificate) {
|
|
|
64
67
|
const rsaPublicKey = asn1_schema_1.AsnParser.parse(subjectPublicKeyInfo.subjectPublicKey, asn1_rsa_1.RSAPublicKey);
|
|
65
68
|
const coseRSAPubKey = new Map();
|
|
66
69
|
coseRSAPubKey.set(cose_js_1.COSEKEYS.kty, cose_js_1.COSEKTY.RSA);
|
|
67
|
-
|
|
70
|
+
/**
|
|
71
|
+
* The algorithm ID is too ambiguous to know what this alg should really be. But practically
|
|
72
|
+
* speaking `shaHashOverride` is always specified when verifying signatures with RSA public keys
|
|
73
|
+
* which ultimately overrides this sensible default. Using RS256 also gets the correct WebCrypto
|
|
74
|
+
* alg name later on in verifyRSA.ts
|
|
75
|
+
*/
|
|
76
|
+
coseRSAPubKey.set(cose_js_1.COSEKEYS.alg, cose_js_1.COSEALG.RS256);
|
|
68
77
|
coseRSAPubKey.set(cose_js_1.COSEKEYS.n, new Uint8Array(rsaPublicKey.modulus));
|
|
69
78
|
coseRSAPubKey.set(cose_js_1.COSEKEYS.e, new Uint8Array(rsaPublicKey.publicExponent));
|
|
70
79
|
cosePublicKey = coseRSAPubKey;
|
|
71
80
|
}
|
|
81
|
+
else if ([asn1_x509_post_quantum_1.id_ml_dsa_44, asn1_x509_post_quantum_1.id_ml_dsa_65, asn1_x509_post_quantum_1.id_ml_dsa_87].indexOf(publicKeyAlgorithmID) >= 0) {
|
|
82
|
+
const coseAKPPubKey = new Map();
|
|
83
|
+
coseAKPPubKey.set(cose_js_1.COSEKEYS.kty, cose_js_1.COSEKTY.AKP);
|
|
84
|
+
coseAKPPubKey.set(cose_js_1.COSEKEYS.alg, (0, mapX509SignatureAlgToCOSEAlg_js_1.mapX509SignatureAlgToCOSEAlg)(publicKeyAlgorithmID));
|
|
85
|
+
coseAKPPubKey.set(cose_js_1.COSEKEYS.pub, new Uint8Array(subjectPublicKeyInfo.subjectPublicKey));
|
|
86
|
+
cosePublicKey = coseAKPPubKey;
|
|
87
|
+
}
|
|
72
88
|
else {
|
|
73
89
|
throw new Error(`Certificate public key contained unexpected algorithm ID ${publicKeyAlgorithmID}`);
|
|
74
90
|
}
|
package/script/helpers/cose.d.ts
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"cose.d.ts","sourceRoot":"","sources":["../../src/helpers/cose.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,WAAW,EAAE,MAAM,mBAAmB,CAAC;AAErD;;;;;;;;;;GAUG;AAEH;;GAEG;AACH,MAAM,MAAM,aAAa,GAAG;IAE1B,GAAG,CAAC,GAAG,EAAE,QAAQ,CAAC,GAAG,GAAG,OAAO,GAAG,SAAS,CAAC;IAC5C,GAAG,CAAC,GAAG,EAAE,QAAQ,CAAC,GAAG,GAAG,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IAAI,OAAO,CAEjE;AAED;;;;GAIG;AACH,oBAAY,OAAO;IACjB,IAAI,IAAI;IACR,IAAI,IAAI;IACR,IAAI,IAAI;IACR,OAAO,IAAI;IACX,SAAS,IAAI;CACd;AAED,wBAAgB,SAAS,CAAC,GAAG,EAAE,MAAM,GAAG,SAAS,GAAG,GAAG,IAAI,OAAO,CAEjE;AAED;;;;GAIG;AACH,oBAAY,OAAO;IACjB,KAAK,KAAK;IACV,KAAK,KAAK;IACV,KAAK,MAAM;IACX,KAAK,MAAM;IACX,KAAK,MAAM;IACX,KAAK,MAAM;IACX,KAAK,MAAM;IACX,MAAM,MAAM;IACZ,SAAS,MAAM;IACf,SAAS,MAAM;IACf,SAAS,MAAM;IACf,KAAK,OAAO;IACZ,KAAK,OAAO;IACZ,KAAK,OAAO;IACZ,GAAG,SAAS;CACb;AAED,wBAAgB,SAAS,CAAC,GAAG,EAAE,MAAM,GAAG,SAAS,GAAG,GAAG,IAAI,OAAO,CAEjE;AAED,wBAAgB,YAAY,CAAC,GAAG,EAAE,OAAO,GAAG,OAAO,CAElD"}
|
package/script/helpers/cose.js
CHANGED
|
@@ -8,6 +8,7 @@ exports.isCOSEPublicKeyAKP = isCOSEPublicKeyAKP;
|
|
|
8
8
|
exports.isCOSEKty = isCOSEKty;
|
|
9
9
|
exports.isCOSECrv = isCOSECrv;
|
|
10
10
|
exports.isCOSEAlg = isCOSEAlg;
|
|
11
|
+
exports.isPQCCOSEAlg = isPQCCOSEAlg;
|
|
11
12
|
/**
|
|
12
13
|
* A type guard for determining if a COSE public key is an OKP key pair
|
|
13
14
|
*/
|
|
@@ -110,3 +111,6 @@ var COSEALG;
|
|
|
110
111
|
function isCOSEAlg(alg) {
|
|
111
112
|
return Object.values(COSEALG).indexOf(alg) >= 0;
|
|
112
113
|
}
|
|
114
|
+
function isPQCCOSEAlg(alg) {
|
|
115
|
+
return [COSEALG.ML_DSA_44, COSEALG.ML_DSA_65, COSEALG.ML_DSA_87].indexOf(alg) >= 0;
|
|
116
|
+
}
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"isCertRevoked.d.ts","sourceRoot":"","sources":["../../src/helpers/isCertRevoked.ts"],"names":[],"mappings":"AAAA,OAAO,EAIL,KAAK,eAAe,EAErB,MAAM,gBAAgB,CAAC;AAexB;;;;;GAKG;AACH,wBAAsB,aAAa,CAAC,IAAI,EAAE,eAAe,GAAG,OAAO,CAAC,OAAO,CAAC,CAkG3E"}
|
|
1
|
+
{"version":3,"file":"isCertRevoked.d.ts","sourceRoot":"","sources":["../../src/helpers/isCertRevoked.ts"],"names":[],"mappings":"AAAA,OAAO,kBAAkB,CAAC;AAC1B,OAAO,EAIL,KAAK,eAAe,EAErB,MAAM,gBAAgB,CAAC;AAexB;;;;;GAKG;AACH,wBAAsB,aAAa,CAAC,IAAI,EAAE,eAAe,GAAG,OAAO,CAAC,OAAO,CAAC,CAkG3E"}
|
|
@@ -1,6 +1,7 @@
|
|
|
1
1
|
"use strict";
|
|
2
2
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
3
|
exports.isCertRevoked = isCertRevoked;
|
|
4
|
+
require("reflect-metadata");
|
|
4
5
|
const x509_1 = require("@peculiar/x509");
|
|
5
6
|
const fetch_js_1 = require("./fetch.js");
|
|
6
7
|
const cacheRevokedCerts = {};
|
|
@@ -1 +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;
|
|
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"}
|
|
@@ -6,6 +6,7 @@ const index_js_1 = require("../../index.js");
|
|
|
6
6
|
const importJWKKey_js_1 = require("./importJWKKey.js");
|
|
7
7
|
const getWebCrypto_js_1 = require("./getWebCrypto.js");
|
|
8
8
|
const mapCoseAlgToWebCryptoKeyAlgName_js_1 = require("./mapCoseAlgToWebCryptoKeyAlgName.js");
|
|
9
|
+
const index_js_2 = require("../../../errors/index.js");
|
|
9
10
|
/** AKP, a.k.a ML-DSA */
|
|
10
11
|
async function verifyAKP(opts) {
|
|
11
12
|
const { cosePublicKey, signature, data } = opts;
|
|
@@ -40,7 +41,7 @@ async function verifyAKP(opts) {
|
|
|
40
41
|
catch (err) {
|
|
41
42
|
const _err = err;
|
|
42
43
|
if (_err.name === 'NotSupportedError') {
|
|
43
|
-
throw new
|
|
44
|
+
throw new index_js_2.PQCNotSupportedError(alg);
|
|
44
45
|
}
|
|
45
46
|
else {
|
|
46
47
|
throw err;
|
|
@@ -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,36 +1,45 @@
|
|
|
1
1
|
"use strict";
|
|
2
2
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
3
|
exports.mapX509SignatureAlgToCOSEAlg = mapX509SignatureAlgToCOSEAlg;
|
|
4
|
+
const asn1_ecc_1 = require("@peculiar/asn1-ecc");
|
|
5
|
+
const asn1_rsa_1 = require("@peculiar/asn1-rsa");
|
|
6
|
+
const asn1_x509_post_quantum_1 = require("@peculiar/asn1-x509-post-quantum");
|
|
4
7
|
const cose_js_1 = require("./cose.js");
|
|
5
8
|
/**
|
|
6
9
|
* Map X.509 signature algorithm OIDs to COSE algorithm IDs
|
|
7
|
-
*
|
|
8
|
-
* - EC2 OIDs: https://oidref.com/1.2.840.10045.4.3
|
|
9
|
-
* - RSA OIDs: https://oidref.com/1.2.840.113549.1.1
|
|
10
10
|
*/
|
|
11
11
|
function mapX509SignatureAlgToCOSEAlg(signatureAlgorithm) {
|
|
12
12
|
let alg;
|
|
13
|
-
if (signatureAlgorithm ===
|
|
13
|
+
if (signatureAlgorithm === asn1_ecc_1.id_ecdsaWithSHA256) {
|
|
14
14
|
alg = cose_js_1.COSEALG.ES256;
|
|
15
15
|
}
|
|
16
|
-
else if (signatureAlgorithm ===
|
|
16
|
+
else if (signatureAlgorithm === asn1_ecc_1.id_ecdsaWithSHA384) {
|
|
17
17
|
alg = cose_js_1.COSEALG.ES384;
|
|
18
18
|
}
|
|
19
|
-
else if (signatureAlgorithm ===
|
|
19
|
+
else if (signatureAlgorithm === asn1_ecc_1.id_ecdsaWithSHA512) {
|
|
20
20
|
alg = cose_js_1.COSEALG.ES512;
|
|
21
21
|
}
|
|
22
|
-
else if (signatureAlgorithm ===
|
|
22
|
+
else if (signatureAlgorithm === asn1_rsa_1.id_sha256WithRSAEncryption) {
|
|
23
23
|
alg = cose_js_1.COSEALG.RS256;
|
|
24
24
|
}
|
|
25
|
-
else if (signatureAlgorithm ===
|
|
25
|
+
else if (signatureAlgorithm === asn1_rsa_1.id_sha384WithRSAEncryption) {
|
|
26
26
|
alg = cose_js_1.COSEALG.RS384;
|
|
27
27
|
}
|
|
28
|
-
else if (signatureAlgorithm ===
|
|
28
|
+
else if (signatureAlgorithm === asn1_rsa_1.id_sha512WithRSAEncryption) {
|
|
29
29
|
alg = cose_js_1.COSEALG.RS512;
|
|
30
30
|
}
|
|
31
|
-
else if (signatureAlgorithm ===
|
|
31
|
+
else if (signatureAlgorithm === asn1_rsa_1.id_sha1WithRSAEncryption) {
|
|
32
32
|
alg = cose_js_1.COSEALG.RS1;
|
|
33
33
|
}
|
|
34
|
+
else if (signatureAlgorithm === asn1_x509_post_quantum_1.id_ml_dsa_44) {
|
|
35
|
+
alg = cose_js_1.COSEALG.ML_DSA_44;
|
|
36
|
+
}
|
|
37
|
+
else if (signatureAlgorithm === asn1_x509_post_quantum_1.id_ml_dsa_65) {
|
|
38
|
+
alg = cose_js_1.COSEALG.ML_DSA_65;
|
|
39
|
+
}
|
|
40
|
+
else if (signatureAlgorithm === asn1_x509_post_quantum_1.id_ml_dsa_87) {
|
|
41
|
+
alg = cose_js_1.COSEALG.ML_DSA_87;
|
|
42
|
+
}
|
|
34
43
|
else {
|
|
35
44
|
throw new Error(`Unable to map X.509 signature algorithm ${signatureAlgorithm} to a COSE algorithm`);
|
|
36
45
|
}
|
|
@@ -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,6 +1,7 @@
|
|
|
1
1
|
"use strict";
|
|
2
2
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
3
|
exports.validateCertificatePath = validateCertificatePath;
|
|
4
|
+
require("reflect-metadata");
|
|
4
5
|
const x509_1 = require("@peculiar/x509");
|
|
5
6
|
const isCertRevoked_js_1 = require("./isCertRevoked.js");
|
|
6
7
|
/**
|
package/script/index.d.ts
CHANGED
package/script/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/script/index.js
CHANGED
|
@@ -22,3 +22,4 @@ __exportStar(require("./services/metadataService.js"), exports);
|
|
|
22
22
|
__exportStar(require("./services/settingsService.js"), exports);
|
|
23
23
|
__exportStar(require("./metadata/mdsTypes.js"), exports);
|
|
24
24
|
__exportStar(require("./types/index.js"), exports);
|
|
25
|
+
__exportStar(require("./errors/index.js"), exports);
|
|
@@ -94,7 +94,7 @@ async function verifyAttestationPacked(options) {
|
|
|
94
94
|
}
|
|
95
95
|
catch (err) {
|
|
96
96
|
const _err = err;
|
|
97
|
-
throw new Error(`${_err.message} (Packed|Full)
|
|
97
|
+
throw new Error(`${_err.message} (Packed|Full)`, { cause: _err });
|
|
98
98
|
}
|
|
99
99
|
}
|
|
100
100
|
verified = await (0, verifySignature_js_1.verifySignature)({
|
|
@@ -1 +1 @@
|
|
|
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;
|
|
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,MAA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Y,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,6 +1,7 @@
|
|
|
1
1
|
"use strict";
|
|
2
2
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
3
|
exports.verifyRegistrationResponse = verifyRegistrationResponse;
|
|
4
|
+
const index_js_1 = require("../errors/index.js");
|
|
4
5
|
const decodeAttestationObject_js_1 = require("../helpers/decodeAttestationObject.js");
|
|
5
6
|
const decodeClientDataJSON_js_1 = require("../helpers/decodeClientDataJSON.js");
|
|
6
7
|
const parseAuthenticatorData_js_1 = require("../helpers/parseAuthenticatorData.js");
|
|
@@ -10,7 +11,7 @@ const cose_js_1 = require("../helpers/cose.js");
|
|
|
10
11
|
const convertAAGUIDToString_js_1 = require("../helpers/convertAAGUIDToString.js");
|
|
11
12
|
const parseBackupFlags_js_1 = require("../helpers/parseBackupFlags.js");
|
|
12
13
|
const matchExpectedRPID_js_1 = require("../helpers/matchExpectedRPID.js");
|
|
13
|
-
const
|
|
14
|
+
const index_js_2 = require("../helpers/iso/index.js");
|
|
14
15
|
const settingsService_js_1 = require("../services/settingsService.js");
|
|
15
16
|
const generateRegistrationOptions_js_1 = require("./generateRegistrationOptions.js");
|
|
16
17
|
const verifyAttestationFIDOU2F_js_1 = require("./verifications/verifyAttestationFIDOU2F.js");
|
|
@@ -94,7 +95,7 @@ async function verifyRegistrationResponse(options) {
|
|
|
94
95
|
throw new Error(`Unexpected tokenBinding.status value of "${tokenBinding.status}"`);
|
|
95
96
|
}
|
|
96
97
|
}
|
|
97
|
-
const attestationObject =
|
|
98
|
+
const attestationObject = index_js_2.isoBase64URL.toBuffer(attestationResponse.attestationObject);
|
|
98
99
|
const decodedAttestationObject = (0, decodeAttestationObject_js_1.decodeAttestationObject)(attestationObject);
|
|
99
100
|
const fmt = decodedAttestationObject.get('fmt');
|
|
100
101
|
const authData = decodedAttestationObject.get('authData');
|
|
@@ -131,19 +132,29 @@ async function verifyRegistrationResponse(options) {
|
|
|
131
132
|
throw new Error('No AAGUID was present during registration');
|
|
132
133
|
}
|
|
133
134
|
const decodedPublicKey = (0, decodeCredentialPublicKey_js_1.decodeCredentialPublicKey)(credentialPublicKey);
|
|
134
|
-
const
|
|
135
|
-
if (typeof
|
|
135
|
+
const pubKeyAlg = decodedPublicKey.get(cose_js_1.COSEKEYS.alg);
|
|
136
|
+
if (typeof pubKeyAlg !== 'number') {
|
|
136
137
|
throw new Error('Credential public key was missing numeric alg');
|
|
137
138
|
}
|
|
138
139
|
// Make sure the key algorithm is one we specified within the registration options
|
|
139
|
-
if (!supportedAlgorithmIDs.includes(
|
|
140
|
+
if (!supportedAlgorithmIDs.includes(pubKeyAlg)) {
|
|
140
141
|
const supported = supportedAlgorithmIDs.join(', ');
|
|
141
|
-
throw new Error(`Unexpected public key alg "${
|
|
142
|
+
throw new Error(`Unexpected public key alg "${pubKeyAlg}", expected one of "${supported}"`);
|
|
142
143
|
}
|
|
143
|
-
|
|
144
|
-
|
|
145
|
-
|
|
146
|
-
|
|
144
|
+
/**
|
|
145
|
+
* If the runtime doesn't support PQC passkeys then terminate here at the first sign of a PQC
|
|
146
|
+
* algorithm so that downstream issues that arise due to lack of PQC support won't get masked as
|
|
147
|
+
* unexpected behavior.
|
|
148
|
+
*
|
|
149
|
+
* I'm choosing to raise here even if attestation is "none" because it feels weird to allow an RP
|
|
150
|
+
* to parse a registration response w/o attestation only to encounter failure when trying to auth
|
|
151
|
+
* with the PQC passkey and the runtime doesn't support PQC.
|
|
152
|
+
*/
|
|
153
|
+
if ((0, cose_js_1.isPQCCOSEAlg)(pubKeyAlg) && !settingsService_js_1.SettingsService.runtimeSupportsPQC()) {
|
|
154
|
+
throw new index_js_1.PQCNotSupportedError(pubKeyAlg);
|
|
155
|
+
}
|
|
156
|
+
const clientDataHash = await (0, toHash_js_1.toHash)(index_js_2.isoBase64URL.toBuffer(attestationResponse.clientDataJSON));
|
|
157
|
+
const rootCertificates = settingsService_js_1.SettingsService.getRootCertificates({ identifier: fmt });
|
|
147
158
|
// Prepare arguments to pass to the relevant verification method
|
|
148
159
|
const verifierOpts = {
|
|
149
160
|
aaguid,
|
|
@@ -199,7 +210,7 @@ async function verifyRegistrationResponse(options) {
|
|
|
199
210
|
aaguid: (0, convertAAGUIDToString_js_1.convertAAGUIDToString)(aaguid),
|
|
200
211
|
credentialType,
|
|
201
212
|
credential: {
|
|
202
|
-
id:
|
|
213
|
+
id: index_js_2.isoBase64URL.fromBuffer(credentialID),
|
|
203
214
|
publicKey: credentialPublicKey,
|
|
204
215
|
counter,
|
|
205
216
|
transports: response.response.transports,
|