@simplewebauthn/server 14.0.0 → 14.0.2

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.
Files changed (61) hide show
  1. package/esm/authentication/verifyAuthenticationResponse.d.ts.map +1 -1
  2. package/esm/authentication/verifyAuthenticationResponse.js +12 -0
  3. package/esm/errors/index.d.ts +17 -0
  4. package/esm/errors/index.d.ts.map +1 -0
  5. package/esm/errors/index.js +24 -0
  6. package/esm/helpers/convertX509PublicKeyToCOSE.d.ts +1 -1
  7. package/esm/helpers/convertX509PublicKeyToCOSE.d.ts.map +1 -1
  8. package/esm/helpers/convertX509PublicKeyToCOSE.js +22 -6
  9. package/esm/helpers/cose.d.ts +1 -0
  10. package/esm/helpers/cose.d.ts.map +1 -1
  11. package/esm/helpers/cose.js +3 -0
  12. package/esm/helpers/isCertRevoked.d.ts +2 -1
  13. package/esm/helpers/isCertRevoked.d.ts.map +1 -1
  14. package/esm/helpers/isCertRevoked.js +91 -70
  15. package/esm/helpers/iso/isoCrypto/verifyAKP.d.ts.map +1 -1
  16. package/esm/helpers/iso/isoCrypto/verifyAKP.js +2 -1
  17. package/esm/helpers/mapX509SignatureAlgToCOSEAlg.d.ts +0 -3
  18. package/esm/helpers/mapX509SignatureAlgToCOSEAlg.d.ts.map +1 -1
  19. package/esm/helpers/mapX509SignatureAlgToCOSEAlg.js +19 -10
  20. package/esm/helpers/validateCertificatePath.d.ts +1 -0
  21. package/esm/helpers/validateCertificatePath.d.ts.map +1 -1
  22. package/esm/helpers/validateCertificatePath.js +94 -52
  23. package/esm/index.d.ts +1 -0
  24. package/esm/index.d.ts.map +1 -1
  25. package/esm/index.js +1 -0
  26. package/esm/metadata/verifyAttestationWithMetadata.d.ts.map +1 -1
  27. package/esm/metadata/verifyAttestationWithMetadata.js +1 -7
  28. package/esm/registration/verifications/verifyAttestationPacked.js +1 -1
  29. package/esm/registration/verifyRegistrationResponse.d.ts.map +1 -1
  30. package/esm/registration/verifyRegistrationResponse.js +19 -8
  31. package/package.json +4 -2
  32. package/script/authentication/verifyAuthenticationResponse.d.ts.map +1 -1
  33. package/script/authentication/verifyAuthenticationResponse.js +12 -0
  34. package/script/errors/index.d.ts +17 -0
  35. package/script/errors/index.d.ts.map +1 -0
  36. package/script/errors/index.js +29 -0
  37. package/script/helpers/convertX509PublicKeyToCOSE.d.ts +1 -1
  38. package/script/helpers/convertX509PublicKeyToCOSE.d.ts.map +1 -1
  39. package/script/helpers/convertX509PublicKeyToCOSE.js +21 -5
  40. package/script/helpers/cose.d.ts +1 -0
  41. package/script/helpers/cose.d.ts.map +1 -1
  42. package/script/helpers/cose.js +4 -0
  43. package/script/helpers/isCertRevoked.d.ts +2 -1
  44. package/script/helpers/isCertRevoked.d.ts.map +1 -1
  45. package/script/helpers/isCertRevoked.js +91 -70
  46. package/script/helpers/iso/isoCrypto/verifyAKP.d.ts.map +1 -1
  47. package/script/helpers/iso/isoCrypto/verifyAKP.js +2 -1
  48. package/script/helpers/mapX509SignatureAlgToCOSEAlg.d.ts +0 -3
  49. package/script/helpers/mapX509SignatureAlgToCOSEAlg.d.ts.map +1 -1
  50. package/script/helpers/mapX509SignatureAlgToCOSEAlg.js +19 -10
  51. package/script/helpers/validateCertificatePath.d.ts +1 -0
  52. package/script/helpers/validateCertificatePath.d.ts.map +1 -1
  53. package/script/helpers/validateCertificatePath.js +94 -52
  54. package/script/index.d.ts +1 -0
  55. package/script/index.d.ts.map +1 -1
  56. package/script/index.js +1 -0
  57. package/script/metadata/verifyAttestationWithMetadata.d.ts.map +1 -1
  58. package/script/metadata/verifyAttestationWithMetadata.js +1 -7
  59. package/script/registration/verifications/verifyAttestationPacked.js +1 -1
  60. package/script/registration/verifyRegistrationResponse.d.ts.map +1 -1
  61. package/script/registration/verifyRegistrationResponse.js +22 -11
@@ -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 index_js_1 = require("../helpers/iso/index.js");
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 = index_js_1.isoBase64URL.toBuffer(attestationResponse.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 alg = decodedPublicKey.get(cose_js_1.COSEKEYS.alg);
135
- if (typeof alg !== 'number') {
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(alg)) {
140
+ if (!supportedAlgorithmIDs.includes(pubKeyAlg)) {
140
141
  const supported = supportedAlgorithmIDs.join(', ');
141
- throw new Error(`Unexpected public key alg "${alg}", expected one of "${supported}"`);
142
+ throw new Error(`Unexpected public key alg "${pubKeyAlg}", expected one of "${supported}"`);
142
143
  }
143
- const clientDataHash = await (0, toHash_js_1.toHash)(index_js_1.isoBase64URL.toBuffer(attestationResponse.clientDataJSON));
144
- const rootCertificates = settingsService_js_1.SettingsService.getRootCertificates({
145
- identifier: fmt,
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: index_js_1.isoBase64URL.fromBuffer(credentialID),
213
+ id: index_js_2.isoBase64URL.fromBuffer(credentialID),
203
214
  publicKey: credentialPublicKey,
204
215
  counter,
205
216
  transports: response.response.transports,