UNPKG

@wristband/express-auth

Version:

SDK for integrating your ExpressJS application with Wristband. Handles user authentication, session management, and token management.

46 lines (45 loc) 1.52 kB
import { Request, Response, NextFunction } from 'express'; import { Session, SessionData, SessionOptions } from '@wristband/typescript-session'; /** * Augments the Express Request interface to include a session property. * * This type declaration adds the `session` property to all Express Request objects, * providing type-safe access to session data and methods throughout your Express application. * * To add custom fields to your session data, augment the SessionData interface: * * @example * ```typescript * declare module '@wristband/typescript-session' { * interface SessionData { * cartId?: string; * theme?: 'light' | 'dark'; * } * } * ``` */ declare module 'express-serve-static-core' { interface Request { /** Session instance with management methods and typed data access */ session: Session<SessionData> & SessionData; } } /** * Create Wristband session middleware for Express. * * @param options - Session configuration options from @wristband/typescript-session * @returns Express middleware function * * @example * ```typescript * import { createWristbandSession } from '@wristband/express-auth'; * * app.use(createWristbandSession({ * secrets: process.env.SESSION_SECRET, * cookieName: 'my-app.session', * maxAge: 3600, // 1 hour * secure: process.env.NODE_ENV === 'production' * })); * ``` */ export declare function createWristbandSession(options: SessionOptions): (req: Request, res: Response, next: NextFunction) => void;