@stratosphere-network/wallet
Version:
Wallet module for StratoSphere SDK
130 lines • 4.76 kB
JavaScript
"use strict";
var __createBinding = (this && this.__createBinding) || (Object.create ? (function(o, m, k, k2) {
if (k2 === undefined) k2 = k;
var desc = Object.getOwnPropertyDescriptor(m, k);
if (!desc || ("get" in desc ? !m.__esModule : desc.writable || desc.configurable)) {
desc = { enumerable: true, get: function() { return m[k]; } };
}
Object.defineProperty(o, k2, desc);
}) : (function(o, m, k, k2) {
if (k2 === undefined) k2 = k;
o[k2] = m[k];
}));
var __exportStar = (this && this.__exportStar) || function(m, exports) {
for (var p in m) if (p !== "default" && !Object.prototype.hasOwnProperty.call(exports, p)) __createBinding(exports, m, p);
};
Object.defineProperty(exports, "__esModule", { value: true });
exports.NotificationService = exports.Environment = exports.Sphere = void 0;
const types_1 = require("./types");
Object.defineProperty(exports, "Environment", { enumerable: true, get: function () { return types_1.Environment; } });
const http_client_1 = require("./http-client");
const auth_1 = require("./services/auth");
const wallet_1 = require("./services/wallet");
const transactions_1 = require("./services/transactions");
const payment_links_1 = require("./services/payment-links");
const proxy_wallet_1 = require("./services/proxy-wallet");
const defi_1 = require("./services/defi");
const assets_1 = require("./services/assets");
const onramp_1 = require("./services/onramp");
const notifications_1 = require("./services/notifications");
class Sphere {
config;
httpClient;
// Service instances
auth;
wallet;
transactions;
paymentLinks;
proxyWallet;
defi;
assets;
onramp;
notifications;
constructor(config) {
this.config = config;
this.httpClient = new http_client_1.SphereHttpClient(config);
// Initialize all services
this.auth = new auth_1.AuthService(this.httpClient);
this.wallet = new wallet_1.WalletService(this.httpClient);
this.transactions = new transactions_1.TransactionService(this.httpClient);
this.paymentLinks = new payment_links_1.PaymentLinksService(this.httpClient);
this.proxyWallet = new proxy_wallet_1.ProxyWalletService(this.httpClient);
this.defi = new defi_1.DeFiService(this.httpClient);
this.assets = new assets_1.AssetsService(this.httpClient);
this.onramp = new onramp_1.OnrampService(this.httpClient, config);
this.notifications = new notifications_1.NotificationService(this.httpClient);
}
/**
* Set the API key for project authentication
*/
setApiKey(apiKey) {
this.httpClient.setApiKey(apiKey);
}
/**
* Set the bearer token for user authentication across all services
*/
setBearerToken(token) {
this.auth.setBearerToken(token);
this.wallet.setBearerToken(token);
this.transactions.setBearerToken(token);
this.paymentLinks.setBearerToken(token);
this.proxyWallet.setBearerToken(token);
this.defi.setBearerToken(token);
this.assets.setBearerToken(token);
this.notifications.setBearerToken(token);
// Note: onramp doesn't use bearer tokens
}
/**
* Clear the bearer token from all services
*/
clearBearerToken() {
this.auth.clearBearerToken();
this.wallet.clearBearerToken();
this.transactions.clearBearerToken();
this.paymentLinks.clearBearerToken();
this.proxyWallet.clearBearerToken();
this.defi.clearBearerToken();
this.assets.clearBearerToken();
this.notifications.clearBearerToken();
// Note: onramp doesn't use bearer tokens
}
/**
* Set API key specifically for M-Pesa operations
*/
setMpesaApiKey(apiKey) {
this.onramp.setMpesaApiKey(apiKey);
}
/**
* Check if the SDK is configured with an API key
*/
hasApiKey() {
return !!this.config.apiKey;
}
/**
* Check if the user is authenticated
*/
isAuthenticated() {
return this.auth.isAuthenticated();
}
/**
* Get the current environment
*/
getEnvironment() {
return this.config.environment;
}
/**
* Get the base URL being used
*/
getBaseUrl() {
return this.httpClient["baseUrl"];
}
}
exports.Sphere = Sphere;
// Export types and enums for consumers
__exportStar(require("./types"), exports);
// Export service classes
var notifications_2 = require("./services/notifications");
Object.defineProperty(exports, "NotificationService", { enumerable: true, get: function () { return notifications_2.NotificationService; } });
// Default export
exports.default = Sphere;
//# sourceMappingURL=index.js.map