@abstraxn/passkey-manager
v0.0.12
Published
@abstraxn/passkey-manager is an npm package that provides a set of utilities and classes for creating and managing WebAuthn passkeys, extracting signatures, and handling local storage formats. The package is designed with an object-oriented approach, maki
Downloads
633
Keywords
Readme
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.