@foundry-ai/api-auth
Version:
Foundry.ai API auth middleware
22 lines (21 loc) • 871 B
TypeScript
/// <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;
};
}
}
}