UNPKG

@authup/core-http-kit

Version:

Package containing global constants, types & interfaces.

35 lines 1.51 kB
import type { TokenGrantResponse } from '@hapic/oauth2'; import { EventEmitter } from '@posva/event-emitter'; import type { AuthorizationHeader, Client as BaseClient } from 'hapic'; import type { TokenCreator } from '../token-creator'; import type { ClientAuthenticationHookEvents, ClientAuthenticationHookOptions } from './types'; declare const HOOK_SYMBOL: unique symbol; export declare class ClientAuthenticationHook extends EventEmitter<{ [K in keyof ClientAuthenticationHookEvents as `${K}`]: ClientAuthenticationHookEvents[K]; }> { protected isActive: boolean; protected authorizationHeader: AuthorizationHeader | undefined; protected clients: BaseClient[]; protected creator: TokenCreator; protected options: ClientAuthenticationHookOptions; protected timer: ReturnType<typeof setTimeout> | undefined; protected refreshPromise?: Promise<TokenGrantResponse>; constructor(options: ClientAuthenticationHookOptions); enable(): void; disable(): void; setAuthorizationHeader(value: AuthorizationHeader): void; unsetAuthorizationHeader(): void; isAttached(client: BaseClient): client is BaseClient & Record<typeof HOOK_SYMBOL, unknown>; attach(client: BaseClient): void; detach(client: BaseClient): void; setTimer(expiresIn: number): void; clearTimer(): void; /** * Refresh token * * @throws ClientError */ protected refresh(): Promise<TokenGrantResponse>; } export {}; //# sourceMappingURL=module.d.ts.map