@taquito/http-utils 24.0.0 → 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.
@@ -29,27 +29,35 @@ var __awaiter = (this && this.__awaiter) || function (thisArg, _arguments, P, ge
29
29
  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
- const https_1 = require("https");
33
- const http_1 = require("http");
34
32
  let fetch = globalThis === null || globalThis === void 0 ? void 0 : globalThis.fetch;
35
33
  let createAgent;
36
- // Will only use browser fetch if we are in a browser environment,
37
- // default to the more stable node-fetch otherwise
34
+ let useNodeFetchAgent = false;
38
35
  const isNode = typeof process !== 'undefined' && !!((_a = process === null || process === void 0 ? void 0 : process.versions) === null || _a === void 0 ? void 0 : _a.node);
39
- if (isNode) {
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) {
40
40
  // Handle both ESM and CJS default export patterns for webpack compatibility
41
41
  // eslint-disable-next-line @typescript-eslint/no-var-requires
42
42
  const nodeFetch = require('node-fetch');
43
+ // eslint-disable-next-line @typescript-eslint/no-var-requires
44
+ const https = require('https');
45
+ // eslint-disable-next-line @typescript-eslint/no-var-requires
46
+ const http = require('http');
43
47
  fetch = nodeFetch.default || nodeFetch;
48
+ useNodeFetchAgent = true;
44
49
  if (Number(process.versions.node.split('.')[0]) >= 19) {
45
50
  // we need agent with keepalive false for node 19 and above
46
51
  createAgent = (url) => {
47
52
  return url.startsWith('https')
48
- ? new https_1.Agent({ keepAlive: false })
49
- : new http_1.Agent({ keepAlive: false });
53
+ ? new https.Agent({ keepAlive: false })
54
+ : new http.Agent({ keepAlive: false });
50
55
  };
51
56
  }
52
57
  }
58
+ else if (typeof fetch !== 'function') {
59
+ throw new Error('No fetch implementation available');
60
+ }
53
61
  const errors_1 = require("./errors");
54
62
  __exportStar(require("./status_code"), exports);
55
63
  var version_1 = require("./version");
@@ -115,7 +123,7 @@ class HttpBackend {
115
123
  try {
116
124
  const response = yield fetch(urlWithQuery, Object.assign({ keepalive: false, // Disable keepalive (keepalive defaults to true starting from Node 19 & 20)
117
125
  method,
118
- headers, body: JSON.stringify(data), signal: controller.signal }, (isNode && createAgent ? { agent: createAgent(urlWithQuery) } : {})));
126
+ headers, body: JSON.stringify(data), signal: controller.signal }, (useNodeFetchAgent && createAgent ? { agent: createAgent(urlWithQuery) } : {})));
119
127
  if (typeof response === 'undefined') {
120
128
  throw new Error('Response is undefined');
121
129
  }
@@ -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": "d809b5118dbca5e61edb8228a83b4831be32903b",
7
- "version": "24.0.0"
6
+ "commitHash": "f798e97ba998acc2cc5310278d812448591bd312",
7
+ "version": "24.0.2"
8
8
  };
@@ -1,5 +1,3 @@
1
- import { Agent } from 'https';
2
- import { Agent as Agent$1 } from 'http';
3
1
  import { NetworkError } from '@taquito/core';
4
2
 
5
3
  /******************************************************************************
@@ -399,8 +397,8 @@ var STATUS_CODE;
399
397
 
400
398
  // IMPORTANT: THIS FILE IS AUTO GENERATED! DO NOT MANUALLY EDIT!
401
399
  const VERSION = {
402
- "commitHash": "d809b5118dbca5e61edb8228a83b4831be32903b",
403
- "version": "24.0.0"
400
+ "commitHash": "f798e97ba998acc2cc5310278d812448591bd312",
401
+ "version": "24.0.2"
404
402
  };
405
403
 
406
404
  /**
@@ -410,23 +408,33 @@ const VERSION = {
410
408
  var _a;
411
409
  let fetch = globalThis === null || globalThis === void 0 ? void 0 : globalThis.fetch;
412
410
  let createAgent;
413
- // Will only use browser fetch if we are in a browser environment,
414
- // default to the more stable node-fetch otherwise
411
+ let useNodeFetchAgent = false;
415
412
  const isNode = typeof process !== 'undefined' && !!((_a = process === null || process === void 0 ? void 0 : process.versions) === null || _a === void 0 ? void 0 : _a.node);
416
- if (isNode) {
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) {
417
417
  // Handle both ESM and CJS default export patterns for webpack compatibility
418
418
  // eslint-disable-next-line @typescript-eslint/no-var-requires
419
419
  const nodeFetch = require('node-fetch');
420
+ // eslint-disable-next-line @typescript-eslint/no-var-requires
421
+ const https = require('https');
422
+ // eslint-disable-next-line @typescript-eslint/no-var-requires
423
+ const http = require('http');
420
424
  fetch = nodeFetch.default || nodeFetch;
425
+ useNodeFetchAgent = true;
421
426
  if (Number(process.versions.node.split('.')[0]) >= 19) {
422
427
  // we need agent with keepalive false for node 19 and above
423
428
  createAgent = (url) => {
424
429
  return url.startsWith('https')
425
- ? new Agent({ keepAlive: false })
426
- : new Agent$1({ keepAlive: false });
430
+ ? new https.Agent({ keepAlive: false })
431
+ : new http.Agent({ keepAlive: false });
427
432
  };
428
433
  }
429
434
  }
435
+ else if (typeof fetch !== 'function') {
436
+ throw new Error('No fetch implementation available');
437
+ }
430
438
  class HttpBackend {
431
439
  constructor(timeout = 30000) {
432
440
  this.timeout = timeout;
@@ -484,7 +492,7 @@ class HttpBackend {
484
492
  try {
485
493
  const response = yield fetch(urlWithQuery, Object.assign({ keepalive: false, // Disable keepalive (keepalive defaults to true starting from Node 19 & 20)
486
494
  method,
487
- headers, body: JSON.stringify(data), signal: controller.signal }, (isNode && createAgent ? { agent: createAgent(urlWithQuery) } : {})));
495
+ headers, body: JSON.stringify(data), signal: controller.signal }, (useNodeFetchAgent && createAgent ? { agent: createAgent(urlWithQuery) } : {})));
488
496
  if (typeof response === 'undefined') {
489
497
  throw new Error('Response is undefined');
490
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":";;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;"}
@@ -1,8 +1,8 @@
1
1
  (function (global, factory) {
2
- typeof exports === 'object' && typeof module !== 'undefined' ? factory(exports, require('https'), require('http'), require('@taquito/core')) :
3
- typeof define === 'function' && define.amd ? define(['exports', 'https', 'http', '@taquito/core'], factory) :
4
- (global = typeof globalThis !== 'undefined' ? globalThis : global || self, factory(global.taquitoHttpUtils = {}, global.https, global.http, global.core));
5
- })(this, (function (exports, https, http, core) { 'use strict';
2
+ typeof exports === 'object' && typeof module !== 'undefined' ? factory(exports, require('@taquito/core')) :
3
+ typeof define === 'function' && define.amd ? define(['exports', '@taquito/core'], factory) :
4
+ (global = typeof globalThis !== 'undefined' ? globalThis : global || self, factory(global.taquitoHttpUtils = {}, global.core));
5
+ })(this, (function (exports, core) { 'use strict';
6
6
 
7
7
  /******************************************************************************
8
8
  Copyright (c) Microsoft Corporation.
@@ -401,8 +401,8 @@
401
401
 
402
402
  // IMPORTANT: THIS FILE IS AUTO GENERATED! DO NOT MANUALLY EDIT!
403
403
  const VERSION = {
404
- "commitHash": "d809b5118dbca5e61edb8228a83b4831be32903b",
405
- "version": "24.0.0"
404
+ "commitHash": "f798e97ba998acc2cc5310278d812448591bd312",
405
+ "version": "24.0.2"
406
406
  };
407
407
 
408
408
  /**
@@ -412,14 +412,21 @@
412
412
  var _a;
413
413
  let fetch = globalThis === null || globalThis === void 0 ? void 0 : globalThis.fetch;
414
414
  let createAgent;
415
- // Will only use browser fetch if we are in a browser environment,
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
- if (isNode) {
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
+ // eslint-disable-next-line @typescript-eslint/no-var-requires
425
+ const https = require('https');
426
+ // eslint-disable-next-line @typescript-eslint/no-var-requires
427
+ const http = require('http');
422
428
  fetch = nodeFetch.default || nodeFetch;
429
+ useNodeFetchAgent = true;
423
430
  if (Number(process.versions.node.split('.')[0]) >= 19) {
424
431
  // we need agent with keepalive false for node 19 and above
425
432
  createAgent = (url) => {
@@ -429,6 +436,9 @@
429
436
  };
430
437
  }
431
438
  }
439
+ else if (typeof fetch !== 'function') {
440
+ throw new Error('No fetch implementation available');
441
+ }
432
442
  class HttpBackend {
433
443
  constructor(timeout = 30000) {
434
444
  this.timeout = timeout;
@@ -486,7 +496,7 @@
486
496
  try {
487
497
  const response = yield fetch(urlWithQuery, Object.assign({ keepalive: false, // Disable keepalive (keepalive defaults to true starting from Node 19 & 20)
488
498
  method,
489
- headers, body: JSON.stringify(data), signal: controller.signal }, (isNode && createAgent ? { agent: createAgent(urlWithQuery) } : {})));
499
+ headers, body: JSON.stringify(data), signal: controller.signal }, (useNodeFetchAgent && createAgent ? { agent: createAgent(urlWithQuery) } : {})));
490
500
  if (typeof response === 'undefined') {
491
501
  throw new Error('Response is undefined');
492
502
  }
@@ -1 +1 @@
1
- {"version":3,"file":"taquito-http-utils.umd.js","sources":[],"sourcesContent":[],"names":[],"mappings":";;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;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{
2
2
  "name": "@taquito/http-utils",
3
- "version": "24.0.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.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": "5b08d9e0309bb2badcaec920c1ed8849f8284dfe"
99
+ "gitHead": "1ed75f883b26cbe2a62287813eedb096d81f0f46"
100
100
  }