summaryrefslogtreecommitdiffhomepage
path: root/packages/browser/src
diff options
context:
space:
mode:
Diffstat (limited to 'packages/browser/src')
-rw-r--r--packages/browser/src/helpers/webAuthnAbortService.test.ts12
-rw-r--r--packages/browser/src/helpers/webAuthnAbortService.ts4
-rw-r--r--packages/browser/src/methods/startAuthentication.test.ts5
-rw-r--r--packages/browser/src/methods/startAuthentication.ts4
-rw-r--r--packages/browser/src/methods/startRegistration.test.ts5
-rw-r--r--packages/browser/src/methods/startRegistration.ts4
6 files changed, 16 insertions, 18 deletions
diff --git a/packages/browser/src/helpers/webAuthnAbortService.test.ts b/packages/browser/src/helpers/webAuthnAbortService.test.ts
index 506bb2a..a538dff 100644
--- a/packages/browser/src/helpers/webAuthnAbortService.test.ts
+++ b/packages/browser/src/helpers/webAuthnAbortService.test.ts
@@ -1,23 +1,23 @@
-import { webauthnAbortService } from './webAuthnAbortService';
+import { WebauthnAbortService } from './webAuthnAbortService';
test('should create a new abort signal every time', () => {
- const signal1 = webauthnAbortService.createNewAbortSignal();
- const signal2 = webauthnAbortService.createNewAbortSignal();
+ const signal1 = WebauthnAbortService.createNewAbortSignal();
+ const signal2 = WebauthnAbortService.createNewAbortSignal();
expect(signal2).not.toBe(signal1);
});
test('should call abort() with AbortError on existing controller when creating a new signal', () => {
// Populate `.controller`
- webauthnAbortService.createNewAbortSignal();
+ WebauthnAbortService.createNewAbortSignal();
// Spy on the existing instance of AbortController
const abortSpy = jest.fn();
// @ts-ignore: Ignore the fact that `controller` is private
- webauthnAbortService.controller.abort = abortSpy;
+ WebauthnAbortService.controller.abort = abortSpy;
// Generate a new signal, which should call `abort()` on the existing controller
- webauthnAbortService.createNewAbortSignal();
+ WebauthnAbortService.createNewAbortSignal();
expect(abortSpy).toHaveBeenCalledTimes(1);
// Make sure we raise an AbortError so it can be detected correctly
diff --git a/packages/browser/src/helpers/webAuthnAbortService.ts b/packages/browser/src/helpers/webAuthnAbortService.ts
index 50e00ba..ed007e2 100644
--- a/packages/browser/src/helpers/webAuthnAbortService.ts
+++ b/packages/browser/src/helpers/webAuthnAbortService.ts
@@ -2,7 +2,7 @@
* A way to cancel an existing WebAuthn request, for example to cancel a
* WebAuthn autofill authentication request for a manual authentication attempt.
*/
-class WebAuthnAbortService {
+class BaseWebAuthnAbortService {
private controller: AbortController | undefined;
/**
@@ -26,4 +26,4 @@ class WebAuthnAbortService {
}
}
-export const webauthnAbortService = new WebAuthnAbortService();
+export const WebauthnAbortService = new BaseWebAuthnAbortService();
diff --git a/packages/browser/src/methods/startAuthentication.test.ts b/packages/browser/src/methods/startAuthentication.test.ts
index 11f078e..e535202 100644
--- a/packages/browser/src/methods/startAuthentication.test.ts
+++ b/packages/browser/src/methods/startAuthentication.test.ts
@@ -11,7 +11,7 @@ import { utf8StringToBuffer } from '../helpers/utf8StringToBuffer';
import { bufferToBase64URLString } from '../helpers/bufferToBase64URLString';
import { WebAuthnError } from '../helpers/webAuthnError';
import { generateCustomError } from '../helpers/__jest__/generateCustomError';
-import { webauthnAbortService } from '../helpers/webAuthnAbortService';
+import { WebauthnAbortService } from '../helpers/webAuthnAbortService';
import { startAuthentication } from './startAuthentication';
@@ -62,8 +62,7 @@ beforeEach(() => {
mockSupportsAutofill.mockResolvedValue(true);
// Reset the abort service so we get an accurate call count
- // @ts-ignore: Ignore the fact that `controller` is private
- webauthnAbortService.controller = undefined;
+ WebauthnAbortService.cancelCeremony();
});
afterEach(() => {
diff --git a/packages/browser/src/methods/startAuthentication.ts b/packages/browser/src/methods/startAuthentication.ts
index f6782ab..8474878 100644
--- a/packages/browser/src/methods/startAuthentication.ts
+++ b/packages/browser/src/methods/startAuthentication.ts
@@ -11,7 +11,7 @@ import { browserSupportsWebAuthn } from '../helpers/browserSupportsWebAuthn';
import { browserSupportsWebAuthnAutofill } from '../helpers/browserSupportsWebAuthnAutofill';
import { toPublicKeyCredentialDescriptor } from '../helpers/toPublicKeyCredentialDescriptor';
import { identifyAuthenticationError } from '../helpers/identifyAuthenticationError';
-import { webauthnAbortService } from '../helpers/webAuthnAbortService';
+import { WebauthnAbortService } from '../helpers/webAuthnAbortService';
import { toAuthenticatorAttachment } from '../helpers/toAuthenticatorAttachment';
/**
@@ -79,7 +79,7 @@ export async function startAuthentication(
// Finalize options
options.publicKey = publicKey;
// Set up the ability to cancel this request if the user attempts another
- options.signal = webauthnAbortService.createNewAbortSignal();
+ options.signal = WebauthnAbortService.createNewAbortSignal();
// Wait for the user to complete assertion
let credential;
diff --git a/packages/browser/src/methods/startRegistration.test.ts b/packages/browser/src/methods/startRegistration.test.ts
index 97878c6..66560b1 100644
--- a/packages/browser/src/methods/startRegistration.test.ts
+++ b/packages/browser/src/methods/startRegistration.test.ts
@@ -8,7 +8,7 @@ import { generateCustomError } from '../helpers/__jest__/generateCustomError';
import { browserSupportsWebAuthn } from '../helpers/browserSupportsWebAuthn';
import { bufferToBase64URLString } from '../helpers/bufferToBase64URLString';
import { WebAuthnError } from '../helpers/webAuthnError';
-import { webauthnAbortService } from '../helpers/webAuthnAbortService';
+import { WebauthnAbortService } from '../helpers/webAuthnAbortService';
import { utf8StringToBuffer } from '../helpers/utf8StringToBuffer';
@@ -61,8 +61,7 @@ beforeEach(() => {
mockSupportsWebauthn.mockReturnValue(true);
// Reset the abort service so we get an accurate call count
- // @ts-ignore: Ignore the fact that `controller` is private
- webauthnAbortService.controller = undefined;
+ WebauthnAbortService.cancelCeremony();
});
afterEach(() => {
diff --git a/packages/browser/src/methods/startRegistration.ts b/packages/browser/src/methods/startRegistration.ts
index 2ad3089..c34c21c 100644
--- a/packages/browser/src/methods/startRegistration.ts
+++ b/packages/browser/src/methods/startRegistration.ts
@@ -11,7 +11,7 @@ import { base64URLStringToBuffer } from '../helpers/base64URLStringToBuffer';
import { browserSupportsWebAuthn } from '../helpers/browserSupportsWebAuthn';
import { toPublicKeyCredentialDescriptor } from '../helpers/toPublicKeyCredentialDescriptor';
import { identifyRegistrationError } from '../helpers/identifyRegistrationError';
-import { webauthnAbortService } from '../helpers/webAuthnAbortService';
+import { WebauthnAbortService } from '../helpers/webAuthnAbortService';
import { toAuthenticatorAttachment } from '../helpers/toAuthenticatorAttachment';
/**
@@ -42,7 +42,7 @@ export async function startRegistration(
// Finalize options
const options: CredentialCreationOptions = { publicKey };
// Set up the ability to cancel this request if the user attempts another
- options.signal = webauthnAbortService.createNewAbortSignal();
+ options.signal = WebauthnAbortService.createNewAbortSignal();
// Wait for the user to complete attestation
let credential;