@layr-labs/ecloud-sdk 0.3.3 → 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.cjs CHANGED
@@ -354,7 +354,7 @@ function getBillingEnvironmentConfig(build) {
354
354
  return config;
355
355
  }
356
356
  function getBuildType() {
357
- const buildTimeType = true ? "prod"?.toLowerCase() : void 0;
357
+ const buildTimeType = true ? "dev"?.toLowerCase() : void 0;
358
358
  const runtimeType = process.env.BUILD_TYPE?.toLowerCase();
359
359
  const buildType = buildTimeType || runtimeType;
360
360
  if (buildType === "dev") {
@@ -601,7 +601,7 @@ function generateNewPrivateKey() {
601
601
  }
602
602
 
603
603
  // src/client/common/utils/userapi.ts
604
- var import_axios = __toESM(require("axios"), 1);
604
+ var import_axios2 = __toESM(require("axios"), 1);
605
605
 
606
606
  // src/client/common/utils/auth.ts
607
607
  var import_viem3 = require("viem");
@@ -658,6 +658,41 @@ async function calculateBillingAuthSignature(options) {
658
658
  return { signature, expiry };
659
659
  }
660
660
 
661
+ // src/client/common/utils/retry.ts
662
+ var import_axios = __toESM(require("axios"), 1);
663
+ var MAX_RETRIES = 5;
664
+ var INITIAL_BACKOFF_MS = 1e3;
665
+ var MAX_BACKOFF_MS = 3e4;
666
+ function sleep(ms) {
667
+ return new Promise((resolve) => setTimeout(resolve, ms));
668
+ }
669
+ function getRetryDelay(res, attempt) {
670
+ const backoff = Math.min(INITIAL_BACKOFF_MS * Math.pow(2, attempt), MAX_BACKOFF_MS);
671
+ const retryAfter = res.headers["retry-after"];
672
+ if (retryAfter) {
673
+ const seconds = parseInt(retryAfter, 10);
674
+ if (!isNaN(seconds) && seconds > 0) {
675
+ return Math.min(seconds * 1e3, MAX_BACKOFF_MS);
676
+ }
677
+ }
678
+ return backoff;
679
+ }
680
+ async function requestWithRetry(config) {
681
+ let lastResponse;
682
+ for (let attempt = 0; attempt <= MAX_RETRIES; attempt++) {
683
+ const res = await (0, import_axios.default)({ ...config, validateStatus: () => true });
684
+ lastResponse = res;
685
+ if (res.status !== 429) {
686
+ return res;
687
+ }
688
+ if (attempt < MAX_RETRIES) {
689
+ const delay = getRetryDelay(res, attempt);
690
+ await sleep(delay);
691
+ }
692
+ }
693
+ return lastResponse;
694
+ }
695
+
661
696
  // src/client/common/utils/userapi.ts
662
697
  init_session();
663
698
  function isJsonObject(value) {
@@ -676,7 +711,7 @@ var CanViewAppLogsPermission = "0x2fd3f2fe";
676
711
  var CanViewSensitiveAppInfoPermission = "0x0e67b22f";
677
712
  var CanUpdateAppProfilePermission = "0x036fef61";
678
713
  function getDefaultClientId() {
679
- const version = true ? "0.3.3" : "0.0.0";
714
+ const version = true ? "0.3.4-dev" : "0.0.0";
680
715
  return `ecloud-sdk/v${version}`;
681
716
  }
682
717
  var UserApiClient = class {
@@ -811,7 +846,7 @@ var UserApiClient = class {
811
846
  Object.assign(headers, authHeaders);
812
847
  }
813
848
  try {
814
- const response = await import_axios.default.post(endpoint, formData, {
849
+ const response = await import_axios2.default.post(endpoint, formData, {
815
850
  headers,
816
851
  maxRedirects: 0,
817
852
  validateStatus: () => true,
@@ -861,11 +896,11 @@ Please check:
861
896
  Object.assign(headers, authHeaders);
862
897
  }
863
898
  try {
864
- const response = await import_axios.default.get(url, {
899
+ const response = await requestWithRetry({
900
+ method: "GET",
901
+ url,
865
902
  headers,
866
903
  maxRedirects: 0,
867
- validateStatus: () => true,
868
- // Don't throw on any status
869
904
  withCredentials: true
870
905
  // Include cookies for session auth
871
906
  });
@@ -1013,7 +1048,7 @@ function transformAppRelease(raw) {
1013
1048
  }
1014
1049
 
1015
1050
  // src/client/common/utils/billingapi.ts
1016
- var import_axios2 = __toESM(require("axios"), 1);
1051
+ var import_axios3 = __toESM(require("axios"), 1);
1017
1052
 
1018
1053
  // src/client/common/auth/billingSession.ts
1019
1054
  var BillingSessionError = class extends Error {
@@ -1345,7 +1380,7 @@ Please check:
1345
1380
  headers["Content-Type"] = "application/json";
1346
1381
  }
1347
1382
  try {
1348
- const response = await (0, import_axios2.default)({
1383
+ const response = await (0, import_axios3.default)({
1349
1384
  method,
1350
1385
  url,
1351
1386
  headers,
@@ -1382,38 +1417,6 @@ Please check:
1382
1417
  };
1383
1418
 
1384
1419
  // src/client/common/utils/buildapi.ts
1385
- var import_axios3 = __toESM(require("axios"), 1);
1386
- var MAX_RETRIES = 5;
1387
- var INITIAL_BACKOFF_MS = 1e3;
1388
- var MAX_BACKOFF_MS = 3e4;
1389
- async function sleep(ms) {
1390
- return new Promise((resolve) => setTimeout(resolve, ms));
1391
- }
1392
- function getRetryDelay(res, attempt) {
1393
- const retryAfter = res.headers["retry-after"];
1394
- if (retryAfter) {
1395
- const seconds = parseInt(retryAfter, 10);
1396
- if (!isNaN(seconds)) {
1397
- return Math.min(seconds * 1e3, MAX_BACKOFF_MS);
1398
- }
1399
- }
1400
- return Math.min(INITIAL_BACKOFF_MS * Math.pow(2, attempt), MAX_BACKOFF_MS);
1401
- }
1402
- async function requestWithRetry(config) {
1403
- let lastResponse;
1404
- for (let attempt = 0; attempt <= MAX_RETRIES; attempt++) {
1405
- const res = await (0, import_axios3.default)({ ...config, validateStatus: () => true });
1406
- lastResponse = res;
1407
- if (res.status !== 429) {
1408
- return res;
1409
- }
1410
- if (attempt < MAX_RETRIES) {
1411
- const delay = getRetryDelay(res, attempt);
1412
- await sleep(delay);
1413
- }
1414
- }
1415
- return lastResponse;
1416
- }
1417
1420
  var BuildApiClient = class {
1418
1421
  constructor(options) {
1419
1422
  let url = options.baseUrl;