@coolio/auth-interceptor
Version:
Authentication interceptor for Coolio
22 lines (21 loc) • 1.06 kB
TypeScript
import { HttpFetch, HttpInterceptorInterface, HttpResponse, NormalizedHttpOptions } from '@coolio/http';
import { AuthInterceptorOptions } from './authInterceptor.types';
export declare const hasUnauthorizedResponseCode: (response: HttpResponse<any>) => boolean;
export declare const isUnauthorizedError: (error: any) => boolean;
export declare class AuthInterceptor implements HttpInterceptorInterface {
private readonly options;
private readonly queue;
constructor(options: AuthInterceptorOptions);
readonly pendingRequestCount: number;
onIntercept<Body>(request: HttpFetch<Body>, options: NormalizedHttpOptions): HttpFetch<Body>;
private requestReauthorization;
/**
* Called when:
* - reauthorization fails,
* - a second request fails after reauthorization
*/
private handleAuthorizationError;
private handleUnauthorizedResponse;
}
export declare const createAuthInterceptor: (options: AuthInterceptorOptions) => AuthInterceptor;
//# sourceMappingURL=authInterceptor.d.ts.map