@aymenkits/auth-core
v1.0.0
Published
OTP-first identity & sessions: email/phone code login (find-or-create), Google & Apple ID-token sign-in with account linking, JWT access tokens, pluggable refresh strategies (rotating multi-device / static single-token), OTP-verified contact change. Stora
Maintainers
Readme
@aymenkits/auth-core
OTP-first identity: token service (JWT HS256, drop-in compatible with hand-rolled jsonwebtoken apps), rotating OR static refresh strategies, password login (optional), Google/Apple ID-token sign-in, find-or-create flows and OTP-verified contact change.
Install
npm install @aymenkits/auth-coreInstalls with it: @aymenkits/auth-otp, bcryptjs, jsonwebtoken, jose (automatic dependencies).
You provide
UserStore— find/create users on YOUR schema (profile shape is yours)SessionStore— refresh-token persistence (a table or a single column, per strategy)- Your JWT secrets — keeping them means existing tokens stay valid
The package never owns tables, never imports an ORM, HTTP framework, or provider SDK it can take as a parameter — storage and delivery are seams your app implements on its own stack.
Quick example
import { createTokenService, createAuthFlows } from '@aymenkits/auth-core'
const tokens = createTokenService({ accessSecret, refreshSecret })
const auth = createAuthFlows({ users, sessions, tokens, otp, strategy: 'rotating' })
const session = await auth.verifyOtp({ channel: 'PHONE', destination, code })Pairs with
@aymenkits/auth-expressfor routes/middleware@aymenkits/chat-socketioaccepts the TokenService as its handshakeidentity
Kits pair by shape, never by import — pass the sibling kit, your own service, or a stub in tests.
Docs
Full contracts and integration guides live in the repo:
https://github.com/aymenmokhtarikouki/auth-kit (contracts/, docs/).
License
MIT
