UNPKG

kotanipay-sdk

Version:

Official Kotani Pay SDK for Node.js and Browser

61 lines 2.08 kB
"use strict"; Object.defineProperty(exports, "__esModule", { value: true }); exports.KotaniPayClient = void 0; const http_client_util_1 = require("../utils/http-client.util"); const integrator_1 = require("../modules/integrator"); const auth_1 = require("../modules/auth"); const mobile_money_service_1 = require("../modules/mobile-money/mobile-money.service"); class KotaniPayClient { constructor(config) { // Create HTTP client with config this.httpClient = new http_client_util_1.HttpClientUtil(config); // Initialize services this.integrator = new integrator_1.IntegratorService(this.httpClient); this.auth = new auth_1.AuthService(this.httpClient); this.mobileMoney = new mobile_money_service_1.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 }; } } exports.KotaniPayClient = KotaniPayClient; //# sourceMappingURL=kotani-pay.client.js.map