@simplewebauthn/server 9.0.3 → 10.0.0

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 (46) hide show
  1. package/README.md +2 -2
  2. package/esm/authentication/generateAuthenticationOptions.d.ts +16 -14
  3. package/esm/authentication/generateAuthenticationOptions.js +21 -16
  4. package/esm/authentication/verifyAuthenticationResponse.d.ts +13 -18
  5. package/esm/authentication/verifyAuthenticationResponse.js +12 -17
  6. package/esm/deps.d.ts +1 -1
  7. package/esm/helpers/convertCertBufferToPEM.js +1 -1
  8. package/esm/helpers/decodeClientDataJSON.d.ts +2 -1
  9. package/esm/helpers/decodeClientDataJSON.js +1 -1
  10. package/esm/helpers/generateUserID.d.ts +7 -0
  11. package/esm/helpers/generateUserID.js +17 -0
  12. package/esm/helpers/index.d.ts +2 -1
  13. package/esm/helpers/index.js +2 -1
  14. package/esm/helpers/iso/isoBase64URL.d.ts +10 -5
  15. package/esm/helpers/iso/isoBase64URL.js +13 -7
  16. package/esm/helpers/iso/isoCrypto/getWebCrypto.d.ts +0 -289
  17. package/esm/helpers/iso/isoCrypto/getWebCrypto.js +26 -41
  18. package/esm/metadata/parseJWT.js +2 -2
  19. package/esm/registration/generateRegistrationOptions.d.ts +19 -19
  20. package/esm/registration/generateRegistrationOptions.js +40 -22
  21. package/esm/registration/verifications/verifyAttestationAndroidSafetyNet.js +2 -2
  22. package/esm/registration/verifyRegistrationResponse.d.ts +9 -12
  23. package/esm/registration/verifyRegistrationResponse.js +8 -11
  24. package/package.json +3 -3
  25. package/script/authentication/generateAuthenticationOptions.d.ts +16 -14
  26. package/script/authentication/generateAuthenticationOptions.js +21 -16
  27. package/script/authentication/verifyAuthenticationResponse.d.ts +13 -18
  28. package/script/authentication/verifyAuthenticationResponse.js +12 -17
  29. package/script/deps.d.ts +1 -1
  30. package/script/helpers/convertCertBufferToPEM.js +1 -1
  31. package/script/helpers/decodeClientDataJSON.d.ts +2 -1
  32. package/script/helpers/decodeClientDataJSON.js +1 -1
  33. package/script/helpers/generateUserID.d.ts +7 -0
  34. package/script/helpers/generateUserID.js +21 -0
  35. package/script/helpers/index.d.ts +2 -1
  36. package/script/helpers/index.js +3 -1
  37. package/script/helpers/iso/isoBase64URL.d.ts +10 -5
  38. package/script/helpers/iso/isoBase64URL.js +18 -11
  39. package/script/helpers/iso/isoCrypto/getWebCrypto.d.ts +0 -288
  40. package/script/helpers/iso/isoCrypto/getWebCrypto.js +26 -64
  41. package/script/metadata/parseJWT.js +2 -2
  42. package/script/registration/generateRegistrationOptions.d.ts +19 -19
  43. package/script/registration/generateRegistrationOptions.js +40 -22
  44. package/script/registration/verifications/verifyAttestationAndroidSafetyNet.js +2 -2
  45. package/script/registration/verifyRegistrationResponse.d.ts +9 -12
  46. package/script/registration/verifyRegistrationResponse.js +8 -11
@@ -26,8 +26,8 @@ async function verifyAttestationAndroidSafetyNet(options) {
26
26
  // Prepare to verify a JWT
27
27
  const jwt = index_js_1.isoUint8Array.toUTF8String(response);
28
28
  const jwtParts = jwt.split('.');
29
- const HEADER = JSON.parse(index_js_1.isoBase64URL.toString(jwtParts[0]));
30
- const PAYLOAD = JSON.parse(index_js_1.isoBase64URL.toString(jwtParts[1]));
29
+ const HEADER = JSON.parse(index_js_1.isoBase64URL.toUTF8String(jwtParts[0]));
30
+ const PAYLOAD = JSON.parse(index_js_1.isoBase64URL.toUTF8String(jwtParts[1]));
31
31
  const SIGNATURE = jwtParts[2];
32
32
  /**
33
33
  * START Verify PAYLOAD
@@ -1,4 +1,4 @@
1
- import type { COSEAlgorithmIdentifier, CredentialDeviceType, RegistrationResponseJSON } from '../deps.js';
1
+ import type { Base64URLString, COSEAlgorithmIdentifier, CredentialDeviceType, RegistrationResponseJSON } from '../deps.js';
2
2
  import { AttestationFormat, AttestationStatement } from '../helpers/decodeAttestationObject.js';
3
3
  import { AuthenticationExtensionsAuthenticatorOutputs } from '../helpers/decodeAuthenticatorExtensions.js';
4
4
  export type VerifyRegistrationResponseOpts = {
@@ -15,16 +15,13 @@ export type VerifyRegistrationResponseOpts = {
15
15
  *
16
16
  * **Options:**
17
17
  *
18
- * @param response Response returned by **@simplewebauthn/browser**'s `startAuthentication()`
19
- * @param expectedChallenge The base64url-encoded `options.challenge` returned by
20
- * `generateRegistrationOptions()`
21
- * @param expectedOrigin Website URL (or array of URLs) that the registration should have occurred on
22
- * @param expectedRPID RP ID (or array of IDs) that was specified in the registration options
23
- * @param expectedType (Optional) The response type expected ('webauthn.create')
24
- * @param requireUserVerification (Optional) Enforce user verification by the authenticator
25
- * (via PIN, fingerprint, etc...)
26
- * @param supportedAlgorithmIDs Array of numeric COSE algorithm identifiers supported for
27
- * attestation by this RP. See https://www.iana.org/assignments/cose/cose.xhtml#algorithms
18
+ * @param response - Response returned by **@simplewebauthn/browser**'s `startAuthentication()`
19
+ * @param expectedChallenge - The base64url-encoded `options.challenge` returned by `generateRegistrationOptions()`
20
+ * @param expectedOrigin - Website URL (or array of URLs) that the registration should have occurred on
21
+ * @param expectedRPID - RP ID (or array of IDs) that was specified in the registration options
22
+ * @param expectedType **(Optional)** - The response type expected ('webauthn.create')
23
+ * @param requireUserVerification **(Optional)** - Enforce user verification by the authenticator (via PIN, fingerprint, etc...) Defaults to `true`
24
+ * @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
28
25
  */
29
26
  export declare function verifyRegistrationResponse(options: VerifyRegistrationResponseOpts): Promise<VerifiedRegistrationResponse>;
30
27
  /**
@@ -59,7 +56,7 @@ export type VerifiedRegistrationResponse = {
59
56
  fmt: AttestationFormat;
60
57
  counter: number;
61
58
  aaguid: string;
62
- credentialID: Uint8Array;
59
+ credentialID: Base64URLString;
63
60
  credentialPublicKey: Uint8Array;
64
61
  credentialType: 'public-key';
65
62
  attestationObject: Uint8Array;
@@ -24,16 +24,13 @@ const verifyAttestationApple_js_1 = require("./verifications/verifyAttestationAp
24
24
  *
25
25
  * **Options:**
26
26
  *
27
- * @param response Response returned by **@simplewebauthn/browser**'s `startAuthentication()`
28
- * @param expectedChallenge The base64url-encoded `options.challenge` returned by
29
- * `generateRegistrationOptions()`
30
- * @param expectedOrigin Website URL (or array of URLs) that the registration should have occurred on
31
- * @param expectedRPID RP ID (or array of IDs) that was specified in the registration options
32
- * @param expectedType (Optional) The response type expected ('webauthn.create')
33
- * @param requireUserVerification (Optional) Enforce user verification by the authenticator
34
- * (via PIN, fingerprint, etc...)
35
- * @param supportedAlgorithmIDs Array of numeric COSE algorithm identifiers supported for
36
- * attestation by this RP. See https://www.iana.org/assignments/cose/cose.xhtml#algorithms
27
+ * @param response - Response returned by **@simplewebauthn/browser**'s `startAuthentication()`
28
+ * @param expectedChallenge - The base64url-encoded `options.challenge` returned by `generateRegistrationOptions()`
29
+ * @param expectedOrigin - Website URL (or array of URLs) that the registration should have occurred on
30
+ * @param expectedRPID - RP ID (or array of IDs) that was specified in the registration options
31
+ * @param expectedType **(Optional)** - The response type expected ('webauthn.create')
32
+ * @param requireUserVerification **(Optional)** - Enforce user verification by the authenticator (via PIN, fingerprint, etc...) Defaults to `true`
33
+ * @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
37
34
  */
38
35
  async function verifyRegistrationResponse(options) {
39
36
  const { response, expectedChallenge, expectedOrigin, expectedRPID, expectedType, requireUserVerification = true, supportedAlgorithmIDs = generateRegistrationOptions_js_1.supportedCOSEAlgorithmIdentifiers, } = options;
@@ -197,7 +194,7 @@ async function verifyRegistrationResponse(options) {
197
194
  fmt,
198
195
  counter,
199
196
  aaguid: (0, convertAAGUIDToString_js_1.convertAAGUIDToString)(aaguid),
200
- credentialID,
197
+ credentialID: index_js_1.isoBase64URL.fromBuffer(credentialID),
201
198
  credentialPublicKey,
202
199
  credentialType,
203
200
  attestationObject,