Skip to main content

@rtorcato/browser-common / webauthn

webauthn

Functions

isWebAuthnAvailable()

isWebAuthnAvailable(): boolean

Defined in: webauthn/index.ts:10

Checks if the Credential Management / WebAuthn API is available.

Example

import { isWebAuthnAvailable } from '@rtorcato/browser-common/webauthn'
if (isWebAuthnAvailable()) offerPasskeyLogin()

Returns

boolean

True if navigator.credentials exists, false otherwise.


createCredential()

createCredential(options?): Promise<Credential | null>

Defined in: webauthn/index.ts:25

Creates a new credential (e.g. registers a passkey) via navigator.credentials.create.

Example

import { createCredential } from '@rtorcato/browser-common/webauthn'
const credential = await createCredential({ publicKey })

Parameters

options?

CredentialCreationOptions

Credential creation options (typically with a publicKey field).

Returns

Promise<Credential | null>

A promise resolving to the new Credential, or null.

Throws

If called where the Credential Management API is unsupported.


getCredential()

getCredential(options?): Promise<Credential | null>

Defined in: webauthn/index.ts:43

Requests an existing credential (e.g. authenticates a passkey) via navigator.credentials.get.

Example

import { getCredential } from '@rtorcato/browser-common/webauthn'
const credential = await getCredential({ publicKey })

Parameters

options?

CredentialRequestOptions

Credential request options (typically with a publicKey field).

Returns

Promise<Credential | null>

A promise resolving to the retrieved Credential, or null.

Throws

If called where the Credential Management API is unsupported.