signicat-client-ts
Version:
Community TypeScript client for Signicat Authentication REST API with automatic token management
49 lines (48 loc) • 1.22 kB
TypeScript
export interface TokenOptions {
clientId: string;
clientSecret: string;
tokenUrl?: string;
scope?: string;
expirationBuffer?: number;
}
export interface TokenResponse {
access_token: string;
expires_in: number;
token_type: string;
}
export declare class TokenManager {
private tokenUrl;
private clientId;
private clientSecret;
private scope;
private expirationBuffer;
private currentToken;
private expiresAt;
private isRefreshing;
private refreshPromise;
constructor(options: TokenOptions);
/**
* get a valid access token
* if the token does not exist or has expired or is about to expire, get a new token
*/
getToken(): Promise<string>;
/**
* get a new access token
*/
private fetchNewToken;
/**
* 토큰을 강제로 갱신합니다.
* force refresh the token
*/
refreshToken(): Promise<string>;
/**
* 현재 토큰의 만료 시간을 확인합니다.
* check the expiration time of the current token
*/
getTokenExpiresAt(): number;
/**
* 토큰이 유효한지 확인합니다.
* check if the token is valid
*/
isTokenValid(): boolean;
}