UNPKG

@authx/http-proxy-resource

Version:

The AuthX proxy for resources is a flexible HTTP proxy designed to sit in front of a resource.

39 lines (38 loc) 925 B
/// <reference types="node" resolution-mode="require"/> import { EventEmitter } from "events"; interface FetchConfig { method: "POST"; headers: { "Content-Type": "application/json"; Authorization: string; }; body: string; } export interface FetchFunction { (uri: string, conf: FetchConfig): Promise<FetchResponse>; } interface FetchResponse { status: number; json(): Promise<any>; } interface TokenDataCacheConfig { fetchFunc: FetchFunction; timeSource: () => number; tokenRefreshSeconds: number; tokenExpirySeconds: number; authxUrl: string; } export interface TokenData { access: string[]; id: string; user: { id: string; }; } export declare class TokenDataCache extends EventEmitter { private conf; private cache; constructor(conf: TokenDataCacheConfig); getToken(basicToken: string): Promise<TokenData>; } export {};