@simplewebauthn/server 12.0.0 → 13.0.0-alpha1
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 +2 -2
- package/esm/authentication/generateAuthenticationOptions.d.ts +13 -13
- package/esm/authentication/generateAuthenticationOptions.d.ts.map +1 -1
- package/esm/authentication/verifyAuthenticationResponse.d.ts +18 -15
- package/esm/authentication/verifyAuthenticationResponse.d.ts.map +1 -1
- package/esm/helpers/convertCertBufferToPEM.d.ts +1 -1
- package/esm/helpers/convertCertBufferToPEM.d.ts.map +1 -1
- package/esm/helpers/cose.d.ts +22 -0
- package/esm/helpers/cose.d.ts.map +1 -1
- package/esm/helpers/cose.js +20 -0
- package/esm/helpers/decodeAttestationObject.d.ts +4 -0
- package/esm/helpers/decodeAttestationObject.d.ts.map +1 -1
- package/esm/helpers/decodeAttestationObject.js +4 -1
- package/esm/helpers/decodeClientDataJSON.d.ts +5 -1
- package/esm/helpers/decodeClientDataJSON.d.ts.map +1 -1
- package/esm/helpers/decodeClientDataJSON.js +4 -1
- package/esm/helpers/decodeCredentialPublicKey.d.ts +4 -0
- package/esm/helpers/decodeCredentialPublicKey.d.ts.map +1 -1
- package/esm/helpers/decodeCredentialPublicKey.js +4 -1
- package/esm/helpers/fetch.d.ts +4 -0
- package/esm/helpers/fetch.d.ts.map +1 -1
- package/esm/helpers/fetch.js +4 -1
- package/esm/helpers/generateChallenge.d.ts +4 -0
- package/esm/helpers/generateChallenge.d.ts.map +1 -1
- package/esm/helpers/generateChallenge.js +4 -1
- package/esm/helpers/generateUserID.d.ts +4 -0
- package/esm/helpers/generateUserID.d.ts.map +1 -1
- package/esm/helpers/generateUserID.js +4 -1
- package/esm/helpers/index.d.ts +16 -23
- package/esm/helpers/index.d.ts.map +1 -1
- package/esm/helpers/index.js +16 -17
- package/esm/helpers/iso/isoBase64URL.d.ts +1 -1
- package/esm/helpers/iso/isoBase64URL.d.ts.map +1 -1
- package/esm/helpers/iso/isoBase64URL.js +4 -0
- package/esm/helpers/iso/isoCBOR.d.ts +4 -0
- package/esm/helpers/iso/isoCBOR.d.ts.map +1 -1
- package/esm/helpers/iso/isoCBOR.js +4 -0
- package/esm/helpers/iso/isoCrypto/getWebCrypto.d.ts +1 -1
- package/esm/helpers/iso/isoCrypto/getWebCrypto.d.ts.map +1 -1
- package/esm/helpers/iso/isoCrypto/index.d.ts +4 -0
- package/esm/helpers/iso/isoCrypto/index.d.ts.map +1 -1
- package/esm/helpers/iso/isoCrypto/index.js +4 -0
- package/esm/helpers/iso/isoUint8Array.d.ts +4 -0
- package/esm/helpers/iso/isoUint8Array.d.ts.map +1 -1
- package/esm/helpers/iso/isoUint8Array.js +4 -0
- package/esm/helpers/parseAuthenticatorData.d.ts +4 -0
- package/esm/helpers/parseAuthenticatorData.d.ts.map +1 -1
- package/esm/helpers/parseAuthenticatorData.js +4 -1
- package/esm/helpers/parseBackupFlags.d.ts +1 -1
- package/esm/helpers/parseBackupFlags.d.ts.map +1 -1
- package/esm/helpers/validateCertificatePath.d.ts +3 -3
- package/esm/helpers/validateCertificatePath.d.ts.map +1 -1
- package/esm/helpers/validateCertificatePath.js +81 -58
- package/esm/helpers/verifySignature.d.ts +4 -0
- package/esm/helpers/verifySignature.d.ts.map +1 -1
- package/esm/helpers/verifySignature.js +4 -1
- package/esm/index.d.ts +8 -17
- package/esm/index.d.ts.map +1 -1
- package/esm/index.js +8 -11
- package/esm/metadata/mdsTypes.d.ts +5 -1
- package/esm/metadata/mdsTypes.d.ts.map +1 -1
- package/esm/metadata/verifyAttestationWithMetadata.d.ts +2 -2
- package/esm/metadata/verifyAttestationWithMetadata.d.ts.map +1 -1
- package/esm/metadata/verifyAttestationWithMetadata.js +1 -1
- package/esm/registration/generateRegistrationOptions.d.ts +21 -19
- package/esm/registration/generateRegistrationOptions.d.ts.map +1 -1
- package/esm/registration/generateRegistrationOptions.js +22 -1
- package/esm/registration/verifyRegistrationResponse.d.ts +17 -14
- package/esm/registration/verifyRegistrationResponse.d.ts.map +1 -1
- package/esm/services/metadataService.d.ts +22 -18
- package/esm/services/metadataService.d.ts.map +1 -1
- package/esm/services/metadataService.js +0 -19
- package/esm/services/settingsService.d.ts +11 -1
- package/esm/services/settingsService.d.ts.map +1 -1
- package/esm/services/settingsService.js +0 -10
- package/esm/types/dom.d.ts +329 -0
- package/esm/types/dom.d.ts.map +1 -0
- package/esm/types/dom.js +1 -0
- package/esm/types/index.d.ts +205 -0
- package/esm/types/index.d.ts.map +1 -0
- package/esm/types/index.js +1 -0
- package/package.json +2 -3
- package/script/authentication/generateAuthenticationOptions.d.ts +13 -13
- package/script/authentication/generateAuthenticationOptions.d.ts.map +1 -1
- package/script/authentication/verifyAuthenticationResponse.d.ts +18 -15
- package/script/authentication/verifyAuthenticationResponse.d.ts.map +1 -1
- package/script/helpers/convertCertBufferToPEM.d.ts +1 -1
- package/script/helpers/convertCertBufferToPEM.d.ts.map +1 -1
- package/script/helpers/cose.d.ts +22 -0
- package/script/helpers/cose.d.ts.map +1 -1
- package/script/helpers/cose.js +20 -0
- package/script/helpers/decodeAttestationObject.d.ts +4 -0
- package/script/helpers/decodeAttestationObject.d.ts.map +1 -1
- package/script/helpers/decodeAttestationObject.js +4 -1
- package/script/helpers/decodeClientDataJSON.d.ts +5 -1
- package/script/helpers/decodeClientDataJSON.d.ts.map +1 -1
- package/script/helpers/decodeClientDataJSON.js +4 -1
- package/script/helpers/decodeCredentialPublicKey.d.ts +4 -0
- package/script/helpers/decodeCredentialPublicKey.d.ts.map +1 -1
- package/script/helpers/decodeCredentialPublicKey.js +4 -1
- package/script/helpers/fetch.d.ts +4 -0
- package/script/helpers/fetch.d.ts.map +1 -1
- package/script/helpers/fetch.js +4 -1
- package/script/helpers/generateChallenge.d.ts +4 -0
- package/script/helpers/generateChallenge.d.ts.map +1 -1
- package/script/helpers/generateChallenge.js +4 -1
- package/script/helpers/generateUserID.d.ts +4 -0
- package/script/helpers/generateUserID.d.ts.map +1 -1
- package/script/helpers/generateUserID.js +4 -1
- package/script/helpers/index.d.ts +16 -23
- package/script/helpers/index.d.ts.map +1 -1
- package/script/helpers/index.js +20 -36
- package/script/helpers/iso/isoBase64URL.d.ts +1 -1
- package/script/helpers/iso/isoBase64URL.d.ts.map +1 -1
- package/script/helpers/iso/isoBase64URL.js +4 -0
- package/script/helpers/iso/isoCBOR.d.ts +4 -0
- package/script/helpers/iso/isoCBOR.d.ts.map +1 -1
- package/script/helpers/iso/isoCBOR.js +4 -0
- package/script/helpers/iso/isoCrypto/getWebCrypto.d.ts +1 -1
- package/script/helpers/iso/isoCrypto/getWebCrypto.d.ts.map +1 -1
- package/script/helpers/iso/isoCrypto/index.d.ts +4 -0
- package/script/helpers/iso/isoCrypto/index.d.ts.map +1 -1
- package/script/helpers/iso/isoCrypto/index.js +4 -0
- package/script/helpers/iso/isoUint8Array.d.ts +4 -0
- package/script/helpers/iso/isoUint8Array.d.ts.map +1 -1
- package/script/helpers/iso/isoUint8Array.js +4 -0
- package/script/helpers/parseAuthenticatorData.d.ts +4 -0
- package/script/helpers/parseAuthenticatorData.d.ts.map +1 -1
- package/script/helpers/parseAuthenticatorData.js +4 -1
- package/script/helpers/parseBackupFlags.d.ts +1 -1
- package/script/helpers/parseBackupFlags.d.ts.map +1 -1
- package/script/helpers/validateCertificatePath.d.ts +3 -3
- package/script/helpers/validateCertificatePath.d.ts.map +1 -1
- package/script/helpers/validateCertificatePath.js +81 -58
- package/script/helpers/verifySignature.d.ts +4 -0
- package/script/helpers/verifySignature.d.ts.map +1 -1
- package/script/helpers/verifySignature.js +4 -1
- package/script/index.d.ts +8 -17
- package/script/index.d.ts.map +1 -1
- package/script/index.js +22 -17
- package/script/metadata/mdsTypes.d.ts +5 -1
- package/script/metadata/mdsTypes.d.ts.map +1 -1
- package/script/metadata/verifyAttestationWithMetadata.d.ts +2 -2
- package/script/metadata/verifyAttestationWithMetadata.d.ts.map +1 -1
- package/script/registration/generateRegistrationOptions.d.ts +21 -19
- package/script/registration/generateRegistrationOptions.d.ts.map +1 -1
- package/script/registration/generateRegistrationOptions.js +22 -1
- package/script/registration/verifyRegistrationResponse.d.ts +17 -14
- package/script/registration/verifyRegistrationResponse.d.ts.map +1 -1
- package/script/services/metadataService.d.ts +22 -18
- package/script/services/metadataService.d.ts.map +1 -1
- package/script/services/metadataService.js +0 -19
- package/script/services/settingsService.d.ts +11 -1
- package/script/services/settingsService.d.ts.map +1 -1
- package/script/services/settingsService.js +0 -10
- package/script/types/dom.d.ts +329 -0
- package/script/types/dom.d.ts.map +1 -0
- package/script/types/dom.js +2 -0
- package/script/types/index.d.ts +205 -0
- package/script/types/index.d.ts.map +1 -0
- package/script/types/index.js +2 -0
|
@@ -23,6 +23,10 @@ export type ParsedAuthenticatorData = {
|
|
|
23
23
|
extensionsData?: AuthenticationExtensionsAuthenticatorOutputs;
|
|
24
24
|
extensionsDataBuffer?: Uint8Array;
|
|
25
25
|
};
|
|
26
|
+
/**
|
|
27
|
+
* Make it possible to stub the return value during testing
|
|
28
|
+
* @ignore Don't include this in docs output
|
|
29
|
+
*/
|
|
26
30
|
export declare const _parseAuthenticatorDataInternals: {
|
|
27
31
|
stubThis: (value: ParsedAuthenticatorData) => ParsedAuthenticatorData;
|
|
28
32
|
};
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"parseAuthenticatorData.d.ts","sourceRoot":"","sources":["../../src/helpers/parseAuthenticatorData.ts"],"names":[],"mappings":"AAAA,OAAO,EACL,4CAA4C,EAE7C,MAAM,oCAAoC,CAAC;AAI5C;;GAEG;AACH,wBAAgB,sBAAsB,CACpC,QAAQ,EAAE,UAAU,GACnB,uBAAuB,CAwHzB;AAED,MAAM,MAAM,uBAAuB,GAAG;IACpC,QAAQ,EAAE,UAAU,CAAC;IACrB,QAAQ,EAAE,UAAU,CAAC;IACrB,KAAK,EAAE;QACL,EAAE,EAAE,OAAO,CAAC;QACZ,EAAE,EAAE,OAAO,CAAC;QACZ,EAAE,EAAE,OAAO,C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;AAEF;;;GAGG;AACH,eAAO,MAAM,gCAAgC;sBACzB,uBAAuB;CAC1C,CAAC"}
|
|
@@ -97,7 +97,10 @@ export function parseAuthenticatorData(authData) {
|
|
|
97
97
|
extensionsDataBuffer,
|
|
98
98
|
});
|
|
99
99
|
}
|
|
100
|
-
|
|
100
|
+
/**
|
|
101
|
+
* Make it possible to stub the return value during testing
|
|
102
|
+
* @ignore Don't include this in docs output
|
|
103
|
+
*/
|
|
101
104
|
export const _parseAuthenticatorDataInternals = {
|
|
102
105
|
stubThis: (value) => value,
|
|
103
106
|
};
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"parseBackupFlags.d.ts","sourceRoot":"","sources":["../../src/helpers/parseBackupFlags.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,oBAAoB,EAAE,MAAM,
|
|
1
|
+
{"version":3,"file":"parseBackupFlags.d.ts","sourceRoot":"","sources":["../../src/helpers/parseBackupFlags.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,oBAAoB,EAAE,MAAM,mBAAmB,CAAC;AAE9D;;;;;;;GAOG;AACH,wBAAgB,gBAAgB,CAAC,EAAE,EAAE,EAAE,EAAE,EAAE,EAAE;IAAE,EAAE,EAAE,OAAO,CAAC;IAAC,EAAE,EAAE,OAAO,CAAA;CAAE,GAAG;IAC1E,oBAAoB,EAAE,oBAAoB,CAAC;IAC3C,kBAAkB,EAAE,OAAO,CAAC;CAC7B,CAeA;AAED,qBAAa,kBAAmB,SAAQ,KAAK;gBAC/B,OAAO,EAAE,MAAM;CAI5B"}
|
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
/**
|
|
2
2
|
* Traverse an array of PEM certificates and ensure they form a proper chain
|
|
3
|
-
* @param
|
|
4
|
-
* @param
|
|
3
|
+
* @param x5cCertsPEM Typically the result of `x5c.map(convertASN1toPEM)`
|
|
4
|
+
* @param trustAnchorsPEM PEM-formatted certs that an attestation statement x5c may chain back to
|
|
5
5
|
*/
|
|
6
|
-
export declare function validateCertificatePath(
|
|
6
|
+
export declare function validateCertificatePath(x5cCertsPEM: string[], trustAnchorsPEM?: string[]): Promise<boolean>;
|
|
7
7
|
//# sourceMappingURL=validateCertificatePath.d.ts.map
|
|
@@ -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":"AASA;;;;GAIG;AACH,wBAAsB,uBAAuB,CAC3C,WAAW,EAAE,MAAM,EAAE,EACrB,eAAe,GAAE,MAAM,EAAO,GAC7B,OAAO,CAAC,OAAO,CAAC,CAsClB"}
|
|
@@ -6,23 +6,22 @@ import { getCertificateInfo } from './getCertificateInfo.js';
|
|
|
6
6
|
import { convertPEMToBytes } from './convertPEMToBytes.js';
|
|
7
7
|
/**
|
|
8
8
|
* Traverse an array of PEM certificates and ensure they form a proper chain
|
|
9
|
-
* @param
|
|
10
|
-
* @param
|
|
9
|
+
* @param x5cCertsPEM Typically the result of `x5c.map(convertASN1toPEM)`
|
|
10
|
+
* @param trustAnchorsPEM PEM-formatted certs that an attestation statement x5c may chain back to
|
|
11
11
|
*/
|
|
12
|
-
export async function validateCertificatePath(
|
|
13
|
-
if (
|
|
14
|
-
// We have no
|
|
15
|
-
// TODO: Is this going to be acceptable default behavior??
|
|
12
|
+
export async function validateCertificatePath(x5cCertsPEM, trustAnchorsPEM = []) {
|
|
13
|
+
if (trustAnchorsPEM.length === 0) {
|
|
14
|
+
// We have no trust anchors to chain back to, so skip path validation
|
|
16
15
|
return true;
|
|
17
16
|
}
|
|
18
17
|
let invalidSubjectAndIssuerError = false;
|
|
19
18
|
let certificateNotYetValidOrExpiredErrorMessage = undefined;
|
|
20
|
-
for (const
|
|
19
|
+
for (const anchorPEM of trustAnchorsPEM) {
|
|
21
20
|
try {
|
|
22
|
-
const
|
|
23
|
-
await _validatePath(
|
|
21
|
+
const certsWithTrustAnchor = x5cCertsPEM.concat([anchorPEM]);
|
|
22
|
+
await _validatePath(certsWithTrustAnchor);
|
|
24
23
|
// If we successfully validated a path then there's no need to continue. Reset any existing
|
|
25
|
-
// errors that were thrown by earlier
|
|
24
|
+
// errors that were thrown by earlier trust anchors
|
|
26
25
|
invalidSubjectAndIssuerError = false;
|
|
27
26
|
certificateNotYetValidOrExpiredErrorMessage = undefined;
|
|
28
27
|
break;
|
|
@@ -39,7 +38,7 @@ export async function validateCertificatePath(certificates, rootCertificates = [
|
|
|
39
38
|
}
|
|
40
39
|
}
|
|
41
40
|
}
|
|
42
|
-
// We tried multiple
|
|
41
|
+
// We tried multiple trust anchors and none of them worked
|
|
43
42
|
if (invalidSubjectAndIssuerError) {
|
|
44
43
|
throw new InvalidSubjectAndIssuer();
|
|
45
44
|
}
|
|
@@ -48,64 +47,81 @@ export async function validateCertificatePath(certificates, rootCertificates = [
|
|
|
48
47
|
}
|
|
49
48
|
return true;
|
|
50
49
|
}
|
|
51
|
-
|
|
52
|
-
|
|
50
|
+
/**
|
|
51
|
+
* @param x5cCerts X.509 `x5c` certs in PEM string format
|
|
52
|
+
* @param anchorCert X.509 trust anchor cert in PEM string format
|
|
53
|
+
*/
|
|
54
|
+
async function _validatePath(x5cCertsWithTrustAnchorPEM) {
|
|
55
|
+
if (new Set(x5cCertsWithTrustAnchorPEM).size !== x5cCertsWithTrustAnchorPEM.length) {
|
|
53
56
|
throw new Error('Invalid certificate path: found duplicate certificates');
|
|
54
57
|
}
|
|
55
|
-
//
|
|
56
|
-
for (
|
|
57
|
-
const
|
|
58
|
-
|
|
59
|
-
|
|
60
|
-
|
|
61
|
-
|
|
62
|
-
|
|
63
|
-
|
|
64
|
-
|
|
65
|
-
issuerPem = certificates[i + 1];
|
|
66
|
-
}
|
|
58
|
+
// Make sure no certs are revoked, and all are within their time validity window
|
|
59
|
+
for (const certificatePEM of x5cCertsWithTrustAnchorPEM) {
|
|
60
|
+
const certInfo = getCertificateInfo(convertPEMToBytes(certificatePEM));
|
|
61
|
+
await assertCertNotRevoked(certInfo.parsedCertificate);
|
|
62
|
+
assertCertIsWithinValidTimeWindow(certInfo, certificatePEM);
|
|
63
|
+
}
|
|
64
|
+
// Make sure each x5c cert is issued by the next certificate in the chain
|
|
65
|
+
for (let i = 0; i < (x5cCertsWithTrustAnchorPEM.length - 1); i += 1) {
|
|
66
|
+
const subjectPem = x5cCertsWithTrustAnchorPEM[i];
|
|
67
|
+
const issuerPem = x5cCertsWithTrustAnchorPEM[i + 1];
|
|
67
68
|
const subjectInfo = getCertificateInfo(convertPEMToBytes(subjectPem));
|
|
68
69
|
const issuerInfo = getCertificateInfo(convertPEMToBytes(issuerPem));
|
|
69
|
-
|
|
70
|
-
// Check for certificate revocation
|
|
71
|
-
const subjectCertRevoked = await isCertRevoked(x509Subject);
|
|
72
|
-
if (subjectCertRevoked) {
|
|
73
|
-
throw new Error(`Found revoked certificate in certificate path`);
|
|
74
|
-
}
|
|
75
|
-
// Check that intermediate certificate is within its valid time window
|
|
76
|
-
const { notBefore, notAfter } = issuerInfo;
|
|
77
|
-
const now = new Date(Date.now());
|
|
78
|
-
if (notBefore > now || notAfter < now) {
|
|
79
|
-
if (isLeafCert) {
|
|
80
|
-
throw new CertificateNotYetValidOrExpired(`Leaf certificate is not yet valid or expired: ${issuerPem}`);
|
|
81
|
-
}
|
|
82
|
-
else if (isRootCert) {
|
|
83
|
-
throw new CertificateNotYetValidOrExpired(`Root certificate is not yet valid or expired: ${issuerPem}`);
|
|
84
|
-
}
|
|
85
|
-
else {
|
|
86
|
-
throw new CertificateNotYetValidOrExpired(`Intermediate certificate is not yet valid or expired: ${issuerPem}`);
|
|
87
|
-
}
|
|
88
|
-
}
|
|
70
|
+
// Make sure subject issuer is issuer subject
|
|
89
71
|
if (subjectInfo.issuer.combined !== issuerInfo.subject.combined) {
|
|
90
72
|
throw new InvalidSubjectAndIssuer();
|
|
91
73
|
}
|
|
92
|
-
|
|
93
|
-
|
|
94
|
-
|
|
95
|
-
|
|
96
|
-
|
|
97
|
-
const verified = await verifySignature({
|
|
98
|
-
data: new Uint8Array(data),
|
|
99
|
-
signature: new Uint8Array(signature),
|
|
100
|
-
x509Certificate: issuerCertBytes,
|
|
101
|
-
hashAlgorithm: signatureAlgorithm,
|
|
102
|
-
});
|
|
103
|
-
if (!verified) {
|
|
104
|
-
throw new Error('Invalid certificate path: invalid signature');
|
|
74
|
+
const issuerCertIsRootCert = issuerInfo.issuer.combined === issuerInfo.subject.combined;
|
|
75
|
+
await assertSubjectIsSignedByIssuer(subjectInfo.parsedCertificate, issuerPem);
|
|
76
|
+
// Perform one final check if the issuer cert is also a root certificate
|
|
77
|
+
if (issuerCertIsRootCert) {
|
|
78
|
+
await assertSubjectIsSignedByIssuer(issuerInfo.parsedCertificate, issuerPem);
|
|
105
79
|
}
|
|
106
80
|
}
|
|
107
81
|
return true;
|
|
108
82
|
}
|
|
83
|
+
/**
|
|
84
|
+
* Check if the certificate is revoked or not. If it is, raise an error
|
|
85
|
+
*/
|
|
86
|
+
async function assertCertNotRevoked(certificate) {
|
|
87
|
+
// Check for certificate revocation
|
|
88
|
+
const subjectCertRevoked = await isCertRevoked(certificate);
|
|
89
|
+
if (subjectCertRevoked) {
|
|
90
|
+
throw new Error(`Found revoked certificate in certificate path`);
|
|
91
|
+
}
|
|
92
|
+
}
|
|
93
|
+
/**
|
|
94
|
+
* Require the cert to be within its notBefore and notAfter time window
|
|
95
|
+
*
|
|
96
|
+
* @param certInfo Parsed cert information
|
|
97
|
+
* @param certPEM PEM-formatted certificate, for error reporting
|
|
98
|
+
*/
|
|
99
|
+
function assertCertIsWithinValidTimeWindow(certInfo, certPEM) {
|
|
100
|
+
const { notBefore, notAfter } = certInfo;
|
|
101
|
+
const now = new Date(Date.now());
|
|
102
|
+
if (notBefore > now || notAfter < now) {
|
|
103
|
+
throw new CertificateNotYetValidOrExpired(`Certificate is not yet valid or expired: ${certPEM}`);
|
|
104
|
+
}
|
|
105
|
+
}
|
|
106
|
+
/**
|
|
107
|
+
* Ensure that the subject cert has been signed by the next cert in the chain
|
|
108
|
+
*/
|
|
109
|
+
async function assertSubjectIsSignedByIssuer(subjectCert, issuerPEM) {
|
|
110
|
+
// Verify the subject certificate's signature with the issuer cert's public key
|
|
111
|
+
const data = AsnSerializer.serialize(subjectCert.tbsCertificate);
|
|
112
|
+
const signature = subjectCert.signatureValue;
|
|
113
|
+
const signatureAlgorithm = mapX509SignatureAlgToCOSEAlg(subjectCert.signatureAlgorithm.algorithm);
|
|
114
|
+
const issuerCertBytes = convertPEMToBytes(issuerPEM);
|
|
115
|
+
const verified = await verifySignature({
|
|
116
|
+
data: new Uint8Array(data),
|
|
117
|
+
signature: new Uint8Array(signature),
|
|
118
|
+
x509Certificate: issuerCertBytes,
|
|
119
|
+
hashAlgorithm: signatureAlgorithm,
|
|
120
|
+
});
|
|
121
|
+
if (!verified) {
|
|
122
|
+
throw new InvalidSubjectSignatureForIssuer();
|
|
123
|
+
}
|
|
124
|
+
}
|
|
109
125
|
// Custom errors to help pass on certain errors
|
|
110
126
|
class InvalidSubjectAndIssuer extends Error {
|
|
111
127
|
constructor() {
|
|
@@ -114,6 +130,13 @@ class InvalidSubjectAndIssuer extends Error {
|
|
|
114
130
|
this.name = 'InvalidSubjectAndIssuer';
|
|
115
131
|
}
|
|
116
132
|
}
|
|
133
|
+
class InvalidSubjectSignatureForIssuer extends Error {
|
|
134
|
+
constructor() {
|
|
135
|
+
const message = 'Subject signature was invalid for issuer';
|
|
136
|
+
super(message);
|
|
137
|
+
this.name = 'InvalidSubjectSignatureForIssuer';
|
|
138
|
+
}
|
|
139
|
+
}
|
|
117
140
|
class CertificateNotYetValidOrExpired extends Error {
|
|
118
141
|
constructor(message) {
|
|
119
142
|
super(message);
|
|
@@ -9,6 +9,10 @@ export declare function verifySignature(opts: {
|
|
|
9
9
|
x509Certificate?: Uint8Array;
|
|
10
10
|
hashAlgorithm?: COSEALG;
|
|
11
11
|
}): Promise<boolean>;
|
|
12
|
+
/**
|
|
13
|
+
* Make it possible to stub the return value during testing
|
|
14
|
+
* @ignore Don't include this in docs output
|
|
15
|
+
*/
|
|
12
16
|
export declare const _verifySignatureInternals: {
|
|
13
17
|
stubThis: (value: Promise<boolean>) => Promise<boolean>;
|
|
14
18
|
};
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"verifySignature.d.ts","sourceRoot":"","sources":["../../src/helpers/verifySignature.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,OAAO,EAAiB,MAAM,WAAW,CAAC;AAKnD;;GAEG;AACH,wBAAgB,eAAe,CAAC,IAAI,EAAE;IACpC,SAAS,EAAE,UAAU,CAAC;IACtB,IAAI,EAAE,UAAU,CAAC;IACjB,mBAAmB,CAAC,EAAE,UAAU,CAAC;IACjC,eAAe,CAAC,EAAE,UAAU,CAAC;IAC7B,aAAa,CAAC,EAAE,OAAO,CAAC;CACzB,GAAG,OAAO,CAAC,OAAO,CAAC,CAmCnB;
|
|
1
|
+
{"version":3,"file":"verifySignature.d.ts","sourceRoot":"","sources":["../../src/helpers/verifySignature.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,OAAO,EAAiB,MAAM,WAAW,CAAC;AAKnD;;GAEG;AACH,wBAAgB,eAAe,CAAC,IAAI,EAAE;IACpC,SAAS,EAAE,UAAU,CAAC;IACtB,IAAI,EAAE,UAAU,CAAC;IACjB,mBAAmB,CAAC,EAAE,UAAU,CAAC;IACjC,eAAe,CAAC,EAAE,UAAU,CAAC;IAC7B,aAAa,CAAC,EAAE,OAAO,CAAC;CACzB,GAAG,OAAO,CAAC,OAAO,CAAC,CAmCnB;AAED;;;GAGG;AACH,eAAO,MAAM,yBAAyB;sBAClB,OAAO,CAAC,OAAO,CAAC;CACnC,CAAC"}
|
|
@@ -26,7 +26,10 @@ export function verifySignature(opts) {
|
|
|
26
26
|
shaHashOverride: hashAlgorithm,
|
|
27
27
|
}));
|
|
28
28
|
}
|
|
29
|
-
|
|
29
|
+
/**
|
|
30
|
+
* Make it possible to stub the return value during testing
|
|
31
|
+
* @ignore Don't include this in docs output
|
|
32
|
+
*/
|
|
30
33
|
export const _verifySignatureInternals = {
|
|
31
34
|
stubThis: (value) => value,
|
|
32
35
|
};
|
package/esm/index.d.ts
CHANGED
|
@@ -1,18 +1,9 @@
|
|
|
1
|
-
|
|
2
|
-
*
|
|
3
|
-
*
|
|
4
|
-
|
|
5
|
-
|
|
6
|
-
|
|
7
|
-
|
|
8
|
-
|
|
9
|
-
import { MetadataService } from './services/metadataService.js';
|
|
10
|
-
import { SettingsService } from './services/settingsService.js';
|
|
11
|
-
export { generateAuthenticationOptions, generateRegistrationOptions, MetadataService, SettingsService, verifyAuthenticationResponse, verifyRegistrationResponse, };
|
|
12
|
-
import type { GenerateRegistrationOptionsOpts } from './registration/generateRegistrationOptions.js';
|
|
13
|
-
import type { GenerateAuthenticationOptionsOpts } from './authentication/generateAuthenticationOptions.js';
|
|
14
|
-
import type { MetadataStatement } from './metadata/mdsTypes.js';
|
|
15
|
-
import type { VerifiedRegistrationResponse, VerifyRegistrationResponseOpts } from './registration/verifyRegistrationResponse.js';
|
|
16
|
-
import type { VerifiedAuthenticationResponse, VerifyAuthenticationResponseOpts } from './authentication/verifyAuthenticationResponse.js';
|
|
17
|
-
export type { GenerateAuthenticationOptionsOpts, GenerateRegistrationOptionsOpts, MetadataStatement, VerifiedAuthenticationResponse, VerifiedRegistrationResponse, VerifyAuthenticationResponseOpts, VerifyRegistrationResponseOpts, };
|
|
1
|
+
export * from './registration/generateRegistrationOptions.js';
|
|
2
|
+
export * from './registration/verifyRegistrationResponse.js';
|
|
3
|
+
export * from './authentication/generateAuthenticationOptions.js';
|
|
4
|
+
export * from './authentication/verifyAuthenticationResponse.js';
|
|
5
|
+
export * from './services/metadataService.js';
|
|
6
|
+
export * from './services/settingsService.js';
|
|
7
|
+
export * from './metadata/mdsTypes.js';
|
|
8
|
+
export * from './types/index.js';
|
|
18
9
|
//# sourceMappingURL=index.d.ts.map
|
package/esm/index.d.ts.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../src/index.ts"],"names":[],"mappings":"AAAA
|
|
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"}
|
package/esm/index.js
CHANGED
|
@@ -1,11 +1,8 @@
|
|
|
1
|
-
|
|
2
|
-
*
|
|
3
|
-
*
|
|
4
|
-
|
|
5
|
-
|
|
6
|
-
|
|
7
|
-
|
|
8
|
-
|
|
9
|
-
import { MetadataService } from './services/metadataService.js';
|
|
10
|
-
import { SettingsService } from './services/settingsService.js';
|
|
11
|
-
export { generateAuthenticationOptions, generateRegistrationOptions, MetadataService, SettingsService, verifyAuthenticationResponse, verifyRegistrationResponse, };
|
|
1
|
+
export * from './registration/generateRegistrationOptions.js';
|
|
2
|
+
export * from './registration/verifyRegistrationResponse.js';
|
|
3
|
+
export * from './authentication/generateAuthenticationOptions.js';
|
|
4
|
+
export * from './authentication/verifyAuthenticationResponse.js';
|
|
5
|
+
export * from './services/metadataService.js';
|
|
6
|
+
export * from './services/settingsService.js';
|
|
7
|
+
export * from './metadata/mdsTypes.js';
|
|
8
|
+
export * from './types/index.js';
|
|
@@ -1,8 +1,9 @@
|
|
|
1
|
-
import type { Base64URLString } from '
|
|
1
|
+
import type { Base64URLString } from '../types/index.js';
|
|
2
2
|
/**
|
|
3
3
|
* Metadata Service structures
|
|
4
4
|
* https://fidoalliance.org/specs/mds/fido-metadata-service-v3.0-ps-20210518.html
|
|
5
5
|
*/
|
|
6
|
+
/** */
|
|
6
7
|
export type MDSJWTHeader = {
|
|
7
8
|
alg: string;
|
|
8
9
|
typ: string;
|
|
@@ -105,6 +106,9 @@ export type ExtensionDescriptor = {
|
|
|
105
106
|
data?: string;
|
|
106
107
|
fail_if_unknown: boolean;
|
|
107
108
|
};
|
|
109
|
+
/**
|
|
110
|
+
* langCode -> "en-US", "ja-JP", etc...
|
|
111
|
+
*/
|
|
108
112
|
export type AlternativeDescriptions = {
|
|
109
113
|
[langCode: string]: string;
|
|
110
114
|
};
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"mdsTypes.d.ts","sourceRoot":"","sources":["../../src/metadata/mdsTypes.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,eAAe,EAAE,MAAM,
|
|
1
|
+
{"version":3,"file":"mdsTypes.d.ts","sourceRoot":"","sources":["../../src/metadata/mdsTypes.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,eAAe,EAAE,MAAM,mBAAmB,CAAC;AAEzD;;;GAGG;AAEH,MAAM;AACN,MAAM,MAAM,YAAY,GAAG;IACzB,GAAG,EAAE,MAAM,CAAC;IACZ,GAAG,EAAE,MAAM,CAAC;IACZ,GAAG,EAAE,eAAe,EAAE,CAAC;CACxB,CAAC;AAEF,MAAM,MAAM,aAAa,GAAG;IAC1B,WAAW,EAAE,MAAM,CAAC;IACpB,EAAE,EAAE,MAAM,CAAC;IACX,UAAU,EAAE,MAAM,CAAC;IACnB,OAAO,EAAE,wBAAwB,EAAE,CAAC;CACrC,CAAC;AAEF,MAAM,MAAM,wBAAwB,GAAG;IACrC,IAAI,CAAC,EAAE,MAAM,CAAC;IACd,MAAM,CAAC,EAAE,MAAM,CAAC;IAChB,oCAAoC,CAAC,EAAE,MAAM,EAAE,CAAC;IAChD,iBAAiB,CAAC,EAAE,iBAAiB,CAAC;IACtC,sBAAsB,CAAC,EAAE,qBAAqB,EAAE,CA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ACL,UAAU,GACV,QAAQ,CAAC;AAEb;;GAEG;AACH,MAAM,MAAM,OAAO,GAAG;IACpB,KAAK,EAAE,MAAM,CAAC;IACd,KAAK,EAAE,MAAM,CAAC;CACf,CAAC;AAEF;;GAEG;AACH,MAAM,MAAM,oBAAoB,GAAG;IACjC,QAAQ,EAAE,CAAC,UAAU,GAAG,QAAQ,CAAC,EAAE,CAAC;IACpC,UAAU,CAAC,EAAE,MAAM,EAAE,CAAC;IACtB,MAAM,EAAE,MAAM,CAAC;IACf,OAAO,CAAC,EAAE;QACR,IAAI,CAAC,EAAE,OAAO,CAAC;QACf,EAAE,CAAC,EAAE,OAAO,CAAC;QACb,SAAS,CAAC,EAAE,OAAO,CAAC;QACpB,EAAE,CAAC,EAAE,OAAO,CAAC;QACb,EAAE,CAAC,EAAE,OAAO,CAAC;KACd,CAAC;IACF,UAAU,CAAC,EAAE,MAAM,CAAC;IACpB,YAAY,CAAC,EAAE,MAAM,EAAE,CAAC;IACxB,UAAU,CAAC,EAAE;QAAE,IAAI,EAAE,YAAY,CAAC;QAAC,GAAG,EAAE,MAAM,CAAA;KAAE,EAAE,CAAC;CACpD,CAAC"}
|
|
@@ -1,6 +1,6 @@
|
|
|
1
|
-
import type { Base64URLString } from '
|
|
1
|
+
import type { Base64URLString } from '../types/index.js';
|
|
2
2
|
import type { AlgSign, MetadataStatement } from './mdsTypes.js';
|
|
3
|
-
import { COSEALG, COSECRV, COSEKTY } from '../helpers/cose.js';
|
|
3
|
+
import { type COSEALG, type COSECRV, COSEKTY } from '../helpers/cose.js';
|
|
4
4
|
/**
|
|
5
5
|
* Match properties of the authenticator's attestation statement against expected values as
|
|
6
6
|
* registered with the FIDO Alliance Metadata Service
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"verifyAttestationWithMetadata.d.ts","sourceRoot":"","sources":["../../src/metadata/verifyAttestationWithMetadata.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,eAAe,EAAE,MAAM,
|
|
1
|
+
{"version":3,"file":"verifyAttestationWithMetadata.d.ts","sourceRoot":"","sources":["../../src/metadata/verifyAttestationWithMetadata.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,eAAe,EAAE,MAAM,mBAAmB,CAAC;AACzD,OAAO,KAAK,EAAE,OAAO,EAAE,iBAAiB,EAAE,MAAM,eAAe,CAAC;AAIhE,OAAO,EACL,KAAK,OAAO,EACZ,KAAK,OAAO,EAEZ,OAAO,EAER,MAAM,oBAAoB,CAAC;AAE5B;;;GAGG;AACH,wBAAsB,6BAA6B,CAAC,EAClD,SAAS,EACT,mBAAmB,EACnB,GAAG,EACH,uBAAuB,GACxB,EAAE;IACD,SAAS,EAAE,iBAAiB,CAAC;IAC7B,mBAAmB,EAAE,UAAU,CAAC;IAChC,GAAG,EAAE,UAAU,EAAE,GAAG,eAAe,EAAE,CAAC;IACtC,uBAAuB,CAAC,EAAE,MAAM,CAAC;CAClC,GAAG,OAAO,CAAC,OAAO,CAAC,CAoJnB;AAED,KAAK,QAAQ,GAAG;IACd,GAAG,EAAE,OAAO,CAAC;IACb,GAAG,EAAE,OAAO,CAAC;IACb,GAAG,CAAC,EAAE,OAAO,CAAC;CACf,CAAC;AAEF;;;;;;GAMG;AACH,eAAO,MAAM,oBAAoB,EAAE;KAAG,GAAG,IAAI,OAAO,GAAG,QAAQ;CAe9D,CAAC"}
|
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
import { convertCertBufferToPEM } from '../helpers/convertCertBufferToPEM.js';
|
|
2
2
|
import { validateCertificatePath } from '../helpers/validateCertificatePath.js';
|
|
3
3
|
import { decodeCredentialPublicKey } from '../helpers/decodeCredentialPublicKey.js';
|
|
4
|
-
import { COSEKEYS, COSEKTY, isCOSEPublicKeyEC2 } from '../helpers/cose.js';
|
|
4
|
+
import { COSEKEYS, COSEKTY, isCOSEPublicKeyEC2, } from '../helpers/cose.js';
|
|
5
5
|
/**
|
|
6
6
|
* Match properties of the authenticator's attestation statement against expected values as
|
|
7
7
|
* registered with the FIDO Alliance Metadata Service
|
|
@@ -1,21 +1,5 @@
|
|
|
1
|
-
import type {
|
|
2
|
-
export type GenerateRegistrationOptionsOpts =
|
|
3
|
-
rpName: string;
|
|
4
|
-
rpID: string;
|
|
5
|
-
userName: string;
|
|
6
|
-
userID?: Uint8Array;
|
|
7
|
-
challenge?: string | Uint8Array;
|
|
8
|
-
userDisplayName?: string;
|
|
9
|
-
timeout?: number;
|
|
10
|
-
attestationType?: AttestationConveyancePreference;
|
|
11
|
-
excludeCredentials?: {
|
|
12
|
-
id: Base64URLString;
|
|
13
|
-
transports?: AuthenticatorTransportFuture[];
|
|
14
|
-
}[];
|
|
15
|
-
authenticatorSelection?: AuthenticatorSelectionCriteria;
|
|
16
|
-
extensions?: AuthenticationExtensionsClientInputs;
|
|
17
|
-
supportedAlgorithmIDs?: COSEAlgorithmIdentifier[];
|
|
18
|
-
};
|
|
1
|
+
import type { AuthenticationExtensionsClientInputs, AuthenticatorSelectionCriteria, AuthenticatorTransportFuture, Base64URLString, COSEAlgorithmIdentifier, PublicKeyCredentialCreationOptionsJSON } from '../types/index.js';
|
|
2
|
+
export type GenerateRegistrationOptionsOpts = Parameters<typeof generateRegistrationOptions>[0];
|
|
19
3
|
/**
|
|
20
4
|
* Supported crypto algo identifiers
|
|
21
5
|
* See https://w3c.github.io/webauthn/#sctn-alg-identifier
|
|
@@ -39,6 +23,24 @@ export declare const supportedCOSEAlgorithmIdentifiers: COSEAlgorithmIdentifier[
|
|
|
39
23
|
* @param authenticatorSelection **(Optional)** - Advanced criteria for restricting the types of authenticators that may be used. Defaults to `{ residentKey: 'preferred', userVerification: 'preferred' }`
|
|
40
24
|
* @param extensions **(Optional)** - Additional plugins the authenticator or browser should use during attestation
|
|
41
25
|
* @param supportedAlgorithmIDs **(Optional)** - Array of numeric COSE algorithm identifiers supported for attestation by this RP. See https://www.iana.org/assignments/cose/cose.xhtml#algorithms. Defaults to `[-8, -7, -257]`
|
|
26
|
+
* @param preferredAuthenticatorType **(Optional)** - Encourage the browser to prompt the user to register a specific type of authenticator
|
|
42
27
|
*/
|
|
43
|
-
export declare function generateRegistrationOptions(options:
|
|
28
|
+
export declare function generateRegistrationOptions(options: {
|
|
29
|
+
rpName: string;
|
|
30
|
+
rpID: string;
|
|
31
|
+
userName: string;
|
|
32
|
+
userID?: Uint8Array;
|
|
33
|
+
challenge?: string | Uint8Array;
|
|
34
|
+
userDisplayName?: string;
|
|
35
|
+
timeout?: number;
|
|
36
|
+
attestationType?: 'direct' | 'enterprise' | 'none';
|
|
37
|
+
excludeCredentials?: {
|
|
38
|
+
id: Base64URLString;
|
|
39
|
+
transports?: AuthenticatorTransportFuture[];
|
|
40
|
+
}[];
|
|
41
|
+
authenticatorSelection?: AuthenticatorSelectionCriteria;
|
|
42
|
+
extensions?: AuthenticationExtensionsClientInputs;
|
|
43
|
+
supportedAlgorithmIDs?: COSEAlgorithmIdentifier[];
|
|
44
|
+
preferredAuthenticatorType?: 'securityKey' | 'localDevice' | 'remoteDevice';
|
|
45
|
+
}): Promise<PublicKeyCredentialCreationOptionsJSON>;
|
|
44
46
|
//# 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
|
|
1
|
+
{"version":3,"file":"generateRegistrationOptions.d.ts","sourceRoot":"","sources":["../../src/registration/generateRegistrationOptions.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EACV,oCAAoC,EACpC,8BAA8B,EAC9B,4BAA4B,EAC5B,eAAe,EACf,uBAAuB,EACvB,sCAAsC,EAGvC,MAAM,mBAAmB,CAAC;AAK3B,MAAM,MAAM,+BAA+B,GAAG,UAAU,CAAC,OAAO,2BAA2B,CAAC,CAAC,CAAC,CAAC,CAAC;AAEhG;;;;GAIG;AACH,eAAO,MAAM,iCAAiC,EAAE,uBAAuB,EAqBtE,CAAC;AAsBF;;;;;;;;;;;;;;;;;;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,UAAU,CAAC;IACpB,SAAS,CAAC,EAAE,MAAM,GAAG,UAAU,CAAC;IAChC,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,4BAA4B,EAAE,CAAC;KAC7C,EAAE,CAAC;IACJ,sBAAsB,CAAC,EAAE,8BAA8B,CAAC;IACxD,UAAU,CAAC,EAAE,oCAAoC,CAAC;IAClD,qBAAqB,CAAC,EAAE,uBAAuB,EAAE,CAAC;IAClD,0BAA0B,CAAC,EAAE,aAAa,GAAG,aAAa,GAAG,cAAc,CAAC;CAC7E,GACA,OAAO,CAAC,sCAAsC,CAAC,CAqIjD"}
|
|
@@ -63,9 +63,10 @@ const defaultSupportedAlgorithmIDs = [-8, -7, -257];
|
|
|
63
63
|
* @param authenticatorSelection **(Optional)** - Advanced criteria for restricting the types of authenticators that may be used. Defaults to `{ residentKey: 'preferred', userVerification: 'preferred' }`
|
|
64
64
|
* @param extensions **(Optional)** - Additional plugins the authenticator or browser should use during attestation
|
|
65
65
|
* @param supportedAlgorithmIDs **(Optional)** - Array of numeric COSE algorithm identifiers supported for attestation by this RP. See https://www.iana.org/assignments/cose/cose.xhtml#algorithms. Defaults to `[-8, -7, -257]`
|
|
66
|
+
* @param preferredAuthenticatorType **(Optional)** - Encourage the browser to prompt the user to register a specific type of authenticator
|
|
66
67
|
*/
|
|
67
68
|
export async function generateRegistrationOptions(options) {
|
|
68
|
-
const { rpName, rpID, userName, userID, challenge = await generateChallenge(), userDisplayName = '', timeout = 60000, attestationType = 'none', excludeCredentials = [], authenticatorSelection = defaultAuthenticatorSelection, extensions, supportedAlgorithmIDs = defaultSupportedAlgorithmIDs, } = options;
|
|
69
|
+
const { rpName, rpID, userName, userID, challenge = await generateChallenge(), userDisplayName = '', timeout = 60000, attestationType = 'none', excludeCredentials = [], authenticatorSelection = defaultAuthenticatorSelection, extensions, supportedAlgorithmIDs = defaultSupportedAlgorithmIDs, preferredAuthenticatorType, } = options;
|
|
69
70
|
/**
|
|
70
71
|
* Prepare pubKeyCredParams from the array of algorithm ID's
|
|
71
72
|
*/
|
|
@@ -127,6 +128,25 @@ export async function generateRegistrationOptions(options) {
|
|
|
127
128
|
if (!_userID) {
|
|
128
129
|
_userID = await generateUserID();
|
|
129
130
|
}
|
|
131
|
+
/**
|
|
132
|
+
* Map authenticator preference to hints. Map to authenticatorAttachment as well for
|
|
133
|
+
* backwards-compatibility.
|
|
134
|
+
*/
|
|
135
|
+
const hints = [];
|
|
136
|
+
if (preferredAuthenticatorType) {
|
|
137
|
+
if (preferredAuthenticatorType === 'securityKey') {
|
|
138
|
+
hints.push('security-key');
|
|
139
|
+
authenticatorSelection.authenticatorAttachment = 'cross-platform';
|
|
140
|
+
}
|
|
141
|
+
else if (preferredAuthenticatorType === 'localDevice') {
|
|
142
|
+
hints.push('client-device');
|
|
143
|
+
authenticatorSelection.authenticatorAttachment = 'platform';
|
|
144
|
+
}
|
|
145
|
+
else if (preferredAuthenticatorType === 'remoteDevice') {
|
|
146
|
+
hints.push('hybrid');
|
|
147
|
+
authenticatorSelection.authenticatorAttachment = 'cross-platform';
|
|
148
|
+
}
|
|
149
|
+
}
|
|
130
150
|
return {
|
|
131
151
|
challenge: isoBase64URL.fromBuffer(_challenge),
|
|
132
152
|
rp: {
|
|
@@ -156,5 +176,6 @@ export async function generateRegistrationOptions(options) {
|
|
|
156
176
|
...extensions,
|
|
157
177
|
credProps: true,
|
|
158
178
|
},
|
|
179
|
+
hints,
|
|
159
180
|
};
|
|
160
181
|
}
|
|
@@ -1,16 +1,10 @@
|
|
|
1
|
-
import type { COSEAlgorithmIdentifier, CredentialDeviceType, RegistrationResponseJSON, WebAuthnCredential } from '
|
|
2
|
-
import { AttestationFormat, AttestationStatement } from '../helpers/decodeAttestationObject.js';
|
|
3
|
-
import { AuthenticationExtensionsAuthenticatorOutputs } from '../helpers/decodeAuthenticatorExtensions.js';
|
|
4
|
-
|
|
5
|
-
|
|
6
|
-
|
|
7
|
-
|
|
8
|
-
expectedRPID?: string | string[];
|
|
9
|
-
expectedType?: string | string[];
|
|
10
|
-
requireUserPresence?: boolean;
|
|
11
|
-
requireUserVerification?: boolean;
|
|
12
|
-
supportedAlgorithmIDs?: COSEAlgorithmIdentifier[];
|
|
13
|
-
};
|
|
1
|
+
import type { COSEAlgorithmIdentifier, CredentialDeviceType, RegistrationResponseJSON, WebAuthnCredential } from '../types/index.js';
|
|
2
|
+
import { type AttestationFormat, type AttestationStatement } from '../helpers/decodeAttestationObject.js';
|
|
3
|
+
import type { AuthenticationExtensionsAuthenticatorOutputs } from '../helpers/decodeAuthenticatorExtensions.js';
|
|
4
|
+
/**
|
|
5
|
+
* Configurable options when calling `verifyRegistrationResponse()`
|
|
6
|
+
*/
|
|
7
|
+
export type VerifyRegistrationResponseOpts = Parameters<typeof verifyRegistrationResponse>[0];
|
|
14
8
|
/**
|
|
15
9
|
* Verify that the user has legitimately completed the registration process
|
|
16
10
|
*
|
|
@@ -25,7 +19,16 @@ export type VerifyRegistrationResponseOpts = {
|
|
|
25
19
|
* @param requireUserVerification **(Optional)** - Enforce user verification by the authenticator (via PIN, fingerprint, etc...) Defaults to `true`
|
|
26
20
|
* @param supportedAlgorithmIDs **(Optional)** - Array of numeric COSE algorithm identifiers supported for attestation by this RP. See https://www.iana.org/assignments/cose/cose.xhtml#algorithms. Defaults to all supported algorithm IDs
|
|
27
21
|
*/
|
|
28
|
-
export declare function verifyRegistrationResponse(options:
|
|
22
|
+
export declare function verifyRegistrationResponse(options: {
|
|
23
|
+
response: RegistrationResponseJSON;
|
|
24
|
+
expectedChallenge: string | ((challenge: string) => boolean | Promise<boolean>);
|
|
25
|
+
expectedOrigin: string | string[];
|
|
26
|
+
expectedRPID?: string | string[];
|
|
27
|
+
expectedType?: string | string[];
|
|
28
|
+
requireUserPresence?: boolean;
|
|
29
|
+
requireUserVerification?: boolean;
|
|
30
|
+
supportedAlgorithmIDs?: COSEAlgorithmIdentifier[];
|
|
31
|
+
}): Promise<VerifiedRegistrationResponse>;
|
|
29
32
|
/**
|
|
30
33
|
* Result of registration verification
|
|
31
34
|
*
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"verifyRegistrationResponse.d.ts","sourceRoot":"","sources":["../../src/registration/verifyRegistrationResponse.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EACV,uBAAuB,EACvB,oBAAoB,EACpB,wBAAwB,EACxB,kBAAkB,EACnB,MAAM,
|
|
1
|
+
{"version":3,"file":"verifyRegistrationResponse.d.ts","sourceRoot":"","sources":["../../src/registration/verifyRegistrationResponse.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EACV,uBAAuB,EACvB,oBAAoB,EACpB,wBAAwB,EACxB,kBAAkB,EACnB,MAAM,mBAAmB,CAAC;AAC3B,OAAO,EACL,KAAK,iBAAiB,EACtB,KAAK,oBAAoB,EAE1B,MAAM,uCAAuC,CAAC;AAC/C,OAAO,KAAK,EAAE,4CAA4C,EAAE,MAAM,6CAA6C,CAAC;AAoBhH;;GAEG;AACH,MAAM,MAAM,8BAA8B,GAAG,UAAU,CAAC,OAAO,0BAA0B,CAAC,CAAC,CAAC,CAAC,CAAC;AAE9F;;;;;;;;;;;;;GAaG;AACH,wBAAsB,0BAA0B,CAC9C,OAAO,EAAE;IACP,QAAQ,EAAE,wBAAwB,CAAC;IACnC,iBAAiB,EAAE,MAAM,GAAG,CAAC,CAAC,SA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