@sveltejs/adapter-netlify 2.0.4 → 2.0.6

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/README.md CHANGED
@@ -2,8 +2,6 @@
2
2
 
3
3
  A SvelteKit adapter that creates a Netlify app.
4
4
 
5
- If you're using [adapter-auto](https://kit.svelte.dev/docs/adapter-auto), you don't need to install this unless you need to specify Netlify-specific options, since it's already included.
6
-
7
5
  ## Docs
8
6
 
9
7
  [Docs](https://kit.svelte.dev/docs/adapter-netlify)
@@ -266,7 +266,8 @@ function split_headers(headers) {
266
266
 
267
267
  headers.forEach((value, key) => {
268
268
  if (key === 'set-cookie') {
269
- m[key] = splitCookiesString_1(value);
269
+ if (!m[key]) m[key] = [];
270
+ m[key].push(...splitCookiesString_1(value));
270
271
  } else {
271
272
  h[key] = value;
272
273
  }
@@ -307,6 +307,8 @@ const { Blob: Blob$2 } = require$$7;
307
307
  const nodeUtil = require$$0;
308
308
  const { stringify } = require$$8;
309
309
 
310
+ const [nodeMajor, nodeMinor] = process.versions.node.split('.').map(v => Number(v));
311
+
310
312
  function nop$1 () {}
311
313
 
312
314
  function isStream (obj) {
@@ -510,25 +512,42 @@ function parseHeaders (headers, obj = {}) {
510
512
  for (let i = 0; i < headers.length; i += 2) {
511
513
  const key = headers[i].toString().toLowerCase();
512
514
  let val = obj[key];
515
+
516
+ const encoding = key.length === 19 && key === 'content-disposition'
517
+ ? 'latin1'
518
+ : 'utf8';
519
+
513
520
  if (!val) {
514
521
  if (Array.isArray(headers[i + 1])) {
515
522
  obj[key] = headers[i + 1];
516
523
  } else {
517
- obj[key] = headers[i + 1].toString();
524
+ obj[key] = headers[i + 1].toString(encoding);
518
525
  }
519
526
  } else {
520
527
  if (!Array.isArray(val)) {
521
528
  val = [val];
522
529
  obj[key] = val;
523
530
  }
524
- val.push(headers[i + 1].toString());
531
+ val.push(headers[i + 1].toString(encoding));
525
532
  }
526
533
  }
527
534
  return obj
528
535
  }
529
536
 
530
537
  function parseRawHeaders (headers) {
531
- return headers.map(header => header.toString())
538
+ const ret = [];
539
+ for (let n = 0; n < headers.length; n += 2) {
540
+ const key = headers[n + 0].toString();
541
+
542
+ const encoding = key.length === 19 && key.toLowerCase() === 'content-disposition'
543
+ ? 'latin1'
544
+ : 'utf8';
545
+
546
+ const val = headers[n + 1].toString(encoding);
547
+
548
+ ret.push(key, val);
549
+ }
550
+ return ret
532
551
  }
533
552
 
534
553
  function isBuffer (buffer) {
@@ -700,7 +719,10 @@ var util$g = {
700
719
  validateHandler,
701
720
  getSocketInfo,
702
721
  isFormDataLike,
703
- buildURL: buildURL$2
722
+ buildURL: buildURL$2,
723
+ nodeMajor,
724
+ nodeMinor,
725
+ nodeHasAutoSelectFamily: nodeMajor > 18 || (nodeMajor === 18 && nodeMinor >= 13)
704
726
  };
705
727
 
706
728
  let fastNow = Date.now();
@@ -5118,6 +5140,7 @@ function requireDataURL () {
5118
5140
  dataURLProcessor,
5119
5141
  URLSerializer,
5120
5142
  collectASequenceOfCodePoints,
5143
+ collectASequenceOfCodePointsFast,
5121
5144
  stringPercentDecode,
5122
5145
  parseMIMEType,
5123
5146
  collectAnHTTPQuotedString,
@@ -6394,10 +6417,6 @@ const channels$1 = {};
6394
6417
 
6395
6418
  let extractBody;
6396
6419
 
6397
- const nodeVersion = process.versions.node.split('.');
6398
- const nodeMajor = Number(nodeVersion[0]);
6399
- const nodeMinor = Number(nodeVersion[1]);
6400
-
6401
6420
  try {
6402
6421
  const diagnosticsChannel = require('diagnostics_channel');
6403
6422
  channels$1.create = diagnosticsChannel.channel('undici:request:create');
@@ -6532,7 +6551,7 @@ let Request$1 = class Request {
6532
6551
  }
6533
6552
 
6534
6553
  if (util$e.isFormDataLike(this.body)) {
6535
- if (nodeMajor < 16 || (nodeMajor === 16 && nodeMinor < 8)) {
6554
+ if (util$e.nodeMajor < 16 || (util$e.nodeMajor === 16 && util$e.nodeMinor < 8)) {
6536
6555
  throw new InvalidArgumentError$i('Form-Data bodies are only supported in node v16.8 and newer.')
6537
6556
  }
6538
6557
 
@@ -6664,6 +6683,9 @@ function processHeader (request, key, val) {
6664
6683
  key.length === 4 &&
6665
6684
  key.toLowerCase() === 'host'
6666
6685
  ) {
6686
+ if (headerCharRegex.exec(val) !== null) {
6687
+ throw new InvalidArgumentError$i(`invalid ${key} header`)
6688
+ }
6667
6689
  // Consumed by Client
6668
6690
  request.host = val;
6669
6691
  } else if (
@@ -7772,7 +7794,9 @@ let Client$4 = class Client extends DispatcherBase$3 {
7772
7794
  connect,
7773
7795
  maxRequestsPerClient,
7774
7796
  localAddress,
7775
- maxResponseSize
7797
+ maxResponseSize,
7798
+ autoSelectFamily,
7799
+ autoSelectFamilyAttemptTimeout
7776
7800
  } = {}) {
7777
7801
  super();
7778
7802
 
@@ -7848,12 +7872,20 @@ let Client$4 = class Client extends DispatcherBase$3 {
7848
7872
  throw new InvalidArgumentError$e('maxResponseSize must be a positive number')
7849
7873
  }
7850
7874
 
7875
+ if (
7876
+ autoSelectFamilyAttemptTimeout != null &&
7877
+ (!Number.isInteger(autoSelectFamilyAttemptTimeout) || autoSelectFamilyAttemptTimeout < -1)
7878
+ ) {
7879
+ throw new InvalidArgumentError$e('autoSelectFamilyAttemptTimeout must be a positive number')
7880
+ }
7881
+
7851
7882
  if (typeof connect !== 'function') {
7852
7883
  connect = buildConnector$2({
7853
7884
  ...tls,
7854
7885
  maxCachedSessions,
7855
7886
  socketPath,
7856
7887
  timeout: connectTimeout,
7888
+ ...(util$b.nodeHasAutoSelectFamily && autoSelectFamily ? { autoSelectFamily, autoSelectFamilyAttemptTimeout } : undefined),
7857
7889
  ...connect
7858
7890
  });
7859
7891
  }
@@ -7875,8 +7907,8 @@ let Client$4 = class Client extends DispatcherBase$3 {
7875
7907
  this[kResuming] = 0; // 0, idle, 1, scheduled, 2 resuming
7876
7908
  this[kNeedDrain$3] = 0; // 0, idle, 1, scheduled, 2 resuming
7877
7909
  this[kHostHeader] = `host: ${this[kUrl$3].hostname}${this[kUrl$3].port ? `:${this[kUrl$3].port}` : ''}\r\n`;
7878
- this[kBodyTimeout] = bodyTimeout != null ? bodyTimeout : 30e3;
7879
- this[kHeadersTimeout] = headersTimeout != null ? headersTimeout : 30e3;
7910
+ this[kBodyTimeout] = bodyTimeout != null ? bodyTimeout : 300e3;
7911
+ this[kHeadersTimeout] = headersTimeout != null ? headersTimeout : 300e3;
7880
7912
  this[kStrictContentLength] = strictContentLength == null ? true : strictContentLength;
7881
7913
  this[kMaxRedirections$1] = maxRedirections;
7882
7914
  this[kMaxRequests] = maxRequestsPerClient;
@@ -9789,6 +9821,8 @@ let Pool$3 = class Pool extends PoolBase$1 {
9789
9821
  tls,
9790
9822
  maxCachedSessions,
9791
9823
  socketPath,
9824
+ autoSelectFamily,
9825
+ autoSelectFamilyAttemptTimeout,
9792
9826
  ...options
9793
9827
  } = {}) {
9794
9828
  super();
@@ -9811,6 +9845,7 @@ let Pool$3 = class Pool extends PoolBase$1 {
9811
9845
  maxCachedSessions,
9812
9846
  socketPath,
9813
9847
  timeout: connectTimeout == null ? 10e3 : connectTimeout,
9848
+ ...(util$a.nodeHasAutoSelectFamily && autoSelectFamily ? { autoSelectFamily, autoSelectFamilyAttemptTimeout } : undefined),
9814
9849
  ...connect
9815
9850
  });
9816
9851
  }
@@ -11635,7 +11670,11 @@ function buildKey$1 (opts) {
11635
11670
  }
11636
11671
 
11637
11672
  function generateKeyValues (data) {
11638
- return Object.entries(data).reduce((keyValuePairs, [key, value]) => [...keyValuePairs, key, value], [])
11673
+ return Object.entries(data).reduce((keyValuePairs, [key, value]) => [
11674
+ ...keyValuePairs,
11675
+ Buffer.from(`${key}`),
11676
+ Array.isArray(value) ? value.map(x => Buffer.from(`${x}`)) : Buffer.from(`${value}`)
11677
+ ], [])
11639
11678
  }
11640
11679
 
11641
11680
  /**
@@ -12610,6 +12649,7 @@ function requireHeaders () {
12610
12649
  isValidHeaderValue
12611
12650
  } = requireUtil$3();
12612
12651
  const { webidl } = requireWebidl();
12652
+ const assert = require$$0$1;
12613
12653
 
12614
12654
  const kHeadersMap = Symbol('headers map');
12615
12655
  const kHeadersSortedMap = Symbol('headers map sorted');
@@ -12622,10 +12662,12 @@ function requireHeaders () {
12622
12662
  // To normalize a byte sequence potentialValue, remove
12623
12663
  // any leading and trailing HTTP whitespace bytes from
12624
12664
  // potentialValue.
12625
- return potentialValue.replace(
12626
- /^[\r\n\t ]+|[\r\n\t ]+$/g,
12627
- ''
12628
- )
12665
+
12666
+ // Trimming the end with `.replace()` and a RegExp is typically subject to
12667
+ // ReDoS. This is safer and faster.
12668
+ let i = potentialValue.length;
12669
+ while (/[\r\n\t ]/.test(potentialValue.charAt(--i)));
12670
+ return potentialValue.slice(0, i + 1).replace(/^[\r\n\t ]+/, '')
12629
12671
  }
12630
12672
 
12631
12673
  function fill (headers, object) {
@@ -12671,6 +12713,7 @@ function requireHeaders () {
12671
12713
  if (init instanceof HeadersList) {
12672
12714
  this[kHeadersMap] = new Map(init[kHeadersMap]);
12673
12715
  this[kHeadersSortedMap] = init[kHeadersSortedMap];
12716
+ this.cookies = init.cookies;
12674
12717
  } else {
12675
12718
  this[kHeadersMap] = new Map(init);
12676
12719
  this[kHeadersSortedMap] = null;
@@ -12714,7 +12757,7 @@ function requireHeaders () {
12714
12757
 
12715
12758
  if (lowercaseName === 'set-cookie') {
12716
12759
  this.cookies ??= [];
12717
- this.cookies.push([name, value]);
12760
+ this.cookies.push(value);
12718
12761
  }
12719
12762
  }
12720
12763
 
@@ -12724,7 +12767,7 @@ function requireHeaders () {
12724
12767
  const lowercaseName = name.toLowerCase();
12725
12768
 
12726
12769
  if (lowercaseName === 'set-cookie') {
12727
- this.cookies = [[name, value]];
12770
+ this.cookies = [value];
12728
12771
  }
12729
12772
 
12730
12773
  // 1. If list contains name, then set the value of
@@ -12975,18 +13018,74 @@ function requireHeaders () {
12975
13018
  return this[kHeadersList].set(name, value)
12976
13019
  }
12977
13020
 
13021
+ // https://fetch.spec.whatwg.org/#dom-headers-getsetcookie
13022
+ getSetCookie () {
13023
+ webidl.brandCheck(this, Headers);
13024
+
13025
+ // 1. If this’s header list does not contain `Set-Cookie`, then return « ».
13026
+ // 2. Return the values of all headers in this’s header list whose name is
13027
+ // a byte-case-insensitive match for `Set-Cookie`, in order.
13028
+
13029
+ const list = this[kHeadersList].cookies;
13030
+
13031
+ if (list) {
13032
+ return [...list]
13033
+ }
13034
+
13035
+ return []
13036
+ }
13037
+
13038
+ // https://fetch.spec.whatwg.org/#concept-header-list-sort-and-combine
12978
13039
  get [kHeadersSortedMap] () {
12979
- if (!this[kHeadersList][kHeadersSortedMap]) {
12980
- this[kHeadersList][kHeadersSortedMap] = new Map([...this[kHeadersList]].sort((a, b) => a[0] < b[0] ? -1 : 1));
13040
+ if (this[kHeadersList][kHeadersSortedMap]) {
13041
+ return this[kHeadersList][kHeadersSortedMap]
13042
+ }
13043
+
13044
+ // 1. Let headers be an empty list of headers with the key being the name
13045
+ // and value the value.
13046
+ const headers = [];
13047
+
13048
+ // 2. Let names be the result of convert header names to a sorted-lowercase
13049
+ // set with all the names of the headers in list.
13050
+ const names = [...this[kHeadersList]].sort((a, b) => a[0] < b[0] ? -1 : 1);
13051
+ const cookies = this[kHeadersList].cookies;
13052
+
13053
+ // 3. For each name of names:
13054
+ for (const [name, value] of names) {
13055
+ // 1. If name is `set-cookie`, then:
13056
+ if (name === 'set-cookie') {
13057
+ // 1. Let values be a list of all values of headers in list whose name
13058
+ // is a byte-case-insensitive match for name, in order.
13059
+
13060
+ // 2. For each value of values:
13061
+ // 1. Append (name, value) to headers.
13062
+ for (const value of cookies) {
13063
+ headers.push([name, value]);
13064
+ }
13065
+ } else {
13066
+ // 2. Otherwise:
13067
+
13068
+ // 1. Let value be the result of getting name from list.
13069
+
13070
+ // 2. Assert: value is non-null.
13071
+ assert(value !== null);
13072
+
13073
+ // 3. Append (name, value) to headers.
13074
+ headers.push([name, value]);
13075
+ }
12981
13076
  }
12982
- return this[kHeadersList][kHeadersSortedMap]
13077
+
13078
+ this[kHeadersList][kHeadersSortedMap] = headers;
13079
+
13080
+ // 4. Return headers.
13081
+ return headers
12983
13082
  }
12984
13083
 
12985
13084
  keys () {
12986
13085
  webidl.brandCheck(this, Headers);
12987
13086
 
12988
13087
  return makeIterator(
12989
- () => [...this[kHeadersSortedMap].entries()],
13088
+ () => [...this[kHeadersSortedMap].values()],
12990
13089
  'Headers',
12991
13090
  'key'
12992
13091
  )
@@ -12996,7 +13095,7 @@ function requireHeaders () {
12996
13095
  webidl.brandCheck(this, Headers);
12997
13096
 
12998
13097
  return makeIterator(
12999
- () => [...this[kHeadersSortedMap].entries()],
13098
+ () => [...this[kHeadersSortedMap].values()],
13000
13099
  'Headers',
13001
13100
  'value'
13002
13101
  )
@@ -13006,7 +13105,7 @@ function requireHeaders () {
13006
13105
  webidl.brandCheck(this, Headers);
13007
13106
 
13008
13107
  return makeIterator(
13009
- () => [...this[kHeadersSortedMap].entries()],
13108
+ () => [...this[kHeadersSortedMap].values()],
13010
13109
  'Headers',
13011
13110
  'key+value'
13012
13111
  )
@@ -13756,6 +13855,7 @@ function requireRequest () {
13756
13855
  const { URLSerializer } = requireDataURL();
13757
13856
  const { kHeadersList } = symbols$3;
13758
13857
  const assert = require$$0$1;
13858
+ const { setMaxListeners, getEventListeners, defaultMaxListeners } = require$$0$4;
13759
13859
 
13760
13860
  let TransformStream = globalThis.TransformStream;
13761
13861
 
@@ -14080,6 +14180,11 @@ function requireRequest () {
14080
14180
  const abort = function () {
14081
14181
  acRef.deref()?.abort(this.reason);
14082
14182
  };
14183
+
14184
+ if (getEventListeners(signal, 'abort').length >= defaultMaxListeners) {
14185
+ setMaxListeners(100, signal);
14186
+ }
14187
+
14083
14188
  signal.addEventListener('abort', abort, { once: true });
14084
14189
  requestFinalizer.register(this, { signal, abort });
14085
14190
  }
@@ -14697,7 +14802,7 @@ function requireFetch () {
14697
14802
  const { kHeadersList } = symbols$3;
14698
14803
  const EE = require$$0$4;
14699
14804
  const { Readable, pipeline } = require$$0$2;
14700
- const { isErrored, isReadable } = util$g;
14805
+ const { isErrored, isReadable, nodeMajor, nodeMinor } = util$g;
14701
14806
  const { dataURLProcessor, serializeAMimeType } = requireDataURL();
14702
14807
  const { TransformStream } = require$$13;
14703
14808
  const { getGlobalDispatcher } = global$2;
@@ -14708,10 +14813,6 @@ function requireFetch () {
14708
14813
  let resolveObjectURL;
14709
14814
  let ReadableStream = globalThis.ReadableStream;
14710
14815
 
14711
- const nodeVersion = process.versions.node.split('.');
14712
- const nodeMajor = Number(nodeVersion[0]);
14713
- const nodeMinor = Number(nodeVersion[1]);
14714
-
14715
14816
  class Fetch extends EE {
14716
14817
  constructor (dispatcher) {
14717
14818
  super();
@@ -18157,7 +18258,7 @@ function requireParse () {
18157
18258
 
18158
18259
  const { maxNameValuePairSize, maxAttributeValueSize } = requireConstants$1();
18159
18260
  const { isCTLExcludingHtab } = requireUtil$1();
18160
- const { collectASequenceOfCodePoints } = requireDataURL();
18261
+ const { collectASequenceOfCodePointsFast } = requireDataURL();
18161
18262
  const assert = require$$0$1;
18162
18263
 
18163
18264
  /**
@@ -18187,7 +18288,7 @@ function requireParse () {
18187
18288
  // (including the %x3B (";") in question).
18188
18289
  const position = { position: 0 };
18189
18290
 
18190
- nameValuePair = collectASequenceOfCodePoints((char) => char !== ';', header, position);
18291
+ nameValuePair = collectASequenceOfCodePointsFast(';', header, position);
18191
18292
  unparsedAttributes = header.slice(position.position);
18192
18293
  } else {
18193
18294
  // Otherwise:
@@ -18209,8 +18310,8 @@ function requireParse () {
18209
18310
  // empty) value string consists of the characters after the first
18210
18311
  // %x3D ("=") character.
18211
18312
  const position = { position: 0 };
18212
- name = collectASequenceOfCodePoints(
18213
- (char) => char !== '=',
18313
+ name = collectASequenceOfCodePointsFast(
18314
+ '=',
18214
18315
  nameValuePair,
18215
18316
  position
18216
18317
  );
@@ -18261,8 +18362,8 @@ function requireParse () {
18261
18362
  if (unparsedAttributes.includes(';')) {
18262
18363
  // 1. Consume the characters of the unparsed-attributes up to, but
18263
18364
  // not including, the first %x3B (";") character.
18264
- cookieAv = collectASequenceOfCodePoints(
18265
- (char) => char !== ';',
18365
+ cookieAv = collectASequenceOfCodePointsFast(
18366
+ ';',
18266
18367
  unparsedAttributes,
18267
18368
  { position: 0 }
18268
18369
  );
@@ -18289,8 +18390,8 @@ function requireParse () {
18289
18390
  // character.
18290
18391
  const position = { position: 0 };
18291
18392
 
18292
- attributeName = collectASequenceOfCodePoints(
18293
- (char) => char !== '=',
18393
+ attributeName = collectASequenceOfCodePointsFast(
18394
+ '=',
18294
18395
  cookieAv,
18295
18396
  position
18296
18397
  );
@@ -18563,7 +18664,8 @@ function requireCookies () {
18563
18664
  return []
18564
18665
  }
18565
18666
 
18566
- return cookies.map((pair) => parseSetCookie(pair[1]))
18667
+ // In older versions of undici, cookies is a list of name:value.
18668
+ return cookies.map((pair) => parseSetCookie(Array.isArray(pair) ? pair[1] : pair))
18567
18669
  }
18568
18670
 
18569
18671
  /**
@@ -20603,10 +20705,6 @@ function requireUndici () {
20603
20705
  const RedirectHandler = RedirectHandler_1;
20604
20706
  const createRedirectInterceptor = redirectInterceptor;
20605
20707
 
20606
- const nodeVersion = process.versions.node.split('.');
20607
- const nodeMajor = Number(nodeVersion[0]);
20608
- const nodeMinor = Number(nodeVersion[1]);
20609
-
20610
20708
  let hasCrypto;
20611
20709
  try {
20612
20710
  require('crypto');
@@ -20683,7 +20781,7 @@ function requireUndici () {
20683
20781
  undici.setGlobalDispatcher = setGlobalDispatcher;
20684
20782
  undici.getGlobalDispatcher = getGlobalDispatcher;
20685
20783
 
20686
- if (nodeMajor > 16 || (nodeMajor === 16 && nodeMinor >= 8)) {
20784
+ if (util.nodeMajor > 16 || (util.nodeMajor === 16 && util.nodeMinor >= 8)) {
20687
20785
  let fetchImpl = null;
20688
20786
  undici.fetch = async function fetch (resource) {
20689
20787
  if (!fetchImpl) {
@@ -20710,7 +20808,7 @@ function requireUndici () {
20710
20808
  undici.getGlobalOrigin = getGlobalOrigin;
20711
20809
  }
20712
20810
 
20713
- if (nodeMajor >= 16) {
20811
+ if (util.nodeMajor >= 16) {
20714
20812
  const { deleteCookie, getCookies, getSetCookies, setCookie } = requireCookies();
20715
20813
 
20716
20814
  undici.deleteCookie = deleteCookie;
@@ -20724,7 +20822,7 @@ function requireUndici () {
20724
20822
  undici.serializeAMimeType = serializeAMimeType;
20725
20823
  }
20726
20824
 
20727
- if (nodeMajor >= 18 && hasCrypto) {
20825
+ if (util.nodeMajor >= 18 && hasCrypto) {
20728
20826
  const { WebSocket } = requireWebsocket();
20729
20827
 
20730
20828
  undici.WebSocket = WebSocket;
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@sveltejs/adapter-netlify",
3
- "version": "2.0.4",
3
+ "version": "2.0.6",
4
4
  "repository": {
5
5
  "type": "git",
6
6
  "url": "https://github.com/sveltejs/kit",
@@ -38,7 +38,7 @@
38
38
  "rollup": "^3.7.0",
39
39
  "typescript": "^4.9.4",
40
40
  "uvu": "^0.5.6",
41
- "@sveltejs/kit": "^1.5.6"
41
+ "@sveltejs/kit": "^1.11.0"
42
42
  },
43
43
  "peerDependencies": {
44
44
  "@sveltejs/kit": "^1.5.0"