@taquito/http-utils 22.0.0 → 23.0.0-beta.0

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.
@@ -30,11 +30,22 @@ var _a;
30
30
  Object.defineProperty(exports, "__esModule", { value: true });
31
31
  exports.HttpBackend = exports.HttpTimeoutError = exports.HttpResponseError = exports.HttpRequestFailed = exports.VERSION = void 0;
32
32
  let fetch = globalThis === null || globalThis === void 0 ? void 0 : globalThis.fetch;
33
+ let createAgent = undefined;
33
34
  // Will only use browser fetch if we are in a browser environment,
34
35
  // default to the more stable node-fetch otherwise
35
36
  const isNode = typeof process !== 'undefined' && !!((_a = process === null || process === void 0 ? void 0 : process.versions) === null || _a === void 0 ? void 0 : _a.node);
36
37
  if (isNode) {
37
38
  fetch = require('node-fetch');
39
+ if (Number(process.versions.node.split('.')[0]) >= 19) {
40
+ // we need agent with keepalive false for node 19 and above
41
+ createAgent = (url) => __awaiter(void 0, void 0, void 0, function* () {
42
+ const { Agent: HttpsAgent } = yield Promise.resolve().then(() => require('https'));
43
+ const { Agent: HttpAgent } = yield Promise.resolve().then(() => require('http'));
44
+ return url.startsWith('https')
45
+ ? new HttpsAgent({ keepAlive: false })
46
+ : new HttpAgent({ keepAlive: false });
47
+ });
48
+ }
38
49
  }
39
50
  const errors_1 = require("./errors");
40
51
  __exportStar(require("./status_code"), exports);
@@ -99,13 +110,9 @@ class HttpBackend {
99
110
  const controller = new AbortController();
100
111
  const t = setTimeout(() => controller.abort(), timeout);
101
112
  try {
102
- const response = yield fetch(urlWithQuery, {
103
- keepalive: false, // Disable keepalive (keepalive defaults to true starting from Node 19 & 20)
113
+ const response = yield fetch(urlWithQuery, Object.assign({ keepalive: false, // Disable keepalive (keepalive defaults to true starting from Node 19 & 20)
104
114
  method,
105
- headers,
106
- body: JSON.stringify(data),
107
- signal: controller.signal,
108
- });
115
+ headers, body: JSON.stringify(data), signal: controller.signal }, (isNode && createAgent ? { agent: yield createAgent(urlWithQuery) } : {})));
109
116
  if (typeof response === 'undefined') {
110
117
  throw new Error('Response is undefined');
111
118
  }
@@ -3,6 +3,6 @@ Object.defineProperty(exports, "__esModule", { value: true });
3
3
  exports.VERSION = void 0;
4
4
  // IMPORTANT: THIS FILE IS AUTO GENERATED! DO NOT MANUALLY EDIT OR CHECKIN!
5
5
  exports.VERSION = {
6
- "commitHash": "6a2c52b9e48b299dfc856149c1fa3388e77180ad",
7
- "version": "22.0.0"
6
+ "commitHash": "7af2138a9e5c5b230c4b4c726f35c2f2e67b721c",
7
+ "version": "23.0.0-beta.0"
8
8
  };
@@ -397,8 +397,8 @@ var STATUS_CODE;
397
397
 
398
398
  // IMPORTANT: THIS FILE IS AUTO GENERATED! DO NOT MANUALLY EDIT OR CHECKIN!
399
399
  const VERSION = {
400
- "commitHash": "6a2c52b9e48b299dfc856149c1fa3388e77180ad",
401
- "version": "22.0.0"
400
+ "commitHash": "7af2138a9e5c5b230c4b4c726f35c2f2e67b721c",
401
+ "version": "23.0.0-beta.0"
402
402
  };
403
403
 
404
404
  /**
@@ -407,11 +407,22 @@ const VERSION = {
407
407
  */
408
408
  var _a;
409
409
  let fetch = globalThis === null || globalThis === void 0 ? void 0 : globalThis.fetch;
410
+ let createAgent = undefined;
410
411
  // Will only use browser fetch if we are in a browser environment,
411
412
  // default to the more stable node-fetch otherwise
412
413
  const isNode = typeof process !== 'undefined' && !!((_a = process === null || process === void 0 ? void 0 : process.versions) === null || _a === void 0 ? void 0 : _a.node);
413
414
  if (isNode) {
414
415
  fetch = require('node-fetch');
416
+ if (Number(process.versions.node.split('.')[0]) >= 19) {
417
+ // we need agent with keepalive false for node 19 and above
418
+ createAgent = (url) => __awaiter(void 0, void 0, void 0, function* () {
419
+ const { Agent: HttpsAgent } = yield import('https');
420
+ const { Agent: HttpAgent } = yield import('http');
421
+ return url.startsWith('https')
422
+ ? new HttpsAgent({ keepAlive: false })
423
+ : new HttpAgent({ keepAlive: false });
424
+ });
425
+ }
415
426
  }
416
427
  class HttpBackend {
417
428
  constructor(timeout = 30000) {
@@ -468,13 +479,9 @@ class HttpBackend {
468
479
  const controller = new AbortController();
469
480
  const t = setTimeout(() => controller.abort(), timeout);
470
481
  try {
471
- const response = yield fetch(urlWithQuery, {
472
- keepalive: false, // Disable keepalive (keepalive defaults to true starting from Node 19 & 20)
482
+ const response = yield fetch(urlWithQuery, Object.assign({ keepalive: false, // Disable keepalive (keepalive defaults to true starting from Node 19 & 20)
473
483
  method,
474
- headers,
475
- body: JSON.stringify(data),
476
- signal: controller.signal,
477
- });
484
+ headers, body: JSON.stringify(data), signal: controller.signal }, (isNode && createAgent ? { agent: yield createAgent(urlWithQuery) } : {})));
478
485
  if (typeof response === 'undefined') {
479
486
  throw new Error('Response is undefined');
480
487
  }
@@ -1 +1 @@
1
- {"version":3,"file":"taquito-http-utils.es6.js","sources":[],"sourcesContent":[],"names":[],"mappings":";;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;"}
1
+ {"version":3,"file":"taquito-http-utils.es6.js","sources":[],"sourcesContent":[],"names":[],"mappings":";;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;"}
@@ -401,8 +401,8 @@
401
401
 
402
402
  // IMPORTANT: THIS FILE IS AUTO GENERATED! DO NOT MANUALLY EDIT OR CHECKIN!
403
403
  const VERSION = {
404
- "commitHash": "6a2c52b9e48b299dfc856149c1fa3388e77180ad",
405
- "version": "22.0.0"
404
+ "commitHash": "7af2138a9e5c5b230c4b4c726f35c2f2e67b721c",
405
+ "version": "23.0.0-beta.0"
406
406
  };
407
407
 
408
408
  /**
@@ -411,11 +411,22 @@
411
411
  */
412
412
  var _a;
413
413
  let fetch = globalThis === null || globalThis === void 0 ? void 0 : globalThis.fetch;
414
+ let createAgent = undefined;
414
415
  // Will only use browser fetch if we are in a browser environment,
415
416
  // default to the more stable node-fetch otherwise
416
417
  const isNode = typeof process !== 'undefined' && !!((_a = process === null || process === void 0 ? void 0 : process.versions) === null || _a === void 0 ? void 0 : _a.node);
417
418
  if (isNode) {
418
419
  fetch = require('node-fetch');
420
+ if (Number(process.versions.node.split('.')[0]) >= 19) {
421
+ // we need agent with keepalive false for node 19 and above
422
+ createAgent = (url) => __awaiter(void 0, void 0, void 0, function* () {
423
+ const { Agent: HttpsAgent } = yield import('https');
424
+ const { Agent: HttpAgent } = yield import('http');
425
+ return url.startsWith('https')
426
+ ? new HttpsAgent({ keepAlive: false })
427
+ : new HttpAgent({ keepAlive: false });
428
+ });
429
+ }
419
430
  }
420
431
  class HttpBackend {
421
432
  constructor(timeout = 30000) {
@@ -472,13 +483,9 @@
472
483
  const controller = new AbortController();
473
484
  const t = setTimeout(() => controller.abort(), timeout);
474
485
  try {
475
- const response = yield fetch(urlWithQuery, {
476
- keepalive: false, // Disable keepalive (keepalive defaults to true starting from Node 19 & 20)
486
+ const response = yield fetch(urlWithQuery, Object.assign({ keepalive: false, // Disable keepalive (keepalive defaults to true starting from Node 19 & 20)
477
487
  method,
478
- headers,
479
- body: JSON.stringify(data),
480
- signal: controller.signal,
481
- });
488
+ headers, body: JSON.stringify(data), signal: controller.signal }, (isNode && createAgent ? { agent: yield createAgent(urlWithQuery) } : {})));
482
489
  if (typeof response === 'undefined') {
483
490
  throw new Error('Response is undefined');
484
491
  }
@@ -1 +1 @@
1
- {"version":3,"file":"taquito-http-utils.umd.js","sources":[],"sourcesContent":[],"names":[],"mappings":";;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;"}
1
+ {"version":3,"file":"taquito-http-utils.umd.js","sources":[],"sourcesContent":[],"names":[],"mappings":";;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;"}
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@taquito/http-utils",
3
- "version": "22.0.0",
3
+ "version": "23.0.0-beta.0",
4
4
  "description": "",
5
5
  "keywords": [
6
6
  "tezos"
@@ -12,6 +12,10 @@
12
12
  "signature.json",
13
13
  "dist"
14
14
  ],
15
+ "browser": {
16
+ "http": false,
17
+ "https": false
18
+ },
15
19
  "author": "Simon Boissonneault-Robert <simon@ecadlabs.com>",
16
20
  "repository": {
17
21
  "type": "git",
@@ -58,7 +62,7 @@
58
62
  ]
59
63
  },
60
64
  "dependencies": {
61
- "@taquito/core": "^22.0.0",
65
+ "@taquito/core": "^23.0.0-beta.0",
62
66
  "node-fetch": "^2.7.0"
63
67
  },
64
68
  "devDependencies": {
@@ -90,5 +94,5 @@
90
94
  "ts-toolbelt": "^9.6.0",
91
95
  "typescript": "~5.5.4"
92
96
  },
93
- "gitHead": "134ec228acbee03b4f40b80c89d78c718557569b"
97
+ "gitHead": "37cc766d60407d7909fbd2d841d9dd946243d04a"
94
98
  }