import { Express } from 'express'; import { IdpProvider } from '../types/provider.js'; /** * The routes that are supported by the protocol middleware. */ export declare enum ProtocolRoute { SIGN_IN = "/sign-in", SIGN_UP = "/sign-up", SIGN_OUT = "/sign-out", ACCESS_TOKEN = "/access-token", USER = "/api/user", PROJECTS = "/api/projects" } /** * The options for the protocol middleware. * @property basePath - The base path for the protoc ol middleware. * @property routes - The routes that are supported by the protocol middleware. * @example * { * basePath: '/', * routes: { * signIn: '/signin', // override the default sign in route * signOut: '/signout', // override the default sign out route * accessToken: '/accesstoken', // override the default access token route * user: '/api/userinfo', // override the default user route * }, * } */ export interface IdpProtocolMiddlewareOptions { basePath?: string; routes?: { signIn?: string; signUp?: string; signOut?: string; accessToken?: string; user?: string; projects?: string; }; } /** * The protocol middleware for the IDP. * @param provider - The provider to use for the middleware. * @param options - The options for the middleware. * @example // Register the middleware with the default routes * const idpProtocolMiddleware = new IdpProtocolMiddleware(provider); * idpProtocolMiddleware.register(app); * * @example // Override the default routes * const app = express(); * const middlewareOptions: IdpProtocolMiddlewareOptions = { * basePath: '/', * routes: { * signIn: '/signin', * signOut: '/signout', * accessToken: '/accesstoken', * user: '/api/userinfo', * } * }; * const idpProtocolMiddleware = new IdpProtocolMiddleware(provider, middlewareOptions); * idpProtocolMiddleware.register(app); */ export declare class IdpProtocolMiddleware { private readonly provider; /** * The default base path for the protocol middleware. */ readonly DEFAULT_BASE_PATH = "/auth"; private readonly basePath; private readonly routes; /** * The constructor for the protocol middleware. * @param provider - The provider to use for the middleware. * @param options - The options for the middleware. */ constructor(provider: IdpProvider, options?: IdpProtocolMiddlewareOptions); /** * Normalize the base path. * @param path - The path to normalize. * @returns The normalized path. */ private normalizeBasePath; /** * Validate the configuration. */ private validateConfiguration; /** * Create a route handler. * @param handler - The handler to create. * @returns The created handler. */ private createRouteHandler; /** * Register the protocol middleware routes with the express app. * @param app - The express app to register the routes with. * @example * const app = express(); * const idpProtocolMiddleware = new IdpProtocolMiddleware(provider); * idpProtocolMiddleware.register(app); * app.listen(3000); */ register(app: Express): void; } //# sourceMappingURL=protocol-middleware.d.ts.map