UNPKG

@authaction/passkey-plus-sdk

Version:

A lightweight frontend SDK for passkey-based passwordless authentication with AuthAction

91 lines (65 loc) 2.44 kB
# Passkey Plus SDK A lightweight frontend SDK that enables seamless integration of passkey authentication into your existing authentication solutions, powered by AuthAction (https://authaction.com). ## Purpose This SDK provides a simple interface to add passkey-based authentication to your applications while working alongside your existing authentication systems. It allows you to leverage the security benefits of passkeys without having to completely replace your current authentication infrastructure. ## Features - Simple and intuitive API - TypeScript support with type definitions - Modern ES modules and CommonJS support - Zero dependencies (except for browser WebAuthn API) - Comprehensive error handling - Integration with AuthAction's passkey authentication service ## Installation ```bash npm install @authaction/passkey-plus-sdk ``` ## Usage ### Initialize the SDK ```typescript import { PasskeyPlus } from "@authaction/passkey-plus-sdk"; // Initialize with your AuthAction tenant credentials const passkeyPlus = new PasskeyPlus({ tenantDomain: "your-tenant.authaction.com", appId: "your-app-id", }); ``` ### Register a New Passkey ```typescript // Start passkey registration process await passkeyPlus.register("transaction-id", { authenticatorAttachment: "platform", // or 'cross-platform' }); ``` ### Authenticate with Passkey ```typescript // Authenticate using an existing passkey await passkeyPlus.authenticate("transaction-id", { isConditionalMediation: true, }); ``` ### Check Passkey Support ```typescript // Check if passkey authentication is available const canAuthenticate = await passkeyPlus.canAuthenticateWithPasskey(); const canRegister = await passkeyPlus.canRegisterPasskey(); const canUseConditionalMediation = await passkeyPlus.canUseConditionalMediation(); ``` ## Error Handling The SDK uses standard JavaScript errors. You can catch and handle any errors that occur during passkey operations: ```typescript try { await passkeyPlus.register("transaction-id"); } catch (error) { // Handle any errors that occur during passkey operations console.error("Error:", error); } ``` ## Browser Support This SDK works with any modern browser that supports the WebAuthn API. It's compatible with: - Chrome - Firefox - Safari - Edge ## Learn More For more information about passkeys and AuthAction's authentication solutions, visit [AuthAction's website](https://authaction.com).