UNPKG

@foundry-ai/api-auth

Version:
22 lines (21 loc) 871 B
/// <reference types="express" /> import { NextFunction, Request, Response } from 'express'; import { AuthenticationError, BadRequestError, ForbiddenError, InternalError, NotFoundError, RateLimitError } from '@foundry-ai/api-errors'; import { ApiAuthConfiguration } from './util/ClientConfigFactory'; export default function (config: ApiAuthConfiguration): (req: Request, res: Response, next: NextFunction) => void; export declare function tokenFromReq(req: Request): string; export declare function toResJson(err: InternalError | AuthenticationError | BadRequestError | ForbiddenError | NotFoundError | RateLimitError): { type: string; status: number; message: string; }; declare global { namespace Express { interface Request { auth: { userId: string; scope: string; }; } } }