@sveltejs/kit 1.0.0-next.346 → 1.0.0-next.347

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.
@@ -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
 
11
14
  /**
12
15
  * Node.js module for Forge.
@@ -5240,6 +5243,10 @@ _IN('1.3.14.3.2.29', 'sha1WithRSASignature');
5240
5243
  _IN('2.16.840.1.101.3.4.2.1', 'sha256');
5241
5244
  _IN('2.16.840.1.101.3.4.2.2', 'sha384');
5242
5245
  _IN('2.16.840.1.101.3.4.2.3', 'sha512');
5246
+ _IN('2.16.840.1.101.3.4.2.4', 'sha224');
5247
+ _IN('2.16.840.1.101.3.4.2.5', 'sha512-224');
5248
+ _IN('2.16.840.1.101.3.4.2.6', 'sha512-256');
5249
+ _IN('1.2.840.113549.2.2', 'md2');
5243
5250
  _IN('1.2.840.113549.2.5', 'md5');
5244
5251
 
5245
5252
  // pkcs#7 content types
@@ -5781,6 +5788,8 @@ var _getValueLength = function(bytes, remaining) {
5781
5788
  * @param [options] object with options or boolean strict flag
5782
5789
  * [strict] true to be strict when checking value lengths, false to
5783
5790
  * allow truncated values (default: true).
5791
+ * [parseAllBytes] true to ensure all bytes are parsed
5792
+ * (default: true)
5784
5793
  * [decodeBitStrings] true to attempt to decode the content of
5785
5794
  * BIT STRINGs (not OCTET STRINGs) using strict mode. Note that
5786
5795
  * without schema support to understand the data context this can
@@ -5788,24 +5797,31 @@ var _getValueLength = function(bytes, remaining) {
5788
5797
  * flag will be deprecated or removed as soon as schema support is
5789
5798
  * available. (default: true)
5790
5799
  *
5800
+ * @throws Will throw an error for various malformed input conditions.
5801
+ *
5791
5802
  * @return the parsed asn1 object.
5792
5803
  */
5793
5804
  asn1$8.fromDer = function(bytes, options) {
5794
5805
  if(options === undefined) {
5795
5806
  options = {
5796
5807
  strict: true,
5808
+ parseAllBytes: true,
5797
5809
  decodeBitStrings: true
5798
5810
  };
5799
5811
  }
5800
5812
  if(typeof options === 'boolean') {
5801
5813
  options = {
5802
5814
  strict: options,
5815
+ parseAllBytes: true,
5803
5816
  decodeBitStrings: true
5804
5817
  };
5805
5818
  }
5806
5819
  if(!('strict' in options)) {
5807
5820
  options.strict = true;
5808
5821
  }
5822
+ if(!('parseAllBytes' in options)) {
5823
+ options.parseAllBytes = true;
5824
+ }
5809
5825
  if(!('decodeBitStrings' in options)) {
5810
5826
  options.decodeBitStrings = true;
5811
5827
  }
@@ -5815,7 +5831,15 @@ asn1$8.fromDer = function(bytes, options) {
5815
5831
  bytes = forge$x.util.createBuffer(bytes);
5816
5832
  }
5817
5833
 
5818
- return _fromDer(bytes, bytes.length(), 0, options);
5834
+ var byteCount = bytes.length();
5835
+ var value = _fromDer(bytes, bytes.length(), 0, options);
5836
+ if(options.parseAllBytes && bytes.length() !== 0) {
5837
+ var error = new Error('Unparsed DER bytes remain after ASN.1 parsing.');
5838
+ error.byteCount = byteCount;
5839
+ error.remaining = bytes.length();
5840
+ throw error;
5841
+ }
5842
+ return value;
5819
5843
  };
5820
5844
 
5821
5845
  /**
@@ -5936,7 +5960,6 @@ function _fromDer(bytes, remaining, depth, options) {
5936
5960
  start = bytes.length();
5937
5961
  var subOptions = {
5938
5962
  // enforce strict mode to avoid parsing ASN.1 from plain data
5939
- verbose: options.verbose,
5940
5963
  strict: true,
5941
5964
  decodeBitStrings: true
5942
5965
  };
@@ -5985,6 +6008,7 @@ function _fromDer(bytes, remaining, depth, options) {
5985
6008
  }
5986
6009
  } else {
5987
6010
  value = bytes.getBytes(length);
6011
+ remaining -= length;
5988
6012
  }
5989
6013
  }
5990
6014
 
@@ -6760,7 +6784,16 @@ asn1$8.prettyPrint = function(obj, level, indentation) {
6760
6784
  }
6761
6785
  rval += '0x' + forge$x.util.bytesToHex(obj.value);
6762
6786
  } else if(obj.type === asn1$8.Type.UTF8) {
6763
- rval += forge$x.util.decodeUtf8(obj.value);
6787
+ try {
6788
+ rval += forge$x.util.decodeUtf8(obj.value);
6789
+ } catch(e) {
6790
+ if(e.message === 'URI malformed') {
6791
+ rval +=
6792
+ '0x' + forge$x.util.bytesToHex(obj.value) + ' (malformed UTF8)';
6793
+ } else {
6794
+ throw e;
6795
+ }
6796
+ }
6764
6797
  } else if(obj.type === asn1$8.Type.PRINTABLESTRING ||
6765
6798
  obj.type === asn1$8.Type.IA5String) {
6766
6799
  rval += obj.value;
@@ -11937,6 +11970,43 @@ var publicKeyValidator$2 = forge$i.pki.rsa.publicKeyValidator = {
11937
11970
  }]
11938
11971
  };
11939
11972
 
11973
+ // validator for a DigestInfo structure
11974
+ var digestInfoValidator = {
11975
+ name: 'DigestInfo',
11976
+ tagClass: asn1$7.Class.UNIVERSAL,
11977
+ type: asn1$7.Type.SEQUENCE,
11978
+ constructed: true,
11979
+ value: [{
11980
+ name: 'DigestInfo.DigestAlgorithm',
11981
+ tagClass: asn1$7.Class.UNIVERSAL,
11982
+ type: asn1$7.Type.SEQUENCE,
11983
+ constructed: true,
11984
+ value: [{
11985
+ name: 'DigestInfo.DigestAlgorithm.algorithmIdentifier',
11986
+ tagClass: asn1$7.Class.UNIVERSAL,
11987
+ type: asn1$7.Type.OID,
11988
+ constructed: false,
11989
+ capture: 'algorithmIdentifier'
11990
+ }, {
11991
+ // NULL paramters
11992
+ name: 'DigestInfo.DigestAlgorithm.parameters',
11993
+ tagClass: asn1$7.Class.UNIVERSAL,
11994
+ type: asn1$7.Type.NULL,
11995
+ // captured only to check existence for md2 and md5
11996
+ capture: 'parameters',
11997
+ optional: true,
11998
+ constructed: false
11999
+ }]
12000
+ }, {
12001
+ // digest
12002
+ name: 'DigestInfo.digest',
12003
+ tagClass: asn1$7.Class.UNIVERSAL,
12004
+ type: asn1$7.Type.OCTETSTRING,
12005
+ constructed: false,
12006
+ capture: 'digest'
12007
+ }]
12008
+ };
12009
+
11940
12010
  /**
11941
12011
  * Wrap digest in DigestInfo object.
11942
12012
  *
@@ -12765,15 +12835,27 @@ pki$4.setRsaPublicKey = pki$4.rsa.setPublicKey = function(n, e) {
12765
12835
  * a Forge PSS object for RSASSA-PSS,
12766
12836
  * 'NONE' or null for none, DigestInfo will not be expected, but
12767
12837
  * PKCS#1 v1.5 padding will still be used.
12838
+ * @param options optional verify options
12839
+ * _parseAllDigestBytes testing flag to control parsing of all
12840
+ * digest bytes. Unsupported and not for general usage.
12841
+ * (default: true)
12768
12842
  *
12769
12843
  * @return true if the signature was verified, false if not.
12770
12844
  */
12771
- key.verify = function(digest, signature, scheme) {
12845
+ key.verify = function(digest, signature, scheme, options) {
12772
12846
  if(typeof scheme === 'string') {
12773
12847
  scheme = scheme.toUpperCase();
12774
12848
  } else if(scheme === undefined) {
12775
12849
  scheme = 'RSASSA-PKCS1-V1_5';
12776
12850
  }
12851
+ if(options === undefined) {
12852
+ options = {
12853
+ _parseAllDigestBytes: true
12854
+ };
12855
+ }
12856
+ if(!('_parseAllDigestBytes' in options)) {
12857
+ options._parseAllDigestBytes = true;
12858
+ }
12777
12859
 
12778
12860
  if(scheme === 'RSASSA-PKCS1-V1_5') {
12779
12861
  scheme = {
@@ -12781,9 +12863,51 @@ pki$4.setRsaPublicKey = pki$4.rsa.setPublicKey = function(n, e) {
12781
12863
  // remove padding
12782
12864
  d = _decodePkcs1_v1_5(d, key, true);
12783
12865
  // d is ASN.1 BER-encoded DigestInfo
12784
- var obj = asn1$7.fromDer(d);
12866
+ var obj = asn1$7.fromDer(d, {
12867
+ parseAllBytes: options._parseAllDigestBytes
12868
+ });
12869
+
12870
+ // validate DigestInfo
12871
+ var capture = {};
12872
+ var errors = [];
12873
+ if(!asn1$7.validate(obj, digestInfoValidator, capture, errors)) {
12874
+ var error = new Error(
12875
+ 'ASN.1 object does not contain a valid RSASSA-PKCS1-v1_5 ' +
12876
+ 'DigestInfo value.');
12877
+ error.errors = errors;
12878
+ throw error;
12879
+ }
12880
+ // check hash algorithm identifier
12881
+ // see PKCS1-v1-5DigestAlgorithms in RFC 8017
12882
+ // FIXME: add support to vaidator for strict value choices
12883
+ var oid = asn1$7.derToOid(capture.algorithmIdentifier);
12884
+ if(!(oid === forge$i.oids.md2 ||
12885
+ oid === forge$i.oids.md5 ||
12886
+ oid === forge$i.oids.sha1 ||
12887
+ oid === forge$i.oids.sha224 ||
12888
+ oid === forge$i.oids.sha256 ||
12889
+ oid === forge$i.oids.sha384 ||
12890
+ oid === forge$i.oids.sha512 ||
12891
+ oid === forge$i.oids['sha512-224'] ||
12892
+ oid === forge$i.oids['sha512-256'])) {
12893
+ var error = new Error(
12894
+ 'Unknown RSASSA-PKCS1-v1_5 DigestAlgorithm identifier.');
12895
+ error.oid = oid;
12896
+ throw error;
12897
+ }
12898
+
12899
+ // special check for md2 and md5 that NULL parameters exist
12900
+ if(oid === forge$i.oids.md2 || oid === forge$i.oids.md5) {
12901
+ if(!('parameters' in capture)) {
12902
+ throw new Error(
12903
+ 'ASN.1 object does not contain a valid RSASSA-PKCS1-v1_5 ' +
12904
+ 'DigestInfo value. ' +
12905
+ 'Missing algorithm identifer NULL parameters.');
12906
+ }
12907
+ }
12908
+
12785
12909
  // compare the given digest to the decrypted one
12786
- return digest === obj.value[1].value;
12910
+ return digest === capture.digest;
12787
12911
  }
12788
12912
  };
12789
12913
  } else if(scheme === 'NONE' || scheme === 'NULL' || scheme === null) {
@@ -26379,7 +26503,7 @@ if(typeof(console) !== 'undefined' && 'log' in console) {
26379
26503
  }
26380
26504
 
26381
26505
  /*
26382
- * Check for logging control query vars.
26506
+ * Check for logging control query vars in current URL.
26383
26507
  *
26384
26508
  * console.level=<level-name>
26385
26509
  * Set's the console log level by name. Useful to override defaults and
@@ -26390,13 +26514,10 @@ if(typeof(console) !== 'undefined' && 'log' in console) {
26390
26514
  * after console.level is processed. Useful to force a level of verbosity
26391
26515
  * that could otherwise be limited by a user config.
26392
26516
  */
26393
- if(sConsoleLogger !== null) {
26394
- var query;
26395
- if(typeof window !== 'undefined' && window.location) {
26396
- query = new URL(window.location.href).searchParams;
26397
- } else {
26398
- query = new URLSearchParams();
26399
- }
26517
+ if(sConsoleLogger !== null &&
26518
+ typeof window !== 'undefined' && window.location
26519
+ ) {
26520
+ var query = new URL(window.location.href).searchParams;
26400
26521
  if(query.has('console.level')) {
26401
26522
  // set with last value
26402
26523
  forge$3.log.setLevel(
@@ -577,7 +577,7 @@ function toHeaders(name, stats, isEtag) {
577
577
  return headers;
578
578
  }
579
579
 
580
- function sirv (dir, opts={}) {
580
+ function sirv (dir, opts) {
581
581
  dir = resolve(dir || '.');
582
582
 
583
583
  let isNotFound = opts.onNoMatch || is404;
@@ -12,16 +12,20 @@ import { pathToFileURL, URL as URL$1 } from 'url';
12
12
  import { installPolyfills } from '../node/polyfills.js';
13
13
  import './write_tsconfig.js';
14
14
  import 'chokidar';
15
- import 'child_process';
16
15
  import 'net';
16
+ import 'child_process';
17
17
  import 'sade';
18
18
  import 'os';
19
19
  import 'node:http';
20
20
  import 'node:https';
21
21
  import 'node:zlib';
22
22
  import 'node:stream';
23
+ import 'node:buffer';
23
24
  import 'node:util';
24
25
  import 'node:url';
26
+ import 'node:net';
27
+ import 'node:fs';
28
+ import 'node:path';
25
29
  import 'crypto';
26
30
 
27
31
  const absolute = /^([a-z]+:)?\/?\//;
@@ -4,8 +4,8 @@ import { g as generate_manifest } from './index2.js';
4
4
  import 'chokidar';
5
5
  import 'fs';
6
6
  import 'path';
7
- import 'child_process';
8
7
  import 'net';
8
+ import 'child_process';
9
9
  import 'sade';
10
10
  import 'vite';
11
11
  import 'url';
@@ -13,11 +13,15 @@ import 'node:http';
13
13
  import 'node:https';
14
14
  import 'node:zlib';
15
15
  import 'node:stream';
16
+ import 'node:buffer';
16
17
  import 'node:util';
17
18
  import 'node:url';
18
- import 'net';
19
+ import 'node:net';
20
+ import 'node:fs';
21
+ import 'node:path';
19
22
  import 'crypto';
20
23
  import 'chokidar';
24
+ import 'net';
21
25
  import 'child_process';
22
26
  import 'sade';
23
27
  import 'vite';
@@ -6,8 +6,8 @@ import chokidar from 'chokidar';
6
6
  import { w as walk$1, m as mkdirp, p as posixify, r as rimraf, c as copy } from './filesystem.js';
7
7
  import { createRequire } from 'module';
8
8
  import { b as write_tsconfig } from './write_tsconfig.js';
9
- import 'child_process';
10
9
  import 'net';
10
+ import 'child_process';
11
11
  import 'sade';
12
12
  import 'vite';
13
13
  import 'url';
@@ -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 '../node/polyfills.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++,
@@ -12,8 +12,8 @@ import { p as posixify } from './filesystem.js';
12
12
  import { p as parse_route_id } from './misc.js';
13
13
  import { d as deep_merge } from './object.js';
14
14
  import 'chokidar';
15
- import 'child_process';
16
15
  import 'net';
16
+ import 'child_process';
17
17
  import 'sade';
18
18
  import 'os';
19
19
  import 'querystring';
@@ -21,8 +21,12 @@ import 'node:http';
21
21
  import 'node:https';
22
22
  import 'node:zlib';
23
23
  import 'node:stream';
24
+ import 'node:buffer';
24
25
  import 'node:util';
25
26
  import 'node:url';
27
+ import 'node:net';
28
+ import 'node:fs';
29
+ import 'node:path';
26
30
  import 'crypto';
27
31
  import './write_tsconfig.js';
28
32
  import 'stream';
@@ -270,9 +274,7 @@ const sveltekit = function (svelte_config) {
270
274
  const file = svelte_config.kit.files.assets + pathname;
271
275
 
272
276
  if (fs__default.existsSync(file) && !fs__default.statSync(file).isDirectory()) {
273
- const has_correct_case = fs__default.realpathSync.native(file) === path__default.resolve(file);
274
-
275
- if (has_correct_case) {
277
+ if (has_correct_case(file, svelte_config.kit.files.assets)) {
276
278
  req.url = encodeURI(pathname); // don't need query/hash
277
279
  asset_server(req, res);
278
280
  return;
@@ -450,7 +452,7 @@ const sveltekit = function (svelte_config) {
450
452
  };
451
453
 
452
454
  /** @param {import('http').ServerResponse} res */
453
- function not_found(res, message = 'Not found') {
455
+ function not_found(res, message) {
454
456
  res.statusCode = 404;
455
457
  res.end(message);
456
458
  }
@@ -512,6 +514,27 @@ async function find_deps(vite, node, deps) {
512
514
  await Promise.all(branches);
513
515
  }
514
516
 
517
+ /**
518
+ * Determine if a file is being requested with the correct case,
519
+ * to ensure consistent behaviour between dev and prod and across
520
+ * operating systems. Note that we can't use realpath here,
521
+ * because we don't want to follow symlinks
522
+ * @param {string} file
523
+ * @param {string} assets
524
+ * @returns {boolean}
525
+ */
526
+ function has_correct_case(file, assets) {
527
+ if (file === assets) return true;
528
+
529
+ const parent = path__default.dirname(file);
530
+
531
+ if (fs__default.readdirSync(parent).includes(path__default.basename(file))) {
532
+ return has_correct_case(parent, assets);
533
+ }
534
+
535
+ return false;
536
+ }
537
+
515
538
  /**
516
539
  * @param {import('types').ValidatedConfig} svelte_config
517
540
  * @return {import('vite').Plugin[]}
@@ -6,8 +6,8 @@ import { p as parse_route_id, s } from './misc.js';
6
6
  import { fileURLToPath } from 'url';
7
7
  import { w as write_if_changed, t as trim, a as write, b as write_tsconfig } from './write_tsconfig.js';
8
8
  import 'chokidar';
9
- import 'child_process';
10
9
  import 'net';
10
+ import 'child_process';
11
11
  import 'sade';
12
12
  import 'vite';
13
13
  import 'os';
package/dist/cli.js CHANGED
@@ -1,8 +1,8 @@
1
1
  import chokidar from 'chokidar';
2
2
  import fs__default from 'fs';
3
3
  import path__default, { join, relative } from 'path';
4
- import * as child_process from 'child_process';
5
- import * as net from 'net';
4
+ import { createConnection, createServer } from 'net';
5
+ import { exec as exec$1 } from 'child_process';
6
6
  import sade from 'sade';
7
7
  import * as vite from 'vite';
8
8
  import * as url from 'url';
@@ -115,39 +115,11 @@ function init(open, close) {
115
115
  };
116
116
  }
117
117
 
118
- /** @param {string} cmd */
119
- function exec(cmd) {
120
- return new Promise((fulfil, reject) => {
121
- child_process.exec(cmd, (error, stdout, stderr) => {
122
- if (error) return reject(error);
123
- fulfil({ stdout, stderr });
124
- });
125
- });
126
- }
127
-
128
- /**
129
- * Find the PID of the process using `port`
130
- * @param {number} port
131
- */
132
- async function blame(port) {
133
- try {
134
- const { stdout } = await exec(`lsof -i :${port} -sTCP:LISTEN -Fp`);
135
-
136
- if (!stdout) return null;
137
- const pid = parseInt(stdout.slice(1), 10);
138
- if (isNaN(pid)) throw new Error(`Invalid stdout ${stdout}`);
139
-
140
- return pid;
141
- } catch (error) {
142
- return null;
143
- }
144
- }
145
-
146
118
  const host = 'localhost';
147
119
 
148
- /** @type {Promise<any>} */
149
120
  let promise;
150
121
 
122
+
151
123
  function weird() {
152
124
  if (!promise) {
153
125
  promise = get_weird(9000);
@@ -155,10 +127,9 @@ function weird() {
155
127
  return promise;
156
128
  }
157
129
 
158
- /** @param {number} port */
159
130
  function get_weird(port) {
160
- return new Promise((fulfil) => {
161
- const server = net.createServer();
131
+ return new Promise(fulfil => {
132
+ const server = createServer();
162
133
 
163
134
  server.unref();
164
135
 
@@ -167,7 +138,7 @@ function get_weird(port) {
167
138
  });
168
139
 
169
140
  server.listen({ host, port }, () => {
170
- const server2 = net.createServer();
141
+ const server2 = createServer();
171
142
 
172
143
  server2.unref();
173
144
 
@@ -178,28 +149,24 @@ function get_weird(port) {
178
149
  });
179
150
 
180
151
  server2.listen({ host, port }, () => {
181
- server2.close(() => {
182
- server.close(() => {
183
- fulfil(true);
184
- });
185
- });
186
- });
152
+ server2.close(() => {
153
+ server.close(() => {
154
+ fulfil(true);
155
+ });
156
+ });
157
+ });
187
158
  });
188
159
  });
189
160
  }
190
161
 
191
- /**
192
- * Check if `port` is available
193
- * @param {number} port
194
- */
195
162
  function check(port) {
196
- return weird().then((weird) => {
163
+ return weird().then(weird => {
197
164
  if (weird) {
198
165
  return check_weird(port);
199
166
  }
200
167
 
201
- return new Promise((fulfil) => {
202
- const server = net.createServer();
168
+ return new Promise(fulfil => {
169
+ const server = createServer();
203
170
 
204
171
  server.unref();
205
172
 
@@ -216,11 +183,9 @@ function check(port) {
216
183
  });
217
184
  }
218
185
 
219
- /** @param {number} port */
220
186
  function check_weird(port) {
221
- return new Promise((fulfil) => {
222
- const client = net
223
- .createConnection({ host, port }, () => {
187
+ return new Promise(fulfil => {
188
+ const client = createConnection({ host, port }, () => {
224
189
  client.end();
225
190
  fulfil(false);
226
191
  })
@@ -230,6 +195,29 @@ function check_weird(port) {
230
195
  });
231
196
  }
232
197
 
198
+ function exec(cmd) {
199
+ return new Promise((fulfil, reject) => {
200
+ exec$1(cmd, (error, stdout, stderr) => {
201
+ if (error) return reject(error);
202
+ fulfil({ stdout, stderr });
203
+ });
204
+ });
205
+ }
206
+
207
+ async function blame(port) {
208
+ try {
209
+ const { stdout } = await exec(`lsof -i :${port} -sTCP:LISTEN -Fp`);
210
+
211
+ if (!stdout) return null;
212
+ const pid = parseInt(stdout.slice(1), 10);
213
+ if (isNaN(pid)) throw new Error(`Invalid stdout ${stdout}`);
214
+
215
+ return pid;
216
+ } catch (error) {
217
+ return null;
218
+ }
219
+ }
220
+
233
221
  const get_runtime_path = /** @param {import('types').ValidatedConfig} config */ (config) =>
234
222
  posixify_path(path__default.join(config.kit.outDir, 'runtime'))
235
223
  ;
@@ -554,7 +542,7 @@ const options = object(
554
542
 
555
543
  // TODO: remove this for the 1.0 release
556
544
  force: validate(undefined, (input, keypath) => {
557
- if (typeof input !== undefined) {
545
+ if (typeof input !== 'undefined') {
558
546
  const newSetting = input ? 'continue' : 'fail';
559
547
  const needsSetting = newSetting === 'continue';
560
548
  throw new Error(
@@ -636,7 +624,7 @@ const options = object(
636
624
  * @param {boolean} [allow_unknown]
637
625
  * @returns {Validator}
638
626
  */
639
- function object(children, allow_unknown = false) {
627
+ function object(children, allow_unknown) {
640
628
  return (input, keypath) => {
641
629
  /** @type {Record<string, any>} */
642
630
  const output = {};
@@ -865,7 +853,7 @@ function validate_config(config) {
865
853
  * @param {string=} pathPrefix - prepended in front of the path
866
854
  * @param {string=} scope - used to prefix the whole error message
867
855
  */
868
- function print_config_conflicts(conflicts, pathPrefix = '', scope) {
856
+ function print_config_conflicts(conflicts, pathPrefix, scope) {
869
857
  const prefix = scope ? scope + ': ' : '';
870
858
  const log = logger({ verbose: false });
871
859
  conflicts.forEach((conflict) => {
@@ -920,7 +908,7 @@ async function launch(port, https, base) {
920
908
  exec(`${cmd} ${https ? 'https' : 'http'}://localhost:${port}${base}`);
921
909
  }
922
910
 
923
- const prog = sade('svelte-kit').version('1.0.0-next.346');
911
+ const prog = sade('svelte-kit').version('1.0.0-next.347');
924
912
 
925
913
  prog
926
914
  .command('dev')
@@ -1161,7 +1149,7 @@ async function check_port(port) {
1161
1149
  function welcome({ port, host, https, open, base, loose, allow, cwd }) {
1162
1150
  if (open) launch(port, https, base);
1163
1151
 
1164
- console.log($.bold().cyan(`\n SvelteKit v${'1.0.0-next.346'}\n`));
1152
+ console.log($.bold().cyan(`\n SvelteKit v${'1.0.0-next.347'}\n`));
1165
1153
 
1166
1154
  const protocol = https ? 'https:' : 'http:';
1167
1155
  const exposed = typeof host !== 'undefined' && host !== 'localhost' && host !== '127.0.0.1';
@@ -1,10 +1,13 @@
1
1
  import http from 'node:http';
2
2
  import https from 'node:https';
3
3
  import zlib from 'node:zlib';
4
- import Stream, { PassThrough, pipeline } from 'node:stream';
5
- import { types, deprecate } from 'node:util';
4
+ import Stream, { PassThrough, pipeline as pipeline$1 } from 'node:stream';
5
+ import { Buffer as Buffer$1 } from 'node:buffer';
6
+ import { types, promisify, deprecate } from 'node:util';
6
7
  import { format } from 'node:url';
7
- import { isIP } from 'net';
8
+ import { isIP } from 'node:net';
9
+ import 'node:fs';
10
+ import 'node:path';
8
11
  import { webcrypto } from 'crypto';
9
12
 
10
13
  var commonjsGlobal = typeof globalThis !== 'undefined' ? globalThis : typeof window !== 'undefined' ? window : typeof global !== 'undefined' ? global : typeof self !== 'undefined' ? self : {};
@@ -64,7 +67,7 @@ function dataUriToBuffer(uri) {
64
67
  var ponyfill_es2018 = {exports: {}};
65
68
 
66
69
  /**
67
- * web-streams-polyfill v3.2.0
70
+ * web-streams-polyfill v3.2.1
68
71
  */
69
72
 
70
73
  (function (module, exports) {
@@ -3766,10 +3769,16 @@ var ponyfill_es2018 = {exports: {}};
3766
3769
  const byteLengthSizeFunction = (chunk) => {
3767
3770
  return chunk.byteLength;
3768
3771
  };
3769
- Object.defineProperty(byteLengthSizeFunction, 'name', {
3770
- value: 'size',
3771
- configurable: true
3772
- });
3772
+ try {
3773
+ Object.defineProperty(byteLengthSizeFunction, 'name', {
3774
+ value: 'size',
3775
+ configurable: true
3776
+ });
3777
+ }
3778
+ catch (_a) {
3779
+ // This property is non-configurable in older browsers, so ignore if this throws.
3780
+ // https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/Function/name#browser_compatibility
3781
+ }
3773
3782
  /**
3774
3783
  * A queuing strategy that counts the number of bytes in each chunk.
3775
3784
  *
@@ -3828,10 +3837,16 @@ var ponyfill_es2018 = {exports: {}};
3828
3837
  const countSizeFunction = () => {
3829
3838
  return 1;
3830
3839
  };
3831
- Object.defineProperty(countSizeFunction, 'name', {
3832
- value: 'size',
3833
- configurable: true
3834
- });
3840
+ try {
3841
+ Object.defineProperty(countSizeFunction, 'name', {
3842
+ value: 'size',
3843
+ configurable: true
3844
+ });
3845
+ }
3846
+ catch (_a) {
3847
+ // This property is non-configurable in older browsers, so ignore if this throws.
3848
+ // https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/Function/name#browser_compatibility
3849
+ }
3835
3850
  /**
3836
3851
  * A queuing strategy that counts the number of chunks.
3837
3852
  *
@@ -4319,16 +4334,14 @@ try {
4319
4334
 
4320
4335
  /*! fetch-blob. MIT License. Jimmy Wärting <https://jimmy.warting.se/opensource> */
4321
4336
 
4322
- /** @typedef {import('buffer').Blob} NodeBlob} */
4323
-
4324
4337
  // 64 KiB (same size chrome slice theirs blob into Uint8array's)
4325
4338
  const POOL_SIZE = 65536;
4326
4339
 
4327
- /** @param {(Blob | NodeBlob | Uint8Array)[]} parts */
4328
- async function * toIterator (parts, clone = true) {
4340
+ /** @param {(Blob | Uint8Array)[]} parts */
4341
+ async function * toIterator (parts, clone) {
4329
4342
  for (const part of parts) {
4330
4343
  if ('stream' in part) {
4331
- yield * part.stream();
4344
+ yield * (/** @type {AsyncIterableIterator<Uint8Array>} */ (part.stream()));
4332
4345
  } else if (ArrayBuffer.isView(part)) {
4333
4346
  if (clone) {
4334
4347
  let position = part.byteOffset;
@@ -4342,17 +4355,16 @@ async function * toIterator (parts, clone = true) {
4342
4355
  } else {
4343
4356
  yield part;
4344
4357
  }
4358
+ /* c8 ignore next 10 */
4345
4359
  } else {
4346
- /* c8 ignore start */
4347
4360
  // For blobs that have arrayBuffer but no stream method (nodes buffer.Blob)
4348
- let position = 0;
4349
- while (position !== part.size) {
4350
- const chunk = part.slice(position, Math.min(part.size, position + POOL_SIZE));
4361
+ let position = 0, b = (/** @type {Blob} */ (part));
4362
+ while (position !== b.size) {
4363
+ const chunk = b.slice(position, Math.min(b.size, position + POOL_SIZE));
4351
4364
  const buffer = await chunk.arrayBuffer();
4352
4365
  position += buffer.byteLength;
4353
4366
  yield new Uint8Array(buffer);
4354
4367
  }
4355
- /* c8 ignore end */
4356
4368
  }
4357
4369
  }
4358
4370
  }
@@ -4362,6 +4374,7 @@ const _Blob = class Blob {
4362
4374
  #parts = []
4363
4375
  #type = ''
4364
4376
  #size = 0
4377
+ #endings = 'transparent'
4365
4378
 
4366
4379
  /**
4367
4380
  * The Blob() constructor returns a new Blob object. The content
@@ -4369,7 +4382,7 @@ const _Blob = class Blob {
4369
4382
  * in the parameter array.
4370
4383
  *
4371
4384
  * @param {*} blobParts
4372
- * @param {{ type?: string }} [options]
4385
+ * @param {{ type?: string, endings?: string }} [options]
4373
4386
  */
4374
4387
  constructor (blobParts = [], options = {}) {
4375
4388
  if (typeof blobParts !== 'object' || blobParts === null) {
@@ -4396,15 +4409,19 @@ const _Blob = class Blob {
4396
4409
  } else if (element instanceof Blob) {
4397
4410
  part = element;
4398
4411
  } else {
4399
- part = encoder.encode(element);
4412
+ part = encoder.encode(`${element}`);
4400
4413
  }
4401
4414
 
4402
- this.#size += ArrayBuffer.isView(part) ? part.byteLength : part.size;
4403
- this.#parts.push(part);
4415
+ const size = ArrayBuffer.isView(part) ? part.byteLength : part.size;
4416
+ // Avoid pushing empty parts into the array to better GC them
4417
+ if (size) {
4418
+ this.#size += size;
4419
+ this.#parts.push(part);
4420
+ }
4404
4421
  }
4405
4422
 
4423
+ this.#endings = `${options.endings === undefined ? 'transparent' : options.endings}`;
4406
4424
  const type = options.type === undefined ? '' : String(options.type);
4407
-
4408
4425
  this.#type = /^[\x20-\x7E]*$/.test(type) ? type : '';
4409
4426
  }
4410
4427
 
@@ -4470,6 +4487,7 @@ const _Blob = class Blob {
4470
4487
  const it = toIterator(this.#parts, true);
4471
4488
 
4472
4489
  return new globalThis.ReadableStream({
4490
+ // @ts-ignore
4473
4491
  type: 'bytes',
4474
4492
  async pull (ctrl) {
4475
4493
  const chunk = await it.next();
@@ -4601,6 +4619,11 @@ const _File = class File extends Blob$1 {
4601
4619
  get [Symbol.toStringTag] () {
4602
4620
  return 'File'
4603
4621
  }
4622
+
4623
+ static [Symbol.hasInstance] (object) {
4624
+ return !!object && object instanceof Blob$1 &&
4625
+ /^(File)$/.test(object[Symbol.toStringTag])
4626
+ }
4604
4627
  };
4605
4628
 
4606
4629
  /** @type {typeof globalThis.File} */// @ts-ignore
@@ -4743,6 +4766,22 @@ const isAbortSignal = object => {
4743
4766
  );
4744
4767
  };
4745
4768
 
4769
+ /**
4770
+ * isDomainOrSubdomain reports whether sub is a subdomain (or exact match) of
4771
+ * the parent domain.
4772
+ *
4773
+ * Both domains must already be in canonical form.
4774
+ * @param {string|URL} original
4775
+ * @param {string|URL} destination
4776
+ */
4777
+ const isDomainOrSubdomain = (destination, original) => {
4778
+ const orig = new URL(original).hostname;
4779
+ const dest = new URL(destination).hostname;
4780
+
4781
+ return orig === dest || orig.endsWith(`.${dest}`);
4782
+ };
4783
+
4784
+ const pipeline = promisify(Stream.pipeline);
4746
4785
  const INTERNALS$2 = Symbol('Body internals');
4747
4786
 
4748
4787
  /**
@@ -4765,13 +4804,13 @@ class Body {
4765
4804
  body = null;
4766
4805
  } else if (isURLSearchParameters(body)) {
4767
4806
  // Body is a URLSearchParams
4768
- body = Buffer.from(body.toString());
4769
- } else if (isBlob(body)) ; else if (Buffer.isBuffer(body)) ; else if (types.isAnyArrayBuffer(body)) {
4807
+ body = Buffer$1.from(body.toString());
4808
+ } else if (isBlob(body)) ; else if (Buffer$1.isBuffer(body)) ; else if (types.isAnyArrayBuffer(body)) {
4770
4809
  // Body is ArrayBuffer
4771
- body = Buffer.from(body);
4810
+ body = Buffer$1.from(body);
4772
4811
  } else if (ArrayBuffer.isView(body)) {
4773
4812
  // Body is ArrayBufferView
4774
- body = Buffer.from(body.buffer, body.byteOffset, body.byteLength);
4813
+ body = Buffer$1.from(body.buffer, body.byteOffset, body.byteLength);
4775
4814
  } else if (body instanceof Stream) ; else if (body instanceof FormData) {
4776
4815
  // Body is FormData
4777
4816
  body = formDataToBlob(body);
@@ -4779,12 +4818,12 @@ class Body {
4779
4818
  } else {
4780
4819
  // None of the above
4781
4820
  // coerce to string then buffer
4782
- body = Buffer.from(String(body));
4821
+ body = Buffer$1.from(String(body));
4783
4822
  }
4784
4823
 
4785
4824
  let stream = body;
4786
4825
 
4787
- if (Buffer.isBuffer(body)) {
4826
+ if (Buffer$1.isBuffer(body)) {
4788
4827
  stream = Stream.Readable.from(body);
4789
4828
  } else if (isBlob(body)) {
4790
4829
  stream = Stream.Readable.from(body.stream());
@@ -4852,7 +4891,7 @@ class Body {
4852
4891
  */
4853
4892
  async blob() {
4854
4893
  const ct = (this.headers && this.headers.get('content-type')) || (this[INTERNALS$2].body && this[INTERNALS$2].body.type) || '';
4855
- const buf = await this.buffer();
4894
+ const buf = await this.arrayBuffer();
4856
4895
 
4857
4896
  return new Blob$1([buf], {
4858
4897
  type: ct
@@ -4865,8 +4904,8 @@ class Body {
4865
4904
  * @return Promise
4866
4905
  */
4867
4906
  async json() {
4868
- const buffer = await consumeBody(this);
4869
- return JSON.parse(buffer.toString());
4907
+ const text = await this.text();
4908
+ return JSON.parse(text);
4870
4909
  }
4871
4910
 
4872
4911
  /**
@@ -4876,7 +4915,7 @@ class Body {
4876
4915
  */
4877
4916
  async text() {
4878
4917
  const buffer = await consumeBody(this);
4879
- return buffer.toString();
4918
+ return new TextDecoder().decode(buffer);
4880
4919
  }
4881
4920
 
4882
4921
  /**
@@ -4898,7 +4937,10 @@ Object.defineProperties(Body.prototype, {
4898
4937
  arrayBuffer: {enumerable: true},
4899
4938
  blob: {enumerable: true},
4900
4939
  json: {enumerable: true},
4901
- text: {enumerable: true}
4940
+ text: {enumerable: true},
4941
+ data: {get: deprecate(() => {},
4942
+ 'data doesn\'t exist, use json(), text(), arrayBuffer(), or body instead',
4943
+ 'https://github.com/node-fetch/node-fetch/issues/1000 (response)')}
4902
4944
  });
4903
4945
 
4904
4946
  /**
@@ -4923,12 +4965,12 @@ async function consumeBody(data) {
4923
4965
 
4924
4966
  // Body is null
4925
4967
  if (body === null) {
4926
- return Buffer.alloc(0);
4968
+ return Buffer$1.alloc(0);
4927
4969
  }
4928
4970
 
4929
4971
  /* c8 ignore next 3 */
4930
4972
  if (!(body instanceof Stream)) {
4931
- return Buffer.alloc(0);
4973
+ return Buffer$1.alloc(0);
4932
4974
  }
4933
4975
 
4934
4976
  // Body is stream
@@ -4955,10 +4997,10 @@ async function consumeBody(data) {
4955
4997
  if (body.readableEnded === true || body._readableState.ended === true) {
4956
4998
  try {
4957
4999
  if (accum.every(c => typeof c === 'string')) {
4958
- return Buffer.from(accum.join(''));
5000
+ return Buffer$1.from(accum.join(''));
4959
5001
  }
4960
5002
 
4961
- return Buffer.concat(accum, accumBytes);
5003
+ return Buffer$1.concat(accum, accumBytes);
4962
5004
  } catch (error) {
4963
5005
  throw new FetchError(`Could not create Buffer from response body for ${data.url}: ${error.message}`, 'system', error);
4964
5006
  }
@@ -5038,7 +5080,7 @@ const extractContentType = (body, request) => {
5038
5080
  }
5039
5081
 
5040
5082
  // Body is a Buffer (Buffer, ArrayBuffer or ArrayBufferView)
5041
- if (Buffer.isBuffer(body) || types.isAnyArrayBuffer(body) || ArrayBuffer.isView(body)) {
5083
+ if (Buffer$1.isBuffer(body) || types.isAnyArrayBuffer(body) || ArrayBuffer.isView(body)) {
5042
5084
  return null;
5043
5085
  }
5044
5086
 
@@ -5083,7 +5125,7 @@ const getTotalBytes = request => {
5083
5125
  }
5084
5126
 
5085
5127
  // Body is Buffer
5086
- if (Buffer.isBuffer(body)) {
5128
+ if (Buffer$1.isBuffer(body)) {
5087
5129
  return body.length;
5088
5130
  }
5089
5131
 
@@ -5101,15 +5143,15 @@ const getTotalBytes = request => {
5101
5143
  *
5102
5144
  * @param {Stream.Writable} dest The stream to write to.
5103
5145
  * @param obj.body Body object from the Body instance.
5104
- * @returns {void}
5146
+ * @returns {Promise<void>}
5105
5147
  */
5106
- const writeToStream = (dest, {body}) => {
5148
+ const writeToStream = async (dest, {body}) => {
5107
5149
  if (body === null) {
5108
5150
  // Body is null
5109
5151
  dest.end();
5110
5152
  } else {
5111
5153
  // Body is stream
5112
- body.pipe(dest);
5154
+ await pipeline(body, dest);
5113
5155
  }
5114
5156
  };
5115
5157
 
@@ -5119,6 +5161,7 @@ const writeToStream = (dest, {body}) => {
5119
5161
  * Headers class offers convenient helpers
5120
5162
  */
5121
5163
 
5164
+ /* c8 ignore next 9 */
5122
5165
  const validateHeaderName = typeof http.validateHeaderName === 'function' ?
5123
5166
  http.validateHeaderName :
5124
5167
  name => {
@@ -5129,6 +5172,7 @@ const validateHeaderName = typeof http.validateHeaderName === 'function' ?
5129
5172
  }
5130
5173
  };
5131
5174
 
5175
+ /* c8 ignore next 9 */
5132
5176
  const validateHeaderValue = typeof http.validateHeaderValue === 'function' ?
5133
5177
  http.validateHeaderValue :
5134
5178
  (name, value) => {
@@ -5251,8 +5295,8 @@ class Headers extends URLSearchParams {
5251
5295
  return Reflect.get(target, p, receiver);
5252
5296
  }
5253
5297
  }
5254
- /* c8 ignore next */
5255
5298
  });
5299
+ /* c8 ignore next */
5256
5300
  }
5257
5301
 
5258
5302
  get [Symbol.toStringTag]() {
@@ -5873,12 +5917,20 @@ function parseReferrerPolicyFromHeader(headers) {
5873
5917
  return policy;
5874
5918
  }
5875
5919
 
5920
+ /**
5921
+ * Request.js
5922
+ *
5923
+ * Request class contains server only options
5924
+ *
5925
+ * All spec algorithm step numbers are based on https://fetch.spec.whatwg.org/commit-snapshots/ae716822cb3a61843226cd090eefc6589446c1d2/.
5926
+ */
5927
+
5876
5928
  const INTERNALS = Symbol('Request internals');
5877
5929
 
5878
5930
  /**
5879
5931
  * Check if `obj` is an instance of Request.
5880
5932
  *
5881
- * @param {*} obj
5933
+ * @param {*} object
5882
5934
  * @return {boolean}
5883
5935
  */
5884
5936
  const isRequest = object => {
@@ -5888,6 +5940,10 @@ const isRequest = object => {
5888
5940
  );
5889
5941
  };
5890
5942
 
5943
+ const doBadDataWarn = deprecate(() => {},
5944
+ '.data is not a valid RequestInit property, use .body instead',
5945
+ 'https://github.com/node-fetch/node-fetch/issues/1000 (request)');
5946
+
5891
5947
  /**
5892
5948
  * Request class
5893
5949
  *
@@ -5910,14 +5966,20 @@ class Request extends Body {
5910
5966
  }
5911
5967
 
5912
5968
  if (parsedURL.username !== '' || parsedURL.password !== '') {
5913
- throw new TypeError(`${parsedURL} is an url with embedded credentails.`);
5969
+ throw new TypeError(`${parsedURL} is an url with embedded credentials.`);
5914
5970
  }
5915
5971
 
5916
5972
  let method = init.method || input.method || 'GET';
5917
- method = method.toUpperCase();
5973
+ if (/^(delete|get|head|options|post|put)$/i.test(method)) {
5974
+ method = method.toUpperCase();
5975
+ }
5976
+
5977
+ if ('data' in init) {
5978
+ doBadDataWarn();
5979
+ }
5918
5980
 
5919
5981
  // eslint-disable-next-line no-eq-null, eqeqeq
5920
- if (((init.body != null || isRequest(input)) && input.body !== null) &&
5982
+ if ((init.body != null || (isRequest(input) && input.body !== null)) &&
5921
5983
  (method === 'GET' || method === 'HEAD')) {
5922
5984
  throw new TypeError('Request with GET/HEAD method cannot have body');
5923
5985
  }
@@ -5990,14 +6052,17 @@ class Request extends Body {
5990
6052
  this.referrerPolicy = init.referrerPolicy || input.referrerPolicy || '';
5991
6053
  }
5992
6054
 
6055
+ /** @returns {string} */
5993
6056
  get method() {
5994
6057
  return this[INTERNALS].method;
5995
6058
  }
5996
6059
 
6060
+ /** @returns {string} */
5997
6061
  get url() {
5998
6062
  return format(this[INTERNALS].parsedURL);
5999
6063
  }
6000
6064
 
6065
+ /** @returns {Headers} */
6001
6066
  get headers() {
6002
6067
  return this[INTERNALS].headers;
6003
6068
  }
@@ -6006,6 +6071,7 @@ class Request extends Body {
6006
6071
  return this[INTERNALS].redirect;
6007
6072
  }
6008
6073
 
6074
+ /** @returns {AbortSignal} */
6009
6075
  get signal() {
6010
6076
  return this[INTERNALS].signal;
6011
6077
  }
@@ -6063,8 +6129,8 @@ Object.defineProperties(Request.prototype, {
6063
6129
  /**
6064
6130
  * Convert a Request to Node.js http request options.
6065
6131
  *
6066
- * @param Request A Request instance
6067
- * @return Object The options object to be passed to http.request
6132
+ * @param {Request} request - A Request instance
6133
+ * @return The options object to be passed to http.request
6068
6134
  */
6069
6135
  const getNodeRequestOptions = request => {
6070
6136
  const {parsedURL} = request[INTERNALS];
@@ -6153,6 +6219,7 @@ const getNodeRequestOptions = request => {
6153
6219
  };
6154
6220
 
6155
6221
  return {
6222
+ /** @type {URL} */
6156
6223
  parsedURL,
6157
6224
  options
6158
6225
  };
@@ -6167,6 +6234,21 @@ class AbortError extends FetchBaseError {
6167
6234
  }
6168
6235
  }
6169
6236
 
6237
+ /*! node-domexception. MIT License. Jimmy Wärting <https://jimmy.warting.se/opensource> */
6238
+
6239
+ if (!globalThis.DOMException) {
6240
+ try {
6241
+ const { MessageChannel } = require('worker_threads'),
6242
+ port = new MessageChannel().port1,
6243
+ ab = new ArrayBuffer();
6244
+ port.postMessage(ab, [ab, ab]);
6245
+ } catch (err) {
6246
+ err.constructor.name === 'DOMException' && (
6247
+ globalThis.DOMException = err.constructor
6248
+ );
6249
+ }
6250
+ }
6251
+
6170
6252
  /**
6171
6253
  * Index.js
6172
6254
  *
@@ -6230,7 +6312,7 @@ async function fetch(url, options_) {
6230
6312
  };
6231
6313
 
6232
6314
  // Send request
6233
- const request_ = send(parsedURL, options);
6315
+ const request_ = send(parsedURL.toString(), options);
6234
6316
 
6235
6317
  if (signal) {
6236
6318
  signal.addEventListener('abort', abortAndFinalize);
@@ -6282,7 +6364,19 @@ async function fetch(url, options_) {
6282
6364
  const location = headers.get('Location');
6283
6365
 
6284
6366
  // HTTP fetch step 5.3
6285
- const locationURL = location === null ? null : new URL(location, request.url);
6367
+ let locationURL = null;
6368
+ try {
6369
+ locationURL = location === null ? null : new URL(location, request.url);
6370
+ } catch {
6371
+ // error here can only be invalid URL in Location: header
6372
+ // do not throw when options.redirect == manual
6373
+ // let the user extract the errorneous redirect URL
6374
+ if (request.redirect !== 'manual') {
6375
+ reject(new FetchError(`uri requested responds with an invalid redirect URL: ${location}`, 'invalid-redirect'));
6376
+ finalize();
6377
+ return;
6378
+ }
6379
+ }
6286
6380
 
6287
6381
  // HTTP fetch step 5.5
6288
6382
  switch (request.redirect) {
@@ -6291,11 +6385,7 @@ async function fetch(url, options_) {
6291
6385
  finalize();
6292
6386
  return;
6293
6387
  case 'manual':
6294
- // Node-fetch-specific step: make manual redirect a bit easier to use by setting the Location header value to the resolved URL.
6295
- if (locationURL !== null) {
6296
- headers.set('Location', locationURL);
6297
- }
6298
-
6388
+ // Nothing to do
6299
6389
  break;
6300
6390
  case 'follow': {
6301
6391
  // HTTP-redirect fetch step 2
@@ -6326,6 +6416,18 @@ async function fetch(url, options_) {
6326
6416
  referrerPolicy: request.referrerPolicy
6327
6417
  };
6328
6418
 
6419
+ // when forwarding sensitive headers like "Authorization",
6420
+ // "WWW-Authenticate", and "Cookie" to untrusted targets,
6421
+ // headers will be ignored when following a redirect to a domain
6422
+ // that is not a subdomain match or exact match of the initial domain.
6423
+ // For example, a redirect from "foo.com" to either "foo.com" or "sub.foo.com"
6424
+ // will forward the sensitive headers, but a redirect to "bar.com" will not.
6425
+ if (!isDomainOrSubdomain(request.url, locationURL)) {
6426
+ for (const name of ['authorization', 'www-authenticate', 'cookie', 'cookie2']) {
6427
+ requestOptions.headers.delete(name);
6428
+ }
6429
+ }
6430
+
6329
6431
  // HTTP-redirect fetch step 9
6330
6432
  if (response_.statusCode !== 303 && request.body && options_.body instanceof Stream.Readable) {
6331
6433
  reject(new FetchError('Cannot follow redirect with body being a readable stream', 'unsupported-redirect'));
@@ -6364,8 +6466,13 @@ async function fetch(url, options_) {
6364
6466
  });
6365
6467
  }
6366
6468
 
6367
- let body = pipeline(response_, new PassThrough(), reject);
6469
+ let body = pipeline$1(response_, new PassThrough(), error => {
6470
+ if (error) {
6471
+ reject(error);
6472
+ }
6473
+ });
6368
6474
  // see https://github.com/nodejs/node/pull/29376
6475
+ /* c8 ignore next 3 */
6369
6476
  if (process.version < 'v12.10') {
6370
6477
  response_.on('aborted', abortAndFinalize);
6371
6478
  }
@@ -6409,7 +6516,11 @@ async function fetch(url, options_) {
6409
6516
 
6410
6517
  // For gzip
6411
6518
  if (codings === 'gzip' || codings === 'x-gzip') {
6412
- body = pipeline(body, zlib.createGunzip(zlibOptions), reject);
6519
+ body = pipeline$1(body, zlib.createGunzip(zlibOptions), error => {
6520
+ if (error) {
6521
+ reject(error);
6522
+ }
6523
+ });
6413
6524
  response = new Response(body, responseOptions);
6414
6525
  resolve(response);
6415
6526
  return;
@@ -6419,20 +6530,48 @@ async function fetch(url, options_) {
6419
6530
  if (codings === 'deflate' || codings === 'x-deflate') {
6420
6531
  // Handle the infamous raw deflate response from old servers
6421
6532
  // a hack for old IIS and Apache servers
6422
- const raw = pipeline(response_, new PassThrough(), reject);
6533
+ const raw = pipeline$1(response_, new PassThrough(), error => {
6534
+ if (error) {
6535
+ reject(error);
6536
+ }
6537
+ });
6423
6538
  raw.once('data', chunk => {
6424
6539
  // See http://stackoverflow.com/questions/37519828
6425
- body = (chunk[0] & 0x0F) === 0x08 ? pipeline(body, zlib.createInflate(), reject) : pipeline(body, zlib.createInflateRaw(), reject);
6540
+ if ((chunk[0] & 0x0F) === 0x08) {
6541
+ body = pipeline$1(body, zlib.createInflate(), error => {
6542
+ if (error) {
6543
+ reject(error);
6544
+ }
6545
+ });
6546
+ } else {
6547
+ body = pipeline$1(body, zlib.createInflateRaw(), error => {
6548
+ if (error) {
6549
+ reject(error);
6550
+ }
6551
+ });
6552
+ }
6426
6553
 
6427
6554
  response = new Response(body, responseOptions);
6428
6555
  resolve(response);
6429
6556
  });
6557
+ raw.once('end', () => {
6558
+ // Some old IIS servers return zero-length OK deflate responses, so
6559
+ // 'data' is never emitted. See https://github.com/node-fetch/node-fetch/pull/903
6560
+ if (!response) {
6561
+ response = new Response(body, responseOptions);
6562
+ resolve(response);
6563
+ }
6564
+ });
6430
6565
  return;
6431
6566
  }
6432
6567
 
6433
6568
  // For br
6434
6569
  if (codings === 'br') {
6435
- body = pipeline(body, zlib.createBrotliDecompress(), reject);
6570
+ body = pipeline$1(body, zlib.createBrotliDecompress(), error => {
6571
+ if (error) {
6572
+ reject(error);
6573
+ }
6574
+ });
6436
6575
  response = new Response(body, responseOptions);
6437
6576
  resolve(response);
6438
6577
  return;
@@ -6443,12 +6582,13 @@ async function fetch(url, options_) {
6443
6582
  resolve(response);
6444
6583
  });
6445
6584
 
6446
- writeToStream(request_, request);
6585
+ // eslint-disable-next-line promise/prefer-await-to-then
6586
+ writeToStream(request_, request).catch(reject);
6447
6587
  });
6448
6588
  }
6449
6589
 
6450
6590
  function fixResponseChunkedTransferBadEnding(request, errorCallback) {
6451
- const LAST_CHUNK = Buffer.from('0\r\n\r\n');
6591
+ const LAST_CHUNK = Buffer$1.from('0\r\n\r\n');
6452
6592
 
6453
6593
  let isChunkedTransfer = false;
6454
6594
  let properLastChunkReceived = false;
@@ -6475,13 +6615,13 @@ function fixResponseChunkedTransferBadEnding(request, errorCallback) {
6475
6615
  });
6476
6616
 
6477
6617
  socket.on('data', buf => {
6478
- properLastChunkReceived = Buffer.compare(buf.slice(-5), LAST_CHUNK) === 0;
6618
+ properLastChunkReceived = Buffer$1.compare(buf.slice(-5), LAST_CHUNK) === 0;
6479
6619
 
6480
6620
  // Sometimes final 0-length chunk and end of message code are in separate packets
6481
6621
  if (!properLastChunkReceived && previousChunk) {
6482
6622
  properLastChunkReceived = (
6483
- Buffer.compare(previousChunk.slice(-3), LAST_CHUNK.slice(0, 3)) === 0 &&
6484
- Buffer.compare(buf.slice(-2), LAST_CHUNK.slice(3)) === 0
6623
+ Buffer$1.compare(previousChunk.slice(-3), LAST_CHUNK.slice(0, 3)) === 0 &&
6624
+ Buffer$1.compare(buf.slice(-2), LAST_CHUNK.slice(3)) === 0
6485
6625
  );
6486
6626
  }
6487
6627
 
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@sveltejs/kit",
3
- "version": "1.0.0-next.346",
3
+ "version": "1.0.0-next.347",
4
4
  "repository": {
5
5
  "type": "git",
6
6
  "url": "https://github.com/sveltejs/kit",
@@ -12,25 +12,40 @@
12
12
  "dependencies": {
13
13
  "@sveltejs/vite-plugin-svelte": "^1.0.0-next.46",
14
14
  "chokidar": "^3.5.3",
15
- "sade": "^1.7.4",
15
+ "sade": "^1.8.1",
16
16
  "vite": "^2.9.9"
17
17
  },
18
18
  "devDependencies": {
19
+ "@playwright/test": "^1.22.2",
20
+ "@rollup/plugin-replace": "^4.0.0",
19
21
  "@types/connect": "^3.4.35",
20
- "@types/cookie": "^0.5.0",
21
- "@types/marked": "^4.0.1",
22
+ "@types/cookie": "^0.5.1",
23
+ "@types/marked": "^4.0.3",
22
24
  "@types/mime": "^2.0.3",
23
- "@types/sade": "^1.7.3",
25
+ "@types/node": "^16.11.36",
26
+ "@types/sade": "^1.7.4",
24
27
  "@types/set-cookie-parser": "^2.4.2",
25
28
  "cookie": "^0.5.0",
29
+ "cross-env": "^7.0.3",
26
30
  "devalue": "^2.0.1",
31
+ "eslint": "^8.16.0",
27
32
  "kleur": "^4.1.4",
28
33
  "locate-character": "^2.0.5",
34
+ "marked": "^4.0.16",
29
35
  "mime": "^3.0.0",
30
- "node-fetch": "^3.1.0",
31
- "selfsigned": "^2.0.0",
36
+ "node-fetch": "^3.2.4",
37
+ "port-authority": "^1.2.0",
38
+ "rollup": "^2.75.3",
39
+ "selfsigned": "^2.0.1",
32
40
  "set-cookie-parser": "^2.4.8",
33
- "svelte": "^3.48.0"
41
+ "sirv": "^2.0.2",
42
+ "svelte": "^3.48.0",
43
+ "svelte-check": "^2.7.1",
44
+ "svelte-preprocess": "^4.10.6",
45
+ "svelte2tsx": "~0.5.10",
46
+ "tiny-glob": "^0.2.9",
47
+ "typescript": "^4.7.2",
48
+ "uvu": "^0.5.3"
34
49
  },
35
50
  "peerDependencies": {
36
51
  "svelte": "^3.44.0"