@sveltejs/kit 1.0.0-next.345 → 1.0.0-next.348

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.
@@ -1398,6 +1398,12 @@ function create_client({ target, session, base, trailing_slash }) {
1398
1398
  return new Promise(() => {});
1399
1399
  }
1400
1400
 
1401
+ if (import.meta.hot) {
1402
+ import.meta.hot.on('vite:beforeUpdate', () => {
1403
+ if (current.error) location.reload();
1404
+ });
1405
+ }
1406
+
1401
1407
  return {
1402
1408
  after_navigate: (fn) => {
1403
1409
  onMount(() => {
@@ -2231,10 +2231,7 @@ async function load_node({
2231
2231
  }
2232
2232
 
2233
2233
  response = await respond(
2234
- // we set `credentials` to `undefined` to workaround a bug in Cloudflare
2235
- // (https://github.com/sveltejs/kit/issues/3728) — which is fine, because
2236
- // we only need the headers
2237
- new Request(new URL(requested, event.url).href, { ...opts, credentials: undefined }),
2234
+ new Request(new URL(requested, event.url).href, { ...opts }),
2238
2235
  options,
2239
2236
  {
2240
2237
  ...state,
@@ -3096,8 +3093,9 @@ async function respond(request, options, state) {
3096
3093
  const is_data_request = decoded.endsWith(DATA_SUFFIX);
3097
3094
 
3098
3095
  if (is_data_request) {
3099
- decoded = decoded.slice(0, -DATA_SUFFIX.length) || '/';
3100
- url = new URL(url.origin + url.pathname.slice(0, -DATA_SUFFIX.length) + url.search);
3096
+ const data_suffix_length = DATA_SUFFIX.length - (options.trailing_slash === 'always' ? 1 : 0);
3097
+ decoded = decoded.slice(0, -data_suffix_length) || '/';
3098
+ url = new URL(url.origin + url.pathname.slice(0, -data_suffix_length) + url.search);
3101
3099
  }
3102
3100
 
3103
3101
  if (!state.prerendering?.fallback) {
@@ -3116,19 +3114,26 @@ async function respond(request, options, state) {
3116
3114
  }
3117
3115
  }
3118
3116
 
3119
- if (route?.type === 'page') {
3120
- const normalized = normalize_path(url.pathname, options.trailing_slash);
3117
+ if (route) {
3118
+ if (route.type === 'page') {
3119
+ const normalized = normalize_path(url.pathname, options.trailing_slash);
3121
3120
 
3122
- if (normalized !== url.pathname && !state.prerendering?.fallback) {
3121
+ if (normalized !== url.pathname && !state.prerendering?.fallback) {
3122
+ return new Response(undefined, {
3123
+ status: 301,
3124
+ headers: {
3125
+ 'x-sveltekit-normalize': '1',
3126
+ location:
3127
+ // ensure paths starting with '//' are not treated as protocol-relative
3128
+ (normalized.startsWith('//') ? url.origin + normalized : normalized) +
3129
+ (url.search === '?' ? '' : url.search)
3130
+ }
3131
+ });
3132
+ }
3133
+ } else if (is_data_request) {
3134
+ // requesting /__data.json should fail for a standalone endpoint
3123
3135
  return new Response(undefined, {
3124
- status: 301,
3125
- headers: {
3126
- 'x-sveltekit-normalize': '1',
3127
- location:
3128
- // ensure paths starting with '//' are not treated as protocol-relative
3129
- (normalized.startsWith('//') ? url.origin + normalized : normalized) +
3130
- (url.search === '?' ? '' : url.search)
3131
- }
3136
+ status: 404
3132
3137
  });
3133
3138
  }
3134
3139
  }
@@ -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;