@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/browser.js CHANGED
@@ -492,7 +492,7 @@ function generateNewPrivateKey() {
492
492
  }
493
493
 
494
494
  // src/client/common/utils/userapi.ts
495
- import axios from "axios";
495
+ import axios2 from "axios";
496
496
 
497
497
  // src/client/common/utils/auth.ts
498
498
  import { parseAbi } from "viem";
@@ -549,6 +549,41 @@ async function calculateBillingAuthSignature(options) {
549
549
  return { signature, expiry };
550
550
  }
551
551
 
552
+ // src/client/common/utils/retry.ts
553
+ import axios from "axios";
554
+ var MAX_RETRIES = 5;
555
+ var INITIAL_BACKOFF_MS = 1e3;
556
+ var MAX_BACKOFF_MS = 3e4;
557
+ function sleep(ms) {
558
+ return new Promise((resolve) => setTimeout(resolve, ms));
559
+ }
560
+ function getRetryDelay(res, attempt) {
561
+ const backoff = Math.min(INITIAL_BACKOFF_MS * Math.pow(2, attempt), MAX_BACKOFF_MS);
562
+ const retryAfter = res.headers["retry-after"];
563
+ if (retryAfter) {
564
+ const seconds = parseInt(retryAfter, 10);
565
+ if (!isNaN(seconds) && seconds > 0) {
566
+ return Math.min(seconds * 1e3, MAX_BACKOFF_MS);
567
+ }
568
+ }
569
+ return backoff;
570
+ }
571
+ async function requestWithRetry(config) {
572
+ let lastResponse;
573
+ for (let attempt = 0; attempt <= MAX_RETRIES; attempt++) {
574
+ const res = await axios({ ...config, validateStatus: () => true });
575
+ lastResponse = res;
576
+ if (res.status !== 429) {
577
+ return res;
578
+ }
579
+ if (attempt < MAX_RETRIES) {
580
+ const delay = getRetryDelay(res, attempt);
581
+ await sleep(delay);
582
+ }
583
+ }
584
+ return lastResponse;
585
+ }
586
+
552
587
  // src/client/common/utils/userapi.ts
553
588
  init_session();
554
589
  function isJsonObject(value) {
@@ -567,7 +602,7 @@ var CanViewAppLogsPermission = "0x2fd3f2fe";
567
602
  var CanViewSensitiveAppInfoPermission = "0x0e67b22f";
568
603
  var CanUpdateAppProfilePermission = "0x036fef61";
569
604
  function getDefaultClientId() {
570
- const version = true ? "0.3.3-dev" : "0.0.0";
605
+ const version = true ? "0.3.4-dev" : "0.0.0";
571
606
  return `ecloud-sdk/v${version}`;
572
607
  }
573
608
  var UserApiClient = class {
@@ -702,7 +737,7 @@ var UserApiClient = class {
702
737
  Object.assign(headers, authHeaders);
703
738
  }
704
739
  try {
705
- const response = await axios.post(endpoint, formData, {
740
+ const response = await axios2.post(endpoint, formData, {
706
741
  headers,
707
742
  maxRedirects: 0,
708
743
  validateStatus: () => true,
@@ -752,11 +787,11 @@ Please check:
752
787
  Object.assign(headers, authHeaders);
753
788
  }
754
789
  try {
755
- const response = await axios.get(url, {
790
+ const response = await requestWithRetry({
791
+ method: "GET",
792
+ url,
756
793
  headers,
757
794
  maxRedirects: 0,
758
- validateStatus: () => true,
759
- // Don't throw on any status
760
795
  withCredentials: true
761
796
  // Include cookies for session auth
762
797
  });
@@ -904,7 +939,7 @@ function transformAppRelease(raw) {
904
939
  }
905
940
 
906
941
  // src/client/common/utils/billingapi.ts
907
- import axios2 from "axios";
942
+ import axios3 from "axios";
908
943
 
909
944
  // src/client/common/auth/billingSession.ts
910
945
  var BillingSessionError = class extends Error {
@@ -1236,7 +1271,7 @@ Please check:
1236
1271
  headers["Content-Type"] = "application/json";
1237
1272
  }
1238
1273
  try {
1239
- const response = await axios2({
1274
+ const response = await axios3({
1240
1275
  method,
1241
1276
  url,
1242
1277
  headers,
@@ -1273,38 +1308,6 @@ Please check:
1273
1308
  };
1274
1309
 
1275
1310
  // src/client/common/utils/buildapi.ts
1276
- import axios3 from "axios";
1277
- var MAX_RETRIES = 5;
1278
- var INITIAL_BACKOFF_MS = 1e3;
1279
- var MAX_BACKOFF_MS = 3e4;
1280
- async function sleep(ms) {
1281
- return new Promise((resolve) => setTimeout(resolve, ms));
1282
- }
1283
- function getRetryDelay(res, attempt) {
1284
- const retryAfter = res.headers["retry-after"];
1285
- if (retryAfter) {
1286
- const seconds = parseInt(retryAfter, 10);
1287
- if (!isNaN(seconds)) {
1288
- return Math.min(seconds * 1e3, MAX_BACKOFF_MS);
1289
- }
1290
- }
1291
- return Math.min(INITIAL_BACKOFF_MS * Math.pow(2, attempt), MAX_BACKOFF_MS);
1292
- }
1293
- async function requestWithRetry(config) {
1294
- let lastResponse;
1295
- for (let attempt = 0; attempt <= MAX_RETRIES; attempt++) {
1296
- const res = await axios3({ ...config, validateStatus: () => true });
1297
- lastResponse = res;
1298
- if (res.status !== 429) {
1299
- return res;
1300
- }
1301
- if (attempt < MAX_RETRIES) {
1302
- const delay = getRetryDelay(res, attempt);
1303
- await sleep(delay);
1304
- }
1305
- }
1306
- return lastResponse;
1307
- }
1308
1311
  var BuildApiClient = class {
1309
1312
  constructor(options) {
1310
1313
  let url = options.baseUrl;