npm package discovery and stats viewer.

Discover Tips

  • General search

    [free text search, go nuts!]

  • Package details

    pkg:[package-name]

  • User packages

    @[username]

Sponsor

Optimize Toolset

I’ve always been into building performant and accessible sites, but lately I’ve been taking it extremely seriously. So much so that I’ve been building a tool to help me optimize and monitor the sites that I build to make sure that I’m making an attempt to offer the best experience to those who visit them. If you’re into performant, accessible and SEO friendly sites, you might like it too! You can check it out at Optimize Toolset.

About

Hi, 👋, I’m Ryan Hefner  and I built this site for me, and you! The goal of this site was to provide an easy way for me to check the stats on my npm packages, both for prioritizing issues and updates, and to give me a little kick in the pants to keep up on stuff.

As I was building it, I realized that I was actually using the tool to build the tool, and figured I might as well put this out there and hopefully others will find it to be a fast and useful way to search and browse npm packages as I have.

If you’re interested in other things I’m working on, follow me on Twitter or check out the open source projects I’ve been publishing on GitHub.

I am also working on a Twitter bot for this site to tweet the most popular, newest, random packages from npm. Please follow that account now and it will start sending out packages soon–ish.

Open Software & Tools

This site wouldn’t be possible without the immense generosity and tireless efforts from the people who make contributions to the world and share their work via open source initiatives. Thank you 🙏

© 2025 – Pkg Stats / Ryan Hefner

easywebauthn

v1.0.10

Published

[![Version](https://img.shields.io/npm/v/easywebauthn.svg)](https://www.npmjs.com/package/easywebauthn)

Downloads

42

Readme

Welcome to easywebauthn 👋

Version

The EasyWebAuthN project helps reduce the amount of work needed to incorporate WebAuthn into a website.

Install

npm install easywebauthn@latest

Exported Methods

The easywebauthn package exports two primary methods for WebAuthn integration:

  • startRegistration: Initiates the WebAuthn registration process.
  • startAuthentication: Initiates the WebAuthn authentication process.

Note: Utility methods (bufferToBase64url, base64ToBuffer, base64urlToBuffer, credentialToJSON) are internal and not exported for external use.

Types

| Type | Description | Fields | |------|-------------|--------| | StartRegistrationOptions | Configuration for WebAuthn registration | challenge: stringrp: { name: string }user: { id: string, name: string, displayName: string }pubKeyCredParams: PublicKeyCredentialParameters[]timeout?: numberattestation?: AttestationConveyancePreferenceauthenticatorSelection?: AuthenticatorSelectionCriteriaextensions?: AuthenticationExtensionsClientInputs | | StartAuthenticationOptions | Configuration for WebAuthn authentication | challenge: stringallowCredentials?: PublicKeyCredentialDescriptor[]timeout?: numberuserVerification?: UserVerificationRequirementextensions?: AuthenticationExtensionsClientInputs | | RegistrationResult | Result of WebAuthn registration | id: stringrawId: stringresponse: { attestationObject: string, clientDataJSON: string }type: PublicKeyCredentialTypeclientExtensionResults: AuthenticationExtensionsClientOutputs | | AuthenticationResult | Result of WebAuthn authentication | id: stringrawId: stringresponse: { authenticatorData: string, clientDataJSON: string, signature: string, userHandle: string \| null }type: PublicKeyCredentialTypeclientExtensionResults: AuthenticationExtensionsClientOutputs |

Usage

startRegistration

Initiates the WebAuthn registration process to create a new public key credential.

Parameters:

  • options: StartRegistrationOptions
    • challenge: Base64url-encoded challenge string.
    • user: Object containing user details (id, name, displayName).
    • excludeCredentials: Optional array of credentials to exclude (id, type).
    • Other WebAuthn PublicKeyCredentialCreationOptions properties.

Returns:

  • Promise<RegistrationResult>:
    • id: Credential ID.
    • rawId: Base64url-encoded raw credential ID.
    • response: Object containing:
      • attestationObject: Base64url-encoded attestation object.
      • clientDataJSON: Base64url-encoded client data JSON.
    • type: Credential type.

Example:

import { startRegistration } from 'easywebauthn';

const options = {
  challenge: 'base64url-challenge',
  rp: { name: 'Example Corp' },
  user: {
    id: 'base64url-user-id',
    name: '[email protected]',
    displayName: 'User Name',
  },
  pubKeyCredParams: [{ type: 'public-key', alg: -7 }],
};

const result = await startRegistration(options);
console.log(result);

Throws:

  • Error: If WebAuthn is not supported by the browser or if credential creation fails.

startAuthentication

Initiates the WebAuthn authentication process to verify a user's identity.

Parameters:

  • options: StartAuthenticationOptions
    • challenge: Base64url-encoded challenge string.
    • allowCredentials: Optional array of allowed credentials (id, type, transports).
    • timeout: Optional timeout in milliseconds.
    • userVerification: Optional user verification requirement (preferred, required, discouraged).

Returns:

  • Promise<AuthenticationResult>: JSON representation of the WebAuthn assertion.

Example:

import { startAuthentication } from 'easywebauthn';

const options = {
  challenge: 'base64url-challenge',
  allowCredentials: [{ id: 'base64url-cred-id', type: 'public-key', transports: ['usb'] }],
  timeout: 60000,
  userVerification: 'preferred',
};

const assertion = await startAuthentication(options);
console.log(assertion);

Author

👤 Timur Lebedev