@payload-auth-link/core
v0.13.3
Published
payload-auth-link core: framework-free auth domain and port interfaces.
Readme
@payload-auth-link/core
The framework-free heart of payload-auth-link: the auth domain (roles, emails, sessions, typed errors), the port interfaces every adapter implements, and the use-cases that link provider identities to Payload users. It has no framework, Payload, or provider-SDK imports. You rarely install it directly, because every other package depends on it.
Part of payload-auth-link: an auth plugin for Payload CMS with swappable identity providers (Better Auth, Auth.js) and first-class Next.js and TanStack Start adapters.
Install
npm install @payload-auth-link/coreESM-only, Node 20.9 or later.
What it provides
IdentityProviderPort,UserRepository,SessionPort: the hexagonal seamsensureLinkedUser,registerWithStore: linking and registration use-cases returningResultvaluesparseRole,parseEmail: smart constructors for the brandedRoleandEmailtypessafeRedirectPath: open-redirect-safe post-login destinationscreateProviderRegistry,serializeCookie,isCookieName, and the typed error classes
Usage
import { parseRole, safeRedirectPath } from '@payload-auth-link/core'
parseRole('admin').isOk() // true — roles are lowercase slugs
safeRedirectPath('https://evil.example') // '/account' — off-site falls backDocs
License
MIT
