@kb-labs/core-state-daemon 2.106.0 → 2.107.0

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
package/dist/bin.cjs CHANGED
@@ -13239,14 +13239,15 @@ var require_data = __commonJS({
13239
13239
  }
13240
13240
  });
13241
13241
 
13242
- // ../../../node_modules/.pnpm/fast-uri@3.1.2/node_modules/fast-uri/lib/utils.js
13242
+ // ../../../node_modules/.pnpm/fast-uri@4.1.1/node_modules/fast-uri/lib/utils.js
13243
13243
  var require_utils = __commonJS({
13244
- "../../../node_modules/.pnpm/fast-uri@3.1.2/node_modules/fast-uri/lib/utils.js"(exports$1, module) {
13244
+ "../../../node_modules/.pnpm/fast-uri@4.1.1/node_modules/fast-uri/lib/utils.js"(exports$1, module) {
13245
13245
  var isUUID = RegExp.prototype.test.bind(/^[\da-f]{8}-[\da-f]{4}-[\da-f]{4}-[\da-f]{4}-[\da-f]{12}$/iu);
13246
13246
  var isIPv4 = RegExp.prototype.test.bind(/^(?:(?:25[0-5]|2[0-4]\d|1\d{2}|[1-9]\d|\d)\.){3}(?:25[0-5]|2[0-4]\d|1\d{2}|[1-9]\d|\d)$/u);
13247
13247
  var isHexPair = RegExp.prototype.test.bind(/^[\da-f]{2}$/iu);
13248
13248
  var isUnreserved = RegExp.prototype.test.bind(/^[\da-z\-._~]$/iu);
13249
13249
  var isPathCharacter = RegExp.prototype.test.bind(/^[\da-z\-._~!$&'()*+,;=:@/]$/iu);
13250
+ var isQueryFragmentCharacter = RegExp.prototype.test.bind(/^[\da-z\-._~!$&'()*+,;=:@/?]$/iu);
13250
13251
  function stringArrayToHexStripped(input) {
13251
13252
  let acc = "";
13252
13253
  let code = 0;
@@ -13389,7 +13390,7 @@ var require_utils = __commonJS({
13389
13390
  continue;
13390
13391
  }
13391
13392
  } else if (input[0] === "/") {
13392
- if (input[1] === "." || input[1] === "/") {
13393
+ if (input[1] === ".") {
13393
13394
  output.push("/");
13394
13395
  break;
13395
13396
  }
@@ -13471,10 +13472,30 @@ var require_utils = __commonJS({
13471
13472
  }
13472
13473
  return output;
13473
13474
  }
13475
+ var BYTE_HEX = new Array(256);
13476
+ {
13477
+ const HEX_DIGITS = "0123456789ABCDEF";
13478
+ for (let i = 0; i < 256; i++) {
13479
+ BYTE_HEX[i] = "%" + HEX_DIGITS[i >> 4] + HEX_DIGITS[i & 15];
13480
+ }
13481
+ }
13482
+ function isEscapeSafe(cp2) {
13483
+ return cp2 >= 48 && cp2 <= 57 || cp2 >= 65 && cp2 <= 90 || cp2 >= 97 && cp2 <= 122 || cp2 === 42 || cp2 === 43 || cp2 === 45 || cp2 === 46 || cp2 === 47 || cp2 === 64 || cp2 === 95;
13484
+ }
13485
+ function percentEncodeNonAscii(cp2) {
13486
+ if (cp2 < 2048) {
13487
+ return BYTE_HEX[192 | cp2 >> 6] + BYTE_HEX[128 | cp2 & 63];
13488
+ }
13489
+ if (cp2 < 65536) {
13490
+ return BYTE_HEX[224 | cp2 >> 12] + BYTE_HEX[128 | cp2 >> 6 & 63] + BYTE_HEX[128 | cp2 & 63];
13491
+ }
13492
+ return BYTE_HEX[240 | cp2 >> 18] + BYTE_HEX[128 | cp2 >> 12 & 63] + BYTE_HEX[128 | cp2 >> 6 & 63] + BYTE_HEX[128 | cp2 & 63];
13493
+ }
13474
13494
  function normalizePathEncoding(input) {
13475
13495
  let output = "";
13476
13496
  for (let i = 0; i < input.length; i++) {
13477
- if (input[i] === "%" && i + 2 < input.length) {
13497
+ const ch = input[i];
13498
+ if (ch === "%" && i + 2 < input.length) {
13478
13499
  const hex = input.slice(i + 1, i + 3);
13479
13500
  if (isHexPair(hex)) {
13480
13501
  const normalizedHex = hex.toUpperCase();
@@ -13488,10 +13509,66 @@ var require_utils = __commonJS({
13488
13509
  continue;
13489
13510
  }
13490
13511
  }
13491
- if (isPathCharacter(input[i])) {
13492
- output += input[i];
13512
+ if (isPathCharacter(ch)) {
13513
+ output += ch;
13493
13514
  } else {
13494
- output += escape(input[i]);
13515
+ const code = input.charCodeAt(i);
13516
+ if (code < 128) {
13517
+ output += isEscapeSafe(code) ? ch : BYTE_HEX[code];
13518
+ } else if (code < 55296 || code > 57343) {
13519
+ output += percentEncodeNonAscii(code);
13520
+ } else if (code <= 56319 && i + 1 < input.length) {
13521
+ const low = input.charCodeAt(i + 1);
13522
+ if (low >= 56320 && low <= 57343) {
13523
+ output += percentEncodeNonAscii(65536 + (code - 55296 << 10) + (low - 56320));
13524
+ i++;
13525
+ } else {
13526
+ output += percentEncodeNonAscii(65533);
13527
+ }
13528
+ } else {
13529
+ output += percentEncodeNonAscii(65533);
13530
+ }
13531
+ }
13532
+ }
13533
+ return output;
13534
+ }
13535
+ function normalizeQueryFragmentEncoding(input) {
13536
+ let output = "";
13537
+ for (let i = 0; i < input.length; i++) {
13538
+ const ch = input[i];
13539
+ if (ch === "%" && i + 2 < input.length) {
13540
+ const hex = input.slice(i + 1, i + 3);
13541
+ if (isHexPair(hex)) {
13542
+ const normalizedHex = hex.toUpperCase();
13543
+ const decoded = String.fromCharCode(parseInt(normalizedHex, 16));
13544
+ if (isUnreserved(decoded)) {
13545
+ output += decoded;
13546
+ } else {
13547
+ output += "%" + normalizedHex;
13548
+ }
13549
+ i += 2;
13550
+ continue;
13551
+ }
13552
+ }
13553
+ if (isQueryFragmentCharacter(ch)) {
13554
+ output += ch;
13555
+ } else {
13556
+ const code = input.charCodeAt(i);
13557
+ if (code < 128) {
13558
+ output += isEscapeSafe(code) ? ch : BYTE_HEX[code];
13559
+ } else if (code < 55296 || code > 57343) {
13560
+ output += percentEncodeNonAscii(code);
13561
+ } else if (code <= 56319 && i + 1 < input.length) {
13562
+ const low = input.charCodeAt(i + 1);
13563
+ if (low >= 56320 && low <= 57343) {
13564
+ output += percentEncodeNonAscii(65536 + (code - 55296 << 10) + (low - 56320));
13565
+ i++;
13566
+ } else {
13567
+ output += percentEncodeNonAscii(65533);
13568
+ }
13569
+ } else {
13570
+ output += percentEncodeNonAscii(65533);
13571
+ }
13495
13572
  }
13496
13573
  }
13497
13574
  return output;
@@ -13499,7 +13576,8 @@ var require_utils = __commonJS({
13499
13576
  function escapePreservingEscapes(input) {
13500
13577
  let output = "";
13501
13578
  for (let i = 0; i < input.length; i++) {
13502
- if (input[i] === "%" && i + 2 < input.length) {
13579
+ const ch = input[i];
13580
+ if (ch === "%" && i + 2 < input.length) {
13503
13581
  const hex = input.slice(i + 1, i + 3);
13504
13582
  if (isHexPair(hex)) {
13505
13583
  output += "%" + hex.toUpperCase();
@@ -13507,7 +13585,22 @@ var require_utils = __commonJS({
13507
13585
  continue;
13508
13586
  }
13509
13587
  }
13510
- output += escape(input[i]);
13588
+ const code = input.charCodeAt(i);
13589
+ if (code < 128) {
13590
+ output += isEscapeSafe(code) ? ch : BYTE_HEX[code];
13591
+ } else if (code < 55296 || code > 57343) {
13592
+ output += percentEncodeNonAscii(code);
13593
+ } else if (code <= 56319 && i + 1 < input.length) {
13594
+ const low = input.charCodeAt(i + 1);
13595
+ if (low >= 56320 && low <= 57343) {
13596
+ output += percentEncodeNonAscii(65536 + (code - 55296 << 10) + (low - 56320));
13597
+ i++;
13598
+ } else {
13599
+ output += percentEncodeNonAscii(65533);
13600
+ }
13601
+ } else {
13602
+ output += percentEncodeNonAscii(65533);
13603
+ }
13511
13604
  }
13512
13605
  return output;
13513
13606
  }
@@ -13541,6 +13634,7 @@ var require_utils = __commonJS({
13541
13634
  reescapeHostDelimiters,
13542
13635
  normalizePercentEncoding,
13543
13636
  normalizePathEncoding,
13637
+ normalizeQueryFragmentEncoding,
13544
13638
  escapePreservingEscapes,
13545
13639
  removeDotSegments,
13546
13640
  isIPv4,
@@ -13551,9 +13645,9 @@ var require_utils = __commonJS({
13551
13645
  }
13552
13646
  });
13553
13647
 
13554
- // ../../../node_modules/.pnpm/fast-uri@3.1.2/node_modules/fast-uri/lib/schemes.js
13648
+ // ../../../node_modules/.pnpm/fast-uri@4.1.1/node_modules/fast-uri/lib/schemes.js
13555
13649
  var require_schemes = __commonJS({
13556
- "../../../node_modules/.pnpm/fast-uri@3.1.2/node_modules/fast-uri/lib/schemes.js"(exports$1, module) {
13650
+ "../../../node_modules/.pnpm/fast-uri@4.1.1/node_modules/fast-uri/lib/schemes.js"(exports$1, module) {
13557
13651
  var { isUUID } = require_utils();
13558
13652
  var URN_REG = /([\da-z][\d\-a-z]{0,31}):((?:[\w!$'()*+,\-.:;=@]|%[\da-f]{2})+)/iu;
13559
13653
  var supportedSchemeNames = (
@@ -13760,10 +13854,10 @@ var require_schemes = __commonJS({
13760
13854
  }
13761
13855
  });
13762
13856
 
13763
- // ../../../node_modules/.pnpm/fast-uri@3.1.2/node_modules/fast-uri/index.js
13857
+ // ../../../node_modules/.pnpm/fast-uri@4.1.1/node_modules/fast-uri/index.js
13764
13858
  var require_fast_uri = __commonJS({
13765
- "../../../node_modules/.pnpm/fast-uri@3.1.2/node_modules/fast-uri/index.js"(exports$1, module) {
13766
- var { normalizeIPv6, removeDotSegments, recomposeAuthority, normalizePercentEncoding, normalizePathEncoding, escapePreservingEscapes, reescapeHostDelimiters, isIPv4, nonSimpleDomain } = require_utils();
13859
+ "../../../node_modules/.pnpm/fast-uri@4.1.1/node_modules/fast-uri/index.js"(exports$1, module) {
13860
+ var { normalizeIPv6, removeDotSegments, recomposeAuthority, normalizePercentEncoding, normalizePathEncoding, normalizeQueryFragmentEncoding, escapePreservingEscapes, reescapeHostDelimiters, isIPv4, nonSimpleDomain } = require_utils();
13767
13861
  var { SCHEMES, getSchemeHandler } = require_schemes();
13768
13862
  function normalize2(uri, options) {
13769
13863
  if (typeof uri === "string") {
@@ -13902,6 +13996,7 @@ var require_fast_uri = __commonJS({
13902
13996
  return uriTokens.join("");
13903
13997
  }
13904
13998
  var URI_PARSE = /^(?:([^#/:?]+):)?(?:\/\/((?:([^#/?@]*)@)?(\[[^#/?\]]+\]|[^#/:?]*)(?::(\d*))?))?([^#?]*)(?:\?([^#]*))?(?:#((?:.|[\n\r])*))?/u;
13999
+ var AUTHORITY_PREFIX = /^(?:[^#/:?]+:)?\/\/([^/?#]*)/;
13905
14000
  function getParseError(parsed, matches) {
13906
14001
  if (matches[2] !== void 0 && parsed.path && parsed.path[0] !== "/") {
13907
14002
  return 'URI path must start with "/" when authority is present.';
@@ -13931,9 +14026,14 @@ var require_fast_uri = __commonJS({
13931
14026
  uri = "//" + uri;
13932
14027
  }
13933
14028
  }
14029
+ const authorityMatch = uri.match(AUTHORITY_PREFIX);
14030
+ if (authorityMatch !== null && authorityMatch[1].indexOf("\\") !== -1) {
14031
+ parsed.error = "URI authority must not contain a literal backslash.";
14032
+ malformedAuthorityOrPort = true;
14033
+ }
13934
14034
  const matches = uri.match(URI_PARSE);
13935
14035
  if (matches) {
13936
- parsed.scheme = matches[1];
14036
+ parsed.scheme = matches[1] === void 0 ? void 0 : matches[1].toLowerCase();
13937
14037
  parsed.userinfo = matches[3];
13938
14038
  parsed.host = matches[4];
13939
14039
  parsed.port = parseInt(matches[5], 10);
@@ -13974,7 +14074,7 @@ var require_fast_uri = __commonJS({
13974
14074
  if (!options.unicodeSupport && (!schemeHandler || !schemeHandler.unicodeSupport)) {
13975
14075
  if (parsed.host && (options.domainHost || schemeHandler && schemeHandler.domainHost) && isIP === false && nonSimpleDomain(parsed.host)) {
13976
14076
  try {
13977
- parsed.host = URL.domainToASCII(parsed.host.toLowerCase());
14077
+ parsed.host = new URL("http://" + parsed.host).hostname;
13978
14078
  } catch (e) {
13979
14079
  parsed.error = parsed.error || "Host's domain name can not be converted to ASCII: " + e;
13980
14080
  }
@@ -13992,12 +14092,11 @@ var require_fast_uri = __commonJS({
13992
14092
  if (parsed.path) {
13993
14093
  parsed.path = normalizePathEncoding(parsed.path);
13994
14094
  }
14095
+ if (parsed.query) {
14096
+ parsed.query = normalizeQueryFragmentEncoding(parsed.query);
14097
+ }
13995
14098
  if (parsed.fragment) {
13996
- try {
13997
- parsed.fragment = encodeURI(decodeURIComponent(parsed.fragment));
13998
- } catch {
13999
- parsed.error = parsed.error || "URI malformed";
14000
- }
14099
+ parsed.fragment = normalizeQueryFragmentEncoding(parsed.fragment);
14001
14100
  }
14002
14101
  }
14003
14102
  if (schemeHandler && schemeHandler.parse) {
@@ -45824,9 +45923,9 @@ var require_safe_regex2 = __commonJS({
45824
45923
  }
45825
45924
  });
45826
45925
 
45827
- // ../../../node_modules/.pnpm/find-my-way@9.5.0/node_modules/find-my-way/lib/strategies/http-method.js
45926
+ // ../../../node_modules/.pnpm/find-my-way@9.7.0/node_modules/find-my-way/lib/strategies/http-method.js
45828
45927
  var require_http_method = __commonJS({
45829
- "../../../node_modules/.pnpm/find-my-way@9.5.0/node_modules/find-my-way/lib/strategies/http-method.js"(exports$1, module) {
45928
+ "../../../node_modules/.pnpm/find-my-way@9.7.0/node_modules/find-my-way/lib/strategies/http-method.js"(exports$1, module) {
45830
45929
  module.exports = {
45831
45930
  name: "__fmw_internal_strategy_merged_tree_http_method__",
45832
45931
  storage: function() {
@@ -45847,9 +45946,9 @@ var require_http_method = __commonJS({
45847
45946
  }
45848
45947
  });
45849
45948
 
45850
- // ../../../node_modules/.pnpm/find-my-way@9.5.0/node_modules/find-my-way/lib/pretty-print.js
45949
+ // ../../../node_modules/.pnpm/find-my-way@9.7.0/node_modules/find-my-way/lib/pretty-print.js
45851
45950
  var require_pretty_print = __commonJS({
45852
- "../../../node_modules/.pnpm/find-my-way@9.5.0/node_modules/find-my-way/lib/pretty-print.js"(exports$1, module) {
45951
+ "../../../node_modules/.pnpm/find-my-way@9.7.0/node_modules/find-my-way/lib/pretty-print.js"(exports$1, module) {
45853
45952
  var deepEqual = require_fast_deep_equal();
45854
45953
  var httpMethodStrategy = require_http_method();
45855
45954
  var treeDataSymbol = /* @__PURE__ */ Symbol("treeData");
@@ -45983,9 +46082,9 @@ ${prefix}`);
45983
46082
  }
45984
46083
  });
45985
46084
 
45986
- // ../../../node_modules/.pnpm/find-my-way@9.5.0/node_modules/find-my-way/lib/null-object.js
46085
+ // ../../../node_modules/.pnpm/find-my-way@9.7.0/node_modules/find-my-way/lib/null-object.js
45987
46086
  var require_null_object = __commonJS({
45988
- "../../../node_modules/.pnpm/find-my-way@9.5.0/node_modules/find-my-way/lib/null-object.js"(exports$1, module) {
46087
+ "../../../node_modules/.pnpm/find-my-way@9.7.0/node_modules/find-my-way/lib/null-object.js"(exports$1, module) {
45989
46088
  var NullObject = function() {
45990
46089
  };
45991
46090
  NullObject.prototype = /* @__PURE__ */ Object.create(null);
@@ -45995,9 +46094,9 @@ var require_null_object = __commonJS({
45995
46094
  }
45996
46095
  });
45997
46096
 
45998
- // ../../../node_modules/.pnpm/find-my-way@9.5.0/node_modules/find-my-way/lib/handler-storage.js
46097
+ // ../../../node_modules/.pnpm/find-my-way@9.7.0/node_modules/find-my-way/lib/handler-storage.js
45999
46098
  var require_handler_storage = __commonJS({
46000
- "../../../node_modules/.pnpm/find-my-way@9.5.0/node_modules/find-my-way/lib/handler-storage.js"(exports$1, module) {
46099
+ "../../../node_modules/.pnpm/find-my-way@9.7.0/node_modules/find-my-way/lib/handler-storage.js"(exports$1, module) {
46001
46100
  var { NullObject } = require_null_object();
46002
46101
  var httpMethodStrategy = require_http_method();
46003
46102
  var HandlerStorage = class {
@@ -46130,7 +46229,7 @@ var require_handler_storage = __commonJS({
46130
46229
  lines.push(`if (derivedConstraints.${constraint} !== undefined) return null`);
46131
46230
  }
46132
46231
  }
46133
- lines.push("return this.handlers[Math.floor(Math.log2(candidates))]");
46232
+ lines.push("return this.handlers[31 - Math.clz32(candidates)]");
46134
46233
  this._getHandlerMatchingConstraints = new Function("derivedConstraints", lines.join("\n"));
46135
46234
  }
46136
46235
  };
@@ -46138,9 +46237,9 @@ var require_handler_storage = __commonJS({
46138
46237
  }
46139
46238
  });
46140
46239
 
46141
- // ../../../node_modules/.pnpm/find-my-way@9.5.0/node_modules/find-my-way/lib/node.js
46240
+ // ../../../node_modules/.pnpm/find-my-way@9.7.0/node_modules/find-my-way/lib/node.js
46142
46241
  var require_node = __commonJS({
46143
- "../../../node_modules/.pnpm/find-my-way@9.5.0/node_modules/find-my-way/lib/node.js"(exports$1, module) {
46242
+ "../../../node_modules/.pnpm/find-my-way@9.7.0/node_modules/find-my-way/lib/node.js"(exports$1, module) {
46144
46243
  var HandlerStorage = require_handler_storage();
46145
46244
  var NODE_TYPES = {
46146
46245
  STATIC: 0,
@@ -46328,9 +46427,9 @@ var require_node = __commonJS({
46328
46427
  }
46329
46428
  });
46330
46429
 
46331
- // ../../../node_modules/.pnpm/find-my-way@9.5.0/node_modules/find-my-way/lib/strategies/accept-version.js
46430
+ // ../../../node_modules/.pnpm/find-my-way@9.7.0/node_modules/find-my-way/lib/strategies/accept-version.js
46332
46431
  var require_accept_version = __commonJS({
46333
- "../../../node_modules/.pnpm/find-my-way@9.5.0/node_modules/find-my-way/lib/strategies/accept-version.js"(exports$1, module) {
46432
+ "../../../node_modules/.pnpm/find-my-way@9.7.0/node_modules/find-my-way/lib/strategies/accept-version.js"(exports$1, module) {
46334
46433
  var assert = __require("assert");
46335
46434
  function SemVerStore() {
46336
46435
  if (!(this instanceof SemVerStore)) {
@@ -46385,28 +46484,35 @@ var require_accept_version = __commonJS({
46385
46484
  }
46386
46485
  });
46387
46486
 
46388
- // ../../../node_modules/.pnpm/find-my-way@9.5.0/node_modules/find-my-way/lib/strategies/accept-host.js
46487
+ // ../../../node_modules/.pnpm/find-my-way@9.7.0/node_modules/find-my-way/lib/strategies/accept-host.js
46389
46488
  var require_accept_host = __commonJS({
46390
- "../../../node_modules/.pnpm/find-my-way@9.5.0/node_modules/find-my-way/lib/strategies/accept-host.js"(exports$1, module) {
46489
+ "../../../node_modules/.pnpm/find-my-way@9.7.0/node_modules/find-my-way/lib/strategies/accept-host.js"(exports$1, module) {
46391
46490
  var assert = __require("assert");
46392
46491
  function HostStorage() {
46393
46492
  const hosts = /* @__PURE__ */ new Map();
46394
46493
  const regexHosts = [];
46494
+ const regexCache = /* @__PURE__ */ new Map();
46395
46495
  return {
46396
46496
  get: (host) => {
46397
46497
  const exact = hosts.get(host);
46398
46498
  if (exact) {
46399
46499
  return exact;
46400
46500
  }
46501
+ if (regexHosts.length === 0) return void 0;
46502
+ if (regexCache.has(host)) return regexCache.get(host);
46401
46503
  for (const regex of regexHosts) {
46402
46504
  if (regex.host.test(host)) {
46505
+ regexCache.set(host, regex.value);
46403
46506
  return regex.value;
46404
46507
  }
46405
46508
  }
46509
+ regexCache.set(host, void 0);
46406
46510
  },
46407
46511
  set: (host, value) => {
46408
46512
  if (host instanceof RegExp) {
46409
- regexHosts.push({ host, value });
46513
+ const safeRegex = new RegExp(host.source, host.flags.replace(/[gy]/g, ""));
46514
+ regexHosts.push({ host: safeRegex, value });
46515
+ regexCache.clear();
46410
46516
  } else {
46411
46517
  hosts.set(host, value);
46412
46518
  }
@@ -46424,9 +46530,9 @@ var require_accept_host = __commonJS({
46424
46530
  }
46425
46531
  });
46426
46532
 
46427
- // ../../../node_modules/.pnpm/find-my-way@9.5.0/node_modules/find-my-way/lib/constrainer.js
46533
+ // ../../../node_modules/.pnpm/find-my-way@9.7.0/node_modules/find-my-way/lib/constrainer.js
46428
46534
  var require_constrainer = __commonJS({
46429
- "../../../node_modules/.pnpm/find-my-way@9.5.0/node_modules/find-my-way/lib/constrainer.js"(exports$1, module) {
46535
+ "../../../node_modules/.pnpm/find-my-way@9.7.0/node_modules/find-my-way/lib/constrainer.js"(exports$1, module) {
46430
46536
  var acceptVersionStrategy = require_accept_version();
46431
46537
  var acceptHostStrategy = require_accept_host();
46432
46538
  var assert = __require("assert");
@@ -46527,11 +46633,14 @@ var require_constrainer = __commonJS({
46527
46633
  done(null, constraints);
46528
46634
  return;
46529
46635
  }
46636
+ let errored = false;
46530
46637
  constraints = constraints || {};
46531
46638
  for (const key of this.asyncStrategiesInUse) {
46532
46639
  const strategy = this.strategies[key];
46533
46640
  strategy.deriveConstraint(req, ctx, (err, constraintValue) => {
46641
+ if (errored) return;
46534
46642
  if (err !== null) {
46643
+ errored = true;
46535
46644
  done(err);
46536
46645
  return;
46537
46646
  }
@@ -46568,9 +46677,9 @@ var require_constrainer = __commonJS({
46568
46677
  }
46569
46678
  });
46570
46679
 
46571
- // ../../../node_modules/.pnpm/find-my-way@9.5.0/node_modules/find-my-way/lib/http-methods.js
46680
+ // ../../../node_modules/.pnpm/find-my-way@9.7.0/node_modules/find-my-way/lib/http-methods.js
46572
46681
  var require_http_methods = __commonJS({
46573
- "../../../node_modules/.pnpm/find-my-way@9.5.0/node_modules/find-my-way/lib/http-methods.js"(exports$1, module) {
46682
+ "../../../node_modules/.pnpm/find-my-way@9.7.0/node_modules/find-my-way/lib/http-methods.js"(exports$1, module) {
46574
46683
  var httpMethods = [
46575
46684
  "ACL",
46576
46685
  "BIND",
@@ -46612,9 +46721,9 @@ var require_http_methods = __commonJS({
46612
46721
  }
46613
46722
  });
46614
46723
 
46615
- // ../../../node_modules/.pnpm/find-my-way@9.5.0/node_modules/find-my-way/lib/url-sanitizer.js
46724
+ // ../../../node_modules/.pnpm/find-my-way@9.7.0/node_modules/find-my-way/lib/url-sanitizer.js
46616
46725
  var require_url_sanitizer = __commonJS({
46617
- "../../../node_modules/.pnpm/find-my-way@9.5.0/node_modules/find-my-way/lib/url-sanitizer.js"(exports$1, module) {
46726
+ "../../../node_modules/.pnpm/find-my-way@9.7.0/node_modules/find-my-way/lib/url-sanitizer.js"(exports$1, module) {
46618
46727
  function decodeComponentChar(highCharCode, lowCharCode) {
46619
46728
  if (highCharCode === 50) {
46620
46729
  if (lowCharCode === 53) return "%";
@@ -46694,9 +46803,9 @@ var require_url_sanitizer = __commonJS({
46694
46803
  }
46695
46804
  });
46696
46805
 
46697
- // ../../../node_modules/.pnpm/find-my-way@9.5.0/node_modules/find-my-way/index.js
46806
+ // ../../../node_modules/.pnpm/find-my-way@9.7.0/node_modules/find-my-way/index.js
46698
46807
  var require_find_my_way = __commonJS({
46699
- "../../../node_modules/.pnpm/find-my-way@9.5.0/node_modules/find-my-way/index.js"(exports$1, module) {
46808
+ "../../../node_modules/.pnpm/find-my-way@9.7.0/node_modules/find-my-way/index.js"(exports$1, module) {
46700
46809
  var assert = __require("assert");
46701
46810
  var querystring = require_lib();
46702
46811
  var isRegexSafe = require_safe_regex2();
@@ -46757,11 +46866,12 @@ var require_find_my_way = __commonJS({
46757
46866
  this.ignoreTrailingSlash = opts.ignoreTrailingSlash || false;
46758
46867
  this.ignoreDuplicateSlashes = opts.ignoreDuplicateSlashes || false;
46759
46868
  this.maxParamLength = opts.maxParamLength || 100;
46869
+ this.onMaxParamLength = opts.onMaxParamLength || null;
46760
46870
  this.allowUnsafeRegex = opts.allowUnsafeRegex || false;
46761
46871
  this.constrainer = new Constrainer(opts.constraints);
46762
46872
  this.useSemicolonDelimiter = opts.useSemicolonDelimiter || false;
46763
46873
  this.routes = [];
46764
- this.trees = {};
46874
+ this.trees = /* @__PURE__ */ Object.create(null);
46765
46875
  }
46766
46876
  Router.prototype.on = function on(method, path6, opts, handler, store) {
46767
46877
  if (typeof opts === "function") {
@@ -46970,7 +47080,7 @@ var require_find_my_way = __commonJS({
46970
47080
  }
46971
47081
  regexps.push(trimRegExpStartAndEnd(regexString));
46972
47082
  j = endOfRegexIndex + 1;
46973
- isParamSafe = false;
47083
+ isParamSafe = true;
46974
47084
  } else {
46975
47085
  regexps.push(isParamSafe ? "(.*?)" : `(${backtrack}|(?:(?!${backtrack}).)*)`);
46976
47086
  isParamSafe = false;
@@ -47038,7 +47148,7 @@ var require_find_my_way = __commonJS({
47038
47148
  this._rebuild(this.routes);
47039
47149
  };
47040
47150
  Router.prototype.reset = function reset() {
47041
- this.trees = {};
47151
+ this.trees = /* @__PURE__ */ Object.create(null);
47042
47152
  this.routes = [];
47043
47153
  };
47044
47154
  Router.prototype.off = function off(method, path6, constraints) {
@@ -47053,7 +47163,7 @@ var require_find_my_way = __commonJS({
47053
47163
  if (optionalParamMatch) {
47054
47164
  assert(path6.length === optionalParamMatch.index + optionalParamMatch[0].length, "Optional Parameter needs to be the last parameter of the path");
47055
47165
  const pathFull = path6.replace(OPTIONAL_PARAM_REGEXP, "$1$2");
47056
- const pathOptional = path6.replace(OPTIONAL_PARAM_REGEXP, "$2");
47166
+ const pathOptional = path6.replace(OPTIONAL_PARAM_REGEXP, "$2") || "/";
47057
47167
  this.off(method, pathFull, constraints);
47058
47168
  this.off(method, pathOptional, constraints);
47059
47169
  return;
@@ -47142,6 +47252,7 @@ var require_find_my_way = __commonJS({
47142
47252
  const params = [];
47143
47253
  const pathLen = path6.length;
47144
47254
  const brothersNodesStack = [];
47255
+ let maxParamLengthExceeded = false;
47145
47256
  while (true) {
47146
47257
  if (pathIndex === pathLen && currentNode.isLeafNode) {
47147
47258
  const handle = currentNode.handlerStorage.getMatchingHandler(derivedConstraints);
@@ -47157,6 +47268,9 @@ var require_find_my_way = __commonJS({
47157
47268
  let node = currentNode.getNextNode(path6, pathIndex, brothersNodesStack, params.length);
47158
47269
  if (node === null) {
47159
47270
  if (brothersNodesStack.length === 0) {
47271
+ if (maxParamLengthExceeded && this.onMaxParamLength) {
47272
+ return this._onMaxParamLength(originPath);
47273
+ }
47160
47274
  return null;
47161
47275
  }
47162
47276
  const brotherNodeState = brothersNodesStack.pop();
@@ -47165,44 +47279,88 @@ var require_find_my_way = __commonJS({
47165
47279
  node = brotherNodeState.brotherNode;
47166
47280
  }
47167
47281
  currentNode = node;
47168
- if (currentNode.kind === NODE_TYPES.STATIC) {
47169
- pathIndex += currentNode.prefix.length;
47170
- continue;
47171
- }
47172
- if (currentNode.kind === NODE_TYPES.WILDCARD) {
47173
- let param2 = originPath.slice(pathIndex);
47174
- if (shouldDecodeParam) {
47175
- param2 = safeDecodeURIComponent(param2);
47282
+ while (true) {
47283
+ if (currentNode.kind === NODE_TYPES.STATIC) {
47284
+ pathIndex += currentNode.prefix.length;
47285
+ break;
47176
47286
  }
47177
- params.push(param2);
47178
- pathIndex = pathLen;
47179
- continue;
47180
- }
47181
- let paramEndIndex = originPath.indexOf("/", pathIndex);
47182
- if (paramEndIndex === -1) {
47183
- paramEndIndex = pathLen;
47184
- }
47185
- let param = originPath.slice(pathIndex, paramEndIndex);
47186
- if (shouldDecodeParam) {
47187
- param = safeDecodeURIComponent(param);
47188
- }
47189
- if (currentNode.isRegex) {
47190
- const matchedParameters = currentNode.regex.exec(param);
47191
- if (matchedParameters === null) continue;
47192
- for (let i = 1; i < matchedParameters.length; i++) {
47193
- const matchedParam = matchedParameters[i];
47194
- if (matchedParam.length > maxParamLength) {
47195
- return null;
47287
+ if (currentNode.kind === NODE_TYPES.WILDCARD) {
47288
+ let param2 = originPath.slice(pathIndex);
47289
+ if (shouldDecodeParam) {
47290
+ param2 = safeDecodeURIComponent(param2);
47196
47291
  }
47197
- params.push(matchedParam);
47292
+ params.push(param2);
47293
+ pathIndex = pathLen;
47294
+ break;
47198
47295
  }
47199
- } else {
47200
- if (param.length > maxParamLength) {
47201
- return null;
47296
+ let paramEndIndex = originPath.indexOf("/", pathIndex);
47297
+ if (paramEndIndex === -1) {
47298
+ paramEndIndex = pathLen;
47202
47299
  }
47203
- params.push(param);
47300
+ let param = originPath.slice(pathIndex, paramEndIndex);
47301
+ if (shouldDecodeParam) {
47302
+ param = safeDecodeURIComponent(param);
47303
+ }
47304
+ if (currentNode.isRegex) {
47305
+ const matchedParameters = currentNode.regex.exec(param);
47306
+ if (matchedParameters === null) {
47307
+ if (brothersNodesStack.length === 0) {
47308
+ if (maxParamLengthExceeded && this.onMaxParamLength) {
47309
+ return this._onMaxParamLength(originPath);
47310
+ }
47311
+ return null;
47312
+ }
47313
+ const brotherNodeState = brothersNodesStack.pop();
47314
+ pathIndex = brotherNodeState.brotherPathIndex;
47315
+ params.splice(brotherNodeState.paramsCount);
47316
+ currentNode = brotherNodeState.brotherNode;
47317
+ continue;
47318
+ }
47319
+ let regexMaxParamLengthExceeded = false;
47320
+ for (let i = 1; i < matchedParameters.length; i++) {
47321
+ const matchedParam = matchedParameters[i] ?? "";
47322
+ if (matchedParam.length > maxParamLength) {
47323
+ regexMaxParamLengthExceeded = true;
47324
+ break;
47325
+ }
47326
+ }
47327
+ if (regexMaxParamLengthExceeded) {
47328
+ maxParamLengthExceeded = true;
47329
+ if (brothersNodesStack.length === 0) {
47330
+ if (this.onMaxParamLength) {
47331
+ return this._onMaxParamLength(originPath);
47332
+ }
47333
+ return null;
47334
+ }
47335
+ const brotherNodeState = brothersNodesStack.pop();
47336
+ pathIndex = brotherNodeState.brotherPathIndex;
47337
+ params.splice(brotherNodeState.paramsCount);
47338
+ currentNode = brotherNodeState.brotherNode;
47339
+ continue;
47340
+ }
47341
+ for (let i = 1; i < matchedParameters.length; i++) {
47342
+ params.push(matchedParameters[i] ?? "");
47343
+ }
47344
+ } else {
47345
+ if (param.length > maxParamLength) {
47346
+ maxParamLengthExceeded = true;
47347
+ if (brothersNodesStack.length === 0) {
47348
+ if (this.onMaxParamLength) {
47349
+ return this._onMaxParamLength(originPath);
47350
+ }
47351
+ return null;
47352
+ }
47353
+ const brotherNodeState = brothersNodesStack.pop();
47354
+ pathIndex = brotherNodeState.brotherPathIndex;
47355
+ params.splice(brotherNodeState.paramsCount);
47356
+ currentNode = brotherNodeState.brotherNode;
47357
+ continue;
47358
+ }
47359
+ params.push(param);
47360
+ }
47361
+ pathIndex = paramEndIndex;
47362
+ break;
47204
47363
  }
47205
- pathIndex = paramEndIndex;
47206
47364
  }
47207
47365
  };
47208
47366
  Router.prototype._rebuild = function(routes) {
@@ -47231,6 +47389,17 @@ var require_find_my_way = __commonJS({
47231
47389
  store: null
47232
47390
  };
47233
47391
  };
47392
+ Router.prototype._onMaxParamLength = function(path6) {
47393
+ if (this.onMaxParamLength === null) {
47394
+ return null;
47395
+ }
47396
+ const onMaxParamLength = this.onMaxParamLength;
47397
+ return {
47398
+ handler: (req, res, ctx) => onMaxParamLength(path6, req, res),
47399
+ params: {},
47400
+ store: null
47401
+ };
47402
+ };
47234
47403
  Router.prototype.prettyPrint = function(options = {}) {
47235
47404
  const method = options.method;
47236
47405
  options.buildPrettyMeta = this.buildPrettyMeta.bind(this);
@@ -49664,20 +49833,20 @@ var require_form_data = __commonJS({
49664
49833
  const boundary = `----formdata-${randomUUID8()}`;
49665
49834
  const prefix = `--${boundary}\r
49666
49835
  Content-Disposition: form-data`;
49667
- const escape2 = (str) => str.replace(/\n/g, "%0A").replace(/\r/g, "%0D").replace(/"/g, "%22");
49836
+ const escape = (str) => str.replace(/\n/g, "%0A").replace(/\r/g, "%0D").replace(/"/g, "%22");
49668
49837
  const normalizeLinefeeds = (value) => value.replace(/\r?\n|\r/g, "\r\n");
49669
49838
  const linebreak = new Uint8Array([13, 10]);
49670
49839
  async function* asyncIterator() {
49671
49840
  for (const [name, value] of formdata) {
49672
49841
  if (typeof value === "string") {
49673
- yield textEncoder.encode(`${prefix}; name="${escape2(normalizeLinefeeds(name))}"\r
49842
+ yield textEncoder.encode(`${prefix}; name="${escape(normalizeLinefeeds(name))}"\r
49674
49843
  \r
49675
49844
  `);
49676
49845
  yield textEncoder.encode(`${normalizeLinefeeds(value)}\r
49677
49846
  `);
49678
49847
  } else {
49679
- let header = `${prefix}; name="${escape2(normalizeLinefeeds(name))}"`;
49680
- value.name && (header += `; filename="${escape2(value.name)}"`);
49848
+ let header = `${prefix}; name="${escape(normalizeLinefeeds(name))}"`;
49849
+ value.name && (header += `; filename="${escape(value.name)}"`);
49681
49850
  header += `\r
49682
49851
  Content-Type: ${value.type || "application/octet-stream"}\r
49683
49852
  \r
@@ -72699,6 +72868,29 @@ var InMemoryStateBroker = class {
72699
72868
  }
72700
72869
  }
72701
72870
  }
72871
+ async setIfNotExists(key, value, ttl = 3e5) {
72872
+ const existing = this.store.get(key);
72873
+ if (existing && Date.now() <= existing.expiresAt) {
72874
+ return false;
72875
+ }
72876
+ await this.set(key, value, ttl);
72877
+ return true;
72878
+ }
72879
+ async zadd(key, score, member) {
72880
+ const entries = await this.get(key) ?? [];
72881
+ const next = entries.filter((entry) => entry.member !== member);
72882
+ next.push({ score, member });
72883
+ next.sort((left, right) => left.score - right.score || left.member.localeCompare(right.member));
72884
+ await this.set(key, next);
72885
+ }
72886
+ async zrangebyscore(key, min, max) {
72887
+ const entries = await this.get(key) ?? [];
72888
+ return entries.filter((entry) => entry.score >= min && entry.score <= max).map((entry) => entry.member);
72889
+ }
72890
+ async zrem(key, member) {
72891
+ const entries = await this.get(key) ?? [];
72892
+ await this.set(key, entries.filter((entry) => entry.member !== member));
72893
+ }
72702
72894
  async getStats() {
72703
72895
  const namespaces = {};
72704
72896
  const byTenant = {};
@@ -74970,6 +75162,34 @@ var StateDaemonServer = class {
74970
75162
  reply.code(204);
74971
75163
  return null;
74972
75164
  });
75165
+ server.put("/state/:key/if-absent", async (request, reply) => {
75166
+ const { key } = request.params;
75167
+ const { value, ttl } = request.body;
75168
+ const inserted = await this.observability.observeOperation("state.setIfNotExists", () => this.broker.setIfNotExists(key, value, ttl));
75169
+ reply.code(inserted ? 204 : 409);
75170
+ return null;
75171
+ });
75172
+ server.put("/state/:key/zset", async (request, reply) => {
75173
+ const { key } = request.params;
75174
+ const { score, member } = request.body;
75175
+ await this.observability.observeOperation("state.zadd", () => this.broker.zadd(key, score, member));
75176
+ reply.code(204);
75177
+ return null;
75178
+ });
75179
+ server.delete("/state/:key/zset", async (request, reply) => {
75180
+ const { key } = request.params;
75181
+ const { member } = request.body;
75182
+ await this.observability.observeOperation("state.zrem", () => this.broker.zrem(key, member));
75183
+ reply.code(204);
75184
+ return null;
75185
+ });
75186
+ server.get("/state/:key/range", async (request, reply) => {
75187
+ const { key } = request.params;
75188
+ const query = request.query;
75189
+ const members = await this.observability.observeOperation("state.zrangebyscore", () => this.broker.zrangebyscore(key, Number(query.min), Number(query.max)));
75190
+ reply.type("application/json");
75191
+ return members;
75192
+ });
74973
75193
  server.delete("/state/:key", async (request, reply) => {
74974
75194
  const { key } = request.params;
74975
75195
  await this.observability.observeOperation("state.delete", () => this.broker.delete(key));
@@ -75121,7 +75341,7 @@ http-errors/index.js:
75121
75341
  * MIT Licensed
75122
75342
  *)
75123
75343
 
75124
- content-disposition/index.js:
75344
+ content-disposition/dist/index.js:
75125
75345
  (*!
75126
75346
  * content-disposition
75127
75347
  * Copyright(c) 2014-2017 Douglas Christopher Wilson