Registry / auth-security / better-auth-bsky

better-auth-bsky

JSON →
library0.1.9jsnpmunverified

A better-auth plugin (v0.1.9) adding ATProto/Bluesky OAuth 2.1 authentication via @atcute/oauth-node-client. Supports DPoP, PAR, PKCE and runs as a public or confidential client. Requires better-auth >=1.5.0, Node.js >=20 or Bun >=1.1.0. Ships TypeScript types and reduces install footprint by bundling valibot. Differentiates from app-password flows by implementing the OAuth 2.1 standard, with optional keypair-based confidential mode for longer sessions (180 days vs 14 days for public mode).

npm install better-auth-bsky
INSTALL
IMPORT
SIG · BETTER-AUTH-BSKY
B
better-auth-bsky
auth-securityjavascriptv0.1.9
harness data pending
Install & Compatibility
Where this runs

No compatibility data collected yet for this library.

Code
Verified usage

Verified import paths — ran on the pinned version, not inferred.

atproto
import { atproto } from 'better-auth-bsky'
import atproto from 'better-auth-bsky'
Named export, not default.
atprotoClient
import { atprotoClient } from 'better-auth-bsky/client'
import { atprotoClient } from 'better-auth-bsky'
Client plugin is in a separate subpath.
generateAtprotoKeypair
import { generateAtprotoKeypair } from 'better-auth-bsky'
const generateAtprotoKeypair = require('better-auth-bsky')
ESM-only; require is unsupported.

Initializes server plugin with minimal config and demonstrates client-side sign-in flow.

import { betterAuth } from 'better-auth'; import { atproto } from 'better-auth-bsky'; import { createAuthClient } from 'better-auth/client'; import { atprotoClient } from 'better-auth-bsky/client'; export const auth = betterAuth({ plugins: [ atproto({ clientName: 'My App', clientUri: 'https://myapp.com', keyset: [] // omit for public client }) ] }); // Client-side sign-in export const client = createAuthClient({ plugins: [atprotoClient()] }); async function signIn() { const { data, error } = await client.signIn.atproto({ handle: 'user.bsky.social', callbackURL: '/dashboard' }); if (!error) window.location.href = data.url; }
Debug
Known issues
breakingPeer dependency better-auth must be >=1.5.0; plugin will not work with older versions.
fix
Update better-auth to >=1.5.0.
affects: <0.1.0
breakingNode.js version must be >=20.0.0 (uses modern features).
fix
Upgrade Node.js to >=20.
affects: >=0.1.0
deprecatedvalibot was bundled as a dependency in v0.1.7; shipped inline to reduce install size.
fix
No code change needed. Upgrade to v0.1.7+ to benefit from smaller install.
affects: <0.1.7
deprecatedThe tsdown build tool dropped support for the 'external' option; v0.1.8+ uses 'deps.neverBundle' / 'deps.onlyBundle'.
fix
Update tsdown config if building from source.
affects: <=0.1.7
gotchaPublic client sessions are limited to 14 days; confidential sessions last 180 days.
fix
Provide a keyset via generateAtprotoKeypair() to enable confidential mode.
affects: >=0.1.0
gotchaLoopback (localhost) is only supported in confidential mode during development.
fix
Ensure keyset is provided for local development with loopback.
affects: >=0.1.0
Errors
Common errors & fixes
Cannot find module 'better-auth-bsky' or its corresponding type declarations.
Missing or incorrect installation of better-auth-bsky or its peer dependencies.
fix
Run 'bun add better-auth-bsky better-auth @atcute/oauth-node-client' (or npm/pnpm equivalent).
Uncaught TypeError: client.signIn.atproto is not a function
Client-side atprotoClient() plugin not added to createAuthClient.
fix
Ensure atprotoClient() is passed in the plugins array: createAuthClient({ plugins: [atprotoClient()] }).
SyntaxError: The requested module 'better-auth-bsky' does not provide an export named 'default'
Attempting to default-import a named-only export.
fix
Use named import: import { atproto, generateAtprotoKeypair } from 'better-auth-bsky'.
Upgrade
Version history
0.1.9latest on npm
Audit
Dependencies
better-authrequiredpeer dependency; plugin API required
@atcute/oauth-node-clientrequiredATProto OAuth client implementation
Agent activity
46 hits · last 30 days
node
39
OpenAI (training)
1
Resources