contentful 11.12.3 → 11.12.5

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.
@@ -5,15 +5,17 @@ var require$$0$1 = require('stream');
5
5
  var require$$1$1 = require('path');
6
6
  var require$$3 = require('http');
7
7
  var require$$4 = require('https');
8
- var require$$5 = require('url');
8
+ var require$$2 = require('url');
9
9
  var require$$6 = require('fs');
10
10
  var require$$8 = require('crypto');
11
- var require$$5$1 = require('http2');
12
- var require$$4$1 = require('assert');
11
+ var require$$0$5 = require('net');
12
+ var require$$1$2 = require('tls');
13
+ var require$$3$1 = require('assert');
13
14
  var require$$0$3 = require('tty');
14
15
  var require$$0$2 = require('os');
15
- var require$$9 = require('zlib');
16
- var require$$11 = require('events');
16
+ var require$$0$4 = require('events');
17
+ var require$$6$1 = require('http2');
18
+ var require$$10 = require('zlib');
17
19
  var process$1 = require('process');
18
20
 
19
21
  function _OverloadYield(e, d) {
@@ -12536,7 +12538,7 @@ var util$1 = require$$1;
12536
12538
  var path$1 = require$$1$1;
12537
12539
  var http$2 = require$$3;
12538
12540
  var https$2 = require$$4;
12539
- var parseUrl$2 = require$$5.parse;
12541
+ var parseUrl$2 = require$$2.parse;
12540
12542
  var fs = require$$6;
12541
12543
  var Stream = require$$0$1.Stream;
12542
12544
  var crypto$1 = require$$8;
@@ -12982,9 +12984,9 @@ setToStringTag(FormData$2.prototype, 'FormData');
12982
12984
  // Public API
12983
12985
  var form_data = FormData$2;
12984
12986
 
12985
- var followRedirects$1 = {exports: {}};
12987
+ var agent = {};
12986
12988
 
12987
- var src = {exports: {}};
12989
+ var src$1 = {exports: {}};
12988
12990
 
12989
12991
  var browser = {exports: {}};
12990
12992
 
@@ -13920,15 +13922,529 @@ function requireNode() {
13920
13922
  */
13921
13923
  var hasRequiredSrc;
13922
13924
  function requireSrc() {
13923
- if (hasRequiredSrc) return src.exports;
13925
+ if (hasRequiredSrc) return src$1.exports;
13924
13926
  hasRequiredSrc = 1;
13925
13927
  if (typeof process === 'undefined' || process.type === 'renderer' || process.browser === true || process.__nwjs) {
13926
- src.exports = requireBrowser();
13928
+ src$1.exports = requireBrowser();
13927
13929
  } else {
13928
- src.exports = requireNode();
13930
+ src$1.exports = requireNode();
13929
13931
  }
13930
- return src.exports;
13932
+ return src$1.exports;
13933
+ }
13934
+
13935
+ var promisify$1 = {};
13936
+
13937
+ Object.defineProperty(promisify$1, "__esModule", {
13938
+ value: true
13939
+ });
13940
+ function promisify(fn) {
13941
+ return function (req, opts) {
13942
+ return new Promise((resolve, reject) => {
13943
+ fn.call(this, req, opts, (err, rtn) => {
13944
+ if (err) {
13945
+ reject(err);
13946
+ } else {
13947
+ resolve(rtn);
13948
+ }
13949
+ });
13950
+ });
13951
+ };
13931
13952
  }
13953
+ promisify$1.default = promisify;
13954
+
13955
+ var __importDefault$3 = undefined && undefined.__importDefault || function (mod) {
13956
+ return mod && mod.__esModule ? mod : {
13957
+ "default": mod
13958
+ };
13959
+ };
13960
+ const events_1 = require$$0$4;
13961
+ const debug_1$3 = __importDefault$3(requireSrc());
13962
+ const promisify_1 = __importDefault$3(promisify$1);
13963
+ const debug$4 = debug_1$3.default('agent-base');
13964
+ function isAgent(v) {
13965
+ return Boolean(v) && typeof v.addRequest === 'function';
13966
+ }
13967
+ function isSecureEndpoint() {
13968
+ const {
13969
+ stack
13970
+ } = new Error();
13971
+ if (typeof stack !== 'string') return false;
13972
+ return stack.split('\n').some(l => l.indexOf('(https.js:') !== -1 || l.indexOf('node:https:') !== -1);
13973
+ }
13974
+ function createAgent(callback, opts) {
13975
+ return new createAgent.Agent(callback, opts);
13976
+ }
13977
+ (function (createAgent) {
13978
+ /**
13979
+ * Base `http.Agent` implementation.
13980
+ * No pooling/keep-alive is implemented by default.
13981
+ *
13982
+ * @param {Function} callback
13983
+ * @api public
13984
+ */
13985
+ class Agent extends events_1.EventEmitter {
13986
+ constructor(callback, _opts) {
13987
+ super();
13988
+ let opts = _opts;
13989
+ if (typeof callback === 'function') {
13990
+ this.callback = callback;
13991
+ } else if (callback) {
13992
+ opts = callback;
13993
+ }
13994
+ // Timeout for the socket to be returned from the callback
13995
+ this.timeout = null;
13996
+ if (opts && typeof opts.timeout === 'number') {
13997
+ this.timeout = opts.timeout;
13998
+ }
13999
+ // These aren't actually used by `agent-base`, but are required
14000
+ // for the TypeScript definition files in `@types/node` :/
14001
+ this.maxFreeSockets = 1;
14002
+ this.maxSockets = 1;
14003
+ this.maxTotalSockets = Infinity;
14004
+ this.sockets = {};
14005
+ this.freeSockets = {};
14006
+ this.requests = {};
14007
+ this.options = {};
14008
+ }
14009
+ get defaultPort() {
14010
+ if (typeof this.explicitDefaultPort === 'number') {
14011
+ return this.explicitDefaultPort;
14012
+ }
14013
+ return isSecureEndpoint() ? 443 : 80;
14014
+ }
14015
+ set defaultPort(v) {
14016
+ this.explicitDefaultPort = v;
14017
+ }
14018
+ get protocol() {
14019
+ if (typeof this.explicitProtocol === 'string') {
14020
+ return this.explicitProtocol;
14021
+ }
14022
+ return isSecureEndpoint() ? 'https:' : 'http:';
14023
+ }
14024
+ set protocol(v) {
14025
+ this.explicitProtocol = v;
14026
+ }
14027
+ callback(req, opts, fn) {
14028
+ throw new Error('"agent-base" has no default implementation, you must subclass and override `callback()`');
14029
+ }
14030
+ /**
14031
+ * Called by node-core's "_http_client.js" module when creating
14032
+ * a new HTTP request with this Agent instance.
14033
+ *
14034
+ * @api public
14035
+ */
14036
+ addRequest(req, _opts) {
14037
+ const opts = Object.assign({}, _opts);
14038
+ if (typeof opts.secureEndpoint !== 'boolean') {
14039
+ opts.secureEndpoint = isSecureEndpoint();
14040
+ }
14041
+ if (opts.host == null) {
14042
+ opts.host = 'localhost';
14043
+ }
14044
+ if (opts.port == null) {
14045
+ opts.port = opts.secureEndpoint ? 443 : 80;
14046
+ }
14047
+ if (opts.protocol == null) {
14048
+ opts.protocol = opts.secureEndpoint ? 'https:' : 'http:';
14049
+ }
14050
+ if (opts.host && opts.path) {
14051
+ // If both a `host` and `path` are specified then it's most
14052
+ // likely the result of a `url.parse()` call... we need to
14053
+ // remove the `path` portion so that `net.connect()` doesn't
14054
+ // attempt to open that as a unix socket file.
14055
+ delete opts.path;
14056
+ }
14057
+ delete opts.agent;
14058
+ delete opts.hostname;
14059
+ delete opts._defaultAgent;
14060
+ delete opts.defaultPort;
14061
+ delete opts.createConnection;
14062
+ // Hint to use "Connection: close"
14063
+ // XXX: non-documented `http` module API :(
14064
+ req._last = true;
14065
+ req.shouldKeepAlive = false;
14066
+ let timedOut = false;
14067
+ let timeoutId = null;
14068
+ const timeoutMs = opts.timeout || this.timeout;
14069
+ const onerror = err => {
14070
+ if (req._hadError) return;
14071
+ req.emit('error', err);
14072
+ // For Safety. Some additional errors might fire later on
14073
+ // and we need to make sure we don't double-fire the error event.
14074
+ req._hadError = true;
14075
+ };
14076
+ const ontimeout = () => {
14077
+ timeoutId = null;
14078
+ timedOut = true;
14079
+ const err = new Error(`A "socket" was not created for HTTP request before ${timeoutMs}ms`);
14080
+ err.code = 'ETIMEOUT';
14081
+ onerror(err);
14082
+ };
14083
+ const callbackError = err => {
14084
+ if (timedOut) return;
14085
+ if (timeoutId !== null) {
14086
+ clearTimeout(timeoutId);
14087
+ timeoutId = null;
14088
+ }
14089
+ onerror(err);
14090
+ };
14091
+ const onsocket = socket => {
14092
+ if (timedOut) return;
14093
+ if (timeoutId != null) {
14094
+ clearTimeout(timeoutId);
14095
+ timeoutId = null;
14096
+ }
14097
+ if (isAgent(socket)) {
14098
+ // `socket` is actually an `http.Agent` instance, so
14099
+ // relinquish responsibility for this `req` to the Agent
14100
+ // from here on
14101
+ debug$4('Callback returned another Agent instance %o', socket.constructor.name);
14102
+ socket.addRequest(req, opts);
14103
+ return;
14104
+ }
14105
+ if (socket) {
14106
+ socket.once('free', () => {
14107
+ this.freeSocket(socket, opts);
14108
+ });
14109
+ req.onSocket(socket);
14110
+ return;
14111
+ }
14112
+ const err = new Error(`no Duplex stream was returned to agent-base for \`${req.method} ${req.path}\``);
14113
+ onerror(err);
14114
+ };
14115
+ if (typeof this.callback !== 'function') {
14116
+ onerror(new Error('`callback` is not defined'));
14117
+ return;
14118
+ }
14119
+ if (!this.promisifiedCallback) {
14120
+ if (this.callback.length >= 3) {
14121
+ debug$4('Converting legacy callback function to promise');
14122
+ this.promisifiedCallback = promisify_1.default(this.callback);
14123
+ } else {
14124
+ this.promisifiedCallback = this.callback;
14125
+ }
14126
+ }
14127
+ if (typeof timeoutMs === 'number' && timeoutMs > 0) {
14128
+ timeoutId = setTimeout(ontimeout, timeoutMs);
14129
+ }
14130
+ if ('port' in opts && typeof opts.port !== 'number') {
14131
+ opts.port = Number(opts.port);
14132
+ }
14133
+ try {
14134
+ debug$4('Resolving socket for %o request: %o', opts.protocol, `${req.method} ${req.path}`);
14135
+ Promise.resolve(this.promisifiedCallback(req, opts)).then(onsocket, callbackError);
14136
+ } catch (err) {
14137
+ Promise.reject(err).catch(callbackError);
14138
+ }
14139
+ }
14140
+ freeSocket(socket, opts) {
14141
+ debug$4('Freeing socket %o %o', socket.constructor.name, opts);
14142
+ socket.destroy();
14143
+ }
14144
+ destroy() {
14145
+ debug$4('Destroying agent %o', this.constructor.name);
14146
+ }
14147
+ }
14148
+ createAgent.Agent = Agent;
14149
+ // So that `instanceof` works correctly
14150
+ createAgent.prototype = createAgent.Agent.prototype;
14151
+ })(createAgent || (createAgent = {}));
14152
+ var src = createAgent;
14153
+
14154
+ var parseProxyResponse$1 = {};
14155
+
14156
+ var __importDefault$2 = undefined && undefined.__importDefault || function (mod) {
14157
+ return mod && mod.__esModule ? mod : {
14158
+ "default": mod
14159
+ };
14160
+ };
14161
+ Object.defineProperty(parseProxyResponse$1, "__esModule", {
14162
+ value: true
14163
+ });
14164
+ const debug_1$2 = __importDefault$2(requireSrc());
14165
+ const debug$3 = debug_1$2.default('https-proxy-agent:parse-proxy-response');
14166
+ function parseProxyResponse(socket) {
14167
+ return new Promise((resolve, reject) => {
14168
+ // we need to buffer any HTTP traffic that happens with the proxy before we get
14169
+ // the CONNECT response, so that if the response is anything other than an "200"
14170
+ // response code, then we can re-play the "data" events on the socket once the
14171
+ // HTTP parser is hooked up...
14172
+ let buffersLength = 0;
14173
+ const buffers = [];
14174
+ function read() {
14175
+ const b = socket.read();
14176
+ if (b) ondata(b);else socket.once('readable', read);
14177
+ }
14178
+ function cleanup() {
14179
+ socket.removeListener('end', onend);
14180
+ socket.removeListener('error', onerror);
14181
+ socket.removeListener('close', onclose);
14182
+ socket.removeListener('readable', read);
14183
+ }
14184
+ function onclose(err) {
14185
+ debug$3('onclose had error %o', err);
14186
+ }
14187
+ function onend() {
14188
+ debug$3('onend');
14189
+ }
14190
+ function onerror(err) {
14191
+ cleanup();
14192
+ debug$3('onerror %o', err);
14193
+ reject(err);
14194
+ }
14195
+ function ondata(b) {
14196
+ buffers.push(b);
14197
+ buffersLength += b.length;
14198
+ const buffered = Buffer.concat(buffers, buffersLength);
14199
+ const endOfHeaders = buffered.indexOf('\r\n\r\n');
14200
+ if (endOfHeaders === -1) {
14201
+ // keep buffering
14202
+ debug$3('have not received end of HTTP headers yet...');
14203
+ read();
14204
+ return;
14205
+ }
14206
+ const firstLine = buffered.toString('ascii', 0, buffered.indexOf('\r\n'));
14207
+ const statusCode = +firstLine.split(' ')[1];
14208
+ debug$3('got proxy server response: %o', firstLine);
14209
+ resolve({
14210
+ statusCode,
14211
+ buffered
14212
+ });
14213
+ }
14214
+ socket.on('error', onerror);
14215
+ socket.on('close', onclose);
14216
+ socket.on('end', onend);
14217
+ read();
14218
+ });
14219
+ }
14220
+ parseProxyResponse$1.default = parseProxyResponse;
14221
+
14222
+ var __awaiter = undefined && undefined.__awaiter || function (thisArg, _arguments, P, generator) {
14223
+ function adopt(value) {
14224
+ return value instanceof P ? value : new P(function (resolve) {
14225
+ resolve(value);
14226
+ });
14227
+ }
14228
+ return new (P || (P = Promise))(function (resolve, reject) {
14229
+ function fulfilled(value) {
14230
+ try {
14231
+ step(generator.next(value));
14232
+ } catch (e) {
14233
+ reject(e);
14234
+ }
14235
+ }
14236
+ function rejected(value) {
14237
+ try {
14238
+ step(generator["throw"](value));
14239
+ } catch (e) {
14240
+ reject(e);
14241
+ }
14242
+ }
14243
+ function step(result) {
14244
+ result.done ? resolve(result.value) : adopt(result.value).then(fulfilled, rejected);
14245
+ }
14246
+ step((generator = generator.apply(thisArg, _arguments || [])).next());
14247
+ });
14248
+ };
14249
+ var __importDefault$1 = undefined && undefined.__importDefault || function (mod) {
14250
+ return mod && mod.__esModule ? mod : {
14251
+ "default": mod
14252
+ };
14253
+ };
14254
+ Object.defineProperty(agent, "__esModule", {
14255
+ value: true
14256
+ });
14257
+ const net_1 = __importDefault$1(require$$0$5);
14258
+ const tls_1 = __importDefault$1(require$$1$2);
14259
+ const url_1 = __importDefault$1(require$$2);
14260
+ const assert_1 = __importDefault$1(require$$3$1);
14261
+ const debug_1$1 = __importDefault$1(requireSrc());
14262
+ const agent_base_1 = src;
14263
+ const parse_proxy_response_1 = __importDefault$1(parseProxyResponse$1);
14264
+ const debug$2 = debug_1$1.default('https-proxy-agent:agent');
14265
+ /**
14266
+ * The `HttpsProxyAgent` implements an HTTP Agent subclass that connects to
14267
+ * the specified "HTTP(s) proxy server" in order to proxy HTTPS requests.
14268
+ *
14269
+ * Outgoing HTTP requests are first tunneled through the proxy server using the
14270
+ * `CONNECT` HTTP request method to establish a connection to the proxy server,
14271
+ * and then the proxy server connects to the destination target and issues the
14272
+ * HTTP request from the proxy server.
14273
+ *
14274
+ * `https:` requests have their socket connection upgraded to TLS once
14275
+ * the connection to the proxy server has been established.
14276
+ *
14277
+ * @api public
14278
+ */
14279
+ let HttpsProxyAgent$1 = class HttpsProxyAgent extends agent_base_1.Agent {
14280
+ constructor(_opts) {
14281
+ let opts;
14282
+ if (typeof _opts === 'string') {
14283
+ opts = url_1.default.parse(_opts);
14284
+ } else {
14285
+ opts = _opts;
14286
+ }
14287
+ if (!opts) {
14288
+ throw new Error('an HTTP(S) proxy server `host` and `port` must be specified!');
14289
+ }
14290
+ debug$2('creating new HttpsProxyAgent instance: %o', opts);
14291
+ super(opts);
14292
+ const proxy = Object.assign({}, opts);
14293
+ // If `true`, then connect to the proxy server over TLS.
14294
+ // Defaults to `false`.
14295
+ this.secureProxy = opts.secureProxy || isHTTPS(proxy.protocol);
14296
+ // Prefer `hostname` over `host`, and set the `port` if needed.
14297
+ proxy.host = proxy.hostname || proxy.host;
14298
+ if (typeof proxy.port === 'string') {
14299
+ proxy.port = parseInt(proxy.port, 10);
14300
+ }
14301
+ if (!proxy.port && proxy.host) {
14302
+ proxy.port = this.secureProxy ? 443 : 80;
14303
+ }
14304
+ // ALPN is supported by Node.js >= v5.
14305
+ // attempt to negotiate http/1.1 for proxy servers that support http/2
14306
+ if (this.secureProxy && !('ALPNProtocols' in proxy)) {
14307
+ proxy.ALPNProtocols = ['http 1.1'];
14308
+ }
14309
+ if (proxy.host && proxy.path) {
14310
+ // If both a `host` and `path` are specified then it's most likely
14311
+ // the result of a `url.parse()` call... we need to remove the
14312
+ // `path` portion so that `net.connect()` doesn't attempt to open
14313
+ // that as a Unix socket file.
14314
+ delete proxy.path;
14315
+ delete proxy.pathname;
14316
+ }
14317
+ this.proxy = proxy;
14318
+ }
14319
+ /**
14320
+ * Called when the node-core HTTP client library is creating a
14321
+ * new HTTP request.
14322
+ *
14323
+ * @api protected
14324
+ */
14325
+ callback(req, opts) {
14326
+ return __awaiter(this, void 0, void 0, function* () {
14327
+ const {
14328
+ proxy,
14329
+ secureProxy
14330
+ } = this;
14331
+ // Create a socket connection to the proxy server.
14332
+ let socket;
14333
+ if (secureProxy) {
14334
+ debug$2('Creating `tls.Socket`: %o', proxy);
14335
+ socket = tls_1.default.connect(proxy);
14336
+ } else {
14337
+ debug$2('Creating `net.Socket`: %o', proxy);
14338
+ socket = net_1.default.connect(proxy);
14339
+ }
14340
+ const headers = Object.assign({}, proxy.headers);
14341
+ const hostname = `${opts.host}:${opts.port}`;
14342
+ let payload = `CONNECT ${hostname} HTTP/1.1\r\n`;
14343
+ // Inject the `Proxy-Authorization` header if necessary.
14344
+ if (proxy.auth) {
14345
+ headers['Proxy-Authorization'] = `Basic ${Buffer.from(proxy.auth).toString('base64')}`;
14346
+ }
14347
+ // The `Host` header should only include the port
14348
+ // number when it is not the default port.
14349
+ let {
14350
+ host,
14351
+ port,
14352
+ secureEndpoint
14353
+ } = opts;
14354
+ if (!isDefaultPort(port, secureEndpoint)) {
14355
+ host += `:${port}`;
14356
+ }
14357
+ headers.Host = host;
14358
+ headers.Connection = 'close';
14359
+ for (const name of Object.keys(headers)) {
14360
+ payload += `${name}: ${headers[name]}\r\n`;
14361
+ }
14362
+ const proxyResponsePromise = parse_proxy_response_1.default(socket);
14363
+ socket.write(`${payload}\r\n`);
14364
+ const {
14365
+ statusCode,
14366
+ buffered
14367
+ } = yield proxyResponsePromise;
14368
+ if (statusCode === 200) {
14369
+ req.once('socket', resume);
14370
+ if (opts.secureEndpoint) {
14371
+ // The proxy is connecting to a TLS server, so upgrade
14372
+ // this socket connection to a TLS connection.
14373
+ debug$2('Upgrading socket connection to TLS');
14374
+ const servername = opts.servername || opts.host;
14375
+ return tls_1.default.connect(Object.assign(Object.assign({}, omit(opts, 'host', 'hostname', 'path', 'port')), {
14376
+ socket,
14377
+ servername
14378
+ }));
14379
+ }
14380
+ return socket;
14381
+ }
14382
+ // Some other status code that's not 200... need to re-play the HTTP
14383
+ // header "data" events onto the socket once the HTTP machinery is
14384
+ // attached so that the node core `http` can parse and handle the
14385
+ // error status code.
14386
+ // Close the original socket, and a new "fake" socket is returned
14387
+ // instead, so that the proxy doesn't get the HTTP request
14388
+ // written to it (which may contain `Authorization` headers or other
14389
+ // sensitive data).
14390
+ //
14391
+ // See: https://hackerone.com/reports/541502
14392
+ socket.destroy();
14393
+ const fakeSocket = new net_1.default.Socket({
14394
+ writable: false
14395
+ });
14396
+ fakeSocket.readable = true;
14397
+ // Need to wait for the "socket" event to re-play the "data" events.
14398
+ req.once('socket', s => {
14399
+ debug$2('replaying proxy buffer for failed request');
14400
+ assert_1.default(s.listenerCount('data') > 0);
14401
+ // Replay the "buffered" Buffer onto the fake `socket`, since at
14402
+ // this point the HTTP module machinery has been hooked up for
14403
+ // the user.
14404
+ s.push(buffered);
14405
+ s.push(null);
14406
+ });
14407
+ return fakeSocket;
14408
+ });
14409
+ }
14410
+ };
14411
+ agent.default = HttpsProxyAgent$1;
14412
+ function resume(socket) {
14413
+ socket.resume();
14414
+ }
14415
+ function isDefaultPort(port, secure) {
14416
+ return Boolean(!secure && port === 80 || secure && port === 443);
14417
+ }
14418
+ function isHTTPS(protocol) {
14419
+ return typeof protocol === 'string' ? /^https:?$/i.test(protocol) : false;
14420
+ }
14421
+ function omit(obj, ...keys) {
14422
+ const ret = {};
14423
+ let key;
14424
+ for (key in obj) {
14425
+ if (!keys.includes(key)) {
14426
+ ret[key] = obj[key];
14427
+ }
14428
+ }
14429
+ return ret;
14430
+ }
14431
+
14432
+ var __importDefault = undefined && undefined.__importDefault || function (mod) {
14433
+ return mod && mod.__esModule ? mod : {
14434
+ "default": mod
14435
+ };
14436
+ };
14437
+ const agent_1 = __importDefault(agent);
14438
+ function createHttpsProxyAgent(opts) {
14439
+ return new agent_1.default(opts);
14440
+ }
14441
+ (function (createHttpsProxyAgent) {
14442
+ createHttpsProxyAgent.HttpsProxyAgent = agent_1.default;
14443
+ createHttpsProxyAgent.prototype = agent_1.default.prototype;
14444
+ })(createHttpsProxyAgent || (createHttpsProxyAgent = {}));
14445
+ var dist = createHttpsProxyAgent;
14446
+
14447
+ var followRedirects$1 = {exports: {}};
13932
14448
 
13933
14449
  var debug$1;
13934
14450
  var debug_1 = function () {
@@ -13944,12 +14460,12 @@ var debug_1 = function () {
13944
14460
  debug$1.apply(null, arguments);
13945
14461
  };
13946
14462
 
13947
- var url$1 = require$$5;
14463
+ var url$1 = require$$2;
13948
14464
  var URL$1 = url$1.URL;
13949
14465
  var http$1 = require$$3;
13950
14466
  var https$1 = require$$4;
13951
14467
  var Writable = require$$0$1.Writable;
13952
- var assert = require$$4$1;
14468
+ var assert = require$$3$1;
13953
14469
  var debug = debug_1;
13954
14470
 
13955
14471
  // Preventive platform detection
@@ -14609,16 +15125,17 @@ var followRedirectsExports = followRedirects$1.exports;
14609
15125
 
14610
15126
  var FormData$1 = form_data;
14611
15127
  var crypto = require$$8;
14612
- var url = require$$5;
15128
+ var url = require$$2;
15129
+ var HttpsProxyAgent = dist;
14613
15130
  var http = require$$3;
14614
15131
  var https = require$$4;
14615
- var http2 = require$$5$1;
15132
+ var http2 = require$$6$1;
14616
15133
  var util = require$$1;
14617
15134
  var path = require$$1$1;
14618
15135
  var followRedirects = followRedirectsExports;
14619
- var zlib = require$$9;
15136
+ var zlib = require$$10;
14620
15137
  var stream = require$$0$1;
14621
- var events = require$$11;
15138
+ var events = require$$0$4;
14622
15139
 
14623
15140
  /**
14624
15141
  * Create a bound version of a function with a specified `this` context
@@ -15343,10 +15860,10 @@ function isSpecCompliantForm(thing) {
15343
15860
  * @returns {Object} The JSON-compatible object.
15344
15861
  */
15345
15862
  const toJSONObject = obj => {
15346
- const stack = new Array(10);
15347
- const visit = (source, i) => {
15863
+ const visited = new WeakSet();
15864
+ const visit = source => {
15348
15865
  if (isObject(source)) {
15349
- if (stack.indexOf(source) >= 0) {
15866
+ if (visited.has(source)) {
15350
15867
  return;
15351
15868
  }
15352
15869
 
@@ -15355,19 +15872,20 @@ const toJSONObject = obj => {
15355
15872
  return source;
15356
15873
  }
15357
15874
  if (!('toJSON' in source)) {
15358
- stack[i] = source;
15875
+ // add-on descent / delete-on-ascent: preserves path semantics, so DAG nodes serialise at every occurrence (see #7230).
15876
+ visited.add(source);
15359
15877
  const target = isArray$7(source) ? [] : {};
15360
15878
  forEach(source, (value, key) => {
15361
- const reducedValue = visit(value, i + 1);
15879
+ const reducedValue = visit(value);
15362
15880
  !isUndefined(reducedValue) && (target[key] = reducedValue);
15363
15881
  });
15364
- stack[i] = undefined;
15882
+ visited.delete(source);
15365
15883
  return target;
15366
15884
  }
15367
15885
  }
15368
15886
  return source;
15369
15887
  };
15370
- return visit(obj, 0);
15888
+ return visit(obj);
15371
15889
  };
15372
15890
 
15373
15891
  /**
@@ -15533,8 +16051,6 @@ var parseHeaders = rawHeaders => {
15533
16051
  });
15534
16052
  return parsed;
15535
16053
  };
15536
- const $internals = Symbol('internals');
15537
- const INVALID_HEADER_VALUE_CHARS_RE = /[^\x09\x20-\x7E\x80-\xFF]/g;
15538
16054
  function trimSPorHTAB(str) {
15539
16055
  let start = 0;
15540
16056
  let end = str.length;
@@ -15554,12 +16070,31 @@ function trimSPorHTAB(str) {
15554
16070
  }
15555
16071
  return start === 0 && end === str.length ? str : str.slice(start, end);
15556
16072
  }
16073
+
16074
+ // The control-code ranges are intentional: header sanitization strips C0/DEL bytes.
16075
+ // eslint-disable-next-line no-control-regex
16076
+ const INVALID_UNICODE_HEADER_VALUE_CHARS = new RegExp('[\\u0000-\\u0008\\u000a-\\u001f\\u007f]+', 'g');
16077
+ // eslint-disable-next-line no-control-regex
16078
+ const INVALID_BYTE_STRING_HEADER_VALUE_CHARS = new RegExp('[^\\u0009\\u0020-\\u007e\\u0080-\\u00ff]+', 'g');
16079
+ function sanitizeValue(value, invalidChars) {
16080
+ if (utils$1$1.isArray(value)) {
16081
+ return value.map(item => sanitizeValue(item, invalidChars));
16082
+ }
16083
+ return trimSPorHTAB(String(value).replace(invalidChars, ''));
16084
+ }
16085
+ const sanitizeHeaderValue = value => sanitizeValue(value, INVALID_UNICODE_HEADER_VALUE_CHARS);
16086
+ const sanitizeByteStringHeaderValue = value => sanitizeValue(value, INVALID_BYTE_STRING_HEADER_VALUE_CHARS);
16087
+ function toByteStringHeaderObject(headers) {
16088
+ const byteStringHeaders = Object.create(null);
16089
+ utils$1$1.forEach(headers.toJSON(), (value, header) => {
16090
+ byteStringHeaders[header] = sanitizeByteStringHeaderValue(value);
16091
+ });
16092
+ return byteStringHeaders;
16093
+ }
16094
+ const $internals = Symbol('internals');
15557
16095
  function normalizeHeader(header) {
15558
16096
  return header && String(header).trim().toLowerCase();
15559
16097
  }
15560
- function sanitizeHeaderValue(str) {
15561
- return trimSPorHTAB(str.replace(INVALID_HEADER_VALUE_CHARS_RE, ''));
15562
- }
15563
16098
  function normalizeValue(value) {
15564
16099
  if (value === false || value == null) {
15565
16100
  return value;
@@ -16444,7 +16979,7 @@ function formDataToJSON(formData) {
16444
16979
  }
16445
16980
  return !isNumericKey;
16446
16981
  }
16447
- if (!target[name] || !utils$1$1.isObject(target[name])) {
16982
+ if (!utils$1$1.hasOwnProp(target, name) || !utils$1$1.isObject(target[name])) {
16448
16983
  target[name] = [];
16449
16984
  }
16450
16985
  const result = buildPath(path, value, target[name], index);
@@ -16780,12 +17315,15 @@ function shouldProxy(hostname, port) {
16780
17315
  function getEnv(key) {
16781
17316
  return process.env[key.toLowerCase()] || process.env[key.toUpperCase()] || '';
16782
17317
  }
16783
- const VERSION = "1.16.0";
17318
+ const VERSION = "1.16.1";
16784
17319
  function parseProtocol(url) {
16785
17320
  const match = /^([-+\w]{1,25}):(?:\/\/)?/.exec(url);
16786
17321
  return match && match[1] || '';
16787
17322
  }
16788
- const DATA_URL_PATTERN = /^(?:([^;]+);)?(?:[^;]+;)?(base64|),([\s\S]*)$/;
17323
+
17324
+ // RFC 2397: data:[<mediatype>][;base64],<data>
17325
+ // mediatype = type/subtype followed by optional ;name=value parameters
17326
+ const DATA_URL_PATTERN = /^([^,;]+\/[^,;]+)?((?:;[^,;=]+=[^,;]+)*)(;base64)?,([\s\S]*)$/;
16789
17327
 
16790
17328
  /**
16791
17329
  * Parse data uri to a Buffer or Blob
@@ -16809,10 +17347,20 @@ function fromDataURI(uri, asBlob, options) {
16809
17347
  if (!match) {
16810
17348
  throw new AxiosError('Invalid URL', AxiosError.ERR_INVALID_URL);
16811
17349
  }
16812
- const mime = match[1];
16813
- const isBase64 = match[2];
16814
- const body = match[3];
16815
- const buffer = Buffer.from(decodeURIComponent(body), isBase64 ? 'base64' : 'utf8');
17350
+ const type = match[1];
17351
+ const params = match[2];
17352
+ const encoding = match[3] ? 'base64' : 'utf8';
17353
+ const body = match[4];
17354
+
17355
+ // RFC 2397 section 3: default mediatype is text/plain;charset=US-ASCII
17356
+ // Bare `data:,` leaves mime undefined; Blob normalises that to "" per spec.
17357
+ let mime;
17358
+ if (type) {
17359
+ mime = params ? type + params : type;
17360
+ } else if (params) {
17361
+ mime = 'text/plain' + params;
17362
+ }
17363
+ const buffer = Buffer.from(decodeURIComponent(body), encoding);
16816
17364
  if (asBlob) {
16817
17365
  if (!_Blob) {
16818
17366
  throw new AxiosError('Blob is not supported', AxiosError.ERR_NOT_SUPPORT);
@@ -17293,6 +17841,9 @@ const progressEventReducer = (listener, isDownloadStream, freq = 3) => {
17293
17841
  let bytesNotified = 0;
17294
17842
  const _speedometer = speedometer(50, 250);
17295
17843
  return throttle(e => {
17844
+ if (!e || typeof e.loaded !== 'number') {
17845
+ return;
17846
+ }
17296
17847
  const rawLoaded = e.loaded;
17297
17848
  const total = e.lengthComputable ? e.total : undefined;
17298
17849
  const loaded = total != null ? Math.min(rawLoaded, total) : rawLoaded;
@@ -17443,6 +17994,32 @@ function setFormDataHeaders$1(headers, formHeaders, policy) {
17443
17994
  // the request currently owning that socket across keep-alive reuse (issue #10780).
17444
17995
  const kAxiosSocketListener = Symbol('axios.http.socketListener');
17445
17996
  const kAxiosCurrentReq = Symbol('axios.http.currentReq');
17997
+
17998
+ // Tags HttpsProxyAgent instances installed by setProxy() so the redirect path
17999
+ // can strip them without clobbering a user-supplied agent that happens to be
18000
+ // an HttpsProxyAgent.
18001
+ const kAxiosInstalledTunnel = Symbol('axios.http.installedTunnel');
18002
+
18003
+ // Cache of CONNECT-tunneling agents keyed by proxy config so repeat requests
18004
+ // through the same proxy reuse a single agent (and its socket pool). The
18005
+ // keyspace is bounded by the set of distinct proxy configs the process uses,
18006
+ // so unbounded growth is not a concern in practice.
18007
+ const tunnelingAgentCache = new Map();
18008
+ const tunnelingAgentCacheUser = new WeakMap();
18009
+ function getTunnelingAgent(agentOptions, userHttpsAgent) {
18010
+ const key = agentOptions.protocol + '//' + agentOptions.hostname + ':' + (agentOptions.port || '') + '#' + (agentOptions.auth || '');
18011
+ const cache = userHttpsAgent ? tunnelingAgentCacheUser.get(userHttpsAgent) || tunnelingAgentCacheUser.set(userHttpsAgent, new Map()).get(userHttpsAgent) : tunnelingAgentCache;
18012
+ let agent = cache.get(key);
18013
+ if (agent) return agent;
18014
+ // Forward the user's TLS options (custom CA, rejectUnauthorized, client cert,
18015
+ // etc.) into the tunneling agent so they apply to the origin TLS upgrade
18016
+ // performed after CONNECT. Our proxy fields take precedence on conflict.
18017
+ const merged = userHttpsAgent && userHttpsAgent.options ? _objectSpread2(_objectSpread2({}, userHttpsAgent.options), agentOptions) : agentOptions;
18018
+ agent = new HttpsProxyAgent(merged);
18019
+ agent[kAxiosInstalledTunnel] = true;
18020
+ cache.set(key, agent);
18021
+ return agent;
18022
+ }
17446
18023
  const supportedProtocols = platform.protocols.map(protocol => {
17447
18024
  return protocol + ':';
17448
18025
  });
@@ -17566,7 +18143,7 @@ function dispatchBeforeRedirect(options, responseDetails, requestDetails) {
17566
18143
  *
17567
18144
  * @returns {http.ClientRequestArgs}
17568
18145
  */
17569
- function setProxy(options, configProxy, location, isRedirect) {
18146
+ function setProxy(options, configProxy, location, isRedirect, configHttpsAgent) {
17570
18147
  let proxy = configProxy;
17571
18148
  if (!proxy && proxy !== false) {
17572
18149
  const proxyUrl = getProxyForUrl(location);
@@ -17587,6 +18164,13 @@ function setProxy(options, configProxy, location, isRedirect) {
17587
18164
  }
17588
18165
  }
17589
18166
  }
18167
+ // Strip any tunneling agent we installed for the previous hop so a redirect
18168
+ // that drops the proxy or crosses an HTTPS↔HTTP boundary doesn't reuse a
18169
+ // stale one. Match on our Symbol marker so a user-supplied HttpsProxyAgent
18170
+ // (which won't carry the marker) is left alone.
18171
+ if (isRedirect && options.agent && options.agent[kAxiosInstalledTunnel]) {
18172
+ options.agent = undefined;
18173
+ }
17590
18174
  if (proxy) {
17591
18175
  // Read proxy fields without traversing the prototype chain. URL instances expose
17592
18176
  // username/password/hostname/host/port/protocol via getters on URL.prototype (so
@@ -17619,37 +18203,84 @@ function setProxy(options, configProxy, location, isRedirect) {
17619
18203
  proxy
17620
18204
  });
17621
18205
  }
17622
- const base64 = Buffer.from(proxyAuth, 'utf8').toString('base64');
17623
- options.headers['Proxy-Authorization'] = 'Basic ' + base64;
17624
18206
  }
18207
+ const targetIsHttps = isHttps.test(options.protocol);
18208
+ if (targetIsHttps) {
18209
+ // CONNECT-tunneling path for HTTPS targets. Preserves end-to-end TLS to
18210
+ // the origin so the proxy cannot inspect the URL, headers, or body — the
18211
+ // behavior already promised by THREATMODEL.md (T-R9). HttpsProxyAgent
18212
+ // sends Proxy-Authorization on the CONNECT request only, never on the
18213
+ // wrapped TLS request, which is why we don't stamp it onto
18214
+ // options.headers here. If the user already supplied an HttpsProxyAgent,
18215
+ // they own tunneling end-to-end and we leave them alone; otherwise we
18216
+ // install our own tunneling agent and forward their TLS options (if any)
18217
+ // so a custom httpsAgent for cert pinning / rejectUnauthorized still
18218
+ // applies to the origin TLS upgrade.
18219
+ if (!(configHttpsAgent instanceof HttpsProxyAgent)) {
18220
+ const proxyHost = readProxyField('hostname') || readProxyField('host');
18221
+ const proxyPort = readProxyField('port');
18222
+ const rawProxyProtocol = readProxyField('protocol');
18223
+ const normalizedProtocol = rawProxyProtocol ? rawProxyProtocol.includes(':') ? rawProxyProtocol : `${rawProxyProtocol}:` : 'http:';
18224
+ // Bracket IPv6 literals for URL parsing; URL.hostname strips the
18225
+ // brackets again on read so the agent receives the raw form.
18226
+ const proxyHostForURL = proxyHost && proxyHost.includes(':') && !proxyHost.startsWith('[') ? `[${proxyHost}]` : proxyHost;
18227
+ const proxyURL = new URL(`${normalizedProtocol}//${proxyHostForURL}${proxyPort ? ':' + proxyPort : ''}`);
18228
+ const agentOptions = {
18229
+ protocol: proxyURL.protocol,
18230
+ hostname: proxyURL.hostname.replace(/^\[|\]$/g, ''),
18231
+ port: proxyURL.port,
18232
+ auth: proxyAuth && typeof proxyAuth === 'string' ? proxyAuth : undefined
18233
+ };
18234
+ if (proxyURL.protocol === 'https:') {
18235
+ agentOptions.ALPNProtocols = ['http/1.1'];
18236
+ }
18237
+ const tunnelingAgent = getTunnelingAgent(agentOptions, configHttpsAgent);
18238
+ // Set both: `options.agent` is consumed by the native https.request path
18239
+ // (config.maxRedirects === 0); `options.agents.https` is consumed by
18240
+ // follow-redirects, which ignores `options.agent` when `options.agents`
18241
+ // is present.
18242
+ options.agent = tunnelingAgent;
18243
+ if (options.agents) {
18244
+ options.agents.https = tunnelingAgent;
18245
+ }
18246
+ }
18247
+ } else {
18248
+ // Forward-proxy mode for plaintext HTTP targets. The request line carries
18249
+ // the absolute URL and the proxy sees everything — acceptable for plain
18250
+ // HTTP since the wire was already plaintext.
18251
+ if (proxyAuth) {
18252
+ const base64 = Buffer.from(proxyAuth, 'utf8').toString('base64');
18253
+ options.headers['Proxy-Authorization'] = 'Basic ' + base64;
18254
+ }
17625
18255
 
17626
- // Preserve a user-supplied Host header (case-insensitive) so callers can override
17627
- // the value forwarded to the proxy; otherwise default to the request URL's host.
17628
- let hasUserHostHeader = false;
17629
- for (const name of Object.keys(options.headers)) {
17630
- if (name.toLowerCase() === 'host') {
17631
- hasUserHostHeader = true;
17632
- break;
18256
+ // Preserve a user-supplied Host header (case-insensitive) so callers can override
18257
+ // the value forwarded to the proxy; otherwise default to the request URL's host.
18258
+ let hasUserHostHeader = false;
18259
+ for (const name of Object.keys(options.headers)) {
18260
+ if (name.toLowerCase() === 'host') {
18261
+ hasUserHostHeader = true;
18262
+ break;
18263
+ }
18264
+ }
18265
+ if (!hasUserHostHeader) {
18266
+ options.headers.host = options.hostname + (options.port ? ':' + options.port : '');
18267
+ }
18268
+ const proxyHost = readProxyField('hostname') || readProxyField('host');
18269
+ options.hostname = proxyHost;
18270
+ // Replace 'host' since options is not a URL object
18271
+ options.host = proxyHost;
18272
+ options.port = readProxyField('port');
18273
+ options.path = location;
18274
+ const proxyProtocol = readProxyField('protocol');
18275
+ if (proxyProtocol) {
18276
+ options.protocol = proxyProtocol.includes(':') ? proxyProtocol : `${proxyProtocol}:`;
17633
18277
  }
17634
- }
17635
- if (!hasUserHostHeader) {
17636
- options.headers.host = options.hostname + (options.port ? ':' + options.port : '');
17637
- }
17638
- const proxyHost = readProxyField('hostname') || readProxyField('host');
17639
- options.hostname = proxyHost;
17640
- // Replace 'host' since options is not a URL object
17641
- options.host = proxyHost;
17642
- options.port = readProxyField('port');
17643
- options.path = location;
17644
- const proxyProtocol = readProxyField('protocol');
17645
- if (proxyProtocol) {
17646
- options.protocol = proxyProtocol.includes(':') ? proxyProtocol : `${proxyProtocol}:`;
17647
18278
  }
17648
18279
  }
17649
18280
  options.beforeRedirects.proxy = function beforeRedirect(redirectOptions) {
17650
18281
  // Configure proxy for redirected request, passing the original config proxy to apply
17651
18282
  // the exact same logic as if the redirected request was performed by axios directly.
17652
- setProxy(redirectOptions, configProxy, redirectOptions.href, true);
18283
+ setProxy(redirectOptions, configProxy, redirectOptions.href, true, configHttpsAgent);
17653
18284
  };
17654
18285
  }
17655
18286
  const isHttpAdapterSupported = typeof process !== 'undefined' && utils$1$1.kindOf(process) === 'process';
@@ -17979,7 +18610,7 @@ var httpAdapter = isHttpAdapterSupported && function httpAdapter(config) {
17979
18610
  const options = Object.assign(Object.create(null), {
17980
18611
  path: path$1,
17981
18612
  method: method,
17982
- headers: headers.toJSON(),
18613
+ headers: toByteStringHeaderObject(headers),
17983
18614
  agents: {
17984
18615
  http: config.httpAgent,
17985
18616
  https: config.httpsAgent
@@ -18010,12 +18641,16 @@ var httpAdapter = isHttpAdapterSupported && function httpAdapter(config) {
18010
18641
  } else {
18011
18642
  options.hostname = parsed.hostname.startsWith('[') ? parsed.hostname.slice(1, -1) : parsed.hostname;
18012
18643
  options.port = parsed.port;
18013
- setProxy(options, config.proxy, protocol + '//' + parsed.hostname + (parsed.port ? ':' + parsed.port : '') + options.path);
18644
+ setProxy(options, config.proxy, protocol + '//' + parsed.hostname + (parsed.port ? ':' + parsed.port : '') + options.path, false, config.httpsAgent);
18014
18645
  }
18015
18646
  let transport;
18016
18647
  let isNativeTransport = false;
18017
18648
  const isHttpsRequest = isHttps.test(options.protocol);
18018
- options.agent = isHttpsRequest ? config.httpsAgent : config.httpAgent;
18649
+ // Don't clobber a CONNECT-tunneling agent installed by setProxy() for an
18650
+ // HTTPS target.
18651
+ if (options.agent == null) {
18652
+ options.agent = isHttpsRequest ? config.httpsAgent : config.httpAgent;
18653
+ }
18019
18654
  if (isHttp2) {
18020
18655
  transport = http2Transport;
18021
18656
  } else {
@@ -18704,7 +19339,7 @@ var xhrAdapter = isXHRAdapterSupported && function (config) {
18704
19339
 
18705
19340
  // Add headers to the request
18706
19341
  if ('setRequestHeader' in request) {
18707
- utils$1$1.forEach(requestHeaders.toJSON(), function setRequestHeader(val, key) {
19342
+ utils$1$1.forEach(toByteStringHeaderObject(requestHeaders), function setRequestHeader(val, key) {
18708
19343
  request.setRequestHeader(key, val);
18709
19344
  });
18710
19345
  }
@@ -18759,41 +19394,41 @@ var xhrAdapter = isXHRAdapterSupported && function (config) {
18759
19394
  });
18760
19395
  };
18761
19396
  const composeSignals = (signals, timeout) => {
18762
- const {
18763
- length
18764
- } = signals = signals ? signals.filter(Boolean) : [];
18765
- if (timeout || length) {
18766
- let controller = new AbortController();
18767
- let aborted;
18768
- const onabort = function (reason) {
18769
- if (!aborted) {
18770
- aborted = true;
18771
- unsubscribe();
18772
- const err = reason instanceof Error ? reason : this.reason;
18773
- controller.abort(err instanceof AxiosError ? err : new CanceledError(err instanceof Error ? err.message : err));
18774
- }
18775
- };
18776
- let timer = timeout && setTimeout(() => {
18777
- timer = null;
18778
- onabort(new AxiosError(`timeout of ${timeout}ms exceeded`, AxiosError.ETIMEDOUT));
18779
- }, timeout);
18780
- const unsubscribe = () => {
18781
- if (signals) {
18782
- timer && clearTimeout(timer);
18783
- timer = null;
18784
- signals.forEach(signal => {
18785
- signal.unsubscribe ? signal.unsubscribe(onabort) : signal.removeEventListener('abort', onabort);
18786
- });
18787
- signals = null;
18788
- }
18789
- };
18790
- signals.forEach(signal => signal.addEventListener('abort', onabort));
18791
- const {
18792
- signal
18793
- } = controller;
18794
- signal.unsubscribe = () => utils$1$1.asap(unsubscribe);
18795
- return signal;
19397
+ signals = signals ? signals.filter(Boolean) : [];
19398
+ if (!timeout && !signals.length) {
19399
+ return;
18796
19400
  }
19401
+ const controller = new AbortController();
19402
+ let aborted = false;
19403
+ const onabort = function (reason) {
19404
+ if (!aborted) {
19405
+ aborted = true;
19406
+ unsubscribe();
19407
+ const err = reason instanceof Error ? reason : this.reason;
19408
+ controller.abort(err instanceof AxiosError ? err : new CanceledError(err instanceof Error ? err.message : err));
19409
+ }
19410
+ };
19411
+ let timer = timeout && setTimeout(() => {
19412
+ timer = null;
19413
+ onabort(new AxiosError(`timeout of ${timeout}ms exceeded`, AxiosError.ETIMEDOUT));
19414
+ }, timeout);
19415
+ const unsubscribe = () => {
19416
+ if (!signals) {
19417
+ return;
19418
+ }
19419
+ timer && clearTimeout(timer);
19420
+ timer = null;
19421
+ signals.forEach(signal => {
19422
+ signal.unsubscribe ? signal.unsubscribe(onabort) : signal.removeEventListener('abort', onabort);
19423
+ });
19424
+ signals = null;
19425
+ };
19426
+ signals.forEach(signal => signal.addEventListener('abort', onabort));
19427
+ const {
19428
+ signal
19429
+ } = controller;
19430
+ signal.unsubscribe = () => utils$1$1.asap(unsubscribe);
19431
+ return signal;
18797
19432
  };
18798
19433
  const streamChunk = function* (chunk, chunkSize) {
18799
19434
  let len = chunk.byteLength;
@@ -18919,8 +19554,7 @@ const test = (fn, ...args) => {
18919
19554
  }
18920
19555
  };
18921
19556
  const factory = env => {
18922
- var _utils$global;
18923
- const globalObject = (_utils$global = utils$1$1.global) !== null && _utils$global !== void 0 ? _utils$global : globalThis;
19557
+ const globalObject = utils$1$1.global !== undefined && utils$1$1.global !== null ? utils$1$1.global : globalThis;
18924
19558
  const {
18925
19559
  ReadableStream,
18926
19560
  TextEncoder
@@ -19088,7 +19722,7 @@ const factory = env => {
19088
19722
  const resolvedOptions = _objectSpread2(_objectSpread2({}, fetchOptions), {}, {
19089
19723
  signal: composedSignal,
19090
19724
  method: method.toUpperCase(),
19091
- headers: headers.normalize().toJSON(),
19725
+ headers: toByteStringHeaderObject(headers.normalize()),
19092
19726
  body: data,
19093
19727
  duplex: 'half',
19094
19728
  credentials: isCredentialsSupported ? withCredentials : undefined
@@ -23978,8 +24612,13 @@ function checkEnableTimelinePreviewIsAllowed(host, timelinePreview) {
23978
24612
  }
23979
24613
  const isValidConfig = isValidTimelinePreviewConfig(timelinePreview);
23980
24614
  // Show error if used outside of CPA.
23981
- // Opt-out of the error if a custom domain is used and CPA could not be idenfified
23982
- const isValidHost = typeof host === 'string' && (!host.includes('contentful') || host.startsWith('preview'));
24615
+ // Opt-out of the error if a custom domain is used and CPA could not be identified.
24616
+ // Use an exact domain match to avoid false-positives on proxy hostnames that contain
24617
+ // "contentful" as a substring (e.g. api-contentful-proxy.example.com).
24618
+ const PREVIEW_HOST_REGEX = /^preview(\.eu)?\.contentful\.com$/;
24619
+ const isContentfulHost = typeof host === 'string' && PREVIEW_HOST_REGEX.test(host);
24620
+ const isCustomHost = typeof host !== 'string' || !host.endsWith('.contentful.com');
24621
+ const isValidHost = isContentfulHost || isCustomHost;
23983
24622
  if (isValidConfig && !isValidHost) {
23984
24623
  throw new ValidationError('timelinePreview', `The 'timelinePreview' parameter can only be used with the CPA. Please set host to 'preview.contentful.com' or 'preview.eu.contentful.com' to enable Timeline Preview.
23985
24624
  `);