@simplewebauthn/server 8.0.1 → 8.1.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.
@@ -2,7 +2,7 @@ import type { AuthenticationResponseJSON, AuthenticatorDevice, CredentialDeviceT
2
2
  import { AuthenticationExtensionsAuthenticatorOutputs } from '../helpers/decodeAuthenticatorExtensions.js';
3
3
  export type VerifyAuthenticationResponseOpts = {
4
4
  response: AuthenticationResponseJSON;
5
- expectedChallenge: string | ((challenge: string) => boolean);
5
+ expectedChallenge: string | ((challenge: string) => boolean | Promise<boolean>);
6
6
  expectedOrigin: string | string[];
7
7
  expectedRPID: string | string[];
8
8
  authenticator: AuthenticatorDevice;
@@ -53,7 +53,7 @@ export async function verifyAuthenticationResponse(options) {
53
53
  }
54
54
  // Ensure the device provided the challenge we gave it
55
55
  if (typeof expectedChallenge === 'function') {
56
- if (!expectedChallenge(challenge)) {
56
+ if (!(await expectedChallenge(challenge))) {
57
57
  throw new Error(`Custom challenge verifier returned false for registration response challenge "${challenge}"`);
58
58
  }
59
59
  }
@@ -3,7 +3,7 @@ import { AttestationFormat, AttestationStatement } from '../helpers/decodeAttest
3
3
  import { AuthenticationExtensionsAuthenticatorOutputs } from '../helpers/decodeAuthenticatorExtensions.js';
4
4
  export type VerifyRegistrationResponseOpts = {
5
5
  response: RegistrationResponseJSON;
6
- expectedChallenge: string | ((challenge: string) => boolean);
6
+ expectedChallenge: string | ((challenge: string) => boolean | Promise<boolean>);
7
7
  expectedOrigin: string | string[];
8
8
  expectedRPID?: string | string[];
9
9
  requireUserVerification?: boolean;
@@ -54,7 +54,7 @@ export async function verifyRegistrationResponse(options) {
54
54
  }
55
55
  // Ensure the device provided the challenge we gave it
56
56
  if (typeof expectedChallenge === 'function') {
57
- if (!expectedChallenge(challenge)) {
57
+ if (!(await expectedChallenge(challenge))) {
58
58
  throw new Error(`Custom challenge verifier returned false for registration response challenge "${challenge}"`);
59
59
  }
60
60
  }
package/package.json CHANGED
@@ -2,7 +2,7 @@
2
2
  "module": "./esm/index.js",
3
3
  "main": "./script/index.js",
4
4
  "name": "@simplewebauthn/server",
5
- "version": "8.0.1",
5
+ "version": "8.1.0",
6
6
  "description": "SimpleWebAuthn for Servers",
7
7
  "license": "MIT",
8
8
  "author": "Matthew Miller <matthew@millerti.me>",
@@ -2,7 +2,7 @@ import type { AuthenticationResponseJSON, AuthenticatorDevice, CredentialDeviceT
2
2
  import { AuthenticationExtensionsAuthenticatorOutputs } from '../helpers/decodeAuthenticatorExtensions.js';
3
3
  export type VerifyAuthenticationResponseOpts = {
4
4
  response: AuthenticationResponseJSON;
5
- expectedChallenge: string | ((challenge: string) => boolean);
5
+ expectedChallenge: string | ((challenge: string) => boolean | Promise<boolean>);
6
6
  expectedOrigin: string | string[];
7
7
  expectedRPID: string | string[];
8
8
  authenticator: AuthenticatorDevice;
@@ -56,7 +56,7 @@ async function verifyAuthenticationResponse(options) {
56
56
  }
57
57
  // Ensure the device provided the challenge we gave it
58
58
  if (typeof expectedChallenge === 'function') {
59
- if (!expectedChallenge(challenge)) {
59
+ if (!(await expectedChallenge(challenge))) {
60
60
  throw new Error(`Custom challenge verifier returned false for registration response challenge "${challenge}"`);
61
61
  }
62
62
  }
@@ -3,7 +3,7 @@ import { AttestationFormat, AttestationStatement } from '../helpers/decodeAttest
3
3
  import { AuthenticationExtensionsAuthenticatorOutputs } from '../helpers/decodeAuthenticatorExtensions.js';
4
4
  export type VerifyRegistrationResponseOpts = {
5
5
  response: RegistrationResponseJSON;
6
- expectedChallenge: string | ((challenge: string) => boolean);
6
+ expectedChallenge: string | ((challenge: string) => boolean | Promise<boolean>);
7
7
  expectedOrigin: string | string[];
8
8
  expectedRPID?: string | string[];
9
9
  requireUserVerification?: boolean;
@@ -57,7 +57,7 @@ async function verifyRegistrationResponse(options) {
57
57
  }
58
58
  // Ensure the device provided the challenge we gave it
59
59
  if (typeof expectedChallenge === 'function') {
60
- if (!expectedChallenge(challenge)) {
60
+ if (!(await expectedChallenge(challenge))) {
61
61
  throw new Error(`Custom challenge verifier returned false for registration response challenge "${challenge}"`);
62
62
  }
63
63
  }