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

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
@@ -330,6 +330,12 @@ var CHAIN_ID_TO_ENVIRONMENT = {
330
330
  [SEPOLIA_CHAIN_ID.toString()]: "sepolia",
331
331
  [MAINNET_CHAIN_ID.toString()]: "mainnet-alpha"
332
332
  };
333
+ function getApiUrlOverride() {
334
+ const raw = process.env.ECLOUD_API_URL;
335
+ if (!raw) return void 0;
336
+ const trimmed = raw.trim().replace(/\/+$/, "");
337
+ return trimmed.length > 0 ? trimmed : void 0;
338
+ }
333
339
  function getEnvironmentConfig(environment, chainID) {
334
340
  const env = ENVIRONMENTS[environment];
335
341
  if (!env) {
@@ -347,15 +353,11 @@ function getEnvironmentConfig(environment, chainID) {
347
353
  }
348
354
  }
349
355
  const resolvedChainID = chainID || (environment === "sepolia" || environment === "sepolia-dev" ? SEPOLIA_CHAIN_ID : MAINNET_CHAIN_ID);
356
+ const apiUrlOverride = getApiUrlOverride();
350
357
  return {
351
358
  ...env,
352
359
  chainID: BigInt(resolvedChainID),
353
- ...process.env.ECLOUD_USER_API_URL && {
354
- userApiServerURL: process.env.ECLOUD_USER_API_URL
355
- },
356
- ...process.env.ECLOUD_RPC_URL && {
357
- defaultRPCURL: process.env.ECLOUD_RPC_URL
358
- }
360
+ ...apiUrlOverride ? { userApiServerURL: apiUrlOverride } : {}
359
361
  };
360
362
  }
361
363
  function getBillingEnvironmentConfig(build) {
@@ -363,12 +365,11 @@ function getBillingEnvironmentConfig(build) {
363
365
  if (!config) {
364
366
  throw new Error(`Unknown billing environment: ${build}`);
365
367
  }
366
- return {
367
- ...config,
368
- ...process.env.ECLOUD_BILLING_API_URL && {
369
- billingApiServerURL: process.env.ECLOUD_BILLING_API_URL
370
- }
371
- };
368
+ const apiUrlOverride = getApiUrlOverride();
369
+ if (apiUrlOverride) {
370
+ return { billingApiServerURL: apiUrlOverride };
371
+ }
372
+ return config;
372
373
  }
373
374
  function getBuildType() {
374
375
  const buildTimeType = true ? "dev"?.toLowerCase() : void 0;
@@ -728,7 +729,7 @@ var CanViewAppLogsPermission = "0x2fd3f2fe";
728
729
  var CanViewSensitiveAppInfoPermission = "0x0e67b22f";
729
730
  var CanUpdateAppProfilePermission = "0x036fef61";
730
731
  function getDefaultClientId() {
731
- const version = true ? "1.0.0-dev.1" : "0.0.0";
732
+ const version = true ? "1.0.0-dev.2" : "0.0.0";
732
733
  return `ecloud-sdk/v${version}`;
733
734
  }
734
735
  var UserApiClient = class {
@@ -1316,20 +1317,6 @@ var BillingApiClient = class {
1316
1317
  const endpoint = `${this.config.billingApiServerURL}/products/${productId}/subscription`;
1317
1318
  await this.makeAuthenticatedRequest(endpoint, "DELETE", productId);
1318
1319
  }
1319
- async getPaymentMethods() {
1320
- const endpoint = `${this.config.billingApiServerURL}/v1/payment-methods`;
1321
- const resp = await this.makeAuthenticatedRequest(endpoint, "GET", "compute");
1322
- return resp.json();
1323
- }
1324
- async purchaseCredits(amountCents, paymentMethodId) {
1325
- const endpoint = `${this.config.billingApiServerURL}/v1/credits/purchase`;
1326
- const body = { amountCents };
1327
- if (paymentMethodId) {
1328
- body.paymentMethodId = paymentMethodId;
1329
- }
1330
- const resp = await this.makeAuthenticatedRequest(endpoint, "POST", "compute", body);
1331
- return resp.json();
1332
- }
1333
1320
  // ==========================================================================
1334
1321
  // Internal Methods
1335
1322
  // ==========================================================================
@@ -1339,19 +1326,10 @@ var BillingApiClient = class {
1339
1326
  * Uses session auth if useSession is true, otherwise uses EIP-712 signature auth.
1340
1327
  */
1341
1328
  async makeAuthenticatedRequest(url, method, productId, body) {
1342
- if (this.options.verbose) {
1343
- console.debug(`[BillingAPI] ${method} ${url}`);
1344
- }
1345
- const resp = this.useSession ? await this.makeSessionAuthenticatedRequest(url, method, body) : await this.makeSignatureAuthenticatedRequest(url, method, productId, body);
1346
- if (this.options.verbose) {
1347
- const data = await resp.json();
1348
- console.debug(`[BillingAPI] Response:`, JSON.stringify(data, null, 2));
1349
- return {
1350
- json: async () => data,
1351
- text: async () => JSON.stringify(data)
1352
- };
1329
+ if (this.useSession) {
1330
+ return this.makeSessionAuthenticatedRequest(url, method, body);
1353
1331
  }
1354
- return resp;
1332
+ return this.makeSignatureAuthenticatedRequest(url, method, productId, body);
1355
1333
  }
1356
1334
  /**
1357
1335
  * Make a request using session-based authentication (cookies)