import { MutexInterface } from 'async-mutex'; import { EndpointClientConfig, HttpClientHeaders } from './endpoint-client'; /** * Implement this interface to implement a process for handling authentication. * * This is not meant to be a "service" in the traditional sense because * implementors are not expected to be stateless. */ export interface Authenticator { login?(): Promise; logout?(): Promise; refresh?(clientConfig: EndpointClientConfig): Promise; acquireRefreshMutex?(): Promise; /** * Performs required authentication steps and returns credentials as a set of HTTP headers which * must be included in authenticated requests. * Expected to perform any required steps (such as token refresh) needed to return valid credentials. * * @returns {string} valid auth token */ authenticate(): Promise; } /** * For use in tests or on endpoints that don't need any authentication. */ export declare class NoOpAuthenticator implements Authenticator { authenticate(): Promise; } /** * A simple bearer token authenticator that knows nothing about refreshing * or logging in our out. If the token is expired, it simply won't work. */ export declare class BearerTokenAuthenticator implements Authenticator { token: string; constructor(token: string); authenticate(): Promise; } export interface AuthData { authToken: string; refreshToken: string; } export interface RefreshData { refreshToken: string; clientId: string; clientSecret: string; } export interface RefreshTokenStore { getRefreshData(): Promise; putAuthData(data: AuthData): Promise; } /** * An authenticator that supports refreshing of the access token using a refresh token by loading * the refresh token, client ID, and client secret from a token store, performing the refresh, and * storing the new tokens. * * Note that corruption of the refresh token is unlikely but possible if two of the same * authenticators refresh the same token at the same time. */ export declare class RefreshTokenAuthenticator implements Authenticator { token: string; private tokenStore; constructor(token: string, tokenStore: RefreshTokenStore); authenticate(): Promise; refresh(clientConfig: EndpointClientConfig): Promise; } /** * A an authenticator that works like RefreshTokenAuthenticator but which can use a mutex to help * prevent corruption of the refresh token. * * Note that while `acquireRefreshMutex` is provided for you to use the mutex, the mutex is not * automatically used. */ export declare class SequentialRefreshTokenAuthenticator extends RefreshTokenAuthenticator { private refreshMutex; constructor(token: string, tokenStore: RefreshTokenStore, refreshMutex: MutexInterface); acquireRefreshMutex(): Promise; } //# sourceMappingURL=authenticator.d.ts.map