myinvois-sdk
Version:
TypeScript SDK for interacting with the Malaysia e-invoicing system (MyInvois) API
52 lines (51 loc) • 1.58 kB
TypeScript
/**
* Manages authentication tokens for multiple TINs
*/
export declare class TokenManager {
private tokens;
private defaultToken;
/**
* Sets a token for a specific TIN
* @param tin The TIN to set the token for
* @param token The token to set
* @param expiresIn The token expiry in seconds
*/
setTokenForTIN(tin: string, token: string, expiresIn: number): void;
/**
* Sets the default token (for system authentication)
* @param token The token to set
* @param expiresIn The token expiry in seconds
*/
setDefaultToken(token: string, expiresIn: number): void;
/**
* Gets a token for a specific TIN if it exists and is valid
* @param tin The TIN to get the token for
* @returns The token if it exists and is valid, null otherwise
*/
getTokenForTIN(tin: string): string | null;
/**
* Gets the default token if it exists and is valid
* @returns The default token if it exists and is valid, null otherwise
*/
getDefaultToken(): string | null;
/**
* Checks if a token for a specific TIN is valid
* @param tin The TIN to check
* @returns Whether the token is valid
*/
isTokenValid(tin: string): boolean;
/**
* Checks if the default token is valid
* @returns Whether the default token is valid
*/
isDefaultTokenValid(): boolean;
/**
* Gets all TINs with stored tokens
* @returns An array of TINs
*/
getAllTINs(): string[];
/**
* Clears all tokens
*/
clearAllTokens(): void;
}