myinvois-sdk
Version:
TypeScript SDK for interacting with the Malaysia e-invoicing system (MyInvois) API
53 lines (52 loc) • 1.81 kB
TypeScript
import { HttpClient } from '../utils/http-client';
import { MyInvoisConfig } from '../config';
/**
* Authentication service for MyInvois API
*/
export declare class AuthService {
private httpClient;
private config;
private tokenManager;
/**
* Creates a new authentication service
* @param httpClient The HTTP client to use
* @param config The MyInvois configuration
*/
constructor(httpClient: HttpClient, config: MyInvoisConfig);
/**
* Authenticate with the MyInvois system
* @returns A promise resolving to the authentication token
*/
authenticateSystem(): Promise<string>;
/**
* Authenticate on behalf of a taxpayer
* @param taxpayerTIN The taxpayer's TIN
* @returns A promise resolving to the authentication token
*/
authenticateAsIntermediary(taxpayerTIN: string): Promise<string>;
/**
* Get a valid token for a specific TIN or the system
* @param authTIN The TIN to get a token for, or null for system token
* @returns A promise resolving to the authentication token
*/
getToken(authTIN?: string): Promise<string>;
/**
* Get all TINs with valid tokens
* @returns An array of TINs with valid tokens
*/
getAllAuthenticatedTINs(): string[];
/**
* Validate a taxpayer's TIN
* @param taxpayerTIN The taxpayer's TIN
* @param idType The type of ID
* @param idValue The value of the ID
* @param authTIN The TIN to use for authentication
* @returns A promise resolving to the validation result with consistent format
*/
validateTaxpayerTIN(taxpayerTIN: string, idType: string, idValue: string, authTIN?: string): Promise<{
isValid: boolean;
statusCode: number;
message: string;
data?: any;
}>;
}