Skip to content

Commit

Permalink
Move some docstrings around
Browse files Browse the repository at this point in the history
  • Loading branch information
MasterKale committed Dec 8, 2024
1 parent e2beae1 commit 1c8b522
Show file tree
Hide file tree
Showing 3 changed files with 19 additions and 19 deletions.
16 changes: 8 additions & 8 deletions packages/browser/src/helpers/webAuthnAbortService.ts
Original file line number Diff line number Diff line change
@@ -1,16 +1,19 @@
interface WebAuthnAbortService {
/**
* Prepare an abort signal that will help support multiple auth attempts without needing to
* reload the page. This is automatically called whenever `startRegistration()` and
* `startAuthentication()` are called.
*/
createNewAbortSignal(): AbortSignal;
/**
* Manually cancel any active WebAuthn registration or authentication attempt.
*/
cancelCeremony(): void;
}

class BaseWebAuthnAbortService implements WebAuthnAbortService {
private controller: AbortController | undefined;

/**
* Prepare an abort signal that will help support multiple auth attempts without needing to
* reload the page. This is automatically called whenever `startRegistration()` and
* `startAuthentication()` are called.
*/
createNewAbortSignal(): AbortSignal {
// Abort any existing calls to navigator.credentials.create() or navigator.credentials.get()
if (this.controller) {
Expand All @@ -27,9 +30,6 @@ class BaseWebAuthnAbortService implements WebAuthnAbortService {
return newController.signal;
}

/**
* Manually cancel any active WebAuthn registration or authentication attempt.
*/
cancelCeremony(): void {
if (this.controller) {
const abortError = new Error(
Expand Down
12 changes: 6 additions & 6 deletions packages/browser/src/methods/startAuthentication.ts
Original file line number Diff line number Diff line change
Expand Up @@ -12,11 +12,7 @@ import { identifyAuthenticationError } from '../helpers/identifyAuthenticationEr
import { WebAuthnAbortService } from '../helpers/webAuthnAbortService.ts';
import { toAuthenticatorAttachment } from '../helpers/toAuthenticatorAttachment.ts';

export type StartAuthenticationOpts = {
optionsJSON: PublicKeyCredentialRequestOptionsJSON;
useBrowserAutofill?: boolean;
verifyBrowserAutofillInput?: boolean;
};
export type StartAuthenticationOpts = Parameters<typeof startAuthentication>[0];

/**
* Begin authenticator "login" via WebAuthn assertion
Expand All @@ -26,7 +22,11 @@ export type StartAuthenticationOpts = {
* @param verifyBrowserAutofillInput (Optional) Ensure a suitable `<input>` element is present when `useBrowserAutofill` is `true`. Defaults to `true`.
*/
export async function startAuthentication(
options: StartAuthenticationOpts,
options: {
optionsJSON: PublicKeyCredentialRequestOptionsJSON;
useBrowserAutofill?: boolean;
verifyBrowserAutofillInput?: boolean;
},
): Promise<AuthenticationResponseJSON> {
const {
optionsJSON,
Expand Down
10 changes: 5 additions & 5 deletions packages/browser/src/methods/startRegistration.ts
Original file line number Diff line number Diff line change
Expand Up @@ -12,10 +12,7 @@ import { identifyRegistrationError } from '../helpers/identifyRegistrationError.
import { WebAuthnAbortService } from '../helpers/webAuthnAbortService.ts';
import { toAuthenticatorAttachment } from '../helpers/toAuthenticatorAttachment.ts';

export type StartRegistrationOpts = {
optionsJSON: PublicKeyCredentialCreationOptionsJSON;
useAutoRegister?: boolean;
};
export type StartRegistrationOpts = Parameters<typeof startRegistration>[0];

/**
* Begin authenticator "registration" via WebAuthn attestation
Expand All @@ -24,7 +21,10 @@ export type StartRegistrationOpts = {
* @param useAutoRegister (Optional) Try to silently create a passkey with the password manager that the user just signed in with. Defaults to `false`.
*/
export async function startRegistration(
options: StartRegistrationOpts,
options: {
optionsJSON: PublicKeyCredentialCreationOptionsJSON;
useAutoRegister?: boolean;
},
): Promise<RegistrationResponseJSON> {
const { optionsJSON, useAutoRegister = false } = options;

Expand Down

0 comments on commit 1c8b522

Please sign in to comment.