@taquito/http-utils 24.0.1 → 24.0.2
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.
|
@@ -31,10 +31,12 @@ 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
33
|
let createAgent;
|
|
34
|
-
|
|
35
|
-
// default to the more stable node-fetch otherwise
|
|
34
|
+
let useNodeFetchAgent = false;
|
|
36
35
|
const isNode = typeof process !== 'undefined' && !!((_a = process === null || process === void 0 ? void 0 : process.versions) === null || _a === void 0 ? void 0 : _a.node);
|
|
37
|
-
|
|
36
|
+
const isBrowserLike = typeof window !== 'undefined';
|
|
37
|
+
// Use native fetch in browser-like environments (they have reliable native fetch)
|
|
38
|
+
// Use node-fetch in pure Node.js CLI for better compatibility and keepAlive control
|
|
39
|
+
if (isNode && !isBrowserLike) {
|
|
38
40
|
// Handle both ESM and CJS default export patterns for webpack compatibility
|
|
39
41
|
// eslint-disable-next-line @typescript-eslint/no-var-requires
|
|
40
42
|
const nodeFetch = require('node-fetch');
|
|
@@ -43,6 +45,7 @@ if (isNode) {
|
|
|
43
45
|
// eslint-disable-next-line @typescript-eslint/no-var-requires
|
|
44
46
|
const http = require('http');
|
|
45
47
|
fetch = nodeFetch.default || nodeFetch;
|
|
48
|
+
useNodeFetchAgent = true;
|
|
46
49
|
if (Number(process.versions.node.split('.')[0]) >= 19) {
|
|
47
50
|
// we need agent with keepalive false for node 19 and above
|
|
48
51
|
createAgent = (url) => {
|
|
@@ -52,6 +55,9 @@ if (isNode) {
|
|
|
52
55
|
};
|
|
53
56
|
}
|
|
54
57
|
}
|
|
58
|
+
else if (typeof fetch !== 'function') {
|
|
59
|
+
throw new Error('No fetch implementation available');
|
|
60
|
+
}
|
|
55
61
|
const errors_1 = require("./errors");
|
|
56
62
|
__exportStar(require("./status_code"), exports);
|
|
57
63
|
var version_1 = require("./version");
|
|
@@ -117,7 +123,7 @@ class HttpBackend {
|
|
|
117
123
|
try {
|
|
118
124
|
const response = yield fetch(urlWithQuery, Object.assign({ keepalive: false, // Disable keepalive (keepalive defaults to true starting from Node 19 & 20)
|
|
119
125
|
method,
|
|
120
|
-
headers, body: JSON.stringify(data), signal: controller.signal }, (
|
|
126
|
+
headers, body: JSON.stringify(data), signal: controller.signal }, (useNodeFetchAgent && createAgent ? { agent: createAgent(urlWithQuery) } : {})));
|
|
121
127
|
if (typeof response === 'undefined') {
|
|
122
128
|
throw new Error('Response is undefined');
|
|
123
129
|
}
|
package/dist/lib/version.js
CHANGED
|
@@ -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!
|
|
5
5
|
exports.VERSION = {
|
|
6
|
-
"commitHash": "
|
|
7
|
-
"version": "24.0.
|
|
6
|
+
"commitHash": "f798e97ba998acc2cc5310278d812448591bd312",
|
|
7
|
+
"version": "24.0.2"
|
|
8
8
|
};
|
|
@@ -397,8 +397,8 @@ var STATUS_CODE;
|
|
|
397
397
|
|
|
398
398
|
// IMPORTANT: THIS FILE IS AUTO GENERATED! DO NOT MANUALLY EDIT!
|
|
399
399
|
const VERSION = {
|
|
400
|
-
"commitHash": "
|
|
401
|
-
"version": "24.0.
|
|
400
|
+
"commitHash": "f798e97ba998acc2cc5310278d812448591bd312",
|
|
401
|
+
"version": "24.0.2"
|
|
402
402
|
};
|
|
403
403
|
|
|
404
404
|
/**
|
|
@@ -408,10 +408,12 @@ const VERSION = {
|
|
|
408
408
|
var _a;
|
|
409
409
|
let fetch = globalThis === null || globalThis === void 0 ? void 0 : globalThis.fetch;
|
|
410
410
|
let createAgent;
|
|
411
|
-
|
|
412
|
-
// default to the more stable node-fetch otherwise
|
|
411
|
+
let useNodeFetchAgent = false;
|
|
413
412
|
const isNode = typeof process !== 'undefined' && !!((_a = process === null || process === void 0 ? void 0 : process.versions) === null || _a === void 0 ? void 0 : _a.node);
|
|
414
|
-
|
|
413
|
+
const isBrowserLike = typeof window !== 'undefined';
|
|
414
|
+
// Use native fetch in browser-like environments (they have reliable native fetch)
|
|
415
|
+
// Use node-fetch in pure Node.js CLI for better compatibility and keepAlive control
|
|
416
|
+
if (isNode && !isBrowserLike) {
|
|
415
417
|
// Handle both ESM and CJS default export patterns for webpack compatibility
|
|
416
418
|
// eslint-disable-next-line @typescript-eslint/no-var-requires
|
|
417
419
|
const nodeFetch = require('node-fetch');
|
|
@@ -420,6 +422,7 @@ if (isNode) {
|
|
|
420
422
|
// eslint-disable-next-line @typescript-eslint/no-var-requires
|
|
421
423
|
const http = require('http');
|
|
422
424
|
fetch = nodeFetch.default || nodeFetch;
|
|
425
|
+
useNodeFetchAgent = true;
|
|
423
426
|
if (Number(process.versions.node.split('.')[0]) >= 19) {
|
|
424
427
|
// we need agent with keepalive false for node 19 and above
|
|
425
428
|
createAgent = (url) => {
|
|
@@ -429,6 +432,9 @@ if (isNode) {
|
|
|
429
432
|
};
|
|
430
433
|
}
|
|
431
434
|
}
|
|
435
|
+
else if (typeof fetch !== 'function') {
|
|
436
|
+
throw new Error('No fetch implementation available');
|
|
437
|
+
}
|
|
432
438
|
class HttpBackend {
|
|
433
439
|
constructor(timeout = 30000) {
|
|
434
440
|
this.timeout = timeout;
|
|
@@ -486,7 +492,7 @@ class HttpBackend {
|
|
|
486
492
|
try {
|
|
487
493
|
const response = yield fetch(urlWithQuery, Object.assign({ keepalive: false, // Disable keepalive (keepalive defaults to true starting from Node 19 & 20)
|
|
488
494
|
method,
|
|
489
|
-
headers, body: JSON.stringify(data), signal: controller.signal }, (
|
|
495
|
+
headers, body: JSON.stringify(data), signal: controller.signal }, (useNodeFetchAgent && createAgent ? { agent: createAgent(urlWithQuery) } : {})));
|
|
490
496
|
if (typeof response === 'undefined') {
|
|
491
497
|
throw new Error('Response is undefined');
|
|
492
498
|
}
|
|
@@ -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!
|
|
403
403
|
const VERSION = {
|
|
404
|
-
"commitHash": "
|
|
405
|
-
"version": "24.0.
|
|
404
|
+
"commitHash": "f798e97ba998acc2cc5310278d812448591bd312",
|
|
405
|
+
"version": "24.0.2"
|
|
406
406
|
};
|
|
407
407
|
|
|
408
408
|
/**
|
|
@@ -412,10 +412,12 @@
|
|
|
412
412
|
var _a;
|
|
413
413
|
let fetch = globalThis === null || globalThis === void 0 ? void 0 : globalThis.fetch;
|
|
414
414
|
let createAgent;
|
|
415
|
-
|
|
416
|
-
// default to the more stable node-fetch otherwise
|
|
415
|
+
let useNodeFetchAgent = false;
|
|
417
416
|
const isNode = typeof process !== 'undefined' && !!((_a = process === null || process === void 0 ? void 0 : process.versions) === null || _a === void 0 ? void 0 : _a.node);
|
|
418
|
-
|
|
417
|
+
const isBrowserLike = typeof window !== 'undefined';
|
|
418
|
+
// Use native fetch in browser-like environments (they have reliable native fetch)
|
|
419
|
+
// Use node-fetch in pure Node.js CLI for better compatibility and keepAlive control
|
|
420
|
+
if (isNode && !isBrowserLike) {
|
|
419
421
|
// Handle both ESM and CJS default export patterns for webpack compatibility
|
|
420
422
|
// eslint-disable-next-line @typescript-eslint/no-var-requires
|
|
421
423
|
const nodeFetch = require('node-fetch');
|
|
@@ -424,6 +426,7 @@
|
|
|
424
426
|
// eslint-disable-next-line @typescript-eslint/no-var-requires
|
|
425
427
|
const http = require('http');
|
|
426
428
|
fetch = nodeFetch.default || nodeFetch;
|
|
429
|
+
useNodeFetchAgent = true;
|
|
427
430
|
if (Number(process.versions.node.split('.')[0]) >= 19) {
|
|
428
431
|
// we need agent with keepalive false for node 19 and above
|
|
429
432
|
createAgent = (url) => {
|
|
@@ -433,6 +436,9 @@
|
|
|
433
436
|
};
|
|
434
437
|
}
|
|
435
438
|
}
|
|
439
|
+
else if (typeof fetch !== 'function') {
|
|
440
|
+
throw new Error('No fetch implementation available');
|
|
441
|
+
}
|
|
436
442
|
class HttpBackend {
|
|
437
443
|
constructor(timeout = 30000) {
|
|
438
444
|
this.timeout = timeout;
|
|
@@ -490,7 +496,7 @@
|
|
|
490
496
|
try {
|
|
491
497
|
const response = yield fetch(urlWithQuery, Object.assign({ keepalive: false, // Disable keepalive (keepalive defaults to true starting from Node 19 & 20)
|
|
492
498
|
method,
|
|
493
|
-
headers, body: JSON.stringify(data), signal: controller.signal }, (
|
|
499
|
+
headers, body: JSON.stringify(data), signal: controller.signal }, (useNodeFetchAgent && createAgent ? { agent: createAgent(urlWithQuery) } : {})));
|
|
494
500
|
if (typeof response === 'undefined') {
|
|
495
501
|
throw new Error('Response is undefined');
|
|
496
502
|
}
|
|
@@ -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": "24.0.
|
|
3
|
+
"version": "24.0.2",
|
|
4
4
|
"description": "",
|
|
5
5
|
"keywords": [
|
|
6
6
|
"tezos"
|
|
@@ -63,7 +63,7 @@
|
|
|
63
63
|
]
|
|
64
64
|
},
|
|
65
65
|
"dependencies": {
|
|
66
|
-
"@taquito/core": "^24.0.
|
|
66
|
+
"@taquito/core": "^24.0.2",
|
|
67
67
|
"node-fetch": "^2.7.0"
|
|
68
68
|
},
|
|
69
69
|
"devDependencies": {
|
|
@@ -96,5 +96,5 @@
|
|
|
96
96
|
"ts-toolbelt": "^9.6.0",
|
|
97
97
|
"typescript": "~5.5.4"
|
|
98
98
|
},
|
|
99
|
-
"gitHead": "
|
|
99
|
+
"gitHead": "1ed75f883b26cbe2a62287813eedb096d81f0f46"
|
|
100
100
|
}
|