@layr-labs/ecloud-sdk 1.0.0-dev.2 → 1.0.0-dev.3

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
package/dist/browser.cjs CHANGED
@@ -357,7 +357,13 @@ function getEnvironmentConfig(environment, chainID) {
357
357
  return {
358
358
  ...env,
359
359
  chainID: BigInt(resolvedChainID),
360
- ...apiUrlOverride ? { userApiServerURL: apiUrlOverride } : {}
360
+ ...apiUrlOverride ? { userApiServerURL: apiUrlOverride } : {},
361
+ ...process.env.ECLOUD_USER_API_URL && {
362
+ userApiServerURL: process.env.ECLOUD_USER_API_URL
363
+ },
364
+ ...process.env.ECLOUD_RPC_URL && {
365
+ defaultRPCURL: process.env.ECLOUD_RPC_URL
366
+ }
361
367
  };
362
368
  }
363
369
  function getBillingEnvironmentConfig(build) {
@@ -369,7 +375,12 @@ function getBillingEnvironmentConfig(build) {
369
375
  if (apiUrlOverride) {
370
376
  return { billingApiServerURL: apiUrlOverride };
371
377
  }
372
- return config;
378
+ return {
379
+ ...config,
380
+ ...process.env.ECLOUD_BILLING_API_URL && {
381
+ billingApiServerURL: process.env.ECLOUD_BILLING_API_URL
382
+ }
383
+ };
373
384
  }
374
385
  function getBuildType() {
375
386
  const buildTimeType = true ? "dev"?.toLowerCase() : void 0;
@@ -729,7 +740,7 @@ var CanViewAppLogsPermission = "0x2fd3f2fe";
729
740
  var CanViewSensitiveAppInfoPermission = "0x0e67b22f";
730
741
  var CanUpdateAppProfilePermission = "0x036fef61";
731
742
  function getDefaultClientId() {
732
- const version = true ? "1.0.0-dev.2" : "0.0.0";
743
+ const version = true ? "1.0.0-dev.3" : "0.0.0";
733
744
  return `ecloud-sdk/v${version}`;
734
745
  }
735
746
  var UserApiClient = class {
@@ -1317,6 +1328,20 @@ var BillingApiClient = class {
1317
1328
  const endpoint = `${this.config.billingApiServerURL}/products/${productId}/subscription`;
1318
1329
  await this.makeAuthenticatedRequest(endpoint, "DELETE", productId);
1319
1330
  }
1331
+ async getPaymentMethods() {
1332
+ const endpoint = `${this.config.billingApiServerURL}/v1/payment-methods`;
1333
+ const resp = await this.makeAuthenticatedRequest(endpoint, "GET", "compute");
1334
+ return resp.json();
1335
+ }
1336
+ async purchaseCredits(amountCents, paymentMethodId) {
1337
+ const endpoint = `${this.config.billingApiServerURL}/v1/credits/purchase`;
1338
+ const body = { amountCents };
1339
+ if (paymentMethodId) {
1340
+ body.paymentMethodId = paymentMethodId;
1341
+ }
1342
+ const resp = await this.makeAuthenticatedRequest(endpoint, "POST", "compute", body);
1343
+ return resp.json();
1344
+ }
1320
1345
  // ==========================================================================
1321
1346
  // Internal Methods
1322
1347
  // ==========================================================================
@@ -1326,10 +1351,22 @@ var BillingApiClient = class {
1326
1351
  * Uses session auth if useSession is true, otherwise uses EIP-712 signature auth.
1327
1352
  */
1328
1353
  async makeAuthenticatedRequest(url, method, productId, body) {
1329
- if (this.useSession) {
1330
- return this.makeSessionAuthenticatedRequest(url, method, body);
1354
+ if (this.options.verbose) {
1355
+ console.debug(`[BillingAPI] ${method} ${url}`);
1356
+ if (body) {
1357
+ console.debug(`[BillingAPI] Payload:`, JSON.stringify(body, null, 2));
1358
+ }
1359
+ }
1360
+ const resp = this.useSession ? await this.makeSessionAuthenticatedRequest(url, method, body) : await this.makeSignatureAuthenticatedRequest(url, method, productId, body);
1361
+ if (this.options.verbose) {
1362
+ const data = await resp.json();
1363
+ console.debug(`[BillingAPI] Response:`, JSON.stringify(data, null, 2));
1364
+ return {
1365
+ json: async () => data,
1366
+ text: async () => JSON.stringify(data)
1367
+ };
1331
1368
  }
1332
- return this.makeSignatureAuthenticatedRequest(url, method, productId, body);
1369
+ return resp;
1333
1370
  }
1334
1371
  /**
1335
1372
  * Make a request using session-based authentication (cookies)