Skip to content

WebAuthnP256.sign

Signs a challenge using a stored WebAuthn P256 Credential. If no Credential is provided, a prompt will be displayed for the user to select an existing Credential that was previously registered.

Imports

Named
import { WebAuthnP256 } from 'ox'

Examples

import { WebAuthnP256 } from 'ox'
 
const credential = await WebAuthnP256.createCredential({
  name: 'Example',
})
 
const { metadata, signature } = await WebAuthnP256.sign({ 
  credentialId: credential.id, 
  challenge: '0xdeadbeef', 
})
{
metadata: {
authenticatorData: '0x49960de5880e8c687434170f6476605b8fe4aeb9a28632c7995cf3ba831d97630500000000',
clientDataJSON: '{"type":"webauthn.get","challenge":"9jEFijuhEWrM4SOW-tChJbUEHEP44VcjcJ-Bqo1fTM8","origin":"http://localhost:5173","crossOrigin":false}',
challengeIndex: 23,
typeIndex: 1,
userVerificationRequired: true,
},
signature: { r: 51231...4215n, s: 12345...6789n },
}

Definition

function sign(
  options: sign.Options,
): Promise<sign.ReturnType>

Source: src/WebAuthnP256.ts

Parameters

options

  • Type: sign.Options

Options.

options.challenge

  • Type: 0x${string}

The challenge to sign.

options.credentialId

  • Type: string
  • Optional

The credential ID to use.

options.getFn

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

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

options.rpId

  • Type: string
  • Optional

The relying party identifier to use.

options.userVerification

  • Type: UserVerificationRequirement
  • Optional

The user verification requirement.

Return Type

The signature.

Promise<sign.ReturnType>

Error Type

WebAuthnP256.sign.ErrorType