/** * Express authentication middleware factory */ import type { Request, Response, NextFunction } from 'express'; import type { AuthMiddlewareOptions } from '../types.js'; /** * Create an authentication middleware for Express * * @example * ```typescript * import { createAuthMiddleware } from '@originals/auth/server'; * * const authenticateUser = createAuthMiddleware({ * getUserByTurnkeyId: async (turnkeyId) => { * return db.query.users.findFirst({ * where: eq(users.turnkeySubOrgId, turnkeyId) * }); * }, * createUser: async (turnkeyId, email, temporaryDid) => { * return db.insert(users).values({ * turnkeySubOrgId: turnkeyId, * email, * did: temporaryDid, * }).returning().then(rows => rows[0]); * } * }); * * app.get('/api/protected', authenticateUser, (req, res) => { * res.json({ user: req.user }); * }); * ``` */ export declare function createAuthMiddleware(options: AuthMiddlewareOptions): (req: Request, res: Response, next: NextFunction) => Promise; /** * Optional authentication middleware - doesn't fail if not authenticated * Attaches user to request if valid token exists, otherwise continues without user */ export declare function createOptionalAuthMiddleware(options: AuthMiddlewareOptions): (req: Request, res: Response, next: NextFunction) => Promise; //# sourceMappingURL=middleware.d.ts.map