@magnaflow/passkey
v1.0.4
Published
Standardized passkey management library for WebAuthn authentication
Maintainers
Readme
@magnaflow/passkey
Browser-side WebAuthn helpers for passkey registration and verification flows.
What It Provides
registerPasskeyto create a passkey credential from server-provided challenge dataverifyPasskeyto complete an authentication challenge- Environment capability checks for WebAuthn and platform authenticators
- Utility helpers for automatic RP ID detection and ArrayBuffer/Base64 conversion
Install
npm install @magnaflow/passkeyKey Exports
registerPasskeyverifyPasskeyisPasskeyAvailablegetRelyingPartyIdarrayBufferToBase64base64ToArrayBufferisWebAuthnSupportedisPlatformAuthenticatorAvailable
Example
import { registerPasskey, verifyPasskey } from '@magnaflow/passkey';
const registerResult = await registerPasskey({
challenge: 'register-challenge',
rp_name: 'MagnaFlow',
user_id: 'merchant-123',
});
const verifyResult = await verifyPasskey({
challenge: 'verify-challenge',
rp_name: 'MagnaFlow',
user_id: 'merchant-123',
registered_ids: ['credential-id-base64'],
});
const registerAcrossSubdomains = await registerPasskey(
{
challenge: 'register-challenge',
rp_name: 'MagnaFlow',
user_id: 'merchant-123',
},
{
rootDomains: ['example-payments.test', 'sample-wallet.test'],
},
);
const registerWithAutoDomain = await registerPasskey({
challenge: 'register-challenge',
rp_name: 'Sample Wallet',
user_id: 'merchant-123',
});
// On https://dev.sample-wallet.test/console/auth/sign-in this will use rpId = 'sample-wallet.test'Notes
- This package only performs browser-side WebAuthn work. Backend API requests must be handled by the caller.
- All public APIs in this package require a browser environment.
- By default, the package derives the RP ID from the current hostname using the registrable domain, so
https://dev.sample-wallet.test/...resolves tosample-wallet.test. - If you need strict overrides, pass
rootDomainsorcustomRpId.
Development
bunx nx run passkey:lint
bunx nx run passkey:test
bunx nx run passkey:buildLicense
This package is part of the merchant-v2-sdk monorepo and is covered by the root MIT license.
See ../../LICENSE for details.
