@abstraxn/passkey-manager
TypeScript icon, indicating that this package has built-in type declarations

0.0.3 • Public • Published

Abstraxn - Passkey Manager Package

The Passkey package provides utilities for handling WebAuthn passkeys, local storage, and signature extraction. It simplifies the process of creating, storing, and verifying passkeys using WebAuthn (Web Authentication) API, enabling secure authentication mechanisms in web applications.

Features

  • Passkey Creation: Generate passkeys using WebAuthn API.
  • Signature Extraction: Extract and decode signatures from authenticator responses.
  • Local Storage Management: Store and retrieve passkeys securely in local storage.
  • TypeScript Support: Written in TypeScript for type-safe usage.

Installation

Install the Passkey manager package from npm:

npm install @abstraxn/passkey-manager

Usage

Creating a Passkey

To create a passkey:

import { createPasskey, getPassKey, toLocalStorageFormat, isLocalStoragePasskey, extractSignature, extractClientDataFields } from '@abstraxn/passkey-manager''

async function main() {
  try {
    // Create a passkey
    const passkey = await createPasskey("username");

    console.log("Passkey created:", passkey);

    // Store passkey in local storage format
    const passkeyLocalStorageFormat = toLocalStorageFormat(passkey);
    console.log("Passkey stored in local storage format:", passkeyLocalStorageFormat);

  } catch (error) {
    console.error("Error creating passkey:", error);
  }
}

main();

Creating a Passkey

To retrieve a passkey:

const { getPassKey } = require('passkey');

async function main() {
  try {
    // Retrieve passkey
    const passkey = await getPassKey();

    console.log("Retrieved passkey:", passkey);

  } catch (error) {
    console.error("Error retrieving passkey:", error);
  }
}

main();

Additional Functions

  • extractSignature(signature: ArrayBuffer | Uint8Array): [bigint, bigint]: Extracts R and S values from an authenticator signature.
  • extractClientDataFields(response: AuthenticatorAssertionResponse): { field: string, clientDataJSON: string }: Extracts additional client data fields from an authenticator response.

License

This package is MIT licensed. (c) Antier Solutions 2024.

Authors

Package Sidebar

Install

npm i @abstraxn/passkey-manager

Weekly Downloads

1

Version

0.0.3

License

MIT

Unpacked Size

42.5 kB

Total Files

12

Last publish

Collaborators

  • sandeep_sj
  • jaskaran449