@passageidentity/webauthnutils
TypeScript icon, indicating that this package has built-in type declarations

1.1.6 • Public • Published

Passage logo

About

This package contains utility functions that simplify the creation and management of WebAuthn credentials and passkeys in web applications. Also included are functions that check if the current browser supports different features of WebAuthn, including hybrid credentials and conditional UI (autofill).

Getting Started

Install this package using npm.

npm i --save @passageidentity/webauthnutils

Usage

All the utility functions are static methods on classes. Full Typescript support is included. There are two static classes with functionality for getting and creating credentials, GetCredentialUtils and CreateCredentialUtils.

Methods can be invoked in this manner:

import { CreateCredentialUtils, GetCredentialUtils } from '@passageidentity/webauthnutils'

const createCredentialFeatures = CreateCredentialUtils.createCredentialAvailable()
const getCredendialFeatures = GetCredentialUtils.getCredentialAvailable()

These two methods can be used to check if the current browser supports WebAuthn and features like autofill. Use these methods to conditionally show

A typical credential creation flow will look like this:

// get challenge from server
// ...

// create credential
const supportedFeatures = await CreateCredentialUtils.createCredentialAvailable();
if supportedFeatures.available {
    const { credential, transports } = await CreateCredentialUtils.createCredential(
        challenge
    ).catch((_) => {
        // handle error
    });
}

See inline JSDoc comments for full documentation.

Readme

Keywords

none

Package Sidebar

Install

npm i @passageidentity/webauthnutils

Weekly Downloads

13,774

Version

1.1.6

License

ISC

Unpacked Size

28.9 kB

Total Files

6

Last publish

Collaborators

  • jennmacfarlane
  • passageamy
  • rickypadilla
  • passenger_mac
  • passage-blayne
  • kevinflanagan
  • colehecht
  • apobletts