UNPKG

kotanipay-sdk

Version:

Official Kotani Pay SDK for Node.js and Browser

57 lines 1.87 kB
import { HttpClientUtil } from '../utils/http-client.util'; import { IntegratorService } from '../modules/integrator'; import { AuthService } from '../modules/auth'; import { MobileMoneyService } from '../modules/mobile-money/mobile-money.service'; export class KotaniPayClient { constructor(config) { // Create HTTP client with config this.httpClient = new HttpClientUtil(config); // Initialize services this.integrator = new IntegratorService(this.httpClient); this.auth = new AuthService(this.httpClient); this.mobileMoney = new MobileMoneyService(this.httpClient); } /** * Initialize client with session data after user login */ initializeWithSession(sessionData) { this.auth.setSession(sessionData); } /** * Initialize client with API key (for authenticated operations) */ initializeWithApiKey(apiKey) { this.httpClient.setAuthToken(apiKey, 'Bearer'); } async healthCheck() { const response = await this.httpClient.get('/health'); return response; } getConfig() { return this.httpClient.getConfig(); } getVersion() { return '1.0.0'; } /** * Check if client is authenticated */ isAuthenticated() { return this.auth.isAuthenticated() || !!this.httpClient.getAuthToken(); } /** * Get authentication status with detailed info */ getAuthStatus() { const hasSession = !!this.auth.getSession(); const hasApiKey = !!this.httpClient.getAuthToken(); const tokenInfo = this.auth.getTokenInfo ? this.auth.getTokenInfo() : null; return { isAuthenticated: this.isAuthenticated(), hasSession, hasApiKey, tokenInfo }; } } //# sourceMappingURL=kotani-pay.client.js.map