@layr-labs/ecloud-sdk 0.3.3-dev → 0.3.4-dev

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/index.js CHANGED
@@ -4535,7 +4535,7 @@ async function undelegate(options, logger = noopLogger) {
4535
4535
  }
4536
4536
 
4537
4537
  // src/client/common/utils/userapi.ts
4538
- import axios from "axios";
4538
+ import axios2 from "axios";
4539
4539
 
4540
4540
  // src/client/common/utils/auth.ts
4541
4541
  import { parseAbi } from "viem";
@@ -4592,6 +4592,41 @@ async function calculateBillingAuthSignature(options) {
4592
4592
  return { signature, expiry };
4593
4593
  }
4594
4594
 
4595
+ // src/client/common/utils/retry.ts
4596
+ import axios from "axios";
4597
+ var MAX_RETRIES = 5;
4598
+ var INITIAL_BACKOFF_MS = 1e3;
4599
+ var MAX_BACKOFF_MS = 3e4;
4600
+ function sleep(ms) {
4601
+ return new Promise((resolve2) => setTimeout(resolve2, ms));
4602
+ }
4603
+ function getRetryDelay(res, attempt) {
4604
+ const backoff = Math.min(INITIAL_BACKOFF_MS * Math.pow(2, attempt), MAX_BACKOFF_MS);
4605
+ const retryAfter = res.headers["retry-after"];
4606
+ if (retryAfter) {
4607
+ const seconds = parseInt(retryAfter, 10);
4608
+ if (!isNaN(seconds) && seconds > 0) {
4609
+ return Math.min(seconds * 1e3, MAX_BACKOFF_MS);
4610
+ }
4611
+ }
4612
+ return backoff;
4613
+ }
4614
+ async function requestWithRetry(config) {
4615
+ let lastResponse;
4616
+ for (let attempt = 0; attempt <= MAX_RETRIES; attempt++) {
4617
+ const res = await axios({ ...config, validateStatus: () => true });
4618
+ lastResponse = res;
4619
+ if (res.status !== 429) {
4620
+ return res;
4621
+ }
4622
+ if (attempt < MAX_RETRIES) {
4623
+ const delay = getRetryDelay(res, attempt);
4624
+ await sleep(delay);
4625
+ }
4626
+ }
4627
+ return lastResponse;
4628
+ }
4629
+
4595
4630
  // src/client/common/utils/userapi.ts
4596
4631
  init_session();
4597
4632
  function isJsonObject(value) {
@@ -4610,7 +4645,7 @@ var CanViewAppLogsPermission = "0x2fd3f2fe";
4610
4645
  var CanViewSensitiveAppInfoPermission = "0x0e67b22f";
4611
4646
  var CanUpdateAppProfilePermission = "0x036fef61";
4612
4647
  function getDefaultClientId() {
4613
- const version = true ? "0.3.3-dev" : "0.0.0";
4648
+ const version = true ? "0.3.4-dev" : "0.0.0";
4614
4649
  return `ecloud-sdk/v${version}`;
4615
4650
  }
4616
4651
  var UserApiClient = class {
@@ -4745,7 +4780,7 @@ var UserApiClient = class {
4745
4780
  Object.assign(headers, authHeaders);
4746
4781
  }
4747
4782
  try {
4748
- const response = await axios.post(endpoint, formData, {
4783
+ const response = await axios2.post(endpoint, formData, {
4749
4784
  headers,
4750
4785
  maxRedirects: 0,
4751
4786
  validateStatus: () => true,
@@ -4795,11 +4830,11 @@ Please check:
4795
4830
  Object.assign(headers, authHeaders);
4796
4831
  }
4797
4832
  try {
4798
- const response = await axios.get(url, {
4833
+ const response = await requestWithRetry({
4834
+ method: "GET",
4835
+ url,
4799
4836
  headers,
4800
4837
  maxRedirects: 0,
4801
- validateStatus: () => true,
4802
- // Don't throw on any status
4803
4838
  withCredentials: true
4804
4839
  // Include cookies for session auth
4805
4840
  });
@@ -4983,7 +5018,7 @@ async function watchUntilRunning(options, logger) {
4983
5018
  try {
4984
5019
  const info = await userApiClient.getInfos([appId], 1);
4985
5020
  if (info.length === 0) {
4986
- await sleep(WATCH_POLL_INTERVAL_SECONDS * 1e3);
5021
+ await sleep2(WATCH_POLL_INTERVAL_SECONDS * 1e3);
4987
5022
  continue;
4988
5023
  }
4989
5024
  const appInfo = info[0];
@@ -4992,10 +5027,10 @@ async function watchUntilRunning(options, logger) {
4992
5027
  if (stopCondition(currentStatus, currentIP)) {
4993
5028
  return currentIP || void 0;
4994
5029
  }
4995
- await sleep(WATCH_POLL_INTERVAL_SECONDS * 1e3);
5030
+ await sleep2(WATCH_POLL_INTERVAL_SECONDS * 1e3);
4996
5031
  } catch (error) {
4997
5032
  logger.warn(`Failed to fetch app info: ${error.message}`);
4998
- await sleep(WATCH_POLL_INTERVAL_SECONDS * 1e3);
5033
+ await sleep2(WATCH_POLL_INTERVAL_SECONDS * 1e3);
4999
5034
  }
5000
5035
  }
5001
5036
  }
@@ -5043,7 +5078,7 @@ async function watchUntilUpgradeComplete(options, logger) {
5043
5078
  try {
5044
5079
  const info = await userApiClient.getInfos([appId], 1);
5045
5080
  if (info.length === 0) {
5046
- await sleep(WATCH_POLL_INTERVAL_SECONDS * 1e3);
5081
+ await sleep2(WATCH_POLL_INTERVAL_SECONDS * 1e3);
5047
5082
  continue;
5048
5083
  }
5049
5084
  const appInfo = info[0];
@@ -5052,14 +5087,14 @@ async function watchUntilUpgradeComplete(options, logger) {
5052
5087
  if (stopCondition(currentStatus, currentIP)) {
5053
5088
  return;
5054
5089
  }
5055
- await sleep(WATCH_POLL_INTERVAL_SECONDS * 1e3);
5090
+ await sleep2(WATCH_POLL_INTERVAL_SECONDS * 1e3);
5056
5091
  } catch (error) {
5057
5092
  logger.warn(`Failed to fetch app info: ${error.message}`);
5058
- await sleep(WATCH_POLL_INTERVAL_SECONDS * 1e3);
5093
+ await sleep2(WATCH_POLL_INTERVAL_SECONDS * 1e3);
5059
5094
  }
5060
5095
  }
5061
5096
  }
5062
- function sleep(ms) {
5097
+ function sleep2(ms) {
5063
5098
  return new Promise((resolve2) => setTimeout(resolve2, ms));
5064
5099
  }
5065
5100
 
@@ -5517,7 +5552,7 @@ function isSubscriptionActive(status) {
5517
5552
  }
5518
5553
 
5519
5554
  // src/client/common/utils/billingapi.ts
5520
- import axios2 from "axios";
5555
+ import axios3 from "axios";
5521
5556
 
5522
5557
  // src/client/common/auth/billingSession.ts
5523
5558
  var BillingSessionError = class extends Error {
@@ -5830,7 +5865,7 @@ Please check:
5830
5865
  headers["Content-Type"] = "application/json";
5831
5866
  }
5832
5867
  try {
5833
- const response = await axios2({
5868
+ const response = await axios3({
5834
5869
  method,
5835
5870
  url,
5836
5871
  headers,
@@ -7922,38 +7957,6 @@ function createBillingModule(config) {
7922
7957
  }
7923
7958
 
7924
7959
  // src/client/common/utils/buildapi.ts
7925
- import axios3 from "axios";
7926
- var MAX_RETRIES = 5;
7927
- var INITIAL_BACKOFF_MS = 1e3;
7928
- var MAX_BACKOFF_MS = 3e4;
7929
- async function sleep2(ms) {
7930
- return new Promise((resolve2) => setTimeout(resolve2, ms));
7931
- }
7932
- function getRetryDelay(res, attempt) {
7933
- const retryAfter = res.headers["retry-after"];
7934
- if (retryAfter) {
7935
- const seconds = parseInt(retryAfter, 10);
7936
- if (!isNaN(seconds)) {
7937
- return Math.min(seconds * 1e3, MAX_BACKOFF_MS);
7938
- }
7939
- }
7940
- return Math.min(INITIAL_BACKOFF_MS * Math.pow(2, attempt), MAX_BACKOFF_MS);
7941
- }
7942
- async function requestWithRetry(config) {
7943
- let lastResponse;
7944
- for (let attempt = 0; attempt <= MAX_RETRIES; attempt++) {
7945
- const res = await axios3({ ...config, validateStatus: () => true });
7946
- lastResponse = res;
7947
- if (res.status !== 429) {
7948
- return res;
7949
- }
7950
- if (attempt < MAX_RETRIES) {
7951
- const delay = getRetryDelay(res, attempt);
7952
- await sleep2(delay);
7953
- }
7954
- }
7955
- return lastResponse;
7956
- }
7957
7960
  var BuildApiClient = class {
7958
7961
  constructor(options) {
7959
7962
  let url = options.baseUrl;