@sveltejs/adapter-netlify 1.0.0-next.62 → 1.0.0-next.65
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/files/cjs/{multipart-parser-55fbd1f3.js → multipart-parser-d6fbdf05.js} +2 -8
- package/files/cjs/serverless.js +4 -1
- package/files/cjs/shims.js +211 -71
- package/files/esm/{multipart-parser-172e1198.js → multipart-parser-78ee0a95.js} +2 -8
- package/files/esm/serverless.js +4 -1
- package/files/esm/shims.js +212 -72
- package/index.d.ts +1 -3
- package/index.js +4 -3
- package/package.json +12 -4
package/files/cjs/shims.js
CHANGED
|
@@ -6,9 +6,12 @@ var http = require('node:http');
|
|
|
6
6
|
var https = require('node:https');
|
|
7
7
|
var zlib = require('node:zlib');
|
|
8
8
|
var Stream = require('node:stream');
|
|
9
|
+
var node_buffer = require('node:buffer');
|
|
9
10
|
var node_util = require('node:util');
|
|
10
11
|
var node_url = require('node:url');
|
|
11
|
-
var
|
|
12
|
+
var node_net = require('node:net');
|
|
13
|
+
require('node:fs');
|
|
14
|
+
require('node:path');
|
|
12
15
|
var crypto = require('crypto');
|
|
13
16
|
|
|
14
17
|
function _interopDefaultLegacy (e) { return e && typeof e === 'object' && 'default' in e ? e : { 'default': e }; }
|
|
@@ -75,7 +78,7 @@ function dataUriToBuffer(uri) {
|
|
|
75
78
|
var ponyfill_es2018 = {exports: {}};
|
|
76
79
|
|
|
77
80
|
/**
|
|
78
|
-
* web-streams-polyfill v3.2.
|
|
81
|
+
* web-streams-polyfill v3.2.1
|
|
79
82
|
*/
|
|
80
83
|
|
|
81
84
|
(function (module, exports) {
|
|
@@ -3777,10 +3780,16 @@ var ponyfill_es2018 = {exports: {}};
|
|
|
3777
3780
|
const byteLengthSizeFunction = (chunk) => {
|
|
3778
3781
|
return chunk.byteLength;
|
|
3779
3782
|
};
|
|
3780
|
-
|
|
3781
|
-
|
|
3782
|
-
|
|
3783
|
-
|
|
3783
|
+
try {
|
|
3784
|
+
Object.defineProperty(byteLengthSizeFunction, 'name', {
|
|
3785
|
+
value: 'size',
|
|
3786
|
+
configurable: true
|
|
3787
|
+
});
|
|
3788
|
+
}
|
|
3789
|
+
catch (_a) {
|
|
3790
|
+
// This property is non-configurable in older browsers, so ignore if this throws.
|
|
3791
|
+
// https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/Function/name#browser_compatibility
|
|
3792
|
+
}
|
|
3784
3793
|
/**
|
|
3785
3794
|
* A queuing strategy that counts the number of bytes in each chunk.
|
|
3786
3795
|
*
|
|
@@ -3839,10 +3848,16 @@ var ponyfill_es2018 = {exports: {}};
|
|
|
3839
3848
|
const countSizeFunction = () => {
|
|
3840
3849
|
return 1;
|
|
3841
3850
|
};
|
|
3842
|
-
|
|
3843
|
-
|
|
3844
|
-
|
|
3845
|
-
|
|
3851
|
+
try {
|
|
3852
|
+
Object.defineProperty(countSizeFunction, 'name', {
|
|
3853
|
+
value: 'size',
|
|
3854
|
+
configurable: true
|
|
3855
|
+
});
|
|
3856
|
+
}
|
|
3857
|
+
catch (_a) {
|
|
3858
|
+
// This property is non-configurable in older browsers, so ignore if this throws.
|
|
3859
|
+
// https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/Function/name#browser_compatibility
|
|
3860
|
+
}
|
|
3846
3861
|
/**
|
|
3847
3862
|
* A queuing strategy that counts the number of chunks.
|
|
3848
3863
|
*
|
|
@@ -4330,16 +4345,14 @@ try {
|
|
|
4330
4345
|
|
|
4331
4346
|
/*! fetch-blob. MIT License. Jimmy Wärting <https://jimmy.warting.se/opensource> */
|
|
4332
4347
|
|
|
4333
|
-
/** @typedef {import('buffer').Blob} NodeBlob} */
|
|
4334
|
-
|
|
4335
4348
|
// 64 KiB (same size chrome slice theirs blob into Uint8array's)
|
|
4336
4349
|
const POOL_SIZE = 65536;
|
|
4337
4350
|
|
|
4338
|
-
/** @param {(Blob |
|
|
4339
|
-
async function * toIterator (parts, clone
|
|
4351
|
+
/** @param {(Blob | Uint8Array)[]} parts */
|
|
4352
|
+
async function * toIterator (parts, clone) {
|
|
4340
4353
|
for (const part of parts) {
|
|
4341
4354
|
if ('stream' in part) {
|
|
4342
|
-
yield * part.stream();
|
|
4355
|
+
yield * (/** @type {AsyncIterableIterator<Uint8Array>} */ (part.stream()));
|
|
4343
4356
|
} else if (ArrayBuffer.isView(part)) {
|
|
4344
4357
|
if (clone) {
|
|
4345
4358
|
let position = part.byteOffset;
|
|
@@ -4353,17 +4366,16 @@ async function * toIterator (parts, clone = true) {
|
|
|
4353
4366
|
} else {
|
|
4354
4367
|
yield part;
|
|
4355
4368
|
}
|
|
4369
|
+
/* c8 ignore next 10 */
|
|
4356
4370
|
} else {
|
|
4357
|
-
/* c8 ignore start */
|
|
4358
4371
|
// For blobs that have arrayBuffer but no stream method (nodes buffer.Blob)
|
|
4359
|
-
let position = 0;
|
|
4360
|
-
while (position !==
|
|
4361
|
-
const chunk =
|
|
4372
|
+
let position = 0, b = (/** @type {Blob} */ (part));
|
|
4373
|
+
while (position !== b.size) {
|
|
4374
|
+
const chunk = b.slice(position, Math.min(b.size, position + POOL_SIZE));
|
|
4362
4375
|
const buffer = await chunk.arrayBuffer();
|
|
4363
4376
|
position += buffer.byteLength;
|
|
4364
4377
|
yield new Uint8Array(buffer);
|
|
4365
4378
|
}
|
|
4366
|
-
/* c8 ignore end */
|
|
4367
4379
|
}
|
|
4368
4380
|
}
|
|
4369
4381
|
}
|
|
@@ -4373,6 +4385,7 @@ const _Blob = class Blob {
|
|
|
4373
4385
|
#parts = []
|
|
4374
4386
|
#type = ''
|
|
4375
4387
|
#size = 0
|
|
4388
|
+
#endings = 'transparent'
|
|
4376
4389
|
|
|
4377
4390
|
/**
|
|
4378
4391
|
* The Blob() constructor returns a new Blob object. The content
|
|
@@ -4380,7 +4393,7 @@ const _Blob = class Blob {
|
|
|
4380
4393
|
* in the parameter array.
|
|
4381
4394
|
*
|
|
4382
4395
|
* @param {*} blobParts
|
|
4383
|
-
* @param {{ type?: string }} [options]
|
|
4396
|
+
* @param {{ type?: string, endings?: string }} [options]
|
|
4384
4397
|
*/
|
|
4385
4398
|
constructor (blobParts = [], options = {}) {
|
|
4386
4399
|
if (typeof blobParts !== 'object' || blobParts === null) {
|
|
@@ -4407,15 +4420,19 @@ const _Blob = class Blob {
|
|
|
4407
4420
|
} else if (element instanceof Blob) {
|
|
4408
4421
|
part = element;
|
|
4409
4422
|
} else {
|
|
4410
|
-
part = encoder.encode(element);
|
|
4423
|
+
part = encoder.encode(`${element}`);
|
|
4411
4424
|
}
|
|
4412
4425
|
|
|
4413
|
-
|
|
4414
|
-
|
|
4426
|
+
const size = ArrayBuffer.isView(part) ? part.byteLength : part.size;
|
|
4427
|
+
// Avoid pushing empty parts into the array to better GC them
|
|
4428
|
+
if (size) {
|
|
4429
|
+
this.#size += size;
|
|
4430
|
+
this.#parts.push(part);
|
|
4431
|
+
}
|
|
4415
4432
|
}
|
|
4416
4433
|
|
|
4434
|
+
this.#endings = `${options.endings === undefined ? 'transparent' : options.endings}`;
|
|
4417
4435
|
const type = options.type === undefined ? '' : String(options.type);
|
|
4418
|
-
|
|
4419
4436
|
this.#type = /^[\x20-\x7E]*$/.test(type) ? type : '';
|
|
4420
4437
|
}
|
|
4421
4438
|
|
|
@@ -4481,6 +4498,7 @@ const _Blob = class Blob {
|
|
|
4481
4498
|
const it = toIterator(this.#parts, true);
|
|
4482
4499
|
|
|
4483
4500
|
return new globalThis.ReadableStream({
|
|
4501
|
+
// @ts-ignore
|
|
4484
4502
|
type: 'bytes',
|
|
4485
4503
|
async pull (ctrl) {
|
|
4486
4504
|
const chunk = await it.next();
|
|
@@ -4612,6 +4630,11 @@ const _File = class File extends Blob$1 {
|
|
|
4612
4630
|
get [Symbol.toStringTag] () {
|
|
4613
4631
|
return 'File'
|
|
4614
4632
|
}
|
|
4633
|
+
|
|
4634
|
+
static [Symbol.hasInstance] (object) {
|
|
4635
|
+
return !!object && object instanceof Blob$1 &&
|
|
4636
|
+
/^(File)$/.test(object[Symbol.toStringTag])
|
|
4637
|
+
}
|
|
4615
4638
|
};
|
|
4616
4639
|
|
|
4617
4640
|
/** @type {typeof globalThis.File} */// @ts-ignore
|
|
@@ -4754,6 +4777,22 @@ const isAbortSignal = object => {
|
|
|
4754
4777
|
);
|
|
4755
4778
|
};
|
|
4756
4779
|
|
|
4780
|
+
/**
|
|
4781
|
+
* isDomainOrSubdomain reports whether sub is a subdomain (or exact match) of
|
|
4782
|
+
* the parent domain.
|
|
4783
|
+
*
|
|
4784
|
+
* Both domains must already be in canonical form.
|
|
4785
|
+
* @param {string|URL} original
|
|
4786
|
+
* @param {string|URL} destination
|
|
4787
|
+
*/
|
|
4788
|
+
const isDomainOrSubdomain = (destination, original) => {
|
|
4789
|
+
const orig = new URL(original).hostname;
|
|
4790
|
+
const dest = new URL(destination).hostname;
|
|
4791
|
+
|
|
4792
|
+
return orig === dest || orig.endsWith(`.${dest}`);
|
|
4793
|
+
};
|
|
4794
|
+
|
|
4795
|
+
const pipeline = node_util.promisify(Stream__default["default"].pipeline);
|
|
4757
4796
|
const INTERNALS$2 = Symbol('Body internals');
|
|
4758
4797
|
|
|
4759
4798
|
/**
|
|
@@ -4776,13 +4815,13 @@ class Body {
|
|
|
4776
4815
|
body = null;
|
|
4777
4816
|
} else if (isURLSearchParameters(body)) {
|
|
4778
4817
|
// Body is a URLSearchParams
|
|
4779
|
-
body = Buffer.from(body.toString());
|
|
4780
|
-
} else if (isBlob(body)) ; else if (Buffer.isBuffer(body)) ; else if (node_util.types.isAnyArrayBuffer(body)) {
|
|
4818
|
+
body = node_buffer.Buffer.from(body.toString());
|
|
4819
|
+
} else if (isBlob(body)) ; else if (node_buffer.Buffer.isBuffer(body)) ; else if (node_util.types.isAnyArrayBuffer(body)) {
|
|
4781
4820
|
// Body is ArrayBuffer
|
|
4782
|
-
body = Buffer.from(body);
|
|
4821
|
+
body = node_buffer.Buffer.from(body);
|
|
4783
4822
|
} else if (ArrayBuffer.isView(body)) {
|
|
4784
4823
|
// Body is ArrayBufferView
|
|
4785
|
-
body = Buffer.from(body.buffer, body.byteOffset, body.byteLength);
|
|
4824
|
+
body = node_buffer.Buffer.from(body.buffer, body.byteOffset, body.byteLength);
|
|
4786
4825
|
} else if (body instanceof Stream__default["default"]) ; else if (body instanceof FormData) {
|
|
4787
4826
|
// Body is FormData
|
|
4788
4827
|
body = formDataToBlob(body);
|
|
@@ -4790,12 +4829,12 @@ class Body {
|
|
|
4790
4829
|
} else {
|
|
4791
4830
|
// None of the above
|
|
4792
4831
|
// coerce to string then buffer
|
|
4793
|
-
body = Buffer.from(String(body));
|
|
4832
|
+
body = node_buffer.Buffer.from(String(body));
|
|
4794
4833
|
}
|
|
4795
4834
|
|
|
4796
4835
|
let stream = body;
|
|
4797
4836
|
|
|
4798
|
-
if (Buffer.isBuffer(body)) {
|
|
4837
|
+
if (node_buffer.Buffer.isBuffer(body)) {
|
|
4799
4838
|
stream = Stream__default["default"].Readable.from(body);
|
|
4800
4839
|
} else if (isBlob(body)) {
|
|
4801
4840
|
stream = Stream__default["default"].Readable.from(body.stream());
|
|
@@ -4852,7 +4891,7 @@ class Body {
|
|
|
4852
4891
|
return formData;
|
|
4853
4892
|
}
|
|
4854
4893
|
|
|
4855
|
-
const {toFormData} = await Promise.resolve().then(function () { return require('./multipart-parser-
|
|
4894
|
+
const {toFormData} = await Promise.resolve().then(function () { return require('./multipart-parser-d6fbdf05.js'); });
|
|
4856
4895
|
return toFormData(this.body, ct);
|
|
4857
4896
|
}
|
|
4858
4897
|
|
|
@@ -4863,7 +4902,7 @@ class Body {
|
|
|
4863
4902
|
*/
|
|
4864
4903
|
async blob() {
|
|
4865
4904
|
const ct = (this.headers && this.headers.get('content-type')) || (this[INTERNALS$2].body && this[INTERNALS$2].body.type) || '';
|
|
4866
|
-
const buf = await this.
|
|
4905
|
+
const buf = await this.arrayBuffer();
|
|
4867
4906
|
|
|
4868
4907
|
return new Blob$1([buf], {
|
|
4869
4908
|
type: ct
|
|
@@ -4876,8 +4915,8 @@ class Body {
|
|
|
4876
4915
|
* @return Promise
|
|
4877
4916
|
*/
|
|
4878
4917
|
async json() {
|
|
4879
|
-
const
|
|
4880
|
-
return JSON.parse(
|
|
4918
|
+
const text = await this.text();
|
|
4919
|
+
return JSON.parse(text);
|
|
4881
4920
|
}
|
|
4882
4921
|
|
|
4883
4922
|
/**
|
|
@@ -4887,7 +4926,7 @@ class Body {
|
|
|
4887
4926
|
*/
|
|
4888
4927
|
async text() {
|
|
4889
4928
|
const buffer = await consumeBody(this);
|
|
4890
|
-
return
|
|
4929
|
+
return new TextDecoder().decode(buffer);
|
|
4891
4930
|
}
|
|
4892
4931
|
|
|
4893
4932
|
/**
|
|
@@ -4909,7 +4948,10 @@ Object.defineProperties(Body.prototype, {
|
|
|
4909
4948
|
arrayBuffer: {enumerable: true},
|
|
4910
4949
|
blob: {enumerable: true},
|
|
4911
4950
|
json: {enumerable: true},
|
|
4912
|
-
text: {enumerable: true}
|
|
4951
|
+
text: {enumerable: true},
|
|
4952
|
+
data: {get: node_util.deprecate(() => {},
|
|
4953
|
+
'data doesn\'t exist, use json(), text(), arrayBuffer(), or body instead',
|
|
4954
|
+
'https://github.com/node-fetch/node-fetch/issues/1000 (response)')}
|
|
4913
4955
|
});
|
|
4914
4956
|
|
|
4915
4957
|
/**
|
|
@@ -4934,12 +4976,12 @@ async function consumeBody(data) {
|
|
|
4934
4976
|
|
|
4935
4977
|
// Body is null
|
|
4936
4978
|
if (body === null) {
|
|
4937
|
-
return Buffer.alloc(0);
|
|
4979
|
+
return node_buffer.Buffer.alloc(0);
|
|
4938
4980
|
}
|
|
4939
4981
|
|
|
4940
4982
|
/* c8 ignore next 3 */
|
|
4941
4983
|
if (!(body instanceof Stream__default["default"])) {
|
|
4942
|
-
return Buffer.alloc(0);
|
|
4984
|
+
return node_buffer.Buffer.alloc(0);
|
|
4943
4985
|
}
|
|
4944
4986
|
|
|
4945
4987
|
// Body is stream
|
|
@@ -4966,10 +5008,10 @@ async function consumeBody(data) {
|
|
|
4966
5008
|
if (body.readableEnded === true || body._readableState.ended === true) {
|
|
4967
5009
|
try {
|
|
4968
5010
|
if (accum.every(c => typeof c === 'string')) {
|
|
4969
|
-
return Buffer.from(accum.join(''));
|
|
5011
|
+
return node_buffer.Buffer.from(accum.join(''));
|
|
4970
5012
|
}
|
|
4971
5013
|
|
|
4972
|
-
return Buffer.concat(accum, accumBytes);
|
|
5014
|
+
return node_buffer.Buffer.concat(accum, accumBytes);
|
|
4973
5015
|
} catch (error) {
|
|
4974
5016
|
throw new FetchError(`Could not create Buffer from response body for ${data.url}: ${error.message}`, 'system', error);
|
|
4975
5017
|
}
|
|
@@ -5049,7 +5091,7 @@ const extractContentType = (body, request) => {
|
|
|
5049
5091
|
}
|
|
5050
5092
|
|
|
5051
5093
|
// Body is a Buffer (Buffer, ArrayBuffer or ArrayBufferView)
|
|
5052
|
-
if (Buffer.isBuffer(body) || node_util.types.isAnyArrayBuffer(body) || ArrayBuffer.isView(body)) {
|
|
5094
|
+
if (node_buffer.Buffer.isBuffer(body) || node_util.types.isAnyArrayBuffer(body) || ArrayBuffer.isView(body)) {
|
|
5053
5095
|
return null;
|
|
5054
5096
|
}
|
|
5055
5097
|
|
|
@@ -5094,7 +5136,7 @@ const getTotalBytes = request => {
|
|
|
5094
5136
|
}
|
|
5095
5137
|
|
|
5096
5138
|
// Body is Buffer
|
|
5097
|
-
if (Buffer.isBuffer(body)) {
|
|
5139
|
+
if (node_buffer.Buffer.isBuffer(body)) {
|
|
5098
5140
|
return body.length;
|
|
5099
5141
|
}
|
|
5100
5142
|
|
|
@@ -5112,15 +5154,15 @@ const getTotalBytes = request => {
|
|
|
5112
5154
|
*
|
|
5113
5155
|
* @param {Stream.Writable} dest The stream to write to.
|
|
5114
5156
|
* @param obj.body Body object from the Body instance.
|
|
5115
|
-
* @returns {void}
|
|
5157
|
+
* @returns {Promise<void>}
|
|
5116
5158
|
*/
|
|
5117
|
-
const writeToStream = (dest, {body}) => {
|
|
5159
|
+
const writeToStream = async (dest, {body}) => {
|
|
5118
5160
|
if (body === null) {
|
|
5119
5161
|
// Body is null
|
|
5120
5162
|
dest.end();
|
|
5121
5163
|
} else {
|
|
5122
5164
|
// Body is stream
|
|
5123
|
-
body
|
|
5165
|
+
await pipeline(body, dest);
|
|
5124
5166
|
}
|
|
5125
5167
|
};
|
|
5126
5168
|
|
|
@@ -5130,6 +5172,7 @@ const writeToStream = (dest, {body}) => {
|
|
|
5130
5172
|
* Headers class offers convenient helpers
|
|
5131
5173
|
*/
|
|
5132
5174
|
|
|
5175
|
+
/* c8 ignore next 9 */
|
|
5133
5176
|
const validateHeaderName = typeof http__default["default"].validateHeaderName === 'function' ?
|
|
5134
5177
|
http__default["default"].validateHeaderName :
|
|
5135
5178
|
name => {
|
|
@@ -5140,6 +5183,7 @@ const validateHeaderName = typeof http__default["default"].validateHeaderName ==
|
|
|
5140
5183
|
}
|
|
5141
5184
|
};
|
|
5142
5185
|
|
|
5186
|
+
/* c8 ignore next 9 */
|
|
5143
5187
|
const validateHeaderValue = typeof http__default["default"].validateHeaderValue === 'function' ?
|
|
5144
5188
|
http__default["default"].validateHeaderValue :
|
|
5145
5189
|
(name, value) => {
|
|
@@ -5262,8 +5306,8 @@ class Headers extends URLSearchParams {
|
|
|
5262
5306
|
return Reflect.get(target, p, receiver);
|
|
5263
5307
|
}
|
|
5264
5308
|
}
|
|
5265
|
-
/* c8 ignore next */
|
|
5266
5309
|
});
|
|
5310
|
+
/* c8 ignore next */
|
|
5267
5311
|
}
|
|
5268
5312
|
|
|
5269
5313
|
get [Symbol.toStringTag]() {
|
|
@@ -5651,7 +5695,7 @@ function isOriginPotentiallyTrustworthy(url) {
|
|
|
5651
5695
|
|
|
5652
5696
|
// 4. If origin's host component matches one of the CIDR notations 127.0.0.0/8 or ::1/128 [RFC4632], return "Potentially Trustworthy".
|
|
5653
5697
|
const hostIp = url.host.replace(/(^\[)|(]$)/g, '');
|
|
5654
|
-
const hostIPVersion =
|
|
5698
|
+
const hostIPVersion = node_net.isIP(hostIp);
|
|
5655
5699
|
|
|
5656
5700
|
if (hostIPVersion === 4 && /^127\./.test(hostIp)) {
|
|
5657
5701
|
return true;
|
|
@@ -5884,12 +5928,20 @@ function parseReferrerPolicyFromHeader(headers) {
|
|
|
5884
5928
|
return policy;
|
|
5885
5929
|
}
|
|
5886
5930
|
|
|
5931
|
+
/**
|
|
5932
|
+
* Request.js
|
|
5933
|
+
*
|
|
5934
|
+
* Request class contains server only options
|
|
5935
|
+
*
|
|
5936
|
+
* All spec algorithm step numbers are based on https://fetch.spec.whatwg.org/commit-snapshots/ae716822cb3a61843226cd090eefc6589446c1d2/.
|
|
5937
|
+
*/
|
|
5938
|
+
|
|
5887
5939
|
const INTERNALS = Symbol('Request internals');
|
|
5888
5940
|
|
|
5889
5941
|
/**
|
|
5890
5942
|
* Check if `obj` is an instance of Request.
|
|
5891
5943
|
*
|
|
5892
|
-
* @param {*}
|
|
5944
|
+
* @param {*} object
|
|
5893
5945
|
* @return {boolean}
|
|
5894
5946
|
*/
|
|
5895
5947
|
const isRequest = object => {
|
|
@@ -5899,6 +5951,10 @@ const isRequest = object => {
|
|
|
5899
5951
|
);
|
|
5900
5952
|
};
|
|
5901
5953
|
|
|
5954
|
+
const doBadDataWarn = node_util.deprecate(() => {},
|
|
5955
|
+
'.data is not a valid RequestInit property, use .body instead',
|
|
5956
|
+
'https://github.com/node-fetch/node-fetch/issues/1000 (request)');
|
|
5957
|
+
|
|
5902
5958
|
/**
|
|
5903
5959
|
* Request class
|
|
5904
5960
|
*
|
|
@@ -5921,14 +5977,20 @@ class Request extends Body {
|
|
|
5921
5977
|
}
|
|
5922
5978
|
|
|
5923
5979
|
if (parsedURL.username !== '' || parsedURL.password !== '') {
|
|
5924
|
-
throw new TypeError(`${parsedURL} is an url with embedded
|
|
5980
|
+
throw new TypeError(`${parsedURL} is an url with embedded credentials.`);
|
|
5925
5981
|
}
|
|
5926
5982
|
|
|
5927
5983
|
let method = init.method || input.method || 'GET';
|
|
5928
|
-
|
|
5984
|
+
if (/^(delete|get|head|options|post|put)$/i.test(method)) {
|
|
5985
|
+
method = method.toUpperCase();
|
|
5986
|
+
}
|
|
5987
|
+
|
|
5988
|
+
if ('data' in init) {
|
|
5989
|
+
doBadDataWarn();
|
|
5990
|
+
}
|
|
5929
5991
|
|
|
5930
5992
|
// eslint-disable-next-line no-eq-null, eqeqeq
|
|
5931
|
-
if ((
|
|
5993
|
+
if ((init.body != null || (isRequest(input) && input.body !== null)) &&
|
|
5932
5994
|
(method === 'GET' || method === 'HEAD')) {
|
|
5933
5995
|
throw new TypeError('Request with GET/HEAD method cannot have body');
|
|
5934
5996
|
}
|
|
@@ -6001,14 +6063,17 @@ class Request extends Body {
|
|
|
6001
6063
|
this.referrerPolicy = init.referrerPolicy || input.referrerPolicy || '';
|
|
6002
6064
|
}
|
|
6003
6065
|
|
|
6066
|
+
/** @returns {string} */
|
|
6004
6067
|
get method() {
|
|
6005
6068
|
return this[INTERNALS].method;
|
|
6006
6069
|
}
|
|
6007
6070
|
|
|
6071
|
+
/** @returns {string} */
|
|
6008
6072
|
get url() {
|
|
6009
6073
|
return node_url.format(this[INTERNALS].parsedURL);
|
|
6010
6074
|
}
|
|
6011
6075
|
|
|
6076
|
+
/** @returns {Headers} */
|
|
6012
6077
|
get headers() {
|
|
6013
6078
|
return this[INTERNALS].headers;
|
|
6014
6079
|
}
|
|
@@ -6017,6 +6082,7 @@ class Request extends Body {
|
|
|
6017
6082
|
return this[INTERNALS].redirect;
|
|
6018
6083
|
}
|
|
6019
6084
|
|
|
6085
|
+
/** @returns {AbortSignal} */
|
|
6020
6086
|
get signal() {
|
|
6021
6087
|
return this[INTERNALS].signal;
|
|
6022
6088
|
}
|
|
@@ -6074,8 +6140,8 @@ Object.defineProperties(Request.prototype, {
|
|
|
6074
6140
|
/**
|
|
6075
6141
|
* Convert a Request to Node.js http request options.
|
|
6076
6142
|
*
|
|
6077
|
-
* @param
|
|
6078
|
-
* @return
|
|
6143
|
+
* @param {Request} request - A Request instance
|
|
6144
|
+
* @return The options object to be passed to http.request
|
|
6079
6145
|
*/
|
|
6080
6146
|
const getNodeRequestOptions = request => {
|
|
6081
6147
|
const {parsedURL} = request[INTERNALS];
|
|
@@ -6164,6 +6230,7 @@ const getNodeRequestOptions = request => {
|
|
|
6164
6230
|
};
|
|
6165
6231
|
|
|
6166
6232
|
return {
|
|
6233
|
+
/** @type {URL} */
|
|
6167
6234
|
parsedURL,
|
|
6168
6235
|
options
|
|
6169
6236
|
};
|
|
@@ -6178,6 +6245,21 @@ class AbortError extends FetchBaseError {
|
|
|
6178
6245
|
}
|
|
6179
6246
|
}
|
|
6180
6247
|
|
|
6248
|
+
/*! node-domexception. MIT License. Jimmy Wärting <https://jimmy.warting.se/opensource> */
|
|
6249
|
+
|
|
6250
|
+
if (!globalThis.DOMException) {
|
|
6251
|
+
try {
|
|
6252
|
+
const { MessageChannel } = require('worker_threads'),
|
|
6253
|
+
port = new MessageChannel().port1,
|
|
6254
|
+
ab = new ArrayBuffer();
|
|
6255
|
+
port.postMessage(ab, [ab, ab]);
|
|
6256
|
+
} catch (err) {
|
|
6257
|
+
err.constructor.name === 'DOMException' && (
|
|
6258
|
+
globalThis.DOMException = err.constructor
|
|
6259
|
+
);
|
|
6260
|
+
}
|
|
6261
|
+
}
|
|
6262
|
+
|
|
6181
6263
|
/**
|
|
6182
6264
|
* Index.js
|
|
6183
6265
|
*
|
|
@@ -6241,7 +6323,7 @@ async function fetch(url, options_) {
|
|
|
6241
6323
|
};
|
|
6242
6324
|
|
|
6243
6325
|
// Send request
|
|
6244
|
-
const request_ = send(parsedURL, options);
|
|
6326
|
+
const request_ = send(parsedURL.toString(), options);
|
|
6245
6327
|
|
|
6246
6328
|
if (signal) {
|
|
6247
6329
|
signal.addEventListener('abort', abortAndFinalize);
|
|
@@ -6293,7 +6375,19 @@ async function fetch(url, options_) {
|
|
|
6293
6375
|
const location = headers.get('Location');
|
|
6294
6376
|
|
|
6295
6377
|
// HTTP fetch step 5.3
|
|
6296
|
-
|
|
6378
|
+
let locationURL = null;
|
|
6379
|
+
try {
|
|
6380
|
+
locationURL = location === null ? null : new URL(location, request.url);
|
|
6381
|
+
} catch {
|
|
6382
|
+
// error here can only be invalid URL in Location: header
|
|
6383
|
+
// do not throw when options.redirect == manual
|
|
6384
|
+
// let the user extract the errorneous redirect URL
|
|
6385
|
+
if (request.redirect !== 'manual') {
|
|
6386
|
+
reject(new FetchError(`uri requested responds with an invalid redirect URL: ${location}`, 'invalid-redirect'));
|
|
6387
|
+
finalize();
|
|
6388
|
+
return;
|
|
6389
|
+
}
|
|
6390
|
+
}
|
|
6297
6391
|
|
|
6298
6392
|
// HTTP fetch step 5.5
|
|
6299
6393
|
switch (request.redirect) {
|
|
@@ -6302,11 +6396,7 @@ async function fetch(url, options_) {
|
|
|
6302
6396
|
finalize();
|
|
6303
6397
|
return;
|
|
6304
6398
|
case 'manual':
|
|
6305
|
-
//
|
|
6306
|
-
if (locationURL !== null) {
|
|
6307
|
-
headers.set('Location', locationURL);
|
|
6308
|
-
}
|
|
6309
|
-
|
|
6399
|
+
// Nothing to do
|
|
6310
6400
|
break;
|
|
6311
6401
|
case 'follow': {
|
|
6312
6402
|
// HTTP-redirect fetch step 2
|
|
@@ -6337,6 +6427,18 @@ async function fetch(url, options_) {
|
|
|
6337
6427
|
referrerPolicy: request.referrerPolicy
|
|
6338
6428
|
};
|
|
6339
6429
|
|
|
6430
|
+
// when forwarding sensitive headers like "Authorization",
|
|
6431
|
+
// "WWW-Authenticate", and "Cookie" to untrusted targets,
|
|
6432
|
+
// headers will be ignored when following a redirect to a domain
|
|
6433
|
+
// that is not a subdomain match or exact match of the initial domain.
|
|
6434
|
+
// For example, a redirect from "foo.com" to either "foo.com" or "sub.foo.com"
|
|
6435
|
+
// will forward the sensitive headers, but a redirect to "bar.com" will not.
|
|
6436
|
+
if (!isDomainOrSubdomain(request.url, locationURL)) {
|
|
6437
|
+
for (const name of ['authorization', 'www-authenticate', 'cookie', 'cookie2']) {
|
|
6438
|
+
requestOptions.headers.delete(name);
|
|
6439
|
+
}
|
|
6440
|
+
}
|
|
6441
|
+
|
|
6340
6442
|
// HTTP-redirect fetch step 9
|
|
6341
6443
|
if (response_.statusCode !== 303 && request.body && options_.body instanceof Stream__default["default"].Readable) {
|
|
6342
6444
|
reject(new FetchError('Cannot follow redirect with body being a readable stream', 'unsupported-redirect'));
|
|
@@ -6375,8 +6477,13 @@ async function fetch(url, options_) {
|
|
|
6375
6477
|
});
|
|
6376
6478
|
}
|
|
6377
6479
|
|
|
6378
|
-
let body = Stream.pipeline(response_, new Stream.PassThrough(),
|
|
6480
|
+
let body = Stream.pipeline(response_, new Stream.PassThrough(), error => {
|
|
6481
|
+
if (error) {
|
|
6482
|
+
reject(error);
|
|
6483
|
+
}
|
|
6484
|
+
});
|
|
6379
6485
|
// see https://github.com/nodejs/node/pull/29376
|
|
6486
|
+
/* c8 ignore next 3 */
|
|
6380
6487
|
if (process.version < 'v12.10') {
|
|
6381
6488
|
response_.on('aborted', abortAndFinalize);
|
|
6382
6489
|
}
|
|
@@ -6420,7 +6527,11 @@ async function fetch(url, options_) {
|
|
|
6420
6527
|
|
|
6421
6528
|
// For gzip
|
|
6422
6529
|
if (codings === 'gzip' || codings === 'x-gzip') {
|
|
6423
|
-
body = Stream.pipeline(body, zlib__default["default"].createGunzip(zlibOptions),
|
|
6530
|
+
body = Stream.pipeline(body, zlib__default["default"].createGunzip(zlibOptions), error => {
|
|
6531
|
+
if (error) {
|
|
6532
|
+
reject(error);
|
|
6533
|
+
}
|
|
6534
|
+
});
|
|
6424
6535
|
response = new Response(body, responseOptions);
|
|
6425
6536
|
resolve(response);
|
|
6426
6537
|
return;
|
|
@@ -6430,20 +6541,48 @@ async function fetch(url, options_) {
|
|
|
6430
6541
|
if (codings === 'deflate' || codings === 'x-deflate') {
|
|
6431
6542
|
// Handle the infamous raw deflate response from old servers
|
|
6432
6543
|
// a hack for old IIS and Apache servers
|
|
6433
|
-
const raw = Stream.pipeline(response_, new Stream.PassThrough(),
|
|
6544
|
+
const raw = Stream.pipeline(response_, new Stream.PassThrough(), error => {
|
|
6545
|
+
if (error) {
|
|
6546
|
+
reject(error);
|
|
6547
|
+
}
|
|
6548
|
+
});
|
|
6434
6549
|
raw.once('data', chunk => {
|
|
6435
6550
|
// See http://stackoverflow.com/questions/37519828
|
|
6436
|
-
|
|
6551
|
+
if ((chunk[0] & 0x0F) === 0x08) {
|
|
6552
|
+
body = Stream.pipeline(body, zlib__default["default"].createInflate(), error => {
|
|
6553
|
+
if (error) {
|
|
6554
|
+
reject(error);
|
|
6555
|
+
}
|
|
6556
|
+
});
|
|
6557
|
+
} else {
|
|
6558
|
+
body = Stream.pipeline(body, zlib__default["default"].createInflateRaw(), error => {
|
|
6559
|
+
if (error) {
|
|
6560
|
+
reject(error);
|
|
6561
|
+
}
|
|
6562
|
+
});
|
|
6563
|
+
}
|
|
6437
6564
|
|
|
6438
6565
|
response = new Response(body, responseOptions);
|
|
6439
6566
|
resolve(response);
|
|
6440
6567
|
});
|
|
6568
|
+
raw.once('end', () => {
|
|
6569
|
+
// Some old IIS servers return zero-length OK deflate responses, so
|
|
6570
|
+
// 'data' is never emitted. See https://github.com/node-fetch/node-fetch/pull/903
|
|
6571
|
+
if (!response) {
|
|
6572
|
+
response = new Response(body, responseOptions);
|
|
6573
|
+
resolve(response);
|
|
6574
|
+
}
|
|
6575
|
+
});
|
|
6441
6576
|
return;
|
|
6442
6577
|
}
|
|
6443
6578
|
|
|
6444
6579
|
// For br
|
|
6445
6580
|
if (codings === 'br') {
|
|
6446
|
-
body = Stream.pipeline(body, zlib__default["default"].createBrotliDecompress(),
|
|
6581
|
+
body = Stream.pipeline(body, zlib__default["default"].createBrotliDecompress(), error => {
|
|
6582
|
+
if (error) {
|
|
6583
|
+
reject(error);
|
|
6584
|
+
}
|
|
6585
|
+
});
|
|
6447
6586
|
response = new Response(body, responseOptions);
|
|
6448
6587
|
resolve(response);
|
|
6449
6588
|
return;
|
|
@@ -6454,12 +6593,13 @@ async function fetch(url, options_) {
|
|
|
6454
6593
|
resolve(response);
|
|
6455
6594
|
});
|
|
6456
6595
|
|
|
6457
|
-
|
|
6596
|
+
// eslint-disable-next-line promise/prefer-await-to-then
|
|
6597
|
+
writeToStream(request_, request).catch(reject);
|
|
6458
6598
|
});
|
|
6459
6599
|
}
|
|
6460
6600
|
|
|
6461
6601
|
function fixResponseChunkedTransferBadEnding(request, errorCallback) {
|
|
6462
|
-
const LAST_CHUNK = Buffer.from('0\r\n\r\n');
|
|
6602
|
+
const LAST_CHUNK = node_buffer.Buffer.from('0\r\n\r\n');
|
|
6463
6603
|
|
|
6464
6604
|
let isChunkedTransfer = false;
|
|
6465
6605
|
let properLastChunkReceived = false;
|
|
@@ -6486,13 +6626,13 @@ function fixResponseChunkedTransferBadEnding(request, errorCallback) {
|
|
|
6486
6626
|
});
|
|
6487
6627
|
|
|
6488
6628
|
socket.on('data', buf => {
|
|
6489
|
-
properLastChunkReceived = Buffer.compare(buf.slice(-5), LAST_CHUNK) === 0;
|
|
6629
|
+
properLastChunkReceived = node_buffer.Buffer.compare(buf.slice(-5), LAST_CHUNK) === 0;
|
|
6490
6630
|
|
|
6491
6631
|
// Sometimes final 0-length chunk and end of message code are in separate packets
|
|
6492
6632
|
if (!properLastChunkReceived && previousChunk) {
|
|
6493
6633
|
properLastChunkReceived = (
|
|
6494
|
-
Buffer.compare(previousChunk.slice(-3), LAST_CHUNK.slice(0, 3)) === 0 &&
|
|
6495
|
-
Buffer.compare(buf.slice(-2), LAST_CHUNK.slice(3)) === 0
|
|
6634
|
+
node_buffer.Buffer.compare(previousChunk.slice(-3), LAST_CHUNK.slice(0, 3)) === 0 &&
|
|
6635
|
+
node_buffer.Buffer.compare(buf.slice(-2), LAST_CHUNK.slice(3)) === 0
|
|
6496
6636
|
);
|
|
6497
6637
|
}
|
|
6498
6638
|
|
|
@@ -1,22 +1,16 @@
|
|
|
1
1
|
import 'node:fs';
|
|
2
2
|
import 'node:path';
|
|
3
|
-
import { MessageChannel } from 'node:worker_threads';
|
|
4
3
|
import { F as FormData, a as File } from './shims.js';
|
|
5
4
|
import 'node:http';
|
|
6
5
|
import 'node:https';
|
|
7
6
|
import 'node:zlib';
|
|
8
7
|
import 'node:stream';
|
|
8
|
+
import 'node:buffer';
|
|
9
9
|
import 'node:util';
|
|
10
10
|
import 'node:url';
|
|
11
|
-
import 'net';
|
|
11
|
+
import 'node:net';
|
|
12
12
|
import 'crypto';
|
|
13
13
|
|
|
14
|
-
globalThis.DOMException || (() => {
|
|
15
|
-
const port = new MessageChannel().port1;
|
|
16
|
-
const ab = new ArrayBuffer(0);
|
|
17
|
-
try { port.postMessage(ab, [ab, ab]); } catch (err) { return err.constructor }
|
|
18
|
-
})();
|
|
19
|
-
|
|
20
14
|
let s = 0;
|
|
21
15
|
const S = {
|
|
22
16
|
START_BOUNDARY: s++,
|
package/files/esm/serverless.js
CHANGED
|
@@ -4,9 +4,12 @@ import 'node:http';
|
|
|
4
4
|
import 'node:https';
|
|
5
5
|
import 'node:zlib';
|
|
6
6
|
import 'node:stream';
|
|
7
|
+
import 'node:buffer';
|
|
7
8
|
import 'node:util';
|
|
8
9
|
import 'node:url';
|
|
9
|
-
import 'net';
|
|
10
|
+
import 'node:net';
|
|
11
|
+
import 'node:fs';
|
|
12
|
+
import 'node:path';
|
|
10
13
|
import 'crypto';
|
|
11
14
|
|
|
12
15
|
var setCookie = {exports: {}};
|