Skip to content

WebAuthnP256.createCredential

Creates a new WebAuthn P256 Credential, which can be stored and later used for signing.

Imports

Named
import { WebAuthnP256 } from 'ox'

Examples

import { WebAuthnP256 } from 'ox'
 
const credential = await WebAuthnP256.createCredential({ name: 'Example' })
{
id: 'oZ48...',
publicKey: { x: 51421...5123n, y: 12345...6789n },
raw: PublicKeyCredential {},
}
const { metadata, signature } = await WebAuthnP256.sign({ credentialId: credential.id, challenge: '0xdeadbeef', })

Definition

function createCredential(
  options: createCredential.Options,
): Promise<P256Credential>

Source: src/core/WebAuthnP256.ts

Parameters

options

  • Type: createCredential.Options

Credential creation options.

options.attestation

  • Type: AttestationConveyancePreference
  • Optional

A string specifying the relying party's preference for how the attestation statement (i.e., provision of verifiable evidence of the authenticity of the authenticator and its data) is conveyed during credential creation.

options.authenticatorSelection

  • Type: AuthenticatorSelectionCriteria
  • Optional

An object whose properties are criteria used to filter out the potential authenticators for the credential creation operation.

options.challenge

  • Type: BufferSource
  • Optional

An ArrayBuffer, TypedArray, or DataView used as a cryptographic challenge.

options.createFn

  • Type: (options?: CredentialCreationOptions) => Promise
  • Optional

Credential creation function. Useful for environments that do not support the WebAuthn API natively (i.e. React Native or testing environments).

options.displayName

  • Type: string
  • Optional

options.excludeCredentialIds

  • Type: readonly string[]
  • Optional

List of credential IDs to exclude from the creation. This property can be used to prevent creation of a credential if it already exists.

options.extensions

  • Type: AuthenticationExtensionsClientInputs
  • Optional

List of Web Authentication API credentials to use during creation or authentication.

options.id

  • Type: BufferSource
  • Optional

options.name

  • Type: string

options.rp

  • Type: { id: string; name: string; }
  • Optional

An object describing the relying party that requested the credential creation

options.timeout

  • Type: number
  • Optional

A numerical hint, in milliseconds, which indicates the time the calling web app is willing to wait for the creation operation to complete.

options.user

  • Type: { displayName?: string; id?: BufferSource; name: string; }

An object describing the user account for which the credential is generated.

Return Type

A WebAuthn P256 credential.

Promise<P256Credential>