UNPKG

@planet-a/affinity-node

Version:
56 lines (55 loc) 1.74 kB
import { RequestContext } from "../http/http.js"; /** * Interface authentication schemes. */ export interface SecurityAuthentication { getName(): string; /** * Applies the authentication scheme to the request context * * @params context the request context which should use this authentication scheme */ applySecurityAuthentication(context: RequestContext): void | Promise<void>; } export interface TokenProvider { getToken(): Promise<string> | string; } /** * Applies http authentication to the request context. */ export declare class BearerAuthAuthentication implements SecurityAuthentication { private tokenProvider; /** * Configures the http authentication with the required details. * * @param tokenProvider service that can provide the up-to-date token when needed */ constructor(tokenProvider: TokenProvider); getName(): string; applySecurityAuthentication(context: RequestContext): Promise<void>; } export type AuthMethods = { "default"?: SecurityAuthentication; "bearerAuth"?: SecurityAuthentication; }; export type ApiKeyConfiguration = string; export type HttpBasicConfiguration = { "username": string; "password": string; }; export type HttpBearerConfiguration = { tokenProvider: TokenProvider; }; export type OAuth2Configuration = { accessToken: string; }; export type HttpSignatureConfiguration = unknown; export type AuthMethodsConfiguration = { "default"?: SecurityAuthentication; "bearerAuth"?: HttpBearerConfiguration; }; /** * Creates the authentication methods from a swagger description. * */ export declare function configureAuthMethods(config: AuthMethodsConfiguration | undefined): AuthMethods;