@ardrive/turbo-sdk 1.22.0 → 1.22.1

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.
@@ -310551,7 +310551,7 @@ var import_winston = __toESM(require_winston(), 1);
310551
310551
  init_dirname();
310552
310552
  init_buffer2();
310553
310553
  init_process2();
310554
- var version16 = "1.22.0-alpha.1";
310554
+ var version16 = "1.22.1-alpha.1";
310555
310555
 
310556
310556
  // src/common/logger.ts
310557
310557
  var TurboWinstonLogger = class _TurboWinstonLogger {
@@ -312124,11 +312124,6 @@ init_dirname();
312124
312124
  init_buffer2();
312125
312125
  init_process2();
312126
312126
 
312127
- // src/utils/axiosClient.ts
312128
- init_dirname();
312129
- init_buffer2();
312130
- init_process2();
312131
-
312132
312127
  // node_modules/axios/index.js
312133
312128
  init_dirname();
312134
312129
  init_buffer2();
@@ -314400,6 +314395,11 @@ var {
314400
314395
  mergeConfig: mergeConfig2
314401
314396
  } = axios_default;
314402
314397
 
314398
+ // src/utils/axiosClient.ts
314399
+ init_dirname();
314400
+ init_buffer2();
314401
+ init_process2();
314402
+
314403
314403
  // node_modules/axios-retry/lib/esm/index.js
314404
314404
  init_dirname();
314405
314405
  init_buffer2();
@@ -314609,19 +314609,20 @@ var defaultRequestHeaders = {
314609
314609
  "x-turbo-source-version": version16,
314610
314610
  "x-turbo-source-identifier": "turbo-sdk"
314611
314611
  };
314612
+ var defaultRetryConfig = (logger15 = TurboWinstonLogger.default) => ({
314613
+ retryDelay: axiosRetry.exponentialDelay,
314614
+ retries: 5,
314615
+ retryCondition: (error) => {
314616
+ return !(error instanceof CanceledError2) && axiosRetry.isIdempotentRequestError(error) && axiosRetry.isNetworkError(error);
314617
+ },
314618
+ onRetry: (retryCount, error) => {
314619
+ logger15.debug(`Request failed, ${error}. Retry attempt #${retryCount}...`);
314620
+ }
314621
+ });
314612
314622
  var createAxiosInstance = ({
314613
314623
  logger: logger15 = TurboWinstonLogger.default,
314614
314624
  axiosConfig = {},
314615
- retryConfig = {
314616
- retryDelay: axiosRetry.exponentialDelay,
314617
- retries: 3,
314618
- retryCondition: (error) => {
314619
- return !(error instanceof CanceledError2) && axiosRetry.isNetworkOrIdempotentRequestError(error);
314620
- },
314621
- onRetry: (retryCount, error) => {
314622
- logger15.debug(`Request failed, ${error}. Retry attempt #${retryCount}...`);
314623
- }
314624
- }
314625
+ retryConfig = defaultRetryConfig(logger15)
314625
314626
  } = {}) => {
314626
314627
  const axiosInstance = axios_default.create({
314627
314628
  ...axiosConfig,
@@ -314632,7 +314633,7 @@ var createAxiosInstance = ({
314632
314633
  validateStatus: () => true
314633
314634
  // don't throw on non-200 status codes
314634
314635
  });
314635
- if (retryConfig.retries && retryConfig.retries > 0) {
314636
+ if (retryConfig.retries !== void 0 && retryConfig.retries > 0) {
314636
314637
  axiosRetry(axiosInstance, retryConfig);
314637
314638
  }
314638
314639
  return axiosInstance;
@@ -314649,8 +314650,11 @@ var BaseError = class extends Error {
314649
314650
  }
314650
314651
  };
314651
314652
  var FailedRequestError = class extends BaseError {
314652
- constructor(status, message) {
314653
- super(`Failed request: ${status}: ${message}`);
314653
+ constructor(message, status) {
314654
+ super(
314655
+ `Failed request${status !== void 0 ? ` (Status ${status})` : ""}: ${message}`
314656
+ );
314657
+ this.status = status;
314654
314658
  }
314655
314659
  };
314656
314660
  var ProvidedInputError = class extends BaseError {
@@ -314693,18 +314697,10 @@ var TurboHTTPService = class {
314693
314697
  allowedStatuses = [200, 202],
314694
314698
  headers
314695
314699
  }) {
314696
- const { status, statusText, data } = await this.axios.get(endpoint, {
314697
- headers,
314698
- signal
314699
- });
314700
- if (!allowedStatuses.includes(status)) {
314701
- throw new FailedRequestError(
314702
- status,
314703
- // Return error message from server if available
314704
- typeof data === "string" ? data : statusText
314705
- );
314706
- }
314707
- return data;
314700
+ return this.tryRequest(
314701
+ () => this.axios.get(endpoint, { headers, signal }),
314702
+ allowedStatuses
314703
+ );
314708
314704
  }
314709
314705
  async post({
314710
314706
  endpoint,
@@ -314713,22 +314709,31 @@ var TurboHTTPService = class {
314713
314709
  headers,
314714
314710
  data
314715
314711
  }) {
314716
- const {
314717
- status,
314718
- statusText,
314719
- data: response
314720
- } = await this.axios.post(endpoint, data, {
314721
- headers,
314722
- signal
314723
- });
314724
- if (!allowedStatuses.includes(status)) {
314725
- throw new FailedRequestError(
314726
- status,
314727
- // Return error message from server if available
314728
- typeof response === "string" ? response : statusText
314729
- );
314712
+ return this.tryRequest(
314713
+ () => this.axios.post(endpoint, data, { headers, signal }),
314714
+ allowedStatuses
314715
+ );
314716
+ }
314717
+ async tryRequest(request3, allowedStatuses) {
314718
+ try {
314719
+ const { status, data, statusText } = await request3();
314720
+ if (!allowedStatuses.includes(status)) {
314721
+ throw new FailedRequestError(
314722
+ // Return error message from server if available
314723
+ typeof data === "string" ? data : statusText,
314724
+ status
314725
+ );
314726
+ }
314727
+ return data;
314728
+ } catch (error) {
314729
+ if (error instanceof CanceledError2) {
314730
+ throw error;
314731
+ }
314732
+ if (error instanceof AxiosError2) {
314733
+ throw new FailedRequestError(error.code ?? error.message, error.status);
314734
+ }
314735
+ throw error;
314730
314736
  }
314731
- return response;
314732
314737
  }
314733
314738
  };
314734
314739
 
@@ -349691,8 +349696,8 @@ var defaultUploadServiceURL = "https://upload.ardrive.io";
349691
349696
  var TurboUnauthenticatedUploadService = class {
349692
349697
  constructor({
349693
349698
  url = defaultUploadServiceURL,
349694
- retryConfig,
349695
349699
  logger: logger15 = TurboWinstonLogger.default,
349700
+ retryConfig = defaultRetryConfig(logger15),
349696
349701
  token = "arweave"
349697
349702
  }) {
349698
349703
  this.token = token;
@@ -349702,6 +349707,7 @@ var TurboUnauthenticatedUploadService = class {
349702
349707
  retryConfig,
349703
349708
  logger: this.logger
349704
349709
  });
349710
+ this.retryConfig = retryConfig;
349705
349711
  }
349706
349712
  async uploadSignedDataItem({
349707
349713
  dataItemStreamFactory,
@@ -349738,29 +349744,73 @@ var TurboAuthenticatedBaseUploadService = class extends TurboUnauthenticatedUplo
349738
349744
  signal,
349739
349745
  dataItemOpts
349740
349746
  }) {
349741
- const { dataItemStreamFactory, dataItemSizeFactory } = await this.signer.signDataItem({
349742
- fileStreamFactory,
349743
- fileSizeFactory,
349744
- dataItemOpts
349745
- });
349746
- const signedDataItem = dataItemStreamFactory();
349747
- this.logger.debug("Uploading signed data item...");
349748
- const headers = {
349749
- "content-type": "application/octet-stream",
349750
- "content-length": `${dataItemSizeFactory()}`
349751
- };
349752
- if (dataItemOpts !== void 0 && dataItemOpts.paidBy !== void 0) {
349753
- const paidBy = Array.isArray(dataItemOpts.paidBy) ? dataItemOpts.paidBy : [dataItemOpts.paidBy];
349754
- if (dataItemOpts.paidBy.length > 0) {
349755
- headers["x-paid-by"] = paidBy;
349747
+ let retries = 0;
349748
+ const maxRetries = this.retryConfig.retries ?? 3;
349749
+ const retryDelay = this.retryConfig.retryDelay ?? ((retryNumber) => retryNumber * 1e3);
349750
+ let lastError = void 0;
349751
+ let lastStatusCode = void 0;
349752
+ while (retries < maxRetries) {
349753
+ if (signal?.aborted) {
349754
+ throw new CanceledError2();
349755
+ }
349756
+ const { dataItemStreamFactory, dataItemSizeFactory } = await this.signer.signDataItem({
349757
+ fileStreamFactory,
349758
+ fileSizeFactory,
349759
+ dataItemOpts
349760
+ });
349761
+ try {
349762
+ this.logger.debug("Uploading signed data item...");
349763
+ const headers = {
349764
+ "content-type": "application/octet-stream",
349765
+ "content-length": `${dataItemSizeFactory()}`
349766
+ };
349767
+ if (dataItemOpts !== void 0 && dataItemOpts.paidBy !== void 0) {
349768
+ const paidBy = Array.isArray(dataItemOpts.paidBy) ? dataItemOpts.paidBy : [dataItemOpts.paidBy];
349769
+ if (dataItemOpts.paidBy.length > 0) {
349770
+ headers["x-paid-by"] = paidBy;
349771
+ }
349772
+ }
349773
+ const data = await this.httpService.post({
349774
+ endpoint: `/tx/${this.token}`,
349775
+ signal,
349776
+ data: dataItemStreamFactory(),
349777
+ headers
349778
+ });
349779
+ return data;
349780
+ } catch (error) {
349781
+ lastError = error;
349782
+ if (error instanceof AxiosError2) {
349783
+ lastStatusCode = error.response?.status;
349784
+ } else if (error instanceof FailedRequestError) {
349785
+ lastStatusCode = error.status;
349786
+ }
349787
+ if (lastStatusCode !== void 0 && lastStatusCode >= 400 && lastStatusCode < 500) {
349788
+ break;
349789
+ }
349790
+ this.logger.debug(
349791
+ `Upload failed on attempt ${retries + 1}/${maxRetries + 1}`,
349792
+ { message: error instanceof Error ? error.message : error },
349793
+ error
349794
+ );
349795
+ retries++;
349796
+ const abortEventPromise = new Promise((resolve3) => {
349797
+ signal?.addEventListener("abort", () => {
349798
+ resolve3();
349799
+ });
349800
+ });
349801
+ await Promise.race([
349802
+ sleep(retryDelay(retries, error)),
349803
+ abortEventPromise
349804
+ ]);
349756
349805
  }
349757
349806
  }
349758
- return this.httpService.post({
349759
- endpoint: `/tx/${this.token}`,
349760
- signal,
349761
- data: signedDataItem,
349762
- headers
349763
- });
349807
+ const msg = `Failed to upload file after ${maxRetries + 1} attempts
349808
+ ${lastError instanceof Error ? lastError.message : lastError}`;
349809
+ if (lastError instanceof FailedRequestError) {
349810
+ lastError.message = msg;
349811
+ throw lastError;
349812
+ }
349813
+ throw new FailedRequestError(msg, lastStatusCode);
349764
349814
  }
349765
349815
  async generateManifest({
349766
349816
  paths,
@@ -1,6 +1,22 @@
1
1
  "use strict";
2
2
  Object.defineProperty(exports, "__esModule", { value: true });
3
3
  exports.TurboHTTPService = void 0;
4
+ /**
5
+ * Copyright (C) 2022-2024 Permanent Data Solutions, Inc.
6
+ *
7
+ * Licensed under the Apache License, Version 2.0 (the "License");
8
+ * you may not use this file except in compliance with the License.
9
+ * You may obtain a copy of the License at
10
+ *
11
+ * http://www.apache.org/licenses/LICENSE-2.0
12
+ *
13
+ * Unless required by applicable law or agreed to in writing, software
14
+ * distributed under the License is distributed on an "AS IS" BASIS,
15
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
16
+ * See the License for the specific language governing permissions and
17
+ * limitations under the License.
18
+ */
19
+ const axios_1 = require("axios");
4
20
  const axiosClient_js_1 = require("../utils/axiosClient.js");
5
21
  const errors_js_1 = require("../utils/errors.js");
6
22
  class TurboHTTPService {
@@ -26,28 +42,30 @@ class TurboHTTPService {
26
42
  });
27
43
  }
28
44
  async get({ endpoint, signal, allowedStatuses = [200, 202], headers, }) {
29
- const { status, statusText, data } = await this.axios.get(endpoint, {
30
- headers,
31
- signal,
32
- });
33
- if (!allowedStatuses.includes(status)) {
34
- throw new errors_js_1.FailedRequestError(status,
35
- // Return error message from server if available
36
- typeof data === 'string' ? data : statusText);
37
- }
38
- return data;
45
+ return this.tryRequest(() => this.axios.get(endpoint, { headers, signal }), allowedStatuses);
39
46
  }
40
47
  async post({ endpoint, signal, allowedStatuses = [200, 202], headers, data, }) {
41
- const { status, statusText, data: response, } = await this.axios.post(endpoint, data, {
42
- headers,
43
- signal,
44
- });
45
- if (!allowedStatuses.includes(status)) {
46
- throw new errors_js_1.FailedRequestError(status,
47
- // Return error message from server if available
48
- typeof response === 'string' ? response : statusText);
48
+ return this.tryRequest(() => this.axios.post(endpoint, data, { headers, signal }), allowedStatuses);
49
+ }
50
+ async tryRequest(request, allowedStatuses) {
51
+ try {
52
+ const { status, data, statusText } = await request();
53
+ if (!allowedStatuses.includes(status)) {
54
+ throw new errors_js_1.FailedRequestError(
55
+ // Return error message from server if available
56
+ typeof data === 'string' ? data : statusText, status);
57
+ }
58
+ return data;
59
+ }
60
+ catch (error) {
61
+ if (error instanceof axios_1.CanceledError) {
62
+ throw error;
63
+ }
64
+ if (error instanceof axios_1.AxiosError) {
65
+ throw new errors_js_1.FailedRequestError(error.code ?? error.message, error.status);
66
+ }
67
+ throw error;
49
68
  }
50
- return response;
51
69
  }
52
70
  }
53
71
  exports.TurboHTTPService = TurboHTTPService;
@@ -16,8 +16,12 @@ exports.TurboAuthenticatedBaseUploadService = exports.TurboUnauthenticatedUpload
16
16
  * See the License for the specific language governing permissions and
17
17
  * limitations under the License.
18
18
  */
19
+ const axios_1 = require("axios");
19
20
  const node_buffer_1 = require("node:buffer");
20
21
  const plimit_lit_1 = require("plimit-lit");
22
+ const axiosClient_js_1 = require("../utils/axiosClient.js");
23
+ const common_js_1 = require("../utils/common.js");
24
+ const errors_js_1 = require("../utils/errors.js");
21
25
  const http_js_1 = require("./http.js");
22
26
  const logger_js_1 = require("./logger.js");
23
27
  exports.creditSharingTagNames = {
@@ -29,7 +33,7 @@ exports.creditSharingTagNames = {
29
33
  exports.developmentUploadServiceURL = 'https://upload.ardrive.dev';
30
34
  exports.defaultUploadServiceURL = 'https://upload.ardrive.io';
31
35
  class TurboUnauthenticatedUploadService {
32
- constructor({ url = exports.defaultUploadServiceURL, retryConfig, logger = logger_js_1.TurboWinstonLogger.default, token = 'arweave', }) {
36
+ constructor({ url = exports.defaultUploadServiceURL, logger = logger_js_1.TurboWinstonLogger.default, retryConfig = (0, axiosClient_js_1.defaultRetryConfig)(logger), token = 'arweave', }) {
33
37
  this.token = token;
34
38
  this.logger = logger;
35
39
  this.httpService = new http_js_1.TurboHTTPService({
@@ -37,6 +41,7 @@ class TurboUnauthenticatedUploadService {
37
41
  retryConfig,
38
42
  logger: this.logger,
39
43
  });
44
+ this.retryConfig = retryConfig;
40
45
  }
41
46
  async uploadSignedDataItem({ dataItemStreamFactory, dataItemSizeFactory, signal, }) {
42
47
  const fileSize = dataItemSizeFactory();
@@ -61,32 +66,79 @@ class TurboAuthenticatedBaseUploadService extends TurboUnauthenticatedUploadServ
61
66
  this.signer = signer;
62
67
  }
63
68
  async uploadFile({ fileStreamFactory, fileSizeFactory, signal, dataItemOpts, }) {
64
- const { dataItemStreamFactory, dataItemSizeFactory } = await this.signer.signDataItem({
65
- fileStreamFactory,
66
- fileSizeFactory,
67
- dataItemOpts,
68
- });
69
- const signedDataItem = dataItemStreamFactory();
70
- this.logger.debug('Uploading signed data item...');
71
- // TODO: add p-limit constraint or replace with separate upload class
72
- const headers = {
73
- 'content-type': 'application/octet-stream',
74
- 'content-length': `${dataItemSizeFactory()}`,
75
- };
76
- if (dataItemOpts !== undefined && dataItemOpts.paidBy !== undefined) {
77
- const paidBy = Array.isArray(dataItemOpts.paidBy)
78
- ? dataItemOpts.paidBy
79
- : [dataItemOpts.paidBy];
80
- if (dataItemOpts.paidBy.length > 0) {
81
- headers['x-paid-by'] = paidBy;
69
+ let retries = 0;
70
+ const maxRetries = this.retryConfig.retries ?? 3;
71
+ const retryDelay = this.retryConfig.retryDelay ??
72
+ ((retryNumber) => retryNumber * 1000);
73
+ let lastError = undefined; // Store the last error for throwing
74
+ let lastStatusCode = undefined; // Store the last status code for throwing
75
+ while (retries < maxRetries) {
76
+ if (signal?.aborted) {
77
+ throw new axios_1.CanceledError();
78
+ }
79
+ const { dataItemStreamFactory, dataItemSizeFactory } = await this.signer.signDataItem({
80
+ fileStreamFactory,
81
+ fileSizeFactory,
82
+ dataItemOpts,
83
+ });
84
+ try {
85
+ this.logger.debug('Uploading signed data item...');
86
+ // TODO: add p-limit constraint or replace with separate upload class
87
+ const headers = {
88
+ 'content-type': 'application/octet-stream',
89
+ 'content-length': `${dataItemSizeFactory()}`,
90
+ };
91
+ if (dataItemOpts !== undefined && dataItemOpts.paidBy !== undefined) {
92
+ const paidBy = Array.isArray(dataItemOpts.paidBy)
93
+ ? dataItemOpts.paidBy
94
+ : [dataItemOpts.paidBy];
95
+ if (dataItemOpts.paidBy.length > 0) {
96
+ headers['x-paid-by'] = paidBy;
97
+ }
98
+ }
99
+ const data = await this.httpService.post({
100
+ endpoint: `/tx/${this.token}`,
101
+ signal,
102
+ data: dataItemStreamFactory(),
103
+ headers,
104
+ });
105
+ return data;
106
+ }
107
+ catch (error) {
108
+ // Store the last encountered error and status for re-throwing after retries
109
+ lastError = error;
110
+ if (error instanceof axios_1.AxiosError) {
111
+ lastStatusCode = error.response?.status;
112
+ }
113
+ else if (error instanceof errors_js_1.FailedRequestError) {
114
+ lastStatusCode = error.status;
115
+ }
116
+ if (lastStatusCode !== undefined &&
117
+ lastStatusCode >= 400 &&
118
+ lastStatusCode < 500) {
119
+ // Don't retry client error codes
120
+ break;
121
+ }
122
+ this.logger.debug(`Upload failed on attempt ${retries + 1}/${maxRetries + 1}`, { message: error instanceof Error ? error.message : error }, error);
123
+ retries++;
124
+ const abortEventPromise = new Promise((resolve) => {
125
+ signal?.addEventListener('abort', () => {
126
+ resolve();
127
+ });
128
+ });
129
+ await Promise.race([
130
+ (0, common_js_1.sleep)(retryDelay(retries, error)),
131
+ abortEventPromise,
132
+ ]);
82
133
  }
83
134
  }
84
- return this.httpService.post({
85
- endpoint: `/tx/${this.token}`,
86
- signal,
87
- data: signedDataItem,
88
- headers,
89
- });
135
+ const msg = `Failed to upload file after ${maxRetries + 1} attempts\n${lastError instanceof Error ? lastError.message : lastError}`;
136
+ // After all retries, throw the last error for catching
137
+ if (lastError instanceof errors_js_1.FailedRequestError) {
138
+ lastError.message = msg;
139
+ throw lastError;
140
+ }
141
+ throw new errors_js_1.FailedRequestError(msg, lastStatusCode);
90
142
  }
91
143
  async generateManifest({ paths, indexFile, fallbackFile, }) {
92
144
  const indexPath =
@@ -26,7 +26,7 @@ var __importDefault = (this && this.__importDefault) || function (mod) {
26
26
  return (mod && mod.__esModule) ? mod : { "default": mod };
27
27
  };
28
28
  Object.defineProperty(exports, "__esModule", { value: true });
29
- exports.createAxiosInstance = exports.defaultRequestHeaders = void 0;
29
+ exports.createAxiosInstance = exports.defaultRetryConfig = exports.defaultRequestHeaders = void 0;
30
30
  /**
31
31
  * Copyright (C) 2022-2024 Permanent Data Solutions, Inc.
32
32
  *
@@ -50,17 +50,20 @@ exports.defaultRequestHeaders = {
50
50
  'x-turbo-source-version': version_js_1.version,
51
51
  'x-turbo-source-identifier': 'turbo-sdk',
52
52
  };
53
- const createAxiosInstance = ({ logger = logger_js_1.TurboWinstonLogger.default, axiosConfig = {}, retryConfig = {
53
+ const defaultRetryConfig = (logger = logger_js_1.TurboWinstonLogger.default) => ({
54
54
  retryDelay: axios_retry_1.default.exponentialDelay,
55
- retries: 3,
55
+ retries: 5,
56
56
  retryCondition: (error) => {
57
57
  return (!(error instanceof axios_1.CanceledError) &&
58
- axios_retry_1.default.isNetworkOrIdempotentRequestError(error));
58
+ axios_retry_1.default.isIdempotentRequestError(error) &&
59
+ axios_retry_1.default.isNetworkError(error));
59
60
  },
60
61
  onRetry: (retryCount, error) => {
61
62
  logger.debug(`Request failed, ${error}. Retry attempt #${retryCount}...`);
62
63
  },
63
- }, } = {}) => {
64
+ });
65
+ exports.defaultRetryConfig = defaultRetryConfig;
66
+ const createAxiosInstance = ({ logger = logger_js_1.TurboWinstonLogger.default, axiosConfig = {}, retryConfig = (0, exports.defaultRetryConfig)(logger), } = {}) => {
64
67
  const axiosInstance = axios_1.default.create({
65
68
  ...axiosConfig,
66
69
  headers: {
@@ -69,8 +72,7 @@ const createAxiosInstance = ({ logger = logger_js_1.TurboWinstonLogger.default,
69
72
  },
70
73
  validateStatus: () => true, // don't throw on non-200 status codes
71
74
  });
72
- // eslint-disable-next-line
73
- if (retryConfig.retries && retryConfig.retries > 0) {
75
+ if (retryConfig.retries !== undefined && retryConfig.retries > 0) {
74
76
  (0, axios_retry_1.default)(axiosInstance, retryConfig);
75
77
  }
76
78
  return axiosInstance;
@@ -30,8 +30,9 @@ class UnauthenticatedRequestError extends BaseError {
30
30
  }
31
31
  exports.UnauthenticatedRequestError = UnauthenticatedRequestError;
32
32
  class FailedRequestError extends BaseError {
33
- constructor(status, message) {
34
- super(`Failed request: ${status}: ${message}`);
33
+ constructor(message, status) {
34
+ super(`Failed request${status !== undefined ? ` (Status ${status})` : ''}: ${message}`);
35
+ this.status = status;
35
36
  }
36
37
  }
37
38
  exports.FailedRequestError = FailedRequestError;
@@ -17,4 +17,4 @@
17
17
  Object.defineProperty(exports, "__esModule", { value: true });
18
18
  exports.version = void 0;
19
19
  // AUTOMATICALLY GENERATED FILE - DO NOT TOUCH
20
- exports.version = '1.22.0';
20
+ exports.version = '1.22.1';
@@ -1,3 +1,19 @@
1
+ /**
2
+ * Copyright (C) 2022-2024 Permanent Data Solutions, Inc.
3
+ *
4
+ * Licensed under the Apache License, Version 2.0 (the "License");
5
+ * you may not use this file except in compliance with the License.
6
+ * You may obtain a copy of the License at
7
+ *
8
+ * http://www.apache.org/licenses/LICENSE-2.0
9
+ *
10
+ * Unless required by applicable law or agreed to in writing, software
11
+ * distributed under the License is distributed on an "AS IS" BASIS,
12
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
13
+ * See the License for the specific language governing permissions and
14
+ * limitations under the License.
15
+ */
16
+ import { AxiosError, CanceledError } from 'axios';
1
17
  import { createAxiosInstance } from '../utils/axiosClient.js';
2
18
  import { FailedRequestError } from '../utils/errors.js';
3
19
  export class TurboHTTPService {
@@ -23,27 +39,29 @@ export class TurboHTTPService {
23
39
  });
24
40
  }
25
41
  async get({ endpoint, signal, allowedStatuses = [200, 202], headers, }) {
26
- const { status, statusText, data } = await this.axios.get(endpoint, {
27
- headers,
28
- signal,
29
- });
30
- if (!allowedStatuses.includes(status)) {
31
- throw new FailedRequestError(status,
32
- // Return error message from server if available
33
- typeof data === 'string' ? data : statusText);
34
- }
35
- return data;
42
+ return this.tryRequest(() => this.axios.get(endpoint, { headers, signal }), allowedStatuses);
36
43
  }
37
44
  async post({ endpoint, signal, allowedStatuses = [200, 202], headers, data, }) {
38
- const { status, statusText, data: response, } = await this.axios.post(endpoint, data, {
39
- headers,
40
- signal,
41
- });
42
- if (!allowedStatuses.includes(status)) {
43
- throw new FailedRequestError(status,
44
- // Return error message from server if available
45
- typeof response === 'string' ? response : statusText);
45
+ return this.tryRequest(() => this.axios.post(endpoint, data, { headers, signal }), allowedStatuses);
46
+ }
47
+ async tryRequest(request, allowedStatuses) {
48
+ try {
49
+ const { status, data, statusText } = await request();
50
+ if (!allowedStatuses.includes(status)) {
51
+ throw new FailedRequestError(
52
+ // Return error message from server if available
53
+ typeof data === 'string' ? data : statusText, status);
54
+ }
55
+ return data;
56
+ }
57
+ catch (error) {
58
+ if (error instanceof CanceledError) {
59
+ throw error;
60
+ }
61
+ if (error instanceof AxiosError) {
62
+ throw new FailedRequestError(error.code ?? error.message, error.status);
63
+ }
64
+ throw error;
46
65
  }
47
- return response;
48
66
  }
49
67
  }
@@ -13,8 +13,12 @@
13
13
  * See the License for the specific language governing permissions and
14
14
  * limitations under the License.
15
15
  */
16
+ import { AxiosError, CanceledError } from 'axios';
16
17
  import { Buffer } from 'node:buffer';
17
18
  import { pLimit } from 'plimit-lit';
19
+ import { defaultRetryConfig } from '../utils/axiosClient.js';
20
+ import { sleep } from '../utils/common.js';
21
+ import { FailedRequestError } from '../utils/errors.js';
18
22
  import { TurboHTTPService } from './http.js';
19
23
  import { TurboWinstonLogger } from './logger.js';
20
24
  export const creditSharingTagNames = {
@@ -26,7 +30,7 @@ export const creditSharingTagNames = {
26
30
  export const developmentUploadServiceURL = 'https://upload.ardrive.dev';
27
31
  export const defaultUploadServiceURL = 'https://upload.ardrive.io';
28
32
  export class TurboUnauthenticatedUploadService {
29
- constructor({ url = defaultUploadServiceURL, retryConfig, logger = TurboWinstonLogger.default, token = 'arweave', }) {
33
+ constructor({ url = defaultUploadServiceURL, logger = TurboWinstonLogger.default, retryConfig = defaultRetryConfig(logger), token = 'arweave', }) {
30
34
  this.token = token;
31
35
  this.logger = logger;
32
36
  this.httpService = new TurboHTTPService({
@@ -34,6 +38,7 @@ export class TurboUnauthenticatedUploadService {
34
38
  retryConfig,
35
39
  logger: this.logger,
36
40
  });
41
+ this.retryConfig = retryConfig;
37
42
  }
38
43
  async uploadSignedDataItem({ dataItemStreamFactory, dataItemSizeFactory, signal, }) {
39
44
  const fileSize = dataItemSizeFactory();
@@ -57,32 +62,79 @@ export class TurboAuthenticatedBaseUploadService extends TurboUnauthenticatedUpl
57
62
  this.signer = signer;
58
63
  }
59
64
  async uploadFile({ fileStreamFactory, fileSizeFactory, signal, dataItemOpts, }) {
60
- const { dataItemStreamFactory, dataItemSizeFactory } = await this.signer.signDataItem({
61
- fileStreamFactory,
62
- fileSizeFactory,
63
- dataItemOpts,
64
- });
65
- const signedDataItem = dataItemStreamFactory();
66
- this.logger.debug('Uploading signed data item...');
67
- // TODO: add p-limit constraint or replace with separate upload class
68
- const headers = {
69
- 'content-type': 'application/octet-stream',
70
- 'content-length': `${dataItemSizeFactory()}`,
71
- };
72
- if (dataItemOpts !== undefined && dataItemOpts.paidBy !== undefined) {
73
- const paidBy = Array.isArray(dataItemOpts.paidBy)
74
- ? dataItemOpts.paidBy
75
- : [dataItemOpts.paidBy];
76
- if (dataItemOpts.paidBy.length > 0) {
77
- headers['x-paid-by'] = paidBy;
65
+ let retries = 0;
66
+ const maxRetries = this.retryConfig.retries ?? 3;
67
+ const retryDelay = this.retryConfig.retryDelay ??
68
+ ((retryNumber) => retryNumber * 1000);
69
+ let lastError = undefined; // Store the last error for throwing
70
+ let lastStatusCode = undefined; // Store the last status code for throwing
71
+ while (retries < maxRetries) {
72
+ if (signal?.aborted) {
73
+ throw new CanceledError();
74
+ }
75
+ const { dataItemStreamFactory, dataItemSizeFactory } = await this.signer.signDataItem({
76
+ fileStreamFactory,
77
+ fileSizeFactory,
78
+ dataItemOpts,
79
+ });
80
+ try {
81
+ this.logger.debug('Uploading signed data item...');
82
+ // TODO: add p-limit constraint or replace with separate upload class
83
+ const headers = {
84
+ 'content-type': 'application/octet-stream',
85
+ 'content-length': `${dataItemSizeFactory()}`,
86
+ };
87
+ if (dataItemOpts !== undefined && dataItemOpts.paidBy !== undefined) {
88
+ const paidBy = Array.isArray(dataItemOpts.paidBy)
89
+ ? dataItemOpts.paidBy
90
+ : [dataItemOpts.paidBy];
91
+ if (dataItemOpts.paidBy.length > 0) {
92
+ headers['x-paid-by'] = paidBy;
93
+ }
94
+ }
95
+ const data = await this.httpService.post({
96
+ endpoint: `/tx/${this.token}`,
97
+ signal,
98
+ data: dataItemStreamFactory(),
99
+ headers,
100
+ });
101
+ return data;
102
+ }
103
+ catch (error) {
104
+ // Store the last encountered error and status for re-throwing after retries
105
+ lastError = error;
106
+ if (error instanceof AxiosError) {
107
+ lastStatusCode = error.response?.status;
108
+ }
109
+ else if (error instanceof FailedRequestError) {
110
+ lastStatusCode = error.status;
111
+ }
112
+ if (lastStatusCode !== undefined &&
113
+ lastStatusCode >= 400 &&
114
+ lastStatusCode < 500) {
115
+ // Don't retry client error codes
116
+ break;
117
+ }
118
+ this.logger.debug(`Upload failed on attempt ${retries + 1}/${maxRetries + 1}`, { message: error instanceof Error ? error.message : error }, error);
119
+ retries++;
120
+ const abortEventPromise = new Promise((resolve) => {
121
+ signal?.addEventListener('abort', () => {
122
+ resolve();
123
+ });
124
+ });
125
+ await Promise.race([
126
+ sleep(retryDelay(retries, error)),
127
+ abortEventPromise,
128
+ ]);
78
129
  }
79
130
  }
80
- return this.httpService.post({
81
- endpoint: `/tx/${this.token}`,
82
- signal,
83
- data: signedDataItem,
84
- headers,
85
- });
131
+ const msg = `Failed to upload file after ${maxRetries + 1} attempts\n${lastError instanceof Error ? lastError.message : lastError}`;
132
+ // After all retries, throw the last error for catching
133
+ if (lastError instanceof FailedRequestError) {
134
+ lastError.message = msg;
135
+ throw lastError;
136
+ }
137
+ throw new FailedRequestError(msg, lastStatusCode);
86
138
  }
87
139
  async generateManifest({ paths, indexFile, fallbackFile, }) {
88
140
  const indexPath =
@@ -21,17 +21,19 @@ export const defaultRequestHeaders = {
21
21
  'x-turbo-source-version': version,
22
22
  'x-turbo-source-identifier': 'turbo-sdk',
23
23
  };
24
- export const createAxiosInstance = ({ logger = TurboWinstonLogger.default, axiosConfig = {}, retryConfig = {
24
+ export const defaultRetryConfig = (logger = TurboWinstonLogger.default) => ({
25
25
  retryDelay: axiosRetry.exponentialDelay,
26
- retries: 3,
26
+ retries: 5,
27
27
  retryCondition: (error) => {
28
28
  return (!(error instanceof CanceledError) &&
29
- axiosRetry.isNetworkOrIdempotentRequestError(error));
29
+ axiosRetry.isIdempotentRequestError(error) &&
30
+ axiosRetry.isNetworkError(error));
30
31
  },
31
32
  onRetry: (retryCount, error) => {
32
33
  logger.debug(`Request failed, ${error}. Retry attempt #${retryCount}...`);
33
34
  },
34
- }, } = {}) => {
35
+ });
36
+ export const createAxiosInstance = ({ logger = TurboWinstonLogger.default, axiosConfig = {}, retryConfig = defaultRetryConfig(logger), } = {}) => {
35
37
  const axiosInstance = axios.create({
36
38
  ...axiosConfig,
37
39
  headers: {
@@ -40,8 +42,7 @@ export const createAxiosInstance = ({ logger = TurboWinstonLogger.default, axios
40
42
  },
41
43
  validateStatus: () => true, // don't throw on non-200 status codes
42
44
  });
43
- // eslint-disable-next-line
44
- if (retryConfig.retries && retryConfig.retries > 0) {
45
+ if (retryConfig.retries !== undefined && retryConfig.retries > 0) {
45
46
  axiosRetry(axiosInstance, retryConfig);
46
47
  }
47
48
  return axiosInstance;
@@ -25,8 +25,9 @@ export class UnauthenticatedRequestError extends BaseError {
25
25
  }
26
26
  }
27
27
  export class FailedRequestError extends BaseError {
28
- constructor(status, message) {
29
- super(`Failed request: ${status}: ${message}`);
28
+ constructor(message, status) {
29
+ super(`Failed request${status !== undefined ? ` (Status ${status})` : ''}: ${message}`);
30
+ this.status = status;
30
31
  }
31
32
  }
32
33
  export class ProvidedInputError extends BaseError {
@@ -14,4 +14,4 @@
14
14
  * limitations under the License.
15
15
  */
16
16
  // AUTOMATICALLY GENERATED FILE - DO NOT TOUCH
17
- export const version = '1.22.0';
17
+ export const version = '1.22.1';
@@ -40,5 +40,6 @@ export declare class TurboHTTPService implements TurboHTTPServiceInterface {
40
40
  headers?: Partial<TurboSignedRequestHeaders> & Record<string, string>;
41
41
  data: Readable | Buffer | ReadableStream;
42
42
  }): Promise<T>;
43
+ private tryRequest;
43
44
  }
44
45
  //# sourceMappingURL=http.d.ts.map
@@ -1 +1 @@
1
- {"version":3,"file":"http.d.ts","sourceRoot":"","sources":["../../../src/common/http.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;;;;;GAcG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AI,GACL,EAAE;QACD,QAAQ,EAAE,MAAM,CAAC;QACjB,MAAM,CAAC,EAAE,WAAW,CAAC;QACrB,eAAe,CAAC,EAAE,MAAM,EAAE,CAAC;QAC3B,OAAO,CAAC,EAAE,OAAO,CAAC,yBAAyB,CAAC,GAAG,MAAM,CAAC,MAAM,EAAE,MAAM,CAAC,CAAC;QACtE,IAAI,EAAE,QAAQ,GAAG,MAAM,GAAG,cAAc,CAAC;KAC1C,GAAG,OAAO,CAAC,CAAC,CAAC;YAOA,UAAU;CAwBzB"}
@@ -1,18 +1,4 @@
1
- /**
2
- * Copyright (C) 2022-2024 Permanent Data Solutions, Inc.
3
- *
4
- * Licensed under the Apache License, Version 2.0 (the "License");
5
- * you may not use this file except in compliance with the License.
6
- * You may obtain a copy of the License at
7
- *
8
- * http://www.apache.org/licenses/LICENSE-2.0
9
- *
10
- * Unless required by applicable law or agreed to in writing, software
11
- * distributed under the License is distributed on an "AS IS" BASIS,
12
- * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
13
- * See the License for the specific language governing permissions and
14
- * limitations under the License.
15
- */
1
+ import { IAxiosRetryConfig } from 'axios-retry';
16
2
  import { Buffer } from 'node:buffer';
17
3
  import { Readable } from 'node:stream';
18
4
  import { ArweaveManifest, CreditShareApproval, TokenType, TurboAbortSignal, TurboAuthenticatedUploadServiceConfiguration, TurboAuthenticatedUploadServiceInterface, TurboCreateCreditShareApprovalParams, TurboDataItemSigner, TurboFileFactory, TurboLogger, TurboRevokeCreditsParams, TurboSignedDataItemFactory, TurboUnauthenticatedUploadServiceConfiguration, TurboUnauthenticatedUploadServiceInterface, TurboUploadDataItemResponse, TurboUploadFolderParams, TurboUploadFolderResponse } from '../types.js';
@@ -29,7 +15,8 @@ export declare class TurboUnauthenticatedUploadService implements TurboUnauthent
29
15
  protected httpService: TurboHTTPService;
30
16
  protected logger: TurboLogger;
31
17
  protected token: TokenType;
32
- constructor({ url, retryConfig, logger, token, }: TurboUnauthenticatedUploadServiceConfiguration);
18
+ protected retryConfig: IAxiosRetryConfig;
19
+ constructor({ url, logger, retryConfig, token, }: TurboUnauthenticatedUploadServiceConfiguration);
33
20
  uploadSignedDataItem({ dataItemStreamFactory, dataItemSizeFactory, signal, }: TurboSignedDataItemFactory & TurboAbortSignal): Promise<TurboUploadDataItemResponse>;
34
21
  }
35
22
  export declare abstract class TurboAuthenticatedBaseUploadService extends TurboUnauthenticatedUploadService implements TurboAuthenticatedUploadServiceInterface {
@@ -1 +1 @@
1
- {"version":3,"file":"upload.d.ts","sourceRoot":"","sources":["../../../src/common/upload.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;;;;;GAcG;AACH,OAAO,EAAE,MAAM,EAAE,MAAM,aAAa,CAAC;AACrC,OAAO,EAAE,QAAQ,EAAE,MAAM,aAAa,CAAC;AAGvC,OAAO,EACL,eAAe,EACf,mBAAmB,EAEnB,SAAS,EACT,gBAAgB,EAChB,4CAA4C,EAC5C,wCAAwC,EACxC,oCAAoC,EACpC,mBAAmB,EACnB,gBAAgB,EAChB,WAAW,EACX,wBAAwB,EACxB,0BAA0B,EAC1B,8CAA8C,EAC9C,0CAA0C,EAC1C,2BAA2B,EAC3B,uBAAuB,EACvB,yBAAyB,EAC1B,MAAM,aAAa,CAAC;AACrB,OAAO,EAAE,gBAAgB,EAAE,MAAM,WAAW,CAAC;AAG7C,eAAO,MAAM,qBAAqB;;;;;CAKjC,CAAC;AAEF,eAAO,MAAM,2BAA2B,+BAA+B,CAAC;AACxE,eAAO,MAAM,uBAAuB,8BAA8B,CAAC;AAEnE,qBAAa,iCACX,YAAW,0CAA0C;IAErD,SAAS,CAAC,WAAW,EAAE,gBAAgB,CAAC;IACxC,SAAS,CAAC,MAAM,EAAE,WAAW,CAAC;IAC9B,SAAS,CAAC,KAAK,EAAE,SAAS,CAAC;gBAEf,EACV,GAA6B,EAC7B,WAAW,EACX,MAAmC,EACnC,KAAiB,GAClB,EAAE,8CAA8C;IAU3C,oBAAoB,CAAC,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,CAAC,oBAAoB,CAC3B,cAAc,EAAE,MAAM,GACrB,QAAQ,GAAG,cAAc;IAE5B,OAAO,CAAC,cAAc;IAchB,YAAY,CAChB,MAAM,EAAE,uBAAuB,GAC9B,OAAO,CAAC,yBAAyB,CAAC;IAqGxB,YAAY,CAAC,EACxB,eAAe,EACf,kBAAkB,EAClB,gBAAgB,GACjB,EAAE,oCAAoC,GAAG,OAAO,CAAC,mBAAmB,CAAC;IAqCzD,aAAa,CAAC,EACzB,cAAc,GACf,EAAE,wBAAwB,GAAG,OAAO,CAAC,mBAAmB,EAAE,CAAC;CAwB7D"}
@@ -25,5 +25,6 @@ export interface AxiosInstanceParameters {
25
25
  retryConfig?: IAxiosRetryConfig;
26
26
  logger?: TurboLogger;
27
27
  }
28
+ export declare const defaultRetryConfig: (logger?: TurboLogger) => IAxiosRetryConfig;
28
29
  export declare const createAxiosInstance: ({ logger, axiosConfig, retryConfig, }?: AxiosInstanceParameters) => AxiosInstance;
29
30
  //# sourceMappingURL=axiosClient.d.ts.map
@@ -1 +1 @@
1
- {"version":3,"file":"axiosClient.d.ts","sourceRoot":"","sources":["../../../src/utils/axiosClient.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;;;;;GAcG;AACH,OAAc,EAAE,aAAa,EAAE,kBAAkB,EAAiB,MAAM,OAAO,CAAC;AAChF,OAAmB,EAAE,iBAAiB,EAAE,MAAM,aAAa,CAAC;AAG5D,OAAO,EAAE,WAAW,EAAE,MAAM,aAAa,CAAC;AAG1C,eAAO,MAAM,qBAAqB;;;CAGjC,CAAC;AAEF,MAAM,WAAW,uBAAuB;IACtC,WAAW,CAAC,EAAE,IAAI,CAAC,kBAAkB,EAAE,gBAAgB,CAAC,CAAC;IACzD,WAAW,CAAC,EAAE,iBAAiB,CAAC;IAChC,MAAM,CAAC,EAAE,WAAW,CAAC;CACtB;AAED,eAAO,MAAM,mBAAmB,2CAgB7B,uBAAuB,KAAQ,aAgBjC,CAAC"}
1
+ {"version":3,"file":"axiosClient.d.ts","sourceRoot":"","sources":["../../../src/utils/axiosClient.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;;;;;GAcG;AACH,OAAc,EAAE,aAAa,EAAE,kBAAkB,EAAiB,MAAM,OAAO,CAAC;AAChF,OAAmB,EAAE,iBAAiB,EAAE,MAAM,aAAa,CAAC;AAG5D,OAAO,EAAE,WAAW,EAAE,MAAM,aAAa,CAAC;AAG1C,eAAO,MAAM,qBAAqB;;;CAGjC,CAAC;AAEF,MAAM,WAAW,uBAAuB;IACtC,WAAW,CAAC,EAAE,IAAI,CAAC,kBAAkB,EAAE,gBAAgB,CAAC,CAAC;IACzD,WAAW,CAAC,EAAE,iBAAiB,CAAC;IAChC,MAAM,CAAC,EAAE,WAAW,CAAC;CACtB;AAED,eAAO,MAAM,kBAAkB,EAAE,CAAC,MAAM,CAAC,EAAE,WAAW,KAAK,iBAezD,CAAC;AAEH,eAAO,MAAM,mBAAmB,2CAI7B,uBAAuB,KAAQ,aAejC,CAAC"}
@@ -20,7 +20,8 @@ export declare class UnauthenticatedRequestError extends BaseError {
20
20
  constructor();
21
21
  }
22
22
  export declare class FailedRequestError extends BaseError {
23
- constructor(status: number, message: string);
23
+ status?: number;
24
+ constructor(message: string, status?: number);
24
25
  }
25
26
  export declare class ProvidedInputError extends BaseError {
26
27
  constructor(message?: string);
@@ -1 +1 @@
1
- {"version":3,"file":"errors.d.ts","sourceRoot":"","sources":["../../../src/utils/errors.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;;;;;GAcG;AACH,qBAAa,SAAU,SAAQ,KAAK;gBACtB,OAAO,EAAE,MAAM;CAI5B;AAED,qBAAa,2BAA4B,SAAQ,SAAS;;CAIzD;AAED,qBAAa,kBAAmB,SAAQ,SAAS;gBACnC,MAAM,EAAE,MAAM,EAAE,OAAO,EAAE,MAAM;CAG5C;AAED,qBAAa,kBAAmB,SAAQ,SAAS;gBACnC,OAAO,CAAC,EAAE,MAAM;CAG7B"}
1
+ {"version":3,"file":"errors.d.ts","sourceRoot":"","sources":["../../../src/utils/errors.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;;;;;GAcG;AACH,qBAAa,SAAU,SAAQ,KAAK;gBACtB,OAAO,EAAE,MAAM;CAI5B;AAED,qBAAa,2BAA4B,SAAQ,SAAS;;CAIzD;AAED,qBAAa,kBAAmB,SAAQ,SAAS;IACxC,MAAM,CAAC,EAAE,MAAM,CAAC;gBACX,OAAO,EAAE,MAAM,EAAE,MAAM,CAAC,EAAE,MAAM;CAQ7C;AAED,qBAAa,kBAAmB,SAAQ,SAAS;gBACnC,OAAO,CAAC,EAAE,MAAM;CAG7B"}
@@ -13,5 +13,5 @@
13
13
  * See the License for the specific language governing permissions and
14
14
  * limitations under the License.
15
15
  */
16
- export declare const version = "1.22.0-alpha.1";
16
+ export declare const version = "1.22.1-alpha.1";
17
17
  //# sourceMappingURL=version.d.ts.map
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@ardrive/turbo-sdk",
3
- "version": "1.22.0",
3
+ "version": "1.22.1",
4
4
  "main": "./lib/cjs/node/index.js",
5
5
  "types": "./lib/types/node/index.d.ts",
6
6
  "module": "./lib/esm/node/index.js",