@revenexx/integrations-node-sdk 1.7.0 → 1.8.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.
- package/dist/index.cjs +65 -4
- package/dist/index.d.cts +13 -1
- package/dist/index.d.ts +13 -1
- package/dist/index.js +64 -4
- package/package.json +1 -1
package/dist/index.cjs
CHANGED
|
@@ -61,6 +61,7 @@ __export(index_exports, {
|
|
|
61
61
|
extractCredentialManifests: () => extractCredentialManifests,
|
|
62
62
|
extractManifest: () => extractManifest,
|
|
63
63
|
extractManifests: () => extractManifests,
|
|
64
|
+
headerCrossesOrigin: () => headerCrossesOrigin,
|
|
64
65
|
httpErrorResult: () => httpErrorResult,
|
|
65
66
|
isBlockedAddress: () => isBlockedAddress,
|
|
66
67
|
isNodeWithIteration: () => isNodeWithIteration,
|
|
@@ -475,6 +476,63 @@ var DEFAULT_TIMEOUT_MS = 3e4;
|
|
|
475
476
|
var MAX_TIMEOUT_MS = 12e4;
|
|
476
477
|
var MAX_REDIRECTS = 5;
|
|
477
478
|
var REDIRECT_STATUSES = /* @__PURE__ */ new Set([301, 302, 303, 307, 308]);
|
|
479
|
+
var CROSS_ORIGIN_SAFE_HEADERS = /* @__PURE__ */ new Set([
|
|
480
|
+
"accept",
|
|
481
|
+
"accept-encoding",
|
|
482
|
+
"accept-language",
|
|
483
|
+
"content-encoding",
|
|
484
|
+
"content-language",
|
|
485
|
+
"content-type",
|
|
486
|
+
"idempotency-key",
|
|
487
|
+
"if-match",
|
|
488
|
+
"if-modified-since",
|
|
489
|
+
"if-none-match",
|
|
490
|
+
"if-range",
|
|
491
|
+
"if-unmodified-since",
|
|
492
|
+
"range",
|
|
493
|
+
"soapaction",
|
|
494
|
+
"user-agent"
|
|
495
|
+
]);
|
|
496
|
+
function headerCrossesOrigin(name) {
|
|
497
|
+
return CROSS_ORIGIN_SAFE_HEADERS.has(name.trim().toLowerCase());
|
|
498
|
+
}
|
|
499
|
+
var UNSENDABLE_IN_HEADER_VALUE = /[\0-\x08\x0a-\x1f\x7f\u0100-\uffff]/;
|
|
500
|
+
var HEADER_NAME_TOKEN = /^[!#$%&'*+\-.^_`|~0-9A-Za-z]+$/;
|
|
501
|
+
function isHttpWhitespace(code) {
|
|
502
|
+
return code === 9 || code === 10 || code === 13 || code === 32;
|
|
503
|
+
}
|
|
504
|
+
function trimHttpWhitespace(value) {
|
|
505
|
+
let start = 0;
|
|
506
|
+
let end = value.length;
|
|
507
|
+
while (start < end && isHttpWhitespace(value.charCodeAt(start))) start++;
|
|
508
|
+
while (end > start && isHttpWhitespace(value.charCodeAt(end - 1))) end--;
|
|
509
|
+
return value.slice(start, end);
|
|
510
|
+
}
|
|
511
|
+
function invalidHeader(detail) {
|
|
512
|
+
return new NodeError("INVALID_HEADER", detail, { status: 0 });
|
|
513
|
+
}
|
|
514
|
+
function sendableHeaders(headers) {
|
|
515
|
+
if (typeof headers !== "object" || headers === null) {
|
|
516
|
+
throw invalidHeader("Headers must be an object or a list of pairs");
|
|
517
|
+
}
|
|
518
|
+
if (!(Symbol.iterator in headers) && Object.getOwnPropertySymbols(headers).length > 0) {
|
|
519
|
+
throw invalidHeader("A header name must be a string, not a symbol");
|
|
520
|
+
}
|
|
521
|
+
const entries = Symbol.iterator in headers ? Array.from(headers) : Object.entries(headers);
|
|
522
|
+
return entries.map((entry, i) => {
|
|
523
|
+
const pair = typeof entry === "object" && entry !== null && Symbol.iterator in entry ? Array.from(entry) : [];
|
|
524
|
+
if (pair.length !== 2) throw invalidHeader(`Header entry ${i} is not a name/value pair`);
|
|
525
|
+
const name = String(pair[0]);
|
|
526
|
+
const value = String(pair[1]);
|
|
527
|
+
if (!HEADER_NAME_TOKEN.test(name)) {
|
|
528
|
+
throw invalidHeader(`Header name ${JSON.stringify(name)} cannot be sent`);
|
|
529
|
+
}
|
|
530
|
+
if (UNSENDABLE_IN_HEADER_VALUE.test(trimHttpWhitespace(value))) {
|
|
531
|
+
throw invalidHeader(`Header ${JSON.stringify(name)} has a character in its value that cannot be sent`);
|
|
532
|
+
}
|
|
533
|
+
return [name, value];
|
|
534
|
+
});
|
|
535
|
+
}
|
|
478
536
|
var DEFAULT_RETRY_ATTEMPTS = 0;
|
|
479
537
|
var MAX_RETRY_ATTEMPTS = 5;
|
|
480
538
|
var DEFAULT_RETRY_DELAY_MS = 1e3;
|
|
@@ -547,7 +605,7 @@ async function guardedFetch(url, fetchOptions, ctxSignal, effectiveMs) {
|
|
|
547
605
|
throw new NodeError("BLOCKED_ADDRESS", "Blocked https\u2192http downgrade on redirect", { status: 0 });
|
|
548
606
|
}
|
|
549
607
|
await guardUrl(nextUrl, ctxSignal, effectiveMs);
|
|
550
|
-
const headers = new Headers(currentInit.headers
|
|
608
|
+
const headers = new Headers(currentInit.headers);
|
|
551
609
|
let method = (currentInit.method ?? "GET").toUpperCase();
|
|
552
610
|
let body = currentInit.body;
|
|
553
611
|
if (redirectStatus === 303 || (redirectStatus === 301 || redirectStatus === 302) && method === "POST") {
|
|
@@ -557,9 +615,9 @@ async function guardedFetch(url, fetchOptions, ctxSignal, effectiveMs) {
|
|
|
557
615
|
headers.delete("content-length");
|
|
558
616
|
}
|
|
559
617
|
if (nextUrl.origin !== base.origin) {
|
|
560
|
-
headers.
|
|
561
|
-
|
|
562
|
-
|
|
618
|
+
for (const name of [...headers.keys()]) {
|
|
619
|
+
if (!headerCrossesOrigin(name)) headers.delete(name);
|
|
620
|
+
}
|
|
563
621
|
}
|
|
564
622
|
currentUrl = nextUrl;
|
|
565
623
|
currentInit = { ...currentInit, method, body, headers, redirect: "manual" };
|
|
@@ -572,6 +630,8 @@ async function safeFetch(url, options = {}) {
|
|
|
572
630
|
const safeAttempts = Number.isFinite(rawAttempts) ? Math.min(Math.max(0, rawAttempts), MAX_RETRY_ATTEMPTS) : DEFAULT_RETRY_ATTEMPTS;
|
|
573
631
|
const maxAttempts = safeAttempts + 1;
|
|
574
632
|
const retryDelayMs = retry?.delayMs ?? DEFAULT_RETRY_DELAY_MS;
|
|
633
|
+
if (ctxSignal?.aborted) throw ctxSignal.reason;
|
|
634
|
+
if (fetchOptions.headers !== void 0) fetchOptions.headers = sendableHeaders(fetchOptions.headers);
|
|
575
635
|
let lastError;
|
|
576
636
|
for (let attempt = 1; attempt <= maxAttempts; attempt++) {
|
|
577
637
|
if (ctxSignal?.aborted) throw ctxSignal.reason;
|
|
@@ -1115,6 +1175,7 @@ function base64Url(buf) {
|
|
|
1115
1175
|
extractCredentialManifests,
|
|
1116
1176
|
extractManifest,
|
|
1117
1177
|
extractManifests,
|
|
1178
|
+
headerCrossesOrigin,
|
|
1118
1179
|
httpErrorResult,
|
|
1119
1180
|
isBlockedAddress,
|
|
1120
1181
|
isNodeWithIteration,
|
package/dist/index.d.cts
CHANGED
|
@@ -771,6 +771,18 @@ declare const DEFAULT_TIMEOUT_MS = 30000;
|
|
|
771
771
|
declare const MAX_TIMEOUT_MS = 120000;
|
|
772
772
|
/** Maximum number of redirect hops `safeFetch` follows before giving up. */
|
|
773
773
|
declare const MAX_REDIRECTS = 5;
|
|
774
|
+
/**
|
|
775
|
+
* Whether a request header with this name goes on to the next hop when
|
|
776
|
+
* {@link safeFetch} follows a redirect to another origin — `true` for `Accept`,
|
|
777
|
+
* `Accept-Encoding`, `Accept-Language`, `Content-Encoding`, `Content-Language`,
|
|
778
|
+
* `Content-Type`, `Idempotency-Key`, `If-Match`, `If-Modified-Since`,
|
|
779
|
+
* `If-None-Match`, `If-Range`, `If-Unmodified-Since`, `Range`, `SOAPAction` and
|
|
780
|
+
* `User-Agent`, in any case, and `false` for every other name. The keep-list is by
|
|
781
|
+
* name, so it can only keep a secret out of the headers it drops: a credential
|
|
782
|
+
* whose header name the author chooses must refuse a name this answers `true`
|
|
783
|
+
* for, or its key would cross with the harmless headers.
|
|
784
|
+
*/
|
|
785
|
+
declare function headerCrossesOrigin(name: string): boolean;
|
|
774
786
|
declare const DEFAULT_RETRY_ATTEMPTS = 0;
|
|
775
787
|
declare const MAX_RETRY_ATTEMPTS = 5;
|
|
776
788
|
declare const DEFAULT_RETRY_DELAY_MS = 1000;
|
|
@@ -1239,4 +1251,4 @@ declare abstract class OAuth2AuthCodeCredential extends BaseCredential implement
|
|
|
1239
1251
|
test(_ctx: ICredentialContext, config: Config): Promise<ICredentialTestResult>;
|
|
1240
1252
|
}
|
|
1241
1253
|
|
|
1242
|
-
export { ApiKeyCredential, BaseCredential, BasicAuthCredential, type ConfigType, type CredentialAuthKind, type CredentialFieldType, DEFAULT_MAX_RESPONSE_BYTES, DEFAULT_RETRY_ATTEMPTS, DEFAULT_RETRY_DELAY_MS, DEFAULT_RETRY_POLICY, DEFAULT_TIMEOUT_MS, type DataType, type IConfigField, type IConfigFieldBase, type IConfigOption, type IConfigValidation, type ICredential, type ICredentialContext, type ICredentialDescription, type ICredentialField, type ICredentialOAuthAuthorize, type ICredentialResolveResult, type ICredentialTestResult, type IImage, type IInputPort, type INode, type INodeAuthorContext, type INodeContext, type INodeDescription, type INodeResult, type INodeState, type INodeWithIteration, type IOutputField, type IOutputPort, type IShowIfCondition, type ITemplateDescription, type ITemplateTrigger, type ImageCategory, type LocalizedString, type LookupAddress, type LookupFn, MANIFEST_VERSION, MAX_REDIRECTS, MAX_RESPONSE_BYTES, MAX_RETRY_ATTEMPTS, MAX_TIMEOUT_MS, type NodeCategory, NodeError, type NodeErrorOutput, type NodeManifest, type NodePackageMeta, OAuth2AuthCodeCredential, OAuth2ClientCredentialsCredential, type OAuthTokenResponse, OPERATORS, type Operator, type OutputKind, type RetryHooks, type RetryPolicy, RetryableError, type SafeFetchOptions, type SafeFetchRetry, SimpleValueCredential, type TemplateLevel, type TemplateTriggerType, VALUELESS_OPERATORS, assertPublicUrl, backoffDelay, buildManifest, clampResponseBytes, errorPort, errorResult, evaluate, extractCredentialManifest, extractCredentialManifests, extractManifest, extractManifests, httpErrorResult, isBlockedAddress, isNodeWithIteration, isOAuthAuthorizeCredential, isOperator, maxBytesConfigField, normalizeCredentialType, normalizeLocalized, packageIconProblem, parsePackageMeta, readArrayBuffer, readJsonOrText, readText, retryConfigFields, safeFetch, settingApplies, sleepWithSignal, takesValue, timeoutConfigField, toErrorOutput, toErrorResult, withRetry };
|
|
1254
|
+
export { ApiKeyCredential, BaseCredential, BasicAuthCredential, type ConfigType, type CredentialAuthKind, type CredentialFieldType, DEFAULT_MAX_RESPONSE_BYTES, DEFAULT_RETRY_ATTEMPTS, DEFAULT_RETRY_DELAY_MS, DEFAULT_RETRY_POLICY, DEFAULT_TIMEOUT_MS, type DataType, type IConfigField, type IConfigFieldBase, type IConfigOption, type IConfigValidation, type ICredential, type ICredentialContext, type ICredentialDescription, type ICredentialField, type ICredentialOAuthAuthorize, type ICredentialResolveResult, type ICredentialTestResult, type IImage, type IInputPort, type INode, type INodeAuthorContext, type INodeContext, type INodeDescription, type INodeResult, type INodeState, type INodeWithIteration, type IOutputField, type IOutputPort, type IShowIfCondition, type ITemplateDescription, type ITemplateTrigger, type ImageCategory, type LocalizedString, type LookupAddress, type LookupFn, MANIFEST_VERSION, MAX_REDIRECTS, MAX_RESPONSE_BYTES, MAX_RETRY_ATTEMPTS, MAX_TIMEOUT_MS, type NodeCategory, NodeError, type NodeErrorOutput, type NodeManifest, type NodePackageMeta, OAuth2AuthCodeCredential, OAuth2ClientCredentialsCredential, type OAuthTokenResponse, OPERATORS, type Operator, type OutputKind, type RetryHooks, type RetryPolicy, RetryableError, type SafeFetchOptions, type SafeFetchRetry, SimpleValueCredential, type TemplateLevel, type TemplateTriggerType, VALUELESS_OPERATORS, assertPublicUrl, backoffDelay, buildManifest, clampResponseBytes, errorPort, errorResult, evaluate, extractCredentialManifest, extractCredentialManifests, extractManifest, extractManifests, headerCrossesOrigin, httpErrorResult, isBlockedAddress, isNodeWithIteration, isOAuthAuthorizeCredential, isOperator, maxBytesConfigField, normalizeCredentialType, normalizeLocalized, packageIconProblem, parsePackageMeta, readArrayBuffer, readJsonOrText, readText, retryConfigFields, safeFetch, settingApplies, sleepWithSignal, takesValue, timeoutConfigField, toErrorOutput, toErrorResult, withRetry };
|
package/dist/index.d.ts
CHANGED
|
@@ -771,6 +771,18 @@ declare const DEFAULT_TIMEOUT_MS = 30000;
|
|
|
771
771
|
declare const MAX_TIMEOUT_MS = 120000;
|
|
772
772
|
/** Maximum number of redirect hops `safeFetch` follows before giving up. */
|
|
773
773
|
declare const MAX_REDIRECTS = 5;
|
|
774
|
+
/**
|
|
775
|
+
* Whether a request header with this name goes on to the next hop when
|
|
776
|
+
* {@link safeFetch} follows a redirect to another origin — `true` for `Accept`,
|
|
777
|
+
* `Accept-Encoding`, `Accept-Language`, `Content-Encoding`, `Content-Language`,
|
|
778
|
+
* `Content-Type`, `Idempotency-Key`, `If-Match`, `If-Modified-Since`,
|
|
779
|
+
* `If-None-Match`, `If-Range`, `If-Unmodified-Since`, `Range`, `SOAPAction` and
|
|
780
|
+
* `User-Agent`, in any case, and `false` for every other name. The keep-list is by
|
|
781
|
+
* name, so it can only keep a secret out of the headers it drops: a credential
|
|
782
|
+
* whose header name the author chooses must refuse a name this answers `true`
|
|
783
|
+
* for, or its key would cross with the harmless headers.
|
|
784
|
+
*/
|
|
785
|
+
declare function headerCrossesOrigin(name: string): boolean;
|
|
774
786
|
declare const DEFAULT_RETRY_ATTEMPTS = 0;
|
|
775
787
|
declare const MAX_RETRY_ATTEMPTS = 5;
|
|
776
788
|
declare const DEFAULT_RETRY_DELAY_MS = 1000;
|
|
@@ -1239,4 +1251,4 @@ declare abstract class OAuth2AuthCodeCredential extends BaseCredential implement
|
|
|
1239
1251
|
test(_ctx: ICredentialContext, config: Config): Promise<ICredentialTestResult>;
|
|
1240
1252
|
}
|
|
1241
1253
|
|
|
1242
|
-
export { ApiKeyCredential, BaseCredential, BasicAuthCredential, type ConfigType, type CredentialAuthKind, type CredentialFieldType, DEFAULT_MAX_RESPONSE_BYTES, DEFAULT_RETRY_ATTEMPTS, DEFAULT_RETRY_DELAY_MS, DEFAULT_RETRY_POLICY, DEFAULT_TIMEOUT_MS, type DataType, type IConfigField, type IConfigFieldBase, type IConfigOption, type IConfigValidation, type ICredential, type ICredentialContext, type ICredentialDescription, type ICredentialField, type ICredentialOAuthAuthorize, type ICredentialResolveResult, type ICredentialTestResult, type IImage, type IInputPort, type INode, type INodeAuthorContext, type INodeContext, type INodeDescription, type INodeResult, type INodeState, type INodeWithIteration, type IOutputField, type IOutputPort, type IShowIfCondition, type ITemplateDescription, type ITemplateTrigger, type ImageCategory, type LocalizedString, type LookupAddress, type LookupFn, MANIFEST_VERSION, MAX_REDIRECTS, MAX_RESPONSE_BYTES, MAX_RETRY_ATTEMPTS, MAX_TIMEOUT_MS, type NodeCategory, NodeError, type NodeErrorOutput, type NodeManifest, type NodePackageMeta, OAuth2AuthCodeCredential, OAuth2ClientCredentialsCredential, type OAuthTokenResponse, OPERATORS, type Operator, type OutputKind, type RetryHooks, type RetryPolicy, RetryableError, type SafeFetchOptions, type SafeFetchRetry, SimpleValueCredential, type TemplateLevel, type TemplateTriggerType, VALUELESS_OPERATORS, assertPublicUrl, backoffDelay, buildManifest, clampResponseBytes, errorPort, errorResult, evaluate, extractCredentialManifest, extractCredentialManifests, extractManifest, extractManifests, httpErrorResult, isBlockedAddress, isNodeWithIteration, isOAuthAuthorizeCredential, isOperator, maxBytesConfigField, normalizeCredentialType, normalizeLocalized, packageIconProblem, parsePackageMeta, readArrayBuffer, readJsonOrText, readText, retryConfigFields, safeFetch, settingApplies, sleepWithSignal, takesValue, timeoutConfigField, toErrorOutput, toErrorResult, withRetry };
|
|
1254
|
+
export { ApiKeyCredential, BaseCredential, BasicAuthCredential, type ConfigType, type CredentialAuthKind, type CredentialFieldType, DEFAULT_MAX_RESPONSE_BYTES, DEFAULT_RETRY_ATTEMPTS, DEFAULT_RETRY_DELAY_MS, DEFAULT_RETRY_POLICY, DEFAULT_TIMEOUT_MS, type DataType, type IConfigField, type IConfigFieldBase, type IConfigOption, type IConfigValidation, type ICredential, type ICredentialContext, type ICredentialDescription, type ICredentialField, type ICredentialOAuthAuthorize, type ICredentialResolveResult, type ICredentialTestResult, type IImage, type IInputPort, type INode, type INodeAuthorContext, type INodeContext, type INodeDescription, type INodeResult, type INodeState, type INodeWithIteration, type IOutputField, type IOutputPort, type IShowIfCondition, type ITemplateDescription, type ITemplateTrigger, type ImageCategory, type LocalizedString, type LookupAddress, type LookupFn, MANIFEST_VERSION, MAX_REDIRECTS, MAX_RESPONSE_BYTES, MAX_RETRY_ATTEMPTS, MAX_TIMEOUT_MS, type NodeCategory, NodeError, type NodeErrorOutput, type NodeManifest, type NodePackageMeta, OAuth2AuthCodeCredential, OAuth2ClientCredentialsCredential, type OAuthTokenResponse, OPERATORS, type Operator, type OutputKind, type RetryHooks, type RetryPolicy, RetryableError, type SafeFetchOptions, type SafeFetchRetry, SimpleValueCredential, type TemplateLevel, type TemplateTriggerType, VALUELESS_OPERATORS, assertPublicUrl, backoffDelay, buildManifest, clampResponseBytes, errorPort, errorResult, evaluate, extractCredentialManifest, extractCredentialManifests, extractManifest, extractManifests, headerCrossesOrigin, httpErrorResult, isBlockedAddress, isNodeWithIteration, isOAuthAuthorizeCredential, isOperator, maxBytesConfigField, normalizeCredentialType, normalizeLocalized, packageIconProblem, parsePackageMeta, readArrayBuffer, readJsonOrText, readText, retryConfigFields, safeFetch, settingApplies, sleepWithSignal, takesValue, timeoutConfigField, toErrorOutput, toErrorResult, withRetry };
|
package/dist/index.js
CHANGED
|
@@ -384,6 +384,63 @@ var DEFAULT_TIMEOUT_MS = 3e4;
|
|
|
384
384
|
var MAX_TIMEOUT_MS = 12e4;
|
|
385
385
|
var MAX_REDIRECTS = 5;
|
|
386
386
|
var REDIRECT_STATUSES = /* @__PURE__ */ new Set([301, 302, 303, 307, 308]);
|
|
387
|
+
var CROSS_ORIGIN_SAFE_HEADERS = /* @__PURE__ */ new Set([
|
|
388
|
+
"accept",
|
|
389
|
+
"accept-encoding",
|
|
390
|
+
"accept-language",
|
|
391
|
+
"content-encoding",
|
|
392
|
+
"content-language",
|
|
393
|
+
"content-type",
|
|
394
|
+
"idempotency-key",
|
|
395
|
+
"if-match",
|
|
396
|
+
"if-modified-since",
|
|
397
|
+
"if-none-match",
|
|
398
|
+
"if-range",
|
|
399
|
+
"if-unmodified-since",
|
|
400
|
+
"range",
|
|
401
|
+
"soapaction",
|
|
402
|
+
"user-agent"
|
|
403
|
+
]);
|
|
404
|
+
function headerCrossesOrigin(name) {
|
|
405
|
+
return CROSS_ORIGIN_SAFE_HEADERS.has(name.trim().toLowerCase());
|
|
406
|
+
}
|
|
407
|
+
var UNSENDABLE_IN_HEADER_VALUE = /[\0-\x08\x0a-\x1f\x7f\u0100-\uffff]/;
|
|
408
|
+
var HEADER_NAME_TOKEN = /^[!#$%&'*+\-.^_`|~0-9A-Za-z]+$/;
|
|
409
|
+
function isHttpWhitespace(code) {
|
|
410
|
+
return code === 9 || code === 10 || code === 13 || code === 32;
|
|
411
|
+
}
|
|
412
|
+
function trimHttpWhitespace(value) {
|
|
413
|
+
let start = 0;
|
|
414
|
+
let end = value.length;
|
|
415
|
+
while (start < end && isHttpWhitespace(value.charCodeAt(start))) start++;
|
|
416
|
+
while (end > start && isHttpWhitespace(value.charCodeAt(end - 1))) end--;
|
|
417
|
+
return value.slice(start, end);
|
|
418
|
+
}
|
|
419
|
+
function invalidHeader(detail) {
|
|
420
|
+
return new NodeError("INVALID_HEADER", detail, { status: 0 });
|
|
421
|
+
}
|
|
422
|
+
function sendableHeaders(headers) {
|
|
423
|
+
if (typeof headers !== "object" || headers === null) {
|
|
424
|
+
throw invalidHeader("Headers must be an object or a list of pairs");
|
|
425
|
+
}
|
|
426
|
+
if (!(Symbol.iterator in headers) && Object.getOwnPropertySymbols(headers).length > 0) {
|
|
427
|
+
throw invalidHeader("A header name must be a string, not a symbol");
|
|
428
|
+
}
|
|
429
|
+
const entries = Symbol.iterator in headers ? Array.from(headers) : Object.entries(headers);
|
|
430
|
+
return entries.map((entry, i) => {
|
|
431
|
+
const pair = typeof entry === "object" && entry !== null && Symbol.iterator in entry ? Array.from(entry) : [];
|
|
432
|
+
if (pair.length !== 2) throw invalidHeader(`Header entry ${i} is not a name/value pair`);
|
|
433
|
+
const name = String(pair[0]);
|
|
434
|
+
const value = String(pair[1]);
|
|
435
|
+
if (!HEADER_NAME_TOKEN.test(name)) {
|
|
436
|
+
throw invalidHeader(`Header name ${JSON.stringify(name)} cannot be sent`);
|
|
437
|
+
}
|
|
438
|
+
if (UNSENDABLE_IN_HEADER_VALUE.test(trimHttpWhitespace(value))) {
|
|
439
|
+
throw invalidHeader(`Header ${JSON.stringify(name)} has a character in its value that cannot be sent`);
|
|
440
|
+
}
|
|
441
|
+
return [name, value];
|
|
442
|
+
});
|
|
443
|
+
}
|
|
387
444
|
var DEFAULT_RETRY_ATTEMPTS = 0;
|
|
388
445
|
var MAX_RETRY_ATTEMPTS = 5;
|
|
389
446
|
var DEFAULT_RETRY_DELAY_MS = 1e3;
|
|
@@ -456,7 +513,7 @@ async function guardedFetch(url, fetchOptions, ctxSignal, effectiveMs) {
|
|
|
456
513
|
throw new NodeError("BLOCKED_ADDRESS", "Blocked https\u2192http downgrade on redirect", { status: 0 });
|
|
457
514
|
}
|
|
458
515
|
await guardUrl(nextUrl, ctxSignal, effectiveMs);
|
|
459
|
-
const headers = new Headers(currentInit.headers
|
|
516
|
+
const headers = new Headers(currentInit.headers);
|
|
460
517
|
let method = (currentInit.method ?? "GET").toUpperCase();
|
|
461
518
|
let body = currentInit.body;
|
|
462
519
|
if (redirectStatus === 303 || (redirectStatus === 301 || redirectStatus === 302) && method === "POST") {
|
|
@@ -466,9 +523,9 @@ async function guardedFetch(url, fetchOptions, ctxSignal, effectiveMs) {
|
|
|
466
523
|
headers.delete("content-length");
|
|
467
524
|
}
|
|
468
525
|
if (nextUrl.origin !== base.origin) {
|
|
469
|
-
headers.
|
|
470
|
-
|
|
471
|
-
|
|
526
|
+
for (const name of [...headers.keys()]) {
|
|
527
|
+
if (!headerCrossesOrigin(name)) headers.delete(name);
|
|
528
|
+
}
|
|
472
529
|
}
|
|
473
530
|
currentUrl = nextUrl;
|
|
474
531
|
currentInit = { ...currentInit, method, body, headers, redirect: "manual" };
|
|
@@ -481,6 +538,8 @@ async function safeFetch(url, options = {}) {
|
|
|
481
538
|
const safeAttempts = Number.isFinite(rawAttempts) ? Math.min(Math.max(0, rawAttempts), MAX_RETRY_ATTEMPTS) : DEFAULT_RETRY_ATTEMPTS;
|
|
482
539
|
const maxAttempts = safeAttempts + 1;
|
|
483
540
|
const retryDelayMs = retry?.delayMs ?? DEFAULT_RETRY_DELAY_MS;
|
|
541
|
+
if (ctxSignal?.aborted) throw ctxSignal.reason;
|
|
542
|
+
if (fetchOptions.headers !== void 0) fetchOptions.headers = sendableHeaders(fetchOptions.headers);
|
|
484
543
|
let lastError;
|
|
485
544
|
for (let attempt = 1; attempt <= maxAttempts; attempt++) {
|
|
486
545
|
if (ctxSignal?.aborted) throw ctxSignal.reason;
|
|
@@ -988,6 +1047,7 @@ export {
|
|
|
988
1047
|
extractCredentialManifests,
|
|
989
1048
|
extractManifest,
|
|
990
1049
|
extractManifests,
|
|
1050
|
+
headerCrossesOrigin,
|
|
991
1051
|
httpErrorResult,
|
|
992
1052
|
isBlockedAddress,
|
|
993
1053
|
isNodeWithIteration,
|