UNPKG

codalware-auth

Version:

Complete authentication system with enterprise security, attack protection, team workspaces, waitlist, billing, UI components, 2FA, and account recovery - production-ready in 5 minutes. Enhanced CLI with verification, rollback, and App Router scaffolding.

73 lines (70 loc) 1.92 kB
import { Adapter, User, Session, MagicToken } from './types'; type DrizzleAdapterOpts = { secret: string; // secret used for HMAC hashing of tokens // db: DrizzleClient; // TODO: accept the actual drizzle client }; export function createDrizzleNeonAdapter(_opts: DrizzleAdapterOpts): Adapter { return { async createUser({ email, name, metadata }) { // TODO: insert user via drizzle const now = new Date(); return { id: 'TODO', email, name: name ?? null, metadata: metadata ?? null, createdAt: now, updatedAt: now, } as unknown as User; }, async getUserById(_id) { return null; }, async getUserByEmail(_email) { return null; }, async updateUser(_id, _patch) { throw new Error('Not implemented'); }, async createSession(session) { const now = new Date(); return { id: 'TODO', userId: session.userId, createdAt: now, expiresAt: session.expiresAt, handle: session.handle ?? null, metadata: session.metadata ?? null, } as unknown as Session; }, async getSessionById(_id) { return null; }, async deleteSession(_id) { return; }, async deleteSessionsByUserId(_userId) { return; }, async storeMagicToken({ tokenHash, userId = null, expiresAt, ip = null, userAgent = null }) { const now = new Date(); return { id: 'TODO', tokenHash, userId, createdAt: now, expiresAt, consumedAt: null, ip, userAgent, } as unknown as MagicToken; }, async findValidMagicToken(_tokenHash) { // tokenHash is expected to be stored (hmac) in DB return null; }, async consumeMagicToken(_id) { return; }, }; }