This package is a plugin for the Better Auth ecosystem, extending the functionality of the `@better-auth/passkey` plugin with CorePass-specific identity enrichment. It facilitates user registration via passkeys while integrating signed identity and profile data, such as Core ID, email, and KYC (Know Your Customer) flags, directly from the CorePass application. The plugin performs robust Ed448 signature verification on incoming enrichment data, validates Core IDs using `blockchain-wallet-validator`, and enforces configurable requirements like age verification (`requireO18y`, `requireO21y`) and KYC. It also dynamically updates user profiles and session data, including a `corepass_profile` with configurable expiry. Currently at version 0.1.18, the library exhibits a rapid release cadence with frequent updates and bug fixes, indicating active development. A key differentiator is its strict 'passkey-only access' policy, which blocks users without a registered passkey from most authentication endpoints, making it ideal for anonymous bootstrap flows requiring eventual strong identity binding.
npm install better-auth-corepass-passkeyVerified import paths — ran on the pinned version, not inferred.
This quickstart demonstrates how to initialize `better-auth` with both the `@better-auth/passkey` and `better-auth-corepass-passkey` plugins. It sets up an Express server to expose the authentication routes and an example protected endpoint that relies on the CorePass profile data being present in the user's session.
Update all client-side code and API calls to send CorePass enrichment data to the new `/webauthn/data` endpoint, ensuring your `better-auth` base path is prefixed correctly (e.g., `/auth/webauthn/data`).
For anonymous bootstrap flows that require access to specific routes before passkey registration, configure the `allowRoutesBeforePasskey` option in the `createCorePassPasskeyPlugin` settings to permit access to those paths.
If immediate user access is desired after passkey registration, you must explicitly set `finalize: 'immediate'` within the `createPasskeyPlugin` options (or the appropriate setting if overridden by this plugin).
Ensure your application handles cases where `user.profile.coreId` or other `corepass_profile` fields might be missing due to expiry. Implement a mechanism to prompt users for re-enrichment via the CorePass app if their profile data has expired.
Verify that the Core ID being sent from the CorePass application is valid. Additionally, ensure the `allowNetwork` array in your `createCorePassPasskeyPlugin` options includes the specific CorePass blockchain network(s) from which you expect to receive data.
Confirm that your client-side code sends enrichment data to the correct `/webauthn/data` path relative to your `better-auth` base path (e.g., `/auth/webauthn/data` if your `AuthService` router is mounted at `/auth`). Also, ensure the `createCorePassPasskeyPlugin` is correctly included in the `plugins` array of your `AuthService` instance.
Adjust your client-side flow to ensure an email address is provided either in the request body of the initial anonymous sign-in or is guaranteed to be delivered via CorePass enrichment, satisfying the configured plugin requirements.
Review the plugin's configuration for any uniqueness requirements (e.g., unique email, unique Core ID). Investigate the user flow to ensure that duplicate registrations are handled gracefully, perhaps by prompting for a different credential or linking to an existing account.