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.
- 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.
Install the Passkey manager package from npm:
npm install @abstraxn/passkey-manager
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();
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();
-
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.
This package is MIT licensed. (c) Antier Solutions 2024.