@camstack/system 1.2.380 → 1.2.382

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.
Files changed (117) hide show
  1. package/dist/addon-runner.js +4 -2
  2. package/dist/addon-runner.mjs +4 -2
  3. package/dist/addon-utils.js +1 -1
  4. package/dist/addon-utils.mjs +1 -1
  5. package/dist/auth/admin-token-manager.d.ts +75 -0
  6. package/dist/auth/api-key-manager.d.ts +1 -14
  7. package/dist/auth/auth-audit-log.d.ts +59 -0
  8. package/dist/auth/auth-manager.d.ts +28 -16
  9. package/dist/auth/cidr.d.ts +22 -0
  10. package/dist/auth/login-session-manager.d.ts +158 -0
  11. package/dist/auth/user-management-internal.d.ts +69 -0
  12. package/dist/builtins/addon-pages-aggregator/addon-pages-aggregator.addon.js +1 -1
  13. package/dist/builtins/addon-pages-aggregator/addon-pages-aggregator.addon.mjs +1 -1
  14. package/dist/builtins/addon-widgets-aggregator/addon-widgets-aggregator.addon.js +1 -1
  15. package/dist/builtins/addon-widgets-aggregator/addon-widgets-aggregator.addon.mjs +1 -1
  16. package/dist/builtins/alerts/alerts.addon.js +1 -1
  17. package/dist/builtins/alerts/alerts.addon.mjs +1 -1
  18. package/dist/builtins/autotrack/index.js +1 -1
  19. package/dist/builtins/autotrack/index.mjs +1 -1
  20. package/dist/builtins/backup-orchestrator/backup-orchestrator.addon.d.ts +14 -0
  21. package/dist/builtins/backup-orchestrator/backup-orchestrator.addon.js +291 -3631
  22. package/dist/builtins/backup-orchestrator/backup-orchestrator.addon.mjs +284 -3617
  23. package/dist/builtins/backup-orchestrator/encryption-key-store.d.ts +36 -0
  24. package/dist/builtins/backup-orchestrator/manifest-store.d.ts +19 -1
  25. package/dist/builtins/backup-orchestrator/restore-archive.d.ts +24 -0
  26. package/dist/builtins/calendars/calendars.addon.js +1 -1
  27. package/dist/builtins/calendars/calendars.addon.mjs +1 -1
  28. package/dist/builtins/camera-grid/index.js +1 -1
  29. package/dist/builtins/camera-grid/index.mjs +1 -1
  30. package/dist/builtins/composer/composer.addon.js +2 -2
  31. package/dist/builtins/composer/composer.addon.mjs +2 -2
  32. package/dist/builtins/console-logging/index.js +1 -1
  33. package/dist/builtins/console-logging/index.mjs +1 -1
  34. package/dist/builtins/core-blocks/core-blocks.addon.js +2 -2
  35. package/dist/builtins/core-blocks/core-blocks.addon.mjs +2 -2
  36. package/dist/builtins/device-manager/device-aggregation.d.ts +12 -0
  37. package/dist/builtins/device-manager/device-form-secrets.d.ts +25 -0
  38. package/dist/builtins/device-manager/device-manager.addon.d.ts +2 -0
  39. package/dist/builtins/device-manager/device-manager.addon.js +165 -26
  40. package/dist/builtins/device-manager/device-manager.addon.mjs +165 -26
  41. package/dist/builtins/hub-forwarder/index.js +1 -1
  42. package/dist/builtins/hub-forwarder/index.mjs +1 -1
  43. package/dist/builtins/keychain/index.js +1108 -733
  44. package/dist/builtins/keychain/index.mjs +1108 -733
  45. package/dist/builtins/keychain/keychain-reset-trigger.d.ts +25 -0
  46. package/dist/builtins/keychain/keychain-service.d.ts +36 -3
  47. package/dist/builtins/keychain/keychain-store.d.ts +24 -1
  48. package/dist/builtins/liveness-monitor/liveness-monitor.addon.js +1 -1
  49. package/dist/builtins/liveness-monitor/liveness-monitor.addon.mjs +1 -1
  50. package/dist/builtins/local-auth/local-auth.addon.d.ts +16 -0
  51. package/dist/builtins/local-auth/local-auth.addon.js +1021 -118
  52. package/dist/builtins/local-auth/local-auth.addon.mjs +1034 -141
  53. package/dist/builtins/local-network/local-network.addon.js +3 -3
  54. package/dist/builtins/local-network/local-network.addon.mjs +3 -3
  55. package/dist/builtins/loki-logging/index.js +97 -29
  56. package/dist/builtins/loki-logging/index.mjs +97 -29
  57. package/dist/builtins/loki-logging/loki-logging.addon.d.ts +7 -23
  58. package/dist/builtins/loki-logging/retire-enabled-flag.d.ts +23 -0
  59. package/dist/builtins/native-metrics/native-metrics.addon.js +1 -1
  60. package/dist/builtins/native-metrics/native-metrics.addon.mjs +1 -1
  61. package/dist/builtins/platform-probe/index.js +1 -1
  62. package/dist/builtins/platform-probe/index.mjs +1 -1
  63. package/dist/builtins/remote-access-orchestrator/remote-access-orchestrator.addon.js +1 -1
  64. package/dist/builtins/remote-access-orchestrator/remote-access-orchestrator.addon.mjs +1 -1
  65. package/dist/builtins/snapshot/index.js +1 -1
  66. package/dist/builtins/snapshot/index.mjs +1 -1
  67. package/dist/builtins/sqlite-storage/filesystem-storage.addon.js +1 -1
  68. package/dist/builtins/sqlite-storage/filesystem-storage.addon.mjs +1 -1
  69. package/dist/builtins/sqlite-storage/sqlite-settings.addon.js +0 -0
  70. package/dist/builtins/sqlite-storage/sqlite-settings.addon.mjs +0 -0
  71. package/dist/builtins/storage-orchestrator/storage-orchestrator.addon.js +2 -2
  72. package/dist/builtins/storage-orchestrator/storage-orchestrator.addon.mjs +2 -2
  73. package/dist/builtins/system-backup/backup-encryption.d.ts +57 -0
  74. package/dist/builtins/system-backup/system-backup.service.d.ts +16 -1
  75. package/dist/builtins/system-config/cluster-secret-keeper.d.ts +7 -0
  76. package/dist/builtins/system-config/system-config.addon.d.ts +13 -3
  77. package/dist/builtins/system-config/system-config.addon.js +324 -38
  78. package/dist/builtins/system-config/system-config.addon.mjs +312 -39
  79. package/dist/builtins/winston-logging/index.js +1 -1
  80. package/dist/builtins/winston-logging/index.mjs +1 -1
  81. package/dist/{child-cap-dispatch-CZeRUgYF.js → child-cap-dispatch-BrMdKHfp.js} +6 -3
  82. package/dist/{child-cap-dispatch-CpjohToR.mjs → child-cap-dispatch-WsYPNvnK.mjs} +10 -7
  83. package/dist/{cluster-secret-Dg0OOOSr.js → cluster-secret-BEPLh3LL.js} +1 -1
  84. package/dist/{cluster-secret-BDue-uJj.mjs → cluster-secret-DhPdZ0VA.mjs} +1 -1
  85. package/dist/{composition-sources-CHvLMrFI.js → composition-sources-C6ZynCZ2.js} +1 -1
  86. package/dist/{composition-sources-DT_uJwI3.mjs → composition-sources-XqRX51db.mjs} +1 -1
  87. package/dist/{dist-B9oFw2jh.mjs → dist-CP5TTjwd.mjs} +1713 -157
  88. package/dist/{dist-Cc6KOdY-.js → dist-tnAO12ak.js} +1754 -156
  89. package/dist/{event-loop-stall-monitor-mk6WGxir.js → event-loop-stall-monitor-9kR0sAPS.js} +15 -15
  90. package/dist/{event-loop-stall-monitor-anUH2IE1.mjs → event-loop-stall-monitor-WkssIXjq.mjs} +15 -15
  91. package/dist/{hub-cap-forward-CH6_VWVO.mjs → hub-cap-forward-CDiN1p98.mjs} +18 -2
  92. package/dist/{hub-cap-forward-COCmYaup.js → hub-cap-forward-W8oEm4ME.js} +23 -1
  93. package/dist/index.d.ts +16 -1
  94. package/dist/index.js +3341 -79
  95. package/dist/index.mjs +3567 -354
  96. package/dist/{jwt-signing-key-Qhde8r82.mjs → jwt-signing-key-CAbozwvF.mjs} +1 -1
  97. package/dist/{jwt-signing-key-C2rE3wH6.js → jwt-signing-key-Dgf8sIXY.js} +1 -1
  98. package/dist/kernel/index.d.ts +12 -0
  99. package/dist/kernel/moleculer/broker-factory.d.ts +8 -1
  100. package/dist/kernel/moleculer/child-addon-call-dispatch.d.ts +1 -0
  101. package/dist/kernel/moleculer/hub-service.d.ts +9 -0
  102. package/dist/kernel/moleculer/mesh-access-middleware.d.ts +28 -0
  103. package/dist/kernel/moleculer/mesh-auth-mode.d.ts +64 -0
  104. package/dist/kernel/moleculer/mesh-authenticator.d.ts +71 -0
  105. package/dist/kernel/moleculer/mesh-auto-enforce.d.ts +26 -0
  106. package/dist/kernel/moleculer/mesh-join-client.d.ts +51 -0
  107. package/dist/kernel/moleculer/mesh-join-proof.d.ts +39 -0
  108. package/dist/kernel/system-settings-policy.d.ts +4 -3
  109. package/dist/kernel/transport/hub-cap-forward.d.ts +14 -3
  110. package/dist/kernel/transport/index.d.ts +1 -1
  111. package/dist/restore-archive-BV39nY46.mjs +4045 -0
  112. package/dist/restore-archive-CbvrfPuB.js +4139 -0
  113. package/dist/{retired-settings-keys-YOOKLA3v.js → retired-settings-keys-4bHpL-0m.js} +1 -1
  114. package/dist/{retired-settings-keys-DlZ3VV6x.mjs → retired-settings-keys-CzpIkwS-.mjs} +1 -1
  115. package/dist/{tls-CJHogwTl.mjs → tls-4cRH24Id.mjs} +3 -3
  116. package/package.json +1 -1
  117. package/dist/{tls-CCMX7MjX.js → tls-CljF057D.js} +1 -1
package/dist/index.js CHANGED
@@ -1,7 +1,7 @@
1
1
  Object.defineProperty(exports, Symbol.toStringTag, { value: "Module" });
2
2
  const require_chunk = require("./chunk-Cek0wNdY.js");
3
- const require_dist = require("./dist-Cc6KOdY-.js");
4
- const require_jwt_signing_key = require("./jwt-signing-key-C2rE3wH6.js");
3
+ const require_dist = require("./dist-tnAO12ak.js");
4
+ const require_jwt_signing_key = require("./jwt-signing-key-Dgf8sIXY.js");
5
5
  const require_builtins_alerts_alerts_addon = require("./builtins/alerts/alerts.addon.js");
6
6
  require("./builtins/alerts/index.js");
7
7
  const require_builtins_calendars_calendars_addon = require("./builtins/calendars/calendars.addon.js");
@@ -24,19 +24,20 @@ const require_builtins_native_metrics_native_metrics_addon = require("./builtins
24
24
  const require_builtins_sqlite_storage_filesystem_storage_addon = require("./builtins/sqlite-storage/filesystem-storage.addon.js");
25
25
  const require_builtins_sqlite_storage_sqlite_settings_addon = require("./builtins/sqlite-storage/sqlite-settings.addon.js");
26
26
  const require_builtins_sqlite_storage_index = require("./builtins/sqlite-storage/index.js");
27
- const require_hub_cap_forward = require("./hub-cap-forward-COCmYaup.js");
27
+ const require_hub_cap_forward = require("./hub-cap-forward-W8oEm4ME.js");
28
28
  const require_builtins_storage_orchestrator_storage_orchestrator_addon = require("./builtins/storage-orchestrator/storage-orchestrator.addon.js");
29
29
  require("./builtins/storage-orchestrator/index.js");
30
- const require_cluster_secret = require("./cluster-secret-Dg0OOOSr.js");
30
+ const require_cluster_secret = require("./cluster-secret-BEPLh3LL.js");
31
31
  const require_builtins_system_config_system_config_addon = require("./builtins/system-config/system-config.addon.js");
32
32
  require("./builtins/system-config/index.js");
33
33
  const require_builtins_winston_logging_index = require("./builtins/winston-logging/index.js");
34
- const require_event_loop_stall_monitor = require("./event-loop-stall-monitor-mk6WGxir.js");
35
- const require_tls$1 = require("./tls-CCMX7MjX.js");
36
- const require_child_cap_dispatch = require("./child-cap-dispatch-CZeRUgYF.js");
34
+ const require_event_loop_stall_monitor = require("./event-loop-stall-monitor-9kR0sAPS.js");
35
+ const require_tls$1 = require("./tls-CljF057D.js");
36
+ const require_child_cap_dispatch = require("./child-cap-dispatch-BrMdKHfp.js");
37
37
  const require_platform_key_source = require("./platform-key-source-Di7HrlGR.js");
38
38
  const require_resource_monitor = require("./resource-monitor-BgWGRxN5.js");
39
39
  const require_custom_action_registry = require("./custom-action-registry-acBY3mHA.js");
40
+ const require_restore_archive = require("./restore-archive-CbvrfPuB.js");
40
41
  let zod = require("zod");
41
42
  let node_crypto = require("node:crypto");
42
43
  let _camstack_types_node = require("@camstack/types/node");
@@ -10476,8 +10477,8 @@ function createStoreSettingsView(addonId, cm) {
10476
10477
  *
10477
10478
  * So a bootstrap-owned section is answered from env + config.yaml ONLY, and
10478
10479
  * the store may add exactly the keys in {@link STORE_READABLE_BOOTSTRAP_KEYS}:
10479
- * today `auth.tokenExpiry`, the one value the operator edits in the UI
10480
- * (System → Authentication). Widening this list is a security decision, not a
10480
+ * the values the operator edits on System → Authentication (`auth.tokenExpiry`,
10481
+ * `auth.accessTokenExpiry`, `auth.trustedProxies`). Widening this list is a security decision, not a
10481
10482
  * convenience.
10482
10483
  */
10483
10484
  /** Top-level sections whose authority is env + config.yaml (`bootstrapSchema`). */
@@ -10492,7 +10493,12 @@ var BOOTSTRAP_OWNED_SECTIONS = new Set([
10492
10493
  "keychain"
10493
10494
  ]);
10494
10495
  /** The only keys under a bootstrap-owned section the store may answer. */
10495
- var STORE_READABLE_BOOTSTRAP_KEYS = new Set(["auth.tokenExpiry"]);
10496
+ var STORE_READABLE_BOOTSTRAP_KEYS = new Set([
10497
+ "auth.tokenExpiry",
10498
+ "auth.accessTokenExpiry",
10499
+ "auth.trustedProxies",
10500
+ "auth.trustedNetworks"
10501
+ ]);
10496
10502
  /** May the settings store answer `key`, or is it env + config.yaml only? */
10497
10503
  function storeMayAnswer(key) {
10498
10504
  const dot = key.indexOf(".");
@@ -10511,9 +10517,15 @@ function storeMayAnswer(key) {
10511
10517
  var PRELOADED_SYSTEM_PREFIXES = ["capabilities."];
10512
10518
  /**
10513
10519
  * Single keys loaded the same way. `auth.tokenExpiry` is read synchronously on
10514
- * every mint by the hub's `AuthService` (`AuthManager.signToken`).
10520
+ * every mint by the hub's `AuthService` (`AuthManager.signToken`), and
10521
+ * `auth.trustedProxies` on every public auth request (`auth-network-policy.ts`).
10515
10522
  */
10516
- var PRELOADED_SYSTEM_KEYS = ["auth.tokenExpiry"];
10523
+ var PRELOADED_SYSTEM_KEYS = [
10524
+ "auth.tokenExpiry",
10525
+ "auth.accessTokenExpiry",
10526
+ "auth.trustedProxies",
10527
+ "auth.trustedNetworks"
10528
+ ];
10517
10529
  /** Is `key` served from the boot-time mirror when the engine is isolated? */
10518
10530
  function isPreloadedSystemKey(key) {
10519
10531
  if (PRELOADED_SYSTEM_KEYS.includes(key)) return true;
@@ -31002,8 +31014,8 @@ var require_kleur = /* @__PURE__ */ require_chunk.__commonJSMin(((exports, modul
31002
31014
  var require_utils$3 = /* @__PURE__ */ require_chunk.__commonJSMin(((exports, module) => {
31003
31015
  var kleur = require_kleur();
31004
31016
  var os$19 = require("os");
31005
- var path$39 = require("path");
31006
- var fs$18 = require("fs");
31017
+ var path$40 = require("path");
31018
+ var fs$20 = require("fs");
31007
31019
  var { TimeoutError } = require_errors$2();
31008
31020
  var lut = [];
31009
31021
  for (let i = 0; i < 256; i++) lut[i] = (i < 16 ? "0" : "") + i.toString(16);
@@ -31276,8 +31288,8 @@ var require_utils$3 = /* @__PURE__ */ require_chunk.__commonJSMin(((exports, mod
31276
31288
  * @param {*} value
31277
31289
  * @returns {Object}
31278
31290
  */
31279
- dotSet(obj, path$43, value) {
31280
- const parts = path$43.split(".");
31291
+ dotSet(obj, path$44, value) {
31292
+ const parts = path$44.split(".");
31281
31293
  const part = parts.shift();
31282
31294
  if (part && parts.length > 0) {
31283
31295
  if (!Object.prototype.hasOwnProperty.call(obj, part)) obj[part] = {};
@@ -31286,7 +31298,7 @@ var require_utils$3 = /* @__PURE__ */ require_chunk.__commonJSMin(((exports, mod
31286
31298
  obj[part] = utils.dotSet(obj[part], parts.join("."), value);
31287
31299
  return obj;
31288
31300
  }
31289
- obj[path$43] = value;
31301
+ obj[path$44] = value;
31290
31302
  return obj;
31291
31303
  },
31292
31304
  /**
@@ -31294,9 +31306,9 @@ var require_utils$3 = /* @__PURE__ */ require_chunk.__commonJSMin(((exports, mod
31294
31306
  * @param {String} p - directory path
31295
31307
  */
31296
31308
  makeDirs(p) {
31297
- p.split(path$39.sep).reduce((prevPath, folder) => {
31298
- const currentPath = path$39.join(prevPath, folder, path$39.sep);
31299
- if (!fs$18.existsSync(currentPath)) fs$18.mkdirSync(currentPath);
31309
+ p.split(path$40.sep).reduce((prevPath, folder) => {
31310
+ const currentPath = path$40.join(prevPath, folder, path$40.sep);
31311
+ if (!fs$20.existsSync(currentPath)) fs$20.mkdirSync(currentPath);
31300
31312
  return currentPath;
31301
31313
  }, "");
31302
31314
  },
@@ -32521,8 +32533,8 @@ var require_csv = /* @__PURE__ */ require_chunk.__commonJSMin(((exports, module)
32521
32533
  var BaseReporter = require_base$8();
32522
32534
  var { makeDirs } = require_utils$3();
32523
32535
  var _ = require_lodash();
32524
- var path$38 = require("path");
32525
- var fs$17 = require("fs");
32536
+ var path$39 = require("path");
32537
+ var fs$19 = require("fs");
32526
32538
  var METRIC = require_constants$6();
32527
32539
  var MODE_METRIC = "metric";
32528
32540
  var MODE_LABEL = "label";
@@ -32575,7 +32587,7 @@ var require_csv = /* @__PURE__ */ require_chunk.__commonJSMin(((exports, module)
32575
32587
  this.timer = setInterval(() => this.flush(), this.opts.interval * 1e3);
32576
32588
  this.timer.unref();
32577
32589
  }
32578
- this.folder = path$38.resolve(this.opts.folder);
32590
+ this.folder = path$39.resolve(this.opts.folder);
32579
32591
  makeDirs(this.folder);
32580
32592
  }
32581
32593
  /**
@@ -32600,10 +32612,10 @@ var require_csv = /* @__PURE__ */ require_chunk.__commonJSMin(((exports, module)
32600
32612
  const metricName = this.formatMetricName(metric.name);
32601
32613
  if (this.opts.filenameFormatter) return this.opts.filenameFormatter.call(this, metricName, metric, item);
32602
32614
  switch (this.opts.mode) {
32603
- case MODE_METRIC: return path$38.join(this.folder, `${metricName}.csv`);
32615
+ case MODE_METRIC: return path$39.join(this.folder, `${metricName}.csv`);
32604
32616
  case MODE_LABEL: {
32605
32617
  const labelStr = this.labelsToStr(item.labels);
32606
- return path$38.join(this.folder, metricName, `${metricName}${labelStr ? "--" + labelStr : ""}.csv`);
32618
+ return path$39.join(this.folder, metricName, `${metricName}${labelStr ? "--" + labelStr : ""}.csv`);
32607
32619
  }
32608
32620
  }
32609
32621
  }
@@ -32624,7 +32636,7 @@ var require_csv = /* @__PURE__ */ require_chunk.__commonJSMin(((exports, module)
32624
32636
  metric.values.forEach((item) => {
32625
32637
  if (!this.lastChanges.has([metric.name, this.labelsToStr(item.labels)].join("|"))) return;
32626
32638
  const filename = this.getFilename(metric, item);
32627
- makeDirs(path$38.dirname(filename));
32639
+ makeDirs(path$39.dirname(filename));
32628
32640
  const metricName = this.formatMetricName(metric.name);
32629
32641
  let headers = ["Timestamp", "Metric"];
32630
32642
  let data = [item.timestamp, metricName];
@@ -32681,8 +32693,8 @@ var require_csv = /* @__PURE__ */ require_chunk.__commonJSMin(((exports, module)
32681
32693
  */
32682
32694
  writeRow(filename, headers, fields) {
32683
32695
  try {
32684
- if (!fs$17.existsSync(filename)) fs$17.writeFileSync(filename, headers.join(this.opts.delimiter) + this.opts.rowDelimiter);
32685
- fs$17.appendFileSync(filename, fields.join(this.opts.delimiter) + this.opts.rowDelimiter);
32696
+ if (!fs$19.existsSync(filename)) fs$19.writeFileSync(filename, headers.join(this.opts.delimiter) + this.opts.rowDelimiter);
32697
+ fs$19.appendFileSync(filename, fields.join(this.opts.delimiter) + this.opts.rowDelimiter);
32686
32698
  } catch (err) {
32687
32699
  /* istanbul ignore next */
32688
32700
  this.logger.error(`Unable to write metrics values to the '${filename}' file. Error: ${err.message}`, fields, err);
@@ -37684,7 +37696,7 @@ var require_inherits = /* @__PURE__ */ require_chunk.__commonJSMin(((exports, mo
37684
37696
  }));
37685
37697
  //#endregion
37686
37698
  //#region ../../node_modules/util-deprecate/node.js
37687
- var require_node$2 = /* @__PURE__ */ require_chunk.__commonJSMin(((exports, module) => {
37699
+ var require_node$3 = /* @__PURE__ */ require_chunk.__commonJSMin(((exports, module) => {
37688
37700
  /**
37689
37701
  * For Node.js, simply re-export the core `util.deprecate` function.
37690
37702
  */
@@ -37704,7 +37716,7 @@ var require__stream_writable = /* @__PURE__ */ require_chunk.__commonJSMin(((exp
37704
37716
  }
37705
37717
  var Duplex;
37706
37718
  Writable.WritableState = WritableState;
37707
- var internalUtil = { deprecate: require_node$2() };
37719
+ var internalUtil = { deprecate: require_node$3() };
37708
37720
  var Stream = require_stream$1();
37709
37721
  var Buffer$13 = require("buffer").Buffer;
37710
37722
  var OurUint8Array = (typeof global !== "undefined" ? global : typeof window !== "undefined" ? window : typeof self !== "undefined" ? self : {}).Uint8Array || function() {};
@@ -40691,12 +40703,2609 @@ var require_notepack = /* @__PURE__ */ require_chunk.__commonJSMin(((exports, mo
40691
40703
  module.exports = NotepackSerializer;
40692
40704
  }));
40693
40705
  //#endregion
40694
- //#region __vite-optional-peer-dep:cbor-x:moleculer
40695
- var __vite_optional_peer_dep_cbor_x_moleculer_exports = /* @__PURE__ */ require_chunk.__exportAll({ default: () => __vite_optional_peer_dep_cbor_x_moleculer_default });
40696
- var __vite_optional_peer_dep_cbor_x_moleculer_default;
40697
- var init___vite_optional_peer_dep_cbor_x_moleculer = require_chunk.__esmMin((() => {
40698
- __vite_optional_peer_dep_cbor_x_moleculer_default = {};
40699
- throw new Error(`Could not resolve "cbor-x" imported by "moleculer". Is it installed?`);
40706
+ //#region ../../node_modules/detect-libc/lib/process.js
40707
+ var require_process$1 = /* @__PURE__ */ require_chunk.__commonJSMin(((exports, module) => {
40708
+ var isLinux = () => process.platform === "linux";
40709
+ var report = null;
40710
+ var getReport = () => {
40711
+ if (!report)
40712
+ /* istanbul ignore next */
40713
+ if (isLinux() && process.report) {
40714
+ const orig = process.report.excludeNetwork;
40715
+ process.report.excludeNetwork = true;
40716
+ report = process.report.getReport();
40717
+ process.report.excludeNetwork = orig;
40718
+ } else report = {};
40719
+ return report;
40720
+ };
40721
+ module.exports = {
40722
+ isLinux,
40723
+ getReport
40724
+ };
40725
+ }));
40726
+ //#endregion
40727
+ //#region ../../node_modules/detect-libc/lib/filesystem.js
40728
+ var require_filesystem = /* @__PURE__ */ require_chunk.__commonJSMin(((exports, module) => {
40729
+ var fs$18 = require("fs");
40730
+ var LDD_PATH = "/usr/bin/ldd";
40731
+ var SELF_PATH = "/proc/self/exe";
40732
+ var MAX_LENGTH = 2048;
40733
+ /**
40734
+ * Read the content of a file synchronous
40735
+ *
40736
+ * @param {string} path
40737
+ * @returns {Buffer}
40738
+ */
40739
+ var readFileSync = (path) => {
40740
+ const fd = fs$18.openSync(path, "r");
40741
+ const buffer = Buffer.alloc(MAX_LENGTH);
40742
+ const bytesRead = fs$18.readSync(fd, buffer, 0, MAX_LENGTH, 0);
40743
+ fs$18.close(fd, () => {});
40744
+ return buffer.subarray(0, bytesRead);
40745
+ };
40746
+ /**
40747
+ * Read the content of a file
40748
+ *
40749
+ * @param {string} path
40750
+ * @returns {Promise<Buffer>}
40751
+ */
40752
+ var readFile = (path) => new Promise((resolve, reject) => {
40753
+ fs$18.open(path, "r", (err, fd) => {
40754
+ if (err) reject(err);
40755
+ else {
40756
+ const buffer = Buffer.alloc(MAX_LENGTH);
40757
+ fs$18.read(fd, buffer, 0, MAX_LENGTH, 0, (_, bytesRead) => {
40758
+ resolve(buffer.subarray(0, bytesRead));
40759
+ fs$18.close(fd, () => {});
40760
+ });
40761
+ }
40762
+ });
40763
+ });
40764
+ module.exports = {
40765
+ LDD_PATH,
40766
+ SELF_PATH,
40767
+ readFileSync,
40768
+ readFile
40769
+ };
40770
+ }));
40771
+ //#endregion
40772
+ //#region ../../node_modules/detect-libc/lib/elf.js
40773
+ var require_elf = /* @__PURE__ */ require_chunk.__commonJSMin(((exports, module) => {
40774
+ var interpreterPath = (elf) => {
40775
+ if (elf.length < 64) return null;
40776
+ if (elf.readUInt32BE(0) !== 2135247942) return null;
40777
+ if (elf.readUInt8(4) !== 2) return null;
40778
+ if (elf.readUInt8(5) !== 1) return null;
40779
+ const offset = elf.readUInt32LE(32);
40780
+ const size = elf.readUInt16LE(54);
40781
+ const count = elf.readUInt16LE(56);
40782
+ for (let i = 0; i < count; i++) {
40783
+ const headerOffset = offset + i * size;
40784
+ if (elf.readUInt32LE(headerOffset) === 3) {
40785
+ const fileOffset = elf.readUInt32LE(headerOffset + 8);
40786
+ const fileSize = elf.readUInt32LE(headerOffset + 32);
40787
+ return elf.subarray(fileOffset, fileOffset + fileSize).toString().replace(/\0.*$/g, "");
40788
+ }
40789
+ }
40790
+ return null;
40791
+ };
40792
+ module.exports = { interpreterPath };
40793
+ }));
40794
+ //#endregion
40795
+ //#region ../../node_modules/detect-libc/lib/detect-libc.js
40796
+ var require_detect_libc = /* @__PURE__ */ require_chunk.__commonJSMin(((exports, module) => {
40797
+ var childProcess = require("child_process");
40798
+ var { isLinux, getReport } = require_process$1();
40799
+ var { LDD_PATH, SELF_PATH, readFile, readFileSync } = require_filesystem();
40800
+ var { interpreterPath } = require_elf();
40801
+ var cachedFamilyInterpreter;
40802
+ var cachedFamilyFilesystem;
40803
+ var cachedVersionFilesystem;
40804
+ var command = "getconf GNU_LIBC_VERSION 2>&1 || true; ldd --version 2>&1 || true";
40805
+ var commandOut = "";
40806
+ var safeCommand = () => {
40807
+ if (!commandOut) return new Promise((resolve) => {
40808
+ childProcess.exec(command, (err, out) => {
40809
+ commandOut = err ? " " : out;
40810
+ resolve(commandOut);
40811
+ });
40812
+ });
40813
+ return commandOut;
40814
+ };
40815
+ var safeCommandSync = () => {
40816
+ if (!commandOut) try {
40817
+ commandOut = childProcess.execSync(command, { encoding: "utf8" });
40818
+ } catch (_err) {
40819
+ commandOut = " ";
40820
+ }
40821
+ return commandOut;
40822
+ };
40823
+ /**
40824
+ * A String constant containing the value `glibc`.
40825
+ * @type {string}
40826
+ * @public
40827
+ */
40828
+ var GLIBC = "glibc";
40829
+ /**
40830
+ * A Regexp constant to get the GLIBC Version.
40831
+ * @type {string}
40832
+ */
40833
+ var RE_GLIBC_VERSION = /LIBC[a-z0-9 \-).]*?(\d+\.\d+)/i;
40834
+ /**
40835
+ * A String constant containing the value `musl`.
40836
+ * @type {string}
40837
+ * @public
40838
+ */
40839
+ var MUSL = "musl";
40840
+ var isFileMusl = (f) => f.includes("libc.musl-") || f.includes("ld-musl-");
40841
+ var familyFromReport = () => {
40842
+ const report = getReport();
40843
+ if (report.header && report.header.glibcVersionRuntime) return GLIBC;
40844
+ if (Array.isArray(report.sharedObjects)) {
40845
+ if (report.sharedObjects.some(isFileMusl)) return MUSL;
40846
+ }
40847
+ return null;
40848
+ };
40849
+ var familyFromCommand = (out) => {
40850
+ const [getconf, ldd1] = out.split(/[\r\n]+/);
40851
+ if (getconf && getconf.includes(GLIBC)) return GLIBC;
40852
+ if (ldd1 && ldd1.includes(MUSL)) return MUSL;
40853
+ return null;
40854
+ };
40855
+ var familyFromInterpreterPath = (path) => {
40856
+ if (path) {
40857
+ if (path.includes("/ld-musl-")) return MUSL;
40858
+ else if (path.includes("/ld-linux-")) return GLIBC;
40859
+ }
40860
+ return null;
40861
+ };
40862
+ var getFamilyFromLddContent = (content) => {
40863
+ content = content.toString();
40864
+ if (content.includes("musl")) return MUSL;
40865
+ if (content.includes("GNU C Library")) return GLIBC;
40866
+ return null;
40867
+ };
40868
+ var familyFromFilesystem = async () => {
40869
+ if (cachedFamilyFilesystem !== void 0) return cachedFamilyFilesystem;
40870
+ cachedFamilyFilesystem = null;
40871
+ try {
40872
+ cachedFamilyFilesystem = getFamilyFromLddContent(await readFile(LDD_PATH));
40873
+ } catch (e) {}
40874
+ return cachedFamilyFilesystem;
40875
+ };
40876
+ var familyFromFilesystemSync = () => {
40877
+ if (cachedFamilyFilesystem !== void 0) return cachedFamilyFilesystem;
40878
+ cachedFamilyFilesystem = null;
40879
+ try {
40880
+ cachedFamilyFilesystem = getFamilyFromLddContent(readFileSync(LDD_PATH));
40881
+ } catch (e) {}
40882
+ return cachedFamilyFilesystem;
40883
+ };
40884
+ var familyFromInterpreter = async () => {
40885
+ if (cachedFamilyInterpreter !== void 0) return cachedFamilyInterpreter;
40886
+ cachedFamilyInterpreter = null;
40887
+ try {
40888
+ cachedFamilyInterpreter = familyFromInterpreterPath(interpreterPath(await readFile(SELF_PATH)));
40889
+ } catch (e) {}
40890
+ return cachedFamilyInterpreter;
40891
+ };
40892
+ var familyFromInterpreterSync = () => {
40893
+ if (cachedFamilyInterpreter !== void 0) return cachedFamilyInterpreter;
40894
+ cachedFamilyInterpreter = null;
40895
+ try {
40896
+ cachedFamilyInterpreter = familyFromInterpreterPath(interpreterPath(readFileSync(SELF_PATH)));
40897
+ } catch (e) {}
40898
+ return cachedFamilyInterpreter;
40899
+ };
40900
+ /**
40901
+ * Resolves with the libc family when it can be determined, `null` otherwise.
40902
+ * @returns {Promise<?string>}
40903
+ */
40904
+ var family = async () => {
40905
+ let family = null;
40906
+ if (isLinux()) {
40907
+ family = await familyFromInterpreter();
40908
+ if (!family) {
40909
+ family = await familyFromFilesystem();
40910
+ if (!family) family = familyFromReport();
40911
+ if (!family) family = familyFromCommand(await safeCommand());
40912
+ }
40913
+ }
40914
+ return family;
40915
+ };
40916
+ /**
40917
+ * Returns the libc family when it can be determined, `null` otherwise.
40918
+ * @returns {?string}
40919
+ */
40920
+ var familySync = () => {
40921
+ let family = null;
40922
+ if (isLinux()) {
40923
+ family = familyFromInterpreterSync();
40924
+ if (!family) {
40925
+ family = familyFromFilesystemSync();
40926
+ if (!family) family = familyFromReport();
40927
+ if (!family) family = familyFromCommand(safeCommandSync());
40928
+ }
40929
+ }
40930
+ return family;
40931
+ };
40932
+ /**
40933
+ * Resolves `true` only when the platform is Linux and the libc family is not `glibc`.
40934
+ * @returns {Promise<boolean>}
40935
+ */
40936
+ var isNonGlibcLinux = async () => isLinux() && await family() !== GLIBC;
40937
+ /**
40938
+ * Returns `true` only when the platform is Linux and the libc family is not `glibc`.
40939
+ * @returns {boolean}
40940
+ */
40941
+ var isNonGlibcLinuxSync = () => isLinux() && familySync() !== GLIBC;
40942
+ var versionFromFilesystem = async () => {
40943
+ if (cachedVersionFilesystem !== void 0) return cachedVersionFilesystem;
40944
+ cachedVersionFilesystem = null;
40945
+ try {
40946
+ const versionMatch = (await readFile(LDD_PATH)).match(RE_GLIBC_VERSION);
40947
+ if (versionMatch) cachedVersionFilesystem = versionMatch[1];
40948
+ } catch (e) {}
40949
+ return cachedVersionFilesystem;
40950
+ };
40951
+ var versionFromFilesystemSync = () => {
40952
+ if (cachedVersionFilesystem !== void 0) return cachedVersionFilesystem;
40953
+ cachedVersionFilesystem = null;
40954
+ try {
40955
+ const versionMatch = readFileSync(LDD_PATH).match(RE_GLIBC_VERSION);
40956
+ if (versionMatch) cachedVersionFilesystem = versionMatch[1];
40957
+ } catch (e) {}
40958
+ return cachedVersionFilesystem;
40959
+ };
40960
+ var versionFromReport = () => {
40961
+ const report = getReport();
40962
+ if (report.header && report.header.glibcVersionRuntime) return report.header.glibcVersionRuntime;
40963
+ return null;
40964
+ };
40965
+ var versionSuffix = (s) => s.trim().split(/\s+/)[1];
40966
+ var versionFromCommand = (out) => {
40967
+ const [getconf, ldd1, ldd2] = out.split(/[\r\n]+/);
40968
+ if (getconf && getconf.includes(GLIBC)) return versionSuffix(getconf);
40969
+ if (ldd1 && ldd2 && ldd1.includes(MUSL)) return versionSuffix(ldd2);
40970
+ return null;
40971
+ };
40972
+ /**
40973
+ * Resolves with the libc version when it can be determined, `null` otherwise.
40974
+ * @returns {Promise<?string>}
40975
+ */
40976
+ var version = async () => {
40977
+ let version = null;
40978
+ if (isLinux()) {
40979
+ version = await versionFromFilesystem();
40980
+ if (!version) version = versionFromReport();
40981
+ if (!version) version = versionFromCommand(await safeCommand());
40982
+ }
40983
+ return version;
40984
+ };
40985
+ /**
40986
+ * Returns the libc version when it can be determined, `null` otherwise.
40987
+ * @returns {?string}
40988
+ */
40989
+ var versionSync = () => {
40990
+ let version = null;
40991
+ if (isLinux()) {
40992
+ version = versionFromFilesystemSync();
40993
+ if (!version) version = versionFromReport();
40994
+ if (!version) version = versionFromCommand(safeCommandSync());
40995
+ }
40996
+ return version;
40997
+ };
40998
+ module.exports = {
40999
+ GLIBC,
41000
+ MUSL,
41001
+ family,
41002
+ familySync,
41003
+ isNonGlibcLinux,
41004
+ isNonGlibcLinuxSync,
41005
+ version,
41006
+ versionSync
41007
+ };
41008
+ }));
41009
+ //#endregion
41010
+ //#region ../../node_modules/node-gyp-build-optional-packages/index.js
41011
+ var require_node_gyp_build_optional_packages = /* @__PURE__ */ require_chunk.__commonJSMin(((exports, module) => {
41012
+ var fs$17 = require("fs");
41013
+ var path$38 = require("path");
41014
+ var url$2 = require("url");
41015
+ var vars = process.config && process.config.variables || {};
41016
+ var prebuildsOnly = !!process.env.PREBUILDS_ONLY;
41017
+ var versions = process.versions;
41018
+ var abi = versions.modules;
41019
+ if (versions.deno || process.isBun) abi = "unsupported";
41020
+ var runtime = isElectron() ? "electron" : "node";
41021
+ var arch = process.arch;
41022
+ var platform = process.platform;
41023
+ var libc = process.env.LIBC || (isMusl(platform) ? "musl" : "glibc");
41024
+ var armv = process.env.ARM_VERSION || (arch === "arm64" ? "8" : vars.arm_version) || "";
41025
+ var uv = (versions.uv || "").split(".")[0];
41026
+ module.exports = load;
41027
+ function load(dir) {
41028
+ if (typeof __webpack_require__ === "function") return __non_webpack_require__(load.path(dir));
41029
+ else return require(load.path(dir));
41030
+ }
41031
+ load.path = function(dir) {
41032
+ dir = path$38.resolve(dir || ".");
41033
+ var packageName = "";
41034
+ try {
41035
+ if (typeof __webpack_require__ === "function") packageName = __non_webpack_require__(path$38.join(dir, "package.json")).name;
41036
+ else packageName = require(path$38.join(dir, "package.json")).name;
41037
+ var varName = packageName.toUpperCase().replace(/-/g, "_") + "_PREBUILD";
41038
+ if (process.env[varName]) dir = process.env[varName];
41039
+ } catch (err) {}
41040
+ if (!prebuildsOnly) {
41041
+ var release = getFirst(path$38.join(dir, "build/Release"), matchBuild);
41042
+ if (release) return release;
41043
+ var debug = getFirst(path$38.join(dir, "build/Debug"), matchBuild);
41044
+ if (debug) return debug;
41045
+ }
41046
+ var prebuild = resolve(dir);
41047
+ if (prebuild) return prebuild;
41048
+ var nearby = resolve(path$38.dirname(process.execPath));
41049
+ if (nearby) return nearby;
41050
+ var platformPackage = (packageName[0] == "@" ? "" : "@" + packageName + "/") + packageName + "-" + platform + "-" + arch;
41051
+ try {
41052
+ return resolveFile(path$38.dirname(require("module").createRequire(url$2.pathToFileURL(path$38.join(dir, "package.json"))).resolve(platformPackage)));
41053
+ } catch (error) {}
41054
+ var target = [
41055
+ "platform=" + platform,
41056
+ "arch=" + arch,
41057
+ "runtime=" + runtime,
41058
+ "abi=" + abi,
41059
+ "uv=" + uv,
41060
+ armv ? "armv=" + armv : "",
41061
+ "libc=" + libc,
41062
+ "node=" + process.versions.node,
41063
+ process.versions.electron ? "electron=" + process.versions.electron : "",
41064
+ typeof __webpack_require__ === "function" ? "webpack=true" : ""
41065
+ ].filter(Boolean).join(" ");
41066
+ throw new Error("No native build was found for " + target + "\n attempted loading from: " + dir + " and package: " + platformPackage + "\n");
41067
+ function resolve(dir) {
41068
+ var tuple = readdirSync(path$38.join(dir, "prebuilds")).map(parseTuple).filter(matchTuple(platform, arch)).sort(compareTuples)[0];
41069
+ if (!tuple) return;
41070
+ return resolveFile(path$38.join(dir, "prebuilds", tuple.name));
41071
+ }
41072
+ function resolveFile(prebuilds) {
41073
+ var winner = readdirSync(prebuilds).map(parseTags).filter(matchTags(runtime, abi)).sort(compareTags(runtime))[0];
41074
+ if (winner) return path$38.join(prebuilds, winner.file);
41075
+ }
41076
+ };
41077
+ function readdirSync(dir) {
41078
+ try {
41079
+ return fs$17.readdirSync(dir);
41080
+ } catch (err) {
41081
+ return [];
41082
+ }
41083
+ }
41084
+ function getFirst(dir, filter) {
41085
+ var files = readdirSync(dir).filter(filter);
41086
+ return files[0] && path$38.join(dir, files[0]);
41087
+ }
41088
+ function matchBuild(name) {
41089
+ return /\.node$/.test(name);
41090
+ }
41091
+ function parseTuple(name) {
41092
+ var arr = name.split("-");
41093
+ if (arr.length !== 2) return;
41094
+ var platform = arr[0];
41095
+ var architectures = arr[1].split("+");
41096
+ if (!platform) return;
41097
+ if (!architectures.length) return;
41098
+ if (!architectures.every(Boolean)) return;
41099
+ return {
41100
+ name,
41101
+ platform,
41102
+ architectures
41103
+ };
41104
+ }
41105
+ function matchTuple(platform, arch) {
41106
+ return function(tuple) {
41107
+ if (tuple == null) return false;
41108
+ if (tuple.platform !== platform) return false;
41109
+ return tuple.architectures.includes(arch);
41110
+ };
41111
+ }
41112
+ function compareTuples(a, b) {
41113
+ return a.architectures.length - b.architectures.length;
41114
+ }
41115
+ function parseTags(file) {
41116
+ var arr = file.split(".");
41117
+ var extension = arr.pop();
41118
+ var tags = {
41119
+ file,
41120
+ specificity: 0
41121
+ };
41122
+ if (extension !== "node") return;
41123
+ for (var i = 0; i < arr.length; i++) {
41124
+ var tag = arr[i];
41125
+ if (tag === "node" || tag === "electron" || tag === "node-webkit") tags.runtime = tag;
41126
+ else if (tag === "napi") tags.napi = true;
41127
+ else if (tag.slice(0, 3) === "abi") tags.abi = tag.slice(3);
41128
+ else if (tag.slice(0, 2) === "uv") tags.uv = tag.slice(2);
41129
+ else if (tag.slice(0, 4) === "armv") tags.armv = tag.slice(4);
41130
+ else if (tag === "glibc" || tag === "musl") tags.libc = tag;
41131
+ else continue;
41132
+ tags.specificity++;
41133
+ }
41134
+ return tags;
41135
+ }
41136
+ function matchTags(runtime, abi) {
41137
+ return function(tags) {
41138
+ if (tags == null) return false;
41139
+ if (tags.runtime !== runtime && !runtimeAgnostic(tags)) return false;
41140
+ if (tags.abi !== abi && !tags.napi) return false;
41141
+ if (tags.uv && tags.uv !== uv) return false;
41142
+ if (tags.armv && tags.armv !== armv) return false;
41143
+ if (tags.libc && tags.libc !== libc) return false;
41144
+ return true;
41145
+ };
41146
+ }
41147
+ function runtimeAgnostic(tags) {
41148
+ return tags.runtime === "node" && tags.napi;
41149
+ }
41150
+ function compareTags(runtime) {
41151
+ return function(a, b) {
41152
+ if (a.runtime !== b.runtime) return a.runtime === runtime ? -1 : 1;
41153
+ else if (a.abi !== b.abi) return a.abi ? -1 : 1;
41154
+ else if (a.specificity !== b.specificity) return a.specificity > b.specificity ? -1 : 1;
41155
+ else return 0;
41156
+ };
41157
+ }
41158
+ function isElectron() {
41159
+ if (process.versions && process.versions.electron) return true;
41160
+ if (process.env.ELECTRON_RUN_AS_NODE) return true;
41161
+ return typeof window !== "undefined" && window.process && window.process.type === "renderer";
41162
+ }
41163
+ function isMusl(platform) {
41164
+ if (platform !== "linux") return false;
41165
+ const { familySync, MUSL } = require_detect_libc();
41166
+ return familySync() === MUSL;
41167
+ }
41168
+ load.parseTags = parseTags;
41169
+ load.matchTags = matchTags;
41170
+ load.compareTags = compareTags;
41171
+ load.parseTuple = parseTuple;
41172
+ load.matchTuple = matchTuple;
41173
+ load.compareTuples = compareTuples;
41174
+ }));
41175
+ //#endregion
41176
+ //#region ../../node_modules/cbor-extract/index.js
41177
+ var require_cbor_extract = /* @__PURE__ */ require_chunk.__commonJSMin(((exports, module) => {
41178
+ module.exports = require_node_gyp_build_optional_packages()(__dirname);
41179
+ }));
41180
+ //#endregion
41181
+ //#region ../../node_modules/cbor-x/dist/node.cjs
41182
+ var require_node$2 = /* @__PURE__ */ require_chunk.__commonJSMin(((exports) => {
41183
+ var stream$1 = require("stream");
41184
+ var module$1$1 = require("module");
41185
+ var _documentCurrentScript = typeof document !== "undefined" ? document.currentScript : null;
41186
+ var decoder;
41187
+ try {
41188
+ decoder = new TextDecoder();
41189
+ } catch (error) {}
41190
+ var src;
41191
+ var srcEnd;
41192
+ var position$1 = 0;
41193
+ var EMPTY_ARRAY = [];
41194
+ var LEGACY_RECORD_INLINE_ID = 105;
41195
+ var RECORD_DEFINITIONS_ID = 57342;
41196
+ var RECORD_INLINE_ID = 57343;
41197
+ var BUNDLED_STRINGS_ID = 57337;
41198
+ var PACKED_REFERENCE_TAG_ID = 6;
41199
+ var STOP_CODE = {};
41200
+ var maxArraySize = 11281e4;
41201
+ var maxMapSize = 1681e4;
41202
+ var strings = EMPTY_ARRAY;
41203
+ var stringPosition = 0;
41204
+ var currentDecoder = {};
41205
+ var currentStructures;
41206
+ var srcString;
41207
+ var srcStringStart = 0;
41208
+ var srcStringEnd = 0;
41209
+ var bundledStrings$1;
41210
+ var referenceMap;
41211
+ var currentExtensions = [];
41212
+ var currentExtensionRanges = [];
41213
+ var packedValues;
41214
+ var dataView;
41215
+ var restoreMapsAsObject;
41216
+ var defaultOptions = {
41217
+ useRecords: false,
41218
+ mapsAsObjects: true
41219
+ };
41220
+ var sequentialMode = false;
41221
+ var inlineObjectReadThreshold = 2;
41222
+ try {
41223
+ new Function("");
41224
+ } catch (error) {
41225
+ inlineObjectReadThreshold = Infinity;
41226
+ }
41227
+ var Decoder = class Decoder {
41228
+ constructor(options) {
41229
+ if (options) {
41230
+ if ((options.keyMap || options._keyMap) && !options.useRecords) {
41231
+ options.useRecords = false;
41232
+ options.mapsAsObjects = true;
41233
+ }
41234
+ if (options.useRecords === false && options.mapsAsObjects === void 0) options.mapsAsObjects = true;
41235
+ if (options.getStructures) options.getShared = options.getStructures;
41236
+ if (options.getShared && !options.structures) (options.structures = []).uninitialized = true;
41237
+ if (options.keyMap) {
41238
+ this.mapKey = /* @__PURE__ */ new Map();
41239
+ for (let [k, v] of Object.entries(options.keyMap)) this.mapKey.set(v, k);
41240
+ }
41241
+ }
41242
+ Object.assign(this, options);
41243
+ }
41244
+ decodeKey(key) {
41245
+ return this.keyMap ? this.mapKey.get(key) || key : key;
41246
+ }
41247
+ encodeKey(key) {
41248
+ return this.keyMap && this.keyMap.hasOwnProperty(key) ? this.keyMap[key] : key;
41249
+ }
41250
+ encodeKeys(rec) {
41251
+ if (!this._keyMap) return rec;
41252
+ let map = /* @__PURE__ */ new Map();
41253
+ for (let [k, v] of Object.entries(rec)) map.set(this._keyMap.hasOwnProperty(k) ? this._keyMap[k] : k, v);
41254
+ return map;
41255
+ }
41256
+ decodeKeys(map) {
41257
+ if (!this._keyMap || map.constructor.name != "Map") return map;
41258
+ if (!this._mapKey) {
41259
+ this._mapKey = /* @__PURE__ */ new Map();
41260
+ for (let [k, v] of Object.entries(this._keyMap)) this._mapKey.set(v, k);
41261
+ }
41262
+ let res = {};
41263
+ map.forEach((v, k) => res[safeKey(this._mapKey.has(k) ? this._mapKey.get(k) : k)] = v);
41264
+ return res;
41265
+ }
41266
+ mapDecode(source, end) {
41267
+ let res = this.decode(source);
41268
+ if (this._keyMap) switch (res.constructor.name) {
41269
+ case "Array": return res.map((r) => this.decodeKeys(r));
41270
+ }
41271
+ return res;
41272
+ }
41273
+ decode(source, end) {
41274
+ if (src) return saveState(() => {
41275
+ clearSource();
41276
+ return this ? this.decode(source, end) : Decoder.prototype.decode.call(defaultOptions, source, end);
41277
+ });
41278
+ srcEnd = end > -1 ? end : source.length;
41279
+ position$1 = 0;
41280
+ stringPosition = 0;
41281
+ srcStringEnd = 0;
41282
+ srcString = null;
41283
+ strings = EMPTY_ARRAY;
41284
+ bundledStrings$1 = null;
41285
+ src = source;
41286
+ try {
41287
+ dataView = source.dataView || (source.dataView = new DataView(source.buffer, source.byteOffset, source.byteLength));
41288
+ } catch (error) {
41289
+ src = null;
41290
+ if (source instanceof Uint8Array) throw error;
41291
+ throw new Error("Source must be a Uint8Array or Buffer but was a " + (source && typeof source == "object" ? source.constructor.name : typeof source));
41292
+ }
41293
+ if (this instanceof Decoder) {
41294
+ currentDecoder = this;
41295
+ packedValues = this.sharedValues && (this.pack ? new Array(this.maxPrivatePackedValues || 16).concat(this.sharedValues) : this.sharedValues);
41296
+ if (this.structures) {
41297
+ currentStructures = this.structures;
41298
+ return checkedRead();
41299
+ } else if (!currentStructures || currentStructures.length > 0) currentStructures = [];
41300
+ } else {
41301
+ currentDecoder = defaultOptions;
41302
+ if (!currentStructures || currentStructures.length > 0) currentStructures = [];
41303
+ packedValues = null;
41304
+ }
41305
+ return checkedRead();
41306
+ }
41307
+ decodeMultiple(source, forEach) {
41308
+ let values, lastPosition = 0;
41309
+ try {
41310
+ let size = source.length;
41311
+ sequentialMode = true;
41312
+ let value = this ? this.decode(source, size) : defaultDecoder.decode(source, size);
41313
+ if (forEach) {
41314
+ if (forEach(value) === false) return;
41315
+ while (position$1 < size) {
41316
+ lastPosition = position$1;
41317
+ if (forEach(checkedRead()) === false) return;
41318
+ }
41319
+ } else {
41320
+ values = [value];
41321
+ while (position$1 < size) {
41322
+ lastPosition = position$1;
41323
+ values.push(checkedRead());
41324
+ }
41325
+ return values;
41326
+ }
41327
+ } catch (error) {
41328
+ error.lastPosition = lastPosition;
41329
+ error.values = values;
41330
+ throw error;
41331
+ } finally {
41332
+ sequentialMode = false;
41333
+ clearSource();
41334
+ }
41335
+ }
41336
+ };
41337
+ function checkedRead() {
41338
+ try {
41339
+ let result = read();
41340
+ if (bundledStrings$1) {
41341
+ if (position$1 >= bundledStrings$1.postBundlePosition) {
41342
+ let error = /* @__PURE__ */ new Error("Unexpected bundle position");
41343
+ error.incomplete = true;
41344
+ throw error;
41345
+ }
41346
+ position$1 = bundledStrings$1.postBundlePosition;
41347
+ bundledStrings$1 = null;
41348
+ }
41349
+ if (position$1 == srcEnd) {
41350
+ currentStructures = null;
41351
+ src = null;
41352
+ if (referenceMap) referenceMap = null;
41353
+ } else if (position$1 > srcEnd) {
41354
+ let error = /* @__PURE__ */ new Error("Unexpected end of CBOR data");
41355
+ error.incomplete = true;
41356
+ throw error;
41357
+ } else if (!sequentialMode) throw new Error("Data read, but end of buffer not reached");
41358
+ return result;
41359
+ } catch (error) {
41360
+ clearSource();
41361
+ if (error instanceof RangeError || error.message.startsWith("Unexpected end of buffer")) error.incomplete = true;
41362
+ throw error;
41363
+ }
41364
+ }
41365
+ function endOfCBORError() {
41366
+ let error = /* @__PURE__ */ new Error("Unexpected end of CBOR data");
41367
+ error.incomplete = true;
41368
+ return error;
41369
+ }
41370
+ function read() {
41371
+ if (!(position$1 < srcEnd)) throw endOfCBORError();
41372
+ let token = src[position$1++];
41373
+ let majorType = token >> 5;
41374
+ token = token & 31;
41375
+ if (token > 23) switch (token) {
41376
+ case 24:
41377
+ if (position$1 >= srcEnd) throw endOfCBORError();
41378
+ token = src[position$1++];
41379
+ break;
41380
+ case 25:
41381
+ if (majorType == 7) return getFloat16();
41382
+ token = dataView.getUint16(position$1);
41383
+ position$1 += 2;
41384
+ break;
41385
+ case 26:
41386
+ if (majorType == 7) {
41387
+ let value = dataView.getFloat32(position$1);
41388
+ if (currentDecoder.useFloat32 > 2) {
41389
+ let multiplier = mult10[(src[position$1] & 127) << 1 | src[position$1 + 1] >> 7];
41390
+ position$1 += 4;
41391
+ return (multiplier * value + (value > 0 ? .5 : -.5) >> 0) / multiplier;
41392
+ }
41393
+ position$1 += 4;
41394
+ return value;
41395
+ }
41396
+ token = dataView.getUint32(position$1);
41397
+ position$1 += 4;
41398
+ if (majorType === 1) return -1 - token;
41399
+ break;
41400
+ case 27:
41401
+ if (majorType == 7) {
41402
+ let value = dataView.getFloat64(position$1);
41403
+ position$1 += 8;
41404
+ return value;
41405
+ }
41406
+ if (majorType > 1) {
41407
+ if (dataView.getUint32(position$1) > 0) throw new Error("JavaScript does not support arrays, maps, or strings with length over 4294967295");
41408
+ token = dataView.getUint32(position$1 + 4);
41409
+ } else if (currentDecoder.int64AsNumber) {
41410
+ token = dataView.getUint32(position$1) * 4294967296;
41411
+ token += dataView.getUint32(position$1 + 4);
41412
+ } else token = dataView.getBigUint64(position$1);
41413
+ position$1 += 8;
41414
+ break;
41415
+ case 31: switch (majorType) {
41416
+ case 2:
41417
+ case 3: throw new Error("Indefinite length not supported for byte or text strings");
41418
+ case 4:
41419
+ let array = [];
41420
+ let value, i = 0;
41421
+ while ((value = read()) != STOP_CODE) {
41422
+ if (i >= maxArraySize) throw new Error(`Array length exceeds ${maxArraySize}`);
41423
+ array[i++] = value;
41424
+ }
41425
+ return majorType == 4 ? array : majorType == 3 ? array.join("") : Buffer.concat(array);
41426
+ case 5:
41427
+ let key;
41428
+ if (currentDecoder.mapsAsObjects) {
41429
+ let object = {};
41430
+ let i = 0;
41431
+ if (currentDecoder.keyMap) while ((key = read()) != STOP_CODE) {
41432
+ if (i++ >= maxMapSize) throw new Error(`Property count exceeds ${maxMapSize}`);
41433
+ object[safeKey(currentDecoder.decodeKey(key))] = read();
41434
+ }
41435
+ else while ((key = read()) != STOP_CODE) {
41436
+ if (i++ >= maxMapSize) throw new Error(`Property count exceeds ${maxMapSize}`);
41437
+ object[safeKey(key)] = read();
41438
+ }
41439
+ return object;
41440
+ } else {
41441
+ if (restoreMapsAsObject) {
41442
+ currentDecoder.mapsAsObjects = true;
41443
+ restoreMapsAsObject = false;
41444
+ }
41445
+ let map = /* @__PURE__ */ new Map();
41446
+ if (currentDecoder.keyMap) {
41447
+ let i = 0;
41448
+ while ((key = read()) != STOP_CODE) {
41449
+ if (i++ >= maxMapSize) throw new Error(`Map size exceeds ${maxMapSize}`);
41450
+ map.set(currentDecoder.decodeKey(key), read());
41451
+ }
41452
+ } else {
41453
+ let i = 0;
41454
+ while ((key = read()) != STOP_CODE) {
41455
+ if (i++ >= maxMapSize) throw new Error(`Map size exceeds ${maxMapSize}`);
41456
+ map.set(key, read());
41457
+ }
41458
+ }
41459
+ return map;
41460
+ }
41461
+ case 7: return STOP_CODE;
41462
+ default: throw new Error("Invalid major type for indefinite length " + majorType);
41463
+ }
41464
+ default: throw new Error("Unknown token " + token);
41465
+ }
41466
+ switch (majorType) {
41467
+ case 0: return token;
41468
+ case 1: return ~token;
41469
+ case 2: return readBin(token);
41470
+ case 3:
41471
+ if (srcStringEnd >= position$1) return srcString.slice(position$1 - srcStringStart, (position$1 += token) - srcStringStart);
41472
+ if (srcStringEnd == 0 && srcEnd < 140 && token < 32) {
41473
+ let string = token < 16 ? shortStringInJS(token) : longStringInJS(token);
41474
+ if (string != null) return string;
41475
+ }
41476
+ return readFixedString(token);
41477
+ case 4:
41478
+ if (token >= maxArraySize) throw new Error(`Array length exceeds ${maxArraySize}`);
41479
+ if (token > srcEnd - position$1) throw endOfCBORError();
41480
+ let array = new Array(token);
41481
+ for (let i = 0; i < token; i++) array[i] = read();
41482
+ return array;
41483
+ case 5:
41484
+ if (token >= maxMapSize) throw new Error(`Map size exceeds ${maxArraySize}`);
41485
+ if (token > (srcEnd - position$1) / 2) throw endOfCBORError();
41486
+ if (currentDecoder.mapsAsObjects) {
41487
+ let object = {};
41488
+ if (currentDecoder.keyMap) for (let i = 0; i < token; i++) object[safeKey(currentDecoder.decodeKey(read()))] = read();
41489
+ else for (let i = 0; i < token; i++) object[safeKey(read())] = read();
41490
+ return object;
41491
+ } else {
41492
+ if (restoreMapsAsObject) {
41493
+ currentDecoder.mapsAsObjects = true;
41494
+ restoreMapsAsObject = false;
41495
+ }
41496
+ let map = /* @__PURE__ */ new Map();
41497
+ if (currentDecoder.keyMap) for (let i = 0; i < token; i++) map.set(currentDecoder.decodeKey(read()), read());
41498
+ else for (let i = 0; i < token; i++) map.set(read(), read());
41499
+ return map;
41500
+ }
41501
+ case 6:
41502
+ if (token >= BUNDLED_STRINGS_ID) {
41503
+ let structure = currentStructures[token & 8191];
41504
+ if (structure) {
41505
+ if (!structure.read) structure.read = createStructureReader(structure);
41506
+ return structure.read();
41507
+ }
41508
+ if (token < 65536) {
41509
+ if (token == RECORD_INLINE_ID) {
41510
+ let length = readJustLength();
41511
+ let id = read();
41512
+ let structure = read();
41513
+ recordDefinition(id, structure);
41514
+ let object = {};
41515
+ if (currentDecoder.keyMap) for (let i = 2; i < length; i++) {
41516
+ let key = currentDecoder.decodeKey(structure[i - 2]);
41517
+ object[safeKey(key)] = read();
41518
+ }
41519
+ else for (let i = 2; i < length; i++) {
41520
+ let key = structure[i - 2];
41521
+ object[safeKey(key)] = read();
41522
+ }
41523
+ return object;
41524
+ } else if (token == RECORD_DEFINITIONS_ID) {
41525
+ let length = readJustLength();
41526
+ let id = read();
41527
+ for (let i = 2; i < length; i++) recordDefinition(id++, read());
41528
+ return read();
41529
+ } else if (token == BUNDLED_STRINGS_ID) return readBundleExt();
41530
+ if (currentDecoder.getShared) {
41531
+ loadShared();
41532
+ structure = currentStructures[token & 8191];
41533
+ if (structure) {
41534
+ if (!structure.read) structure.read = createStructureReader(structure);
41535
+ return structure.read();
41536
+ }
41537
+ }
41538
+ }
41539
+ }
41540
+ let extension = currentExtensions[token];
41541
+ if (extension) if (extension.handlesRead) return extension(read);
41542
+ else return extension(read());
41543
+ else {
41544
+ let input = read();
41545
+ for (let i = 0; i < currentExtensionRanges.length; i++) {
41546
+ let value = currentExtensionRanges[i](token, input);
41547
+ if (value !== void 0) return value;
41548
+ }
41549
+ return new Tag(input, token);
41550
+ }
41551
+ case 7: switch (token) {
41552
+ case 20: return false;
41553
+ case 21: return true;
41554
+ case 22: return null;
41555
+ case 23: return;
41556
+ default:
41557
+ let packedValue = (packedValues || getPackedValues())[token];
41558
+ if (packedValue !== void 0) return packedValue;
41559
+ throw new Error("Unknown token " + token);
41560
+ }
41561
+ default:
41562
+ if (isNaN(token)) throw endOfCBORError();
41563
+ throw new Error("Unknown CBOR token " + token);
41564
+ }
41565
+ }
41566
+ var validName = /^[a-zA-Z_$][a-zA-Z\d_$]*$/;
41567
+ function createStructureReader(structure) {
41568
+ if (!structure) throw new Error("Structure is required in record definition");
41569
+ function readObject() {
41570
+ let length = src[position$1++];
41571
+ length = length & 31;
41572
+ if (length > 23) switch (length) {
41573
+ case 24:
41574
+ length = src[position$1++];
41575
+ break;
41576
+ case 25:
41577
+ length = dataView.getUint16(position$1);
41578
+ position$1 += 2;
41579
+ break;
41580
+ case 26:
41581
+ length = dataView.getUint32(position$1);
41582
+ position$1 += 4;
41583
+ break;
41584
+ default: throw new Error("Expected array header, but got " + src[position$1 - 1]);
41585
+ }
41586
+ let compiledReader = this.compiledReader;
41587
+ while (compiledReader) {
41588
+ if (compiledReader.propertyCount === length) return compiledReader(read);
41589
+ compiledReader = compiledReader.next;
41590
+ }
41591
+ if (this.slowReads++ >= inlineObjectReadThreshold) {
41592
+ let array = this.length == length ? this : this.slice(0, length);
41593
+ compiledReader = currentDecoder.keyMap ? new Function("r", "return {" + array.map((k) => currentDecoder.decodeKey(k)).map((k) => validName.test(k) ? safeKey(k) + ":r()" : "[" + JSON.stringify(k) + "]:r()").join(",") + "}") : new Function("r", "return {" + array.map((key) => validName.test(key) ? safeKey(key) + ":r()" : "[" + JSON.stringify(key) + "]:r()").join(",") + "}");
41594
+ if (this.compiledReader) compiledReader.next = this.compiledReader;
41595
+ compiledReader.propertyCount = length;
41596
+ this.compiledReader = compiledReader;
41597
+ return compiledReader(read);
41598
+ }
41599
+ let object = {};
41600
+ if (currentDecoder.keyMap) for (let i = 0; i < length; i++) object[safeKey(currentDecoder.decodeKey(this[i]))] = read();
41601
+ else for (let i = 0; i < length; i++) object[safeKey(this[i])] = read();
41602
+ return object;
41603
+ }
41604
+ structure.slowReads = 0;
41605
+ return readObject;
41606
+ }
41607
+ function safeKey(key) {
41608
+ if (typeof key === "string") return key === "__proto__" ? "__proto_" : key;
41609
+ if (typeof key === "number" || typeof key === "boolean" || typeof key === "bigint") return key.toString();
41610
+ if (key == null) return key + "";
41611
+ throw new Error("Invalid property name type " + typeof key);
41612
+ }
41613
+ var readFixedString = readStringJS;
41614
+ exports.isNativeAccelerationEnabled = false;
41615
+ function setExtractor(extractStrings) {
41616
+ exports.isNativeAccelerationEnabled = true;
41617
+ readFixedString = readString();
41618
+ function readString(headerLength) {
41619
+ return function readString(length) {
41620
+ let string = strings[stringPosition++];
41621
+ if (string == null) {
41622
+ if (bundledStrings$1) return readStringJS(length);
41623
+ let extraction = extractStrings(position$1, srcEnd, length, src);
41624
+ if (typeof extraction == "string") {
41625
+ string = extraction;
41626
+ strings = EMPTY_ARRAY;
41627
+ } else {
41628
+ strings = extraction;
41629
+ stringPosition = 1;
41630
+ srcStringEnd = 1;
41631
+ string = strings[0];
41632
+ if (string === void 0) throw new Error("Unexpected end of buffer");
41633
+ }
41634
+ }
41635
+ let srcStringLength = string.length;
41636
+ if (srcStringLength <= length) {
41637
+ position$1 += length;
41638
+ return string;
41639
+ }
41640
+ srcString = string;
41641
+ srcStringStart = position$1;
41642
+ srcStringEnd = position$1 + srcStringLength;
41643
+ position$1 += length;
41644
+ return string.slice(0, length);
41645
+ };
41646
+ }
41647
+ }
41648
+ function readStringJS(length) {
41649
+ let result;
41650
+ if (length < 16) {
41651
+ if (result = shortStringInJS(length)) return result;
41652
+ }
41653
+ if (length > 64 && decoder) return decoder.decode(src.subarray(position$1, position$1 += length));
41654
+ const end = position$1 + length;
41655
+ const units = [];
41656
+ result = "";
41657
+ while (position$1 < end) {
41658
+ const byte1 = src[position$1++];
41659
+ if ((byte1 & 128) === 0) units.push(byte1);
41660
+ else if ((byte1 & 224) === 192) if (byte1 < 194 || position$1 >= end || (src[position$1] & 192) !== 128) units.push(65533);
41661
+ else {
41662
+ const byte2 = src[position$1++] & 63;
41663
+ units.push((byte1 & 31) << 6 | byte2);
41664
+ }
41665
+ else if ((byte1 & 240) === 224) {
41666
+ const byte2 = position$1 < end ? src[position$1] : 0;
41667
+ if (position$1 >= end || (byte2 & 192) !== 128 || byte1 === 224 && byte2 < 160 || byte1 === 237 && byte2 >= 160) units.push(65533);
41668
+ else {
41669
+ position$1++;
41670
+ if (position$1 >= end || (src[position$1] & 192) !== 128) units.push(65533);
41671
+ else {
41672
+ const byte3 = src[position$1++] & 63;
41673
+ units.push((byte1 & 31) << 12 | (byte2 & 63) << 6 | byte3);
41674
+ }
41675
+ }
41676
+ } else if ((byte1 & 248) === 240) {
41677
+ const byte2 = position$1 < end ? src[position$1] : 0;
41678
+ if (byte1 > 244 || position$1 >= end || (byte2 & 192) !== 128 || byte1 === 240 && byte2 < 144 || byte1 === 244 && byte2 >= 144) units.push(65533);
41679
+ else {
41680
+ position$1++;
41681
+ if (position$1 >= end || (src[position$1] & 192) !== 128) units.push(65533);
41682
+ else {
41683
+ const byte3 = src[position$1++] & 63;
41684
+ if (position$1 >= end || (src[position$1] & 192) !== 128) units.push(65533);
41685
+ else {
41686
+ const byte4 = src[position$1++] & 63;
41687
+ let unit = (byte1 & 7) << 18 | (byte2 & 63) << 12 | byte3 << 6 | byte4;
41688
+ unit -= 65536;
41689
+ units.push(unit >>> 10 & 1023 | 55296);
41690
+ units.push(56320 | unit & 1023);
41691
+ }
41692
+ }
41693
+ }
41694
+ } else units.push(65533);
41695
+ if (units.length >= 4096) {
41696
+ result += fromCharCode.apply(String, units);
41697
+ units.length = 0;
41698
+ }
41699
+ }
41700
+ if (units.length > 0) result += fromCharCode.apply(String, units);
41701
+ return result;
41702
+ }
41703
+ var fromCharCode = String.fromCharCode;
41704
+ function longStringInJS(length) {
41705
+ let start = position$1;
41706
+ let bytes = new Array(length);
41707
+ for (let i = 0; i < length; i++) {
41708
+ const byte = src[position$1++];
41709
+ if ((byte & 128) > 0) {
41710
+ position$1 = start;
41711
+ return;
41712
+ }
41713
+ bytes[i] = byte;
41714
+ }
41715
+ return fromCharCode.apply(String, bytes);
41716
+ }
41717
+ function shortStringInJS(length) {
41718
+ if (length < 4) if (length < 2) if (length === 0) return "";
41719
+ else {
41720
+ let a = src[position$1++];
41721
+ if ((a & 128) > 1) {
41722
+ position$1 -= 1;
41723
+ return;
41724
+ }
41725
+ return fromCharCode(a);
41726
+ }
41727
+ else {
41728
+ let a = src[position$1++];
41729
+ let b = src[position$1++];
41730
+ if ((a & 128) > 0 || (b & 128) > 0) {
41731
+ position$1 -= 2;
41732
+ return;
41733
+ }
41734
+ if (length < 3) return fromCharCode(a, b);
41735
+ let c = src[position$1++];
41736
+ if ((c & 128) > 0) {
41737
+ position$1 -= 3;
41738
+ return;
41739
+ }
41740
+ return fromCharCode(a, b, c);
41741
+ }
41742
+ else {
41743
+ let a = src[position$1++];
41744
+ let b = src[position$1++];
41745
+ let c = src[position$1++];
41746
+ let d = src[position$1++];
41747
+ if ((a & 128) > 0 || (b & 128) > 0 || (c & 128) > 0 || (d & 128) > 0) {
41748
+ position$1 -= 4;
41749
+ return;
41750
+ }
41751
+ if (length < 6) if (length === 4) return fromCharCode(a, b, c, d);
41752
+ else {
41753
+ let e = src[position$1++];
41754
+ if ((e & 128) > 0) {
41755
+ position$1 -= 5;
41756
+ return;
41757
+ }
41758
+ return fromCharCode(a, b, c, d, e);
41759
+ }
41760
+ else if (length < 8) {
41761
+ let e = src[position$1++];
41762
+ let f = src[position$1++];
41763
+ if ((e & 128) > 0 || (f & 128) > 0) {
41764
+ position$1 -= 6;
41765
+ return;
41766
+ }
41767
+ if (length < 7) return fromCharCode(a, b, c, d, e, f);
41768
+ let g = src[position$1++];
41769
+ if ((g & 128) > 0) {
41770
+ position$1 -= 7;
41771
+ return;
41772
+ }
41773
+ return fromCharCode(a, b, c, d, e, f, g);
41774
+ } else {
41775
+ let e = src[position$1++];
41776
+ let f = src[position$1++];
41777
+ let g = src[position$1++];
41778
+ let h = src[position$1++];
41779
+ if ((e & 128) > 0 || (f & 128) > 0 || (g & 128) > 0 || (h & 128) > 0) {
41780
+ position$1 -= 8;
41781
+ return;
41782
+ }
41783
+ if (length < 10) if (length === 8) return fromCharCode(a, b, c, d, e, f, g, h);
41784
+ else {
41785
+ let i = src[position$1++];
41786
+ if ((i & 128) > 0) {
41787
+ position$1 -= 9;
41788
+ return;
41789
+ }
41790
+ return fromCharCode(a, b, c, d, e, f, g, h, i);
41791
+ }
41792
+ else if (length < 12) {
41793
+ let i = src[position$1++];
41794
+ let j = src[position$1++];
41795
+ if ((i & 128) > 0 || (j & 128) > 0) {
41796
+ position$1 -= 10;
41797
+ return;
41798
+ }
41799
+ if (length < 11) return fromCharCode(a, b, c, d, e, f, g, h, i, j);
41800
+ let k = src[position$1++];
41801
+ if ((k & 128) > 0) {
41802
+ position$1 -= 11;
41803
+ return;
41804
+ }
41805
+ return fromCharCode(a, b, c, d, e, f, g, h, i, j, k);
41806
+ } else {
41807
+ let i = src[position$1++];
41808
+ let j = src[position$1++];
41809
+ let k = src[position$1++];
41810
+ let l = src[position$1++];
41811
+ if ((i & 128) > 0 || (j & 128) > 0 || (k & 128) > 0 || (l & 128) > 0) {
41812
+ position$1 -= 12;
41813
+ return;
41814
+ }
41815
+ if (length < 14) if (length === 12) return fromCharCode(a, b, c, d, e, f, g, h, i, j, k, l);
41816
+ else {
41817
+ let m = src[position$1++];
41818
+ if ((m & 128) > 0) {
41819
+ position$1 -= 13;
41820
+ return;
41821
+ }
41822
+ return fromCharCode(a, b, c, d, e, f, g, h, i, j, k, l, m);
41823
+ }
41824
+ else {
41825
+ let m = src[position$1++];
41826
+ let n = src[position$1++];
41827
+ if ((m & 128) > 0 || (n & 128) > 0) {
41828
+ position$1 -= 14;
41829
+ return;
41830
+ }
41831
+ if (length < 15) return fromCharCode(a, b, c, d, e, f, g, h, i, j, k, l, m, n);
41832
+ let o = src[position$1++];
41833
+ if ((o & 128) > 0) {
41834
+ position$1 -= 15;
41835
+ return;
41836
+ }
41837
+ return fromCharCode(a, b, c, d, e, f, g, h, i, j, k, l, m, n, o);
41838
+ }
41839
+ }
41840
+ }
41841
+ }
41842
+ }
41843
+ function readBin(length) {
41844
+ return currentDecoder.copyBuffers ? Uint8Array.prototype.slice.call(src, position$1, position$1 += length) : src.subarray(position$1, position$1 += length);
41845
+ }
41846
+ var f32Array = new Float32Array(1);
41847
+ var u8Array = new Uint8Array(f32Array.buffer, 0, 4);
41848
+ function getFloat16() {
41849
+ let byte0 = src[position$1++];
41850
+ let byte1 = src[position$1++];
41851
+ let exponent = (byte0 & 127) >> 2;
41852
+ if (exponent === 31) {
41853
+ if (byte1 || byte0 & 3) return NaN;
41854
+ return byte0 & 128 ? -Infinity : Infinity;
41855
+ }
41856
+ if (exponent === 0) {
41857
+ let abs = ((byte0 & 3) << 8 | byte1) / (1 << 24);
41858
+ return byte0 & 128 ? -abs : abs;
41859
+ }
41860
+ u8Array[3] = byte0 & 128 | (exponent >> 1) + 56;
41861
+ u8Array[2] = (byte0 & 7) << 5 | byte1 >> 3;
41862
+ u8Array[1] = byte1 << 5;
41863
+ u8Array[0] = 0;
41864
+ return f32Array[0];
41865
+ }
41866
+ new Array(4096);
41867
+ var Tag = class {
41868
+ constructor(value, tag) {
41869
+ this.value = value;
41870
+ this.tag = tag;
41871
+ }
41872
+ };
41873
+ currentExtensions[0] = (dateString) => {
41874
+ return new Date(dateString);
41875
+ };
41876
+ currentExtensions[1] = (epochSec) => {
41877
+ return new Date(Math.round(epochSec * 1e3));
41878
+ };
41879
+ currentExtensions[2] = (buffer) => {
41880
+ let value = BigInt(0);
41881
+ for (let i = 0, l = buffer.byteLength; i < l; i++) value = BigInt(buffer[i]) + (value << BigInt(8));
41882
+ return value;
41883
+ };
41884
+ currentExtensions[3] = (buffer) => {
41885
+ return BigInt(-1) - currentExtensions[2](buffer);
41886
+ };
41887
+ currentExtensions[4] = (fraction) => {
41888
+ return +(fraction[1] + "e" + fraction[0]);
41889
+ };
41890
+ currentExtensions[5] = (fraction) => {
41891
+ return fraction[1] * Math.exp(fraction[0] * Math.log(2));
41892
+ };
41893
+ var recordDefinition = (id, structure) => {
41894
+ id = id - 57344;
41895
+ let existingStructure = currentStructures[id];
41896
+ if (existingStructure && existingStructure.isShared) (currentStructures.restoreStructures || (currentStructures.restoreStructures = []))[id] = existingStructure;
41897
+ currentStructures[id] = structure;
41898
+ structure.read = createStructureReader(structure);
41899
+ };
41900
+ currentExtensions[LEGACY_RECORD_INLINE_ID] = (data) => {
41901
+ let length = data.length;
41902
+ let structure = data[1];
41903
+ recordDefinition(data[0], structure);
41904
+ let object = {};
41905
+ for (let i = 2; i < length; i++) {
41906
+ let key = structure[i - 2];
41907
+ object[safeKey(key)] = data[i];
41908
+ }
41909
+ return object;
41910
+ };
41911
+ currentExtensions[14] = (value) => {
41912
+ if (bundledStrings$1) return bundledStrings$1[0].slice(bundledStrings$1.position0, bundledStrings$1.position0 += value);
41913
+ return new Tag(value, 14);
41914
+ };
41915
+ currentExtensions[15] = (value) => {
41916
+ if (bundledStrings$1) return bundledStrings$1[1].slice(bundledStrings$1.position1, bundledStrings$1.position1 += value);
41917
+ return new Tag(value, 15);
41918
+ };
41919
+ var glbl = {
41920
+ Error,
41921
+ RegExp
41922
+ };
41923
+ currentExtensions[27] = (data) => {
41924
+ return (glbl[data[0]] || Error)(data[1], data[2]);
41925
+ };
41926
+ var packedTable = (read) => {
41927
+ if (src[position$1++] != 132) {
41928
+ let error = /* @__PURE__ */ new Error("Packed values structure must be followed by a 4 element array");
41929
+ if (src.length < position$1) error.incomplete = true;
41930
+ throw error;
41931
+ }
41932
+ let newPackedValues = read();
41933
+ if (!newPackedValues || !newPackedValues.length) {
41934
+ let error = /* @__PURE__ */ new Error("Packed values structure must be followed by a 4 element array");
41935
+ error.incomplete = true;
41936
+ throw error;
41937
+ }
41938
+ packedValues = packedValues ? newPackedValues.concat(packedValues.slice(newPackedValues.length)) : newPackedValues;
41939
+ packedValues.prefixes = read();
41940
+ packedValues.suffixes = read();
41941
+ return read();
41942
+ };
41943
+ packedTable.handlesRead = true;
41944
+ currentExtensions[51] = packedTable;
41945
+ currentExtensions[PACKED_REFERENCE_TAG_ID] = (data) => {
41946
+ if (!packedValues) if (currentDecoder.getShared) loadShared();
41947
+ else return new Tag(data, PACKED_REFERENCE_TAG_ID);
41948
+ if (typeof data == "number") return packedValues[16 + (data >= 0 ? 2 * data : -2 * data - 1)];
41949
+ let error = /* @__PURE__ */ new Error("No support for non-integer packed references yet");
41950
+ if (data === void 0) error.incomplete = true;
41951
+ throw error;
41952
+ };
41953
+ currentExtensions[28] = (read) => {
41954
+ if (!referenceMap) {
41955
+ referenceMap = /* @__PURE__ */ new Map();
41956
+ referenceMap.id = 0;
41957
+ }
41958
+ let id = referenceMap.id++;
41959
+ let startingPosition = position$1;
41960
+ let token = src[position$1];
41961
+ let target;
41962
+ if (token >> 5 == 4) target = [];
41963
+ else target = {};
41964
+ let refEntry = { target };
41965
+ referenceMap.set(id, refEntry);
41966
+ let targetProperties = read();
41967
+ if (refEntry.used) {
41968
+ if (Object.getPrototypeOf(target) !== Object.getPrototypeOf(targetProperties)) {
41969
+ position$1 = startingPosition;
41970
+ target = targetProperties;
41971
+ referenceMap.set(id, { target });
41972
+ targetProperties = read();
41973
+ }
41974
+ return Object.assign(target, targetProperties);
41975
+ }
41976
+ refEntry.target = targetProperties;
41977
+ return targetProperties;
41978
+ };
41979
+ currentExtensions[28].handlesRead = true;
41980
+ currentExtensions[29] = (id) => {
41981
+ let refEntry = referenceMap.get(id);
41982
+ refEntry.used = true;
41983
+ return refEntry.target;
41984
+ };
41985
+ currentExtensions[258] = (array) => new Set(array);
41986
+ (currentExtensions[259] = (read) => {
41987
+ if (currentDecoder.mapsAsObjects) {
41988
+ currentDecoder.mapsAsObjects = false;
41989
+ restoreMapsAsObject = true;
41990
+ }
41991
+ return read();
41992
+ }).handlesRead = true;
41993
+ function combine(a, b) {
41994
+ if (typeof a === "string") return a + b;
41995
+ if (a instanceof Array) return a.concat(b);
41996
+ return Object.assign({}, a, b);
41997
+ }
41998
+ function getPackedValues() {
41999
+ if (!packedValues) if (currentDecoder.getShared) loadShared();
42000
+ else throw new Error("No packed values available");
42001
+ return packedValues;
42002
+ }
42003
+ var SHARED_DATA_TAG_ID = 1399353956;
42004
+ currentExtensionRanges.push((tag, input) => {
42005
+ if (tag >= 225 && tag <= 255) return combine(getPackedValues().prefixes[tag - 224], input);
42006
+ if (tag >= 28704 && tag <= 32767) return combine(getPackedValues().prefixes[tag - 28672], input);
42007
+ if (tag >= 1879052288 && tag <= 2147483647) return combine(getPackedValues().prefixes[tag - 1879048192], input);
42008
+ if (tag >= 216 && tag <= 223) return combine(input, getPackedValues().suffixes[tag - 216]);
42009
+ if (tag >= 27647 && tag <= 28671) return combine(input, getPackedValues().suffixes[tag - 27639]);
42010
+ if (tag >= 1811940352 && tag <= 1879048191) return combine(input, getPackedValues().suffixes[tag - 1811939328]);
42011
+ if (tag == SHARED_DATA_TAG_ID) return {
42012
+ packedValues,
42013
+ structures: currentStructures.slice(0),
42014
+ version: input
42015
+ };
42016
+ if (tag == 55799) return input;
42017
+ });
42018
+ var isLittleEndianMachine$1 = new Uint8Array(new Uint16Array([1]).buffer)[0] == 1;
42019
+ var typedArrays = [
42020
+ Uint8Array,
42021
+ Uint8ClampedArray,
42022
+ Uint16Array,
42023
+ Uint32Array,
42024
+ typeof BigUint64Array == "undefined" ? { name: "BigUint64Array" } : BigUint64Array,
42025
+ Int8Array,
42026
+ Int16Array,
42027
+ Int32Array,
42028
+ typeof BigInt64Array == "undefined" ? { name: "BigInt64Array" } : BigInt64Array,
42029
+ Float32Array,
42030
+ Float64Array
42031
+ ];
42032
+ var typedArrayTags = [
42033
+ 64,
42034
+ 68,
42035
+ 69,
42036
+ 70,
42037
+ 71,
42038
+ 72,
42039
+ 77,
42040
+ 78,
42041
+ 79,
42042
+ 85,
42043
+ 86
42044
+ ];
42045
+ for (let i = 0; i < typedArrays.length; i++) registerTypedArray(typedArrays[i], typedArrayTags[i]);
42046
+ function registerTypedArray(TypedArray, tag) {
42047
+ let dvMethod = "get" + TypedArray.name.slice(0, -5);
42048
+ let bytesPerElement;
42049
+ if (typeof TypedArray === "function") bytesPerElement = TypedArray.BYTES_PER_ELEMENT;
42050
+ else TypedArray = null;
42051
+ for (let littleEndian = 0; littleEndian < 2; littleEndian++) {
42052
+ if (!littleEndian && bytesPerElement == 1) continue;
42053
+ let sizeShift = bytesPerElement == 2 ? 1 : bytesPerElement == 4 ? 2 : bytesPerElement == 8 ? 3 : 0;
42054
+ currentExtensions[littleEndian ? tag : tag - 4] = bytesPerElement == 1 || littleEndian == isLittleEndianMachine$1 ? (buffer) => {
42055
+ if (!TypedArray) throw new Error("Could not find typed array for code " + tag);
42056
+ if (!currentDecoder.copyBuffers) {
42057
+ if (bytesPerElement === 1 || bytesPerElement === 2 && !(buffer.byteOffset & 1) || bytesPerElement === 4 && !(buffer.byteOffset & 3) || bytesPerElement === 8 && !(buffer.byteOffset & 7)) return new TypedArray(buffer.buffer, buffer.byteOffset, buffer.byteLength >> sizeShift);
42058
+ }
42059
+ return new TypedArray(Uint8Array.prototype.slice.call(buffer, 0).buffer);
42060
+ } : (buffer) => {
42061
+ if (!TypedArray) throw new Error("Could not find typed array for code " + tag);
42062
+ let dv = new DataView(buffer.buffer, buffer.byteOffset, buffer.byteLength);
42063
+ let elements = buffer.length >> sizeShift;
42064
+ let ta = new TypedArray(elements);
42065
+ let method = dv[dvMethod];
42066
+ for (let i = 0; i < elements; i++) ta[i] = method.call(dv, i << sizeShift, littleEndian);
42067
+ return ta;
42068
+ };
42069
+ }
42070
+ }
42071
+ function readBundleExt() {
42072
+ let length = readJustLength();
42073
+ let bundlePosition = position$1 + read();
42074
+ for (let i = 2; i < length; i++) {
42075
+ let bundleLength = readJustLength();
42076
+ position$1 += bundleLength;
42077
+ }
42078
+ let dataPosition = position$1;
42079
+ position$1 = bundlePosition;
42080
+ bundledStrings$1 = [readStringJS(readJustLength()), readStringJS(readJustLength())];
42081
+ bundledStrings$1.position0 = 0;
42082
+ bundledStrings$1.position1 = 0;
42083
+ bundledStrings$1.postBundlePosition = position$1;
42084
+ position$1 = dataPosition;
42085
+ return read();
42086
+ }
42087
+ function readJustLength() {
42088
+ if (!(position$1 < srcEnd)) throw endOfCBORError();
42089
+ let token = src[position$1++] & 31;
42090
+ if (token > 23) switch (token) {
42091
+ case 24:
42092
+ if (position$1 >= srcEnd) throw endOfCBORError();
42093
+ token = src[position$1++];
42094
+ break;
42095
+ case 25:
42096
+ token = dataView.getUint16(position$1);
42097
+ position$1 += 2;
42098
+ break;
42099
+ case 26:
42100
+ token = dataView.getUint32(position$1);
42101
+ position$1 += 4;
42102
+ break;
42103
+ }
42104
+ return token;
42105
+ }
42106
+ function loadShared() {
42107
+ if (currentDecoder.getShared) {
42108
+ let sharedData = saveState(() => {
42109
+ src = null;
42110
+ return currentDecoder.getShared();
42111
+ }) || {};
42112
+ let updatedStructures = sharedData.structures || [];
42113
+ currentDecoder.sharedVersion = sharedData.version;
42114
+ packedValues = currentDecoder.sharedValues = sharedData.packedValues;
42115
+ if (currentStructures === true) currentDecoder.structures = currentStructures = updatedStructures;
42116
+ else currentStructures.splice.apply(currentStructures, [0, updatedStructures.length].concat(updatedStructures));
42117
+ }
42118
+ }
42119
+ function saveState(callback) {
42120
+ let savedSrcEnd = srcEnd;
42121
+ let savedPosition = position$1;
42122
+ let savedStringPosition = stringPosition;
42123
+ let savedSrcStringStart = srcStringStart;
42124
+ let savedSrcStringEnd = srcStringEnd;
42125
+ let savedSrcString = srcString;
42126
+ let savedStrings = strings;
42127
+ let savedReferenceMap = referenceMap;
42128
+ let savedBundledStrings = bundledStrings$1;
42129
+ let savedSrc = new Uint8Array(src.slice(0, srcEnd));
42130
+ let savedStructures = currentStructures;
42131
+ let savedDecoder = currentDecoder;
42132
+ let savedSequentialMode = sequentialMode;
42133
+ let value = callback();
42134
+ srcEnd = savedSrcEnd;
42135
+ position$1 = savedPosition;
42136
+ stringPosition = savedStringPosition;
42137
+ srcStringStart = savedSrcStringStart;
42138
+ srcStringEnd = savedSrcStringEnd;
42139
+ srcString = savedSrcString;
42140
+ strings = savedStrings;
42141
+ referenceMap = savedReferenceMap;
42142
+ bundledStrings$1 = savedBundledStrings;
42143
+ src = savedSrc;
42144
+ sequentialMode = savedSequentialMode;
42145
+ currentStructures = savedStructures;
42146
+ currentDecoder = savedDecoder;
42147
+ dataView = new DataView(src.buffer, src.byteOffset, src.byteLength);
42148
+ return value;
42149
+ }
42150
+ function clearSource() {
42151
+ src = null;
42152
+ referenceMap = null;
42153
+ currentStructures = null;
42154
+ }
42155
+ function addExtension$1(extension) {
42156
+ currentExtensions[extension.tag] = extension.decode;
42157
+ }
42158
+ function setSizeLimits(limits) {
42159
+ if (limits.maxMapSize) maxMapSize = limits.maxMapSize;
42160
+ if (limits.maxArraySize) maxArraySize = limits.maxArraySize;
42161
+ if (limits.maxObjectSize) limits.maxObjectSize;
42162
+ }
42163
+ var mult10 = new Array(147);
42164
+ for (let i = 0; i < 256; i++) mult10[i] = +("1e" + Math.floor(45.15 - i * .30103));
42165
+ var defaultDecoder = new Decoder({ useRecords: false });
42166
+ var decode = defaultDecoder.decode;
42167
+ var decodeMultiple = defaultDecoder.decodeMultiple;
42168
+ var FLOAT32_OPTIONS = {
42169
+ NEVER: 0,
42170
+ ALWAYS: 1,
42171
+ DECIMAL_ROUND: 3,
42172
+ DECIMAL_FIT: 4
42173
+ };
42174
+ function roundFloat32(float32Number) {
42175
+ f32Array[0] = float32Number;
42176
+ let multiplier = mult10[(u8Array[3] & 127) << 1 | u8Array[2] >> 7];
42177
+ return (multiplier * float32Number + (float32Number > 0 ? .5 : -.5) >> 0) / multiplier;
42178
+ }
42179
+ var textEncoder;
42180
+ try {
42181
+ textEncoder = new TextEncoder();
42182
+ } catch (error) {}
42183
+ var extensions, extensionClasses;
42184
+ var Buffer$1 = typeof globalThis === "object" && globalThis.Buffer;
42185
+ var hasNodeBuffer = typeof Buffer$1 !== "undefined";
42186
+ var ByteArrayAllocate = hasNodeBuffer ? Buffer$1.allocUnsafeSlow : Uint8Array;
42187
+ var ByteArray = hasNodeBuffer ? Buffer$1 : Uint8Array;
42188
+ var MAX_STRUCTURES = 256;
42189
+ var MAX_BUFFER_SIZE = hasNodeBuffer ? 4294967296 : 2144337920;
42190
+ var throwOnIterable;
42191
+ var target;
42192
+ var targetView;
42193
+ var position = 0;
42194
+ var safeEnd;
42195
+ var bundledStrings = null;
42196
+ var MAX_BUNDLE_SIZE = 61440;
42197
+ var hasNonLatin = /[\u0080-\uFFFF]/;
42198
+ var RECORD_SYMBOL = Symbol("record-id");
42199
+ var Encoder = class extends Decoder {
42200
+ constructor(options) {
42201
+ super(options);
42202
+ this.offset = 0;
42203
+ let start;
42204
+ let sharedStructures;
42205
+ let hasSharedUpdate;
42206
+ let structures;
42207
+ let referenceMap;
42208
+ options = options || {};
42209
+ let encodeUtf8 = ByteArray.prototype.utf8Write ? function(string, position) {
42210
+ return target.utf8Write(string, position, target.byteLength - position);
42211
+ } : textEncoder && textEncoder.encodeInto ? function(string, position) {
42212
+ return textEncoder.encodeInto(string, target.subarray(position)).written;
42213
+ } : false;
42214
+ let encoder = this;
42215
+ let hasSharedStructures = options.structures || options.saveStructures;
42216
+ let maxSharedStructures = options.maxSharedStructures;
42217
+ if (maxSharedStructures == null) maxSharedStructures = hasSharedStructures ? 128 : 0;
42218
+ if (maxSharedStructures > 8190) throw new Error("Maximum maxSharedStructure is 8190");
42219
+ let isSequential = options.sequential;
42220
+ if (isSequential) maxSharedStructures = 0;
42221
+ if (!this.structures) this.structures = [];
42222
+ if (this.saveStructures) this.saveShared = this.saveStructures;
42223
+ let samplingPackedValues, packedObjectMap, sharedValues = options.sharedValues;
42224
+ let sharedPackedObjectMap;
42225
+ if (sharedValues) {
42226
+ sharedPackedObjectMap = Object.create(null);
42227
+ for (let i = 0, l = sharedValues.length; i < l; i++) sharedPackedObjectMap[sharedValues[i]] = i;
42228
+ }
42229
+ let recordIdsToRemove = [];
42230
+ let transitionsCount = 0;
42231
+ let serializationsSinceTransitionRebuild = 0;
42232
+ this.mapEncode = function(value, encodeOptions) {
42233
+ if (this._keyMap && !this._mapped) switch (value.constructor.name) {
42234
+ case "Array":
42235
+ value = value.map((r) => this.encodeKeys(r));
42236
+ break;
42237
+ }
42238
+ return this.encode(value, encodeOptions);
42239
+ };
42240
+ this.encode = function(value, encodeOptions) {
42241
+ if (!target) {
42242
+ target = new ByteArrayAllocate(8192);
42243
+ targetView = new DataView(target.buffer, 0, 8192);
42244
+ position = 0;
42245
+ }
42246
+ safeEnd = target.length - 10;
42247
+ if (safeEnd - position < 2048) {
42248
+ target = new ByteArrayAllocate(target.length);
42249
+ targetView = new DataView(target.buffer, 0, target.length);
42250
+ safeEnd = target.length - 10;
42251
+ position = 0;
42252
+ } else if (encodeOptions === REUSE_BUFFER_MODE) position = position + 7 & 2147483640;
42253
+ start = position;
42254
+ if (encoder.useSelfDescribedHeader) {
42255
+ targetView.setUint32(position, 3654940416);
42256
+ position += 3;
42257
+ }
42258
+ referenceMap = encoder.structuredClone ? /* @__PURE__ */ new Map() : null;
42259
+ if (encoder.bundleStrings && typeof value !== "string") {
42260
+ bundledStrings = [];
42261
+ bundledStrings.size = Infinity;
42262
+ } else bundledStrings = null;
42263
+ sharedStructures = encoder.structures;
42264
+ if (sharedStructures) {
42265
+ if (sharedStructures.uninitialized) {
42266
+ let sharedData = encoder.getShared() || {};
42267
+ encoder.structures = sharedStructures = sharedData.structures || [];
42268
+ encoder.sharedVersion = sharedData.version;
42269
+ let sharedValues = encoder.sharedValues = sharedData.packedValues;
42270
+ if (sharedValues) {
42271
+ sharedPackedObjectMap = {};
42272
+ for (let i = 0, l = sharedValues.length; i < l; i++) sharedPackedObjectMap[sharedValues[i]] = i;
42273
+ }
42274
+ }
42275
+ let sharedStructuresLength = sharedStructures.length;
42276
+ if (sharedStructuresLength > maxSharedStructures && !isSequential) sharedStructuresLength = maxSharedStructures;
42277
+ if (!sharedStructures.transitions) {
42278
+ sharedStructures.transitions = Object.create(null);
42279
+ for (let i = 0; i < sharedStructuresLength; i++) {
42280
+ let keys = sharedStructures[i];
42281
+ if (!keys) continue;
42282
+ let nextTransition, transition = sharedStructures.transitions;
42283
+ for (let j = 0, l = keys.length; j < l; j++) {
42284
+ if (transition[RECORD_SYMBOL] === void 0) transition[RECORD_SYMBOL] = i;
42285
+ let key = keys[j];
42286
+ nextTransition = transition[key];
42287
+ if (!nextTransition) nextTransition = transition[key] = Object.create(null);
42288
+ transition = nextTransition;
42289
+ }
42290
+ transition[RECORD_SYMBOL] = i | 1048576;
42291
+ }
42292
+ }
42293
+ if (!isSequential) sharedStructures.nextId = sharedStructuresLength;
42294
+ }
42295
+ if (hasSharedUpdate) hasSharedUpdate = false;
42296
+ structures = sharedStructures || [];
42297
+ packedObjectMap = sharedPackedObjectMap;
42298
+ if (options.pack) {
42299
+ let packedValues = /* @__PURE__ */ new Map();
42300
+ packedValues.values = [];
42301
+ packedValues.encoder = encoder;
42302
+ packedValues.maxValues = options.maxPrivatePackedValues || (sharedPackedObjectMap ? 16 : Infinity);
42303
+ packedValues.objectMap = sharedPackedObjectMap || false;
42304
+ packedValues.samplingPackedValues = samplingPackedValues;
42305
+ findRepetitiveStrings(value, packedValues);
42306
+ if (packedValues.values.length > 0) {
42307
+ target[position++] = 216;
42308
+ target[position++] = 51;
42309
+ writeArrayHeader(4);
42310
+ let valuesArray = packedValues.values;
42311
+ encode(valuesArray);
42312
+ writeArrayHeader(0);
42313
+ writeArrayHeader(0);
42314
+ packedObjectMap = Object.create(sharedPackedObjectMap || null);
42315
+ for (let i = 0, l = valuesArray.length; i < l; i++) packedObjectMap[valuesArray[i]] = i;
42316
+ }
42317
+ }
42318
+ throwOnIterable = encodeOptions & THROW_ON_ITERABLE;
42319
+ try {
42320
+ if (throwOnIterable) return;
42321
+ encode(value);
42322
+ if (bundledStrings) writeBundles(start, encode);
42323
+ encoder.offset = position;
42324
+ if (referenceMap && referenceMap.idsToInsert) {
42325
+ position += referenceMap.idsToInsert.length * 2;
42326
+ if (position > safeEnd) makeRoom(position);
42327
+ encoder.offset = position;
42328
+ let serialized = insertIds(target.subarray(start, position), referenceMap.idsToInsert);
42329
+ referenceMap = null;
42330
+ return serialized;
42331
+ }
42332
+ if (encodeOptions & REUSE_BUFFER_MODE) {
42333
+ target.start = start;
42334
+ target.end = position;
42335
+ return target;
42336
+ }
42337
+ return target.subarray(start, position);
42338
+ } finally {
42339
+ if (sharedStructures) {
42340
+ if (serializationsSinceTransitionRebuild < 10) serializationsSinceTransitionRebuild++;
42341
+ if (sharedStructures.length > maxSharedStructures) sharedStructures.length = maxSharedStructures;
42342
+ if (transitionsCount > 1e4) {
42343
+ sharedStructures.transitions = null;
42344
+ serializationsSinceTransitionRebuild = 0;
42345
+ transitionsCount = 0;
42346
+ if (recordIdsToRemove.length > 0) recordIdsToRemove = [];
42347
+ } else if (recordIdsToRemove.length > 0 && !isSequential) {
42348
+ for (let i = 0, l = recordIdsToRemove.length; i < l; i++) recordIdsToRemove[i][RECORD_SYMBOL] = void 0;
42349
+ recordIdsToRemove = [];
42350
+ }
42351
+ }
42352
+ if (hasSharedUpdate && encoder.saveShared) {
42353
+ if (encoder.structures.length > maxSharedStructures) encoder.structures = encoder.structures.slice(0, maxSharedStructures);
42354
+ let returnBuffer = target.subarray(start, position);
42355
+ if (encoder.updateSharedData() === false) return encoder.encode(value);
42356
+ return returnBuffer;
42357
+ }
42358
+ if (encodeOptions & RESET_BUFFER_MODE) position = start;
42359
+ }
42360
+ };
42361
+ this.findCommonStringsToPack = () => {
42362
+ samplingPackedValues = /* @__PURE__ */ new Map();
42363
+ if (!sharedPackedObjectMap) sharedPackedObjectMap = Object.create(null);
42364
+ return (options) => {
42365
+ let threshold = options && options.threshold || 4;
42366
+ let position = this.pack ? options.maxPrivatePackedValues || 16 : 0;
42367
+ if (!sharedValues) sharedValues = this.sharedValues = [];
42368
+ for (let [key, status] of samplingPackedValues) if (status.count > threshold) {
42369
+ sharedPackedObjectMap[key] = position++;
42370
+ sharedValues.push(key);
42371
+ hasSharedUpdate = true;
42372
+ }
42373
+ while (this.saveShared && this.updateSharedData() === false);
42374
+ samplingPackedValues = null;
42375
+ };
42376
+ };
42377
+ const encode = (value) => {
42378
+ if (position > safeEnd) target = makeRoom(position);
42379
+ var type = typeof value;
42380
+ var length;
42381
+ if (type === "string") {
42382
+ if (packedObjectMap) {
42383
+ let packedPosition = packedObjectMap[value];
42384
+ if (packedPosition >= 0) {
42385
+ if (packedPosition < 16) target[position++] = packedPosition + 224;
42386
+ else {
42387
+ target[position++] = 198;
42388
+ if (packedPosition & 1) encode(15 - packedPosition >> 1);
42389
+ else encode(packedPosition - 16 >> 1);
42390
+ }
42391
+ return;
42392
+ } else if (samplingPackedValues && !options.pack) {
42393
+ let status = samplingPackedValues.get(value);
42394
+ if (status) status.count++;
42395
+ else samplingPackedValues.set(value, { count: 1 });
42396
+ }
42397
+ }
42398
+ let strLength = value.length;
42399
+ if (bundledStrings && strLength >= 4 && strLength < 1024) {
42400
+ if ((bundledStrings.size += strLength) > MAX_BUNDLE_SIZE) {
42401
+ let extStart;
42402
+ let maxBytes = (bundledStrings[0] ? bundledStrings[0].length * 3 + bundledStrings[1].length : 0) + 10;
42403
+ if (position + maxBytes > safeEnd) target = makeRoom(position + maxBytes);
42404
+ target[position++] = 217;
42405
+ target[position++] = 223;
42406
+ target[position++] = 249;
42407
+ target[position++] = bundledStrings.position ? 132 : 130;
42408
+ target[position++] = 26;
42409
+ extStart = position - start;
42410
+ position += 4;
42411
+ if (bundledStrings.position) writeBundles(start, encode);
42412
+ bundledStrings = ["", ""];
42413
+ bundledStrings.size = 0;
42414
+ bundledStrings.position = extStart;
42415
+ }
42416
+ let twoByte = hasNonLatin.test(value);
42417
+ bundledStrings[twoByte ? 0 : 1] += value;
42418
+ target[position++] = twoByte ? 206 : 207;
42419
+ encode(strLength);
42420
+ return;
42421
+ }
42422
+ let headerSize;
42423
+ if (strLength < 32) headerSize = 1;
42424
+ else if (strLength < 256) headerSize = 2;
42425
+ else if (strLength < 65536) headerSize = 3;
42426
+ else headerSize = 5;
42427
+ let maxBytes = strLength * 3;
42428
+ if (position + maxBytes > safeEnd) target = makeRoom(position + maxBytes);
42429
+ if (strLength < 64 || !encodeUtf8) {
42430
+ let i, c1, c2, strPosition = position + headerSize;
42431
+ for (i = 0; i < strLength; i++) {
42432
+ c1 = value.charCodeAt(i);
42433
+ if (c1 < 128) target[strPosition++] = c1;
42434
+ else if (c1 < 2048) {
42435
+ target[strPosition++] = c1 >> 6 | 192;
42436
+ target[strPosition++] = c1 & 63 | 128;
42437
+ } else if ((c1 & 64512) === 55296 && ((c2 = value.charCodeAt(i + 1)) & 64512) === 56320) {
42438
+ c1 = 65536 + ((c1 & 1023) << 10) + (c2 & 1023);
42439
+ i++;
42440
+ target[strPosition++] = c1 >> 18 | 240;
42441
+ target[strPosition++] = c1 >> 12 & 63 | 128;
42442
+ target[strPosition++] = c1 >> 6 & 63 | 128;
42443
+ target[strPosition++] = c1 & 63 | 128;
42444
+ } else {
42445
+ target[strPosition++] = c1 >> 12 | 224;
42446
+ target[strPosition++] = c1 >> 6 & 63 | 128;
42447
+ target[strPosition++] = c1 & 63 | 128;
42448
+ }
42449
+ }
42450
+ length = strPosition - position - headerSize;
42451
+ } else length = encodeUtf8(value, position + headerSize, maxBytes);
42452
+ if (length < 24) target[position++] = 96 | length;
42453
+ else if (length < 256) {
42454
+ if (headerSize < 2) target.copyWithin(position + 2, position + 1, position + 1 + length);
42455
+ target[position++] = 120;
42456
+ target[position++] = length;
42457
+ } else if (length < 65536) {
42458
+ if (headerSize < 3) target.copyWithin(position + 3, position + 2, position + 2 + length);
42459
+ target[position++] = 121;
42460
+ target[position++] = length >> 8;
42461
+ target[position++] = length & 255;
42462
+ } else {
42463
+ if (headerSize < 5) target.copyWithin(position + 5, position + 3, position + 3 + length);
42464
+ target[position++] = 122;
42465
+ targetView.setUint32(position, length);
42466
+ position += 4;
42467
+ }
42468
+ position += length;
42469
+ } else if (type === "number") if (!this.alwaysUseFloat && value >>> 0 === value) if (value < 24) target[position++] = value;
42470
+ else if (value < 256) {
42471
+ target[position++] = 24;
42472
+ target[position++] = value;
42473
+ } else if (value < 65536) {
42474
+ target[position++] = 25;
42475
+ target[position++] = value >> 8;
42476
+ target[position++] = value & 255;
42477
+ } else {
42478
+ target[position++] = 26;
42479
+ targetView.setUint32(position, value);
42480
+ position += 4;
42481
+ }
42482
+ else if (!this.alwaysUseFloat && value >> 0 === value) if (value >= -24) target[position++] = 31 - value;
42483
+ else if (value >= -256) {
42484
+ target[position++] = 56;
42485
+ target[position++] = ~value;
42486
+ } else if (value >= -65536) {
42487
+ target[position++] = 57;
42488
+ targetView.setUint16(position, ~value);
42489
+ position += 2;
42490
+ } else {
42491
+ target[position++] = 58;
42492
+ targetView.setUint32(position, ~value);
42493
+ position += 4;
42494
+ }
42495
+ else if (!this.alwaysUseFloat && value < 0 && value >= -4294967296 && Math.floor(value) === value) {
42496
+ target[position++] = 58;
42497
+ targetView.setUint32(position, -1 - value);
42498
+ position += 4;
42499
+ } else {
42500
+ let useFloat32;
42501
+ if ((useFloat32 = this.useFloat32) > 0 && value < 4294967296 && value >= -2147483648) {
42502
+ target[position++] = 250;
42503
+ targetView.setFloat32(position, value);
42504
+ let xShifted;
42505
+ if (useFloat32 < 4 || (xShifted = value * mult10[(target[position] & 127) << 1 | target[position + 1] >> 7]) >> 0 === xShifted) {
42506
+ position += 4;
42507
+ return;
42508
+ } else position--;
42509
+ }
42510
+ target[position++] = 251;
42511
+ targetView.setFloat64(position, value);
42512
+ position += 8;
42513
+ }
42514
+ else if (type === "object") if (!value) target[position++] = 246;
42515
+ else {
42516
+ if (referenceMap) {
42517
+ let referee = referenceMap.get(value);
42518
+ if (referee) {
42519
+ target[position++] = 216;
42520
+ target[position++] = 29;
42521
+ target[position++] = 25;
42522
+ if (!referee.references) {
42523
+ let idsToInsert = referenceMap.idsToInsert || (referenceMap.idsToInsert = []);
42524
+ referee.references = [];
42525
+ idsToInsert.push(referee);
42526
+ }
42527
+ referee.references.push(position - start);
42528
+ position += 2;
42529
+ return;
42530
+ } else referenceMap.set(value, { offset: position - start });
42531
+ }
42532
+ let constructor = value.constructor;
42533
+ if (constructor === Object) {
42534
+ if (this.skipFunction === true) value = Object.fromEntries([...Object.keys(value).filter((x) => typeof value[x] !== "function").map((x) => [x, value[x]])]);
42535
+ writeObject(value);
42536
+ } else if (constructor === Array) {
42537
+ length = value.length;
42538
+ if (length < 24) target[position++] = 128 | length;
42539
+ else writeArrayHeader(length);
42540
+ for (let i = 0; i < length; i++) encode(value[i]);
42541
+ } else if (constructor === Map) {
42542
+ if (this.mapsAsObjects ? this.useTag259ForMaps !== false : this.useTag259ForMaps) {
42543
+ target[position++] = 217;
42544
+ target[position++] = 1;
42545
+ target[position++] = 3;
42546
+ }
42547
+ length = value.size;
42548
+ if (length < 24) target[position++] = 160 | length;
42549
+ else if (length < 256) {
42550
+ target[position++] = 184;
42551
+ target[position++] = length;
42552
+ } else if (length < 65536) {
42553
+ target[position++] = 185;
42554
+ target[position++] = length >> 8;
42555
+ target[position++] = length & 255;
42556
+ } else {
42557
+ target[position++] = 186;
42558
+ targetView.setUint32(position, length);
42559
+ position += 4;
42560
+ }
42561
+ if (encoder.keyMap) for (let [key, entryValue] of value) {
42562
+ encode(encoder.encodeKey(key));
42563
+ encode(entryValue);
42564
+ }
42565
+ else for (let [key, entryValue] of value) {
42566
+ encode(key);
42567
+ encode(entryValue);
42568
+ }
42569
+ } else {
42570
+ for (let i = 0, l = extensions.length; i < l; i++) {
42571
+ let extensionClass = extensionClasses[i];
42572
+ if (value instanceof extensionClass) {
42573
+ let extension = extensions[i];
42574
+ let tag = extension.tag;
42575
+ if (tag == void 0) tag = extension.getTag && extension.getTag.call(this, value);
42576
+ if (tag < 24) target[position++] = 192 | tag;
42577
+ else if (tag < 256) {
42578
+ target[position++] = 216;
42579
+ target[position++] = tag;
42580
+ } else if (tag < 65536) {
42581
+ target[position++] = 217;
42582
+ target[position++] = tag >> 8;
42583
+ target[position++] = tag & 255;
42584
+ } else if (tag > -1) {
42585
+ target[position++] = 218;
42586
+ targetView.setUint32(position, tag);
42587
+ position += 4;
42588
+ }
42589
+ extension.encode.call(this, value, encode, makeRoom);
42590
+ return;
42591
+ }
42592
+ }
42593
+ if (value[Symbol.iterator]) {
42594
+ if (throwOnIterable) {
42595
+ let error = /* @__PURE__ */ new Error("Iterable should be serialized as iterator");
42596
+ error.iteratorNotHandled = true;
42597
+ throw error;
42598
+ }
42599
+ target[position++] = 159;
42600
+ for (let entry of value) encode(entry);
42601
+ target[position++] = 255;
42602
+ return;
42603
+ }
42604
+ if (value[Symbol.asyncIterator] || isBlob(value)) {
42605
+ let error = /* @__PURE__ */ new Error("Iterable/blob should be serialized as iterator");
42606
+ error.iteratorNotHandled = true;
42607
+ throw error;
42608
+ }
42609
+ if (this.useToJSON && value.toJSON) {
42610
+ const json = value.toJSON();
42611
+ if (json !== value) return encode(json);
42612
+ }
42613
+ writeObject(value);
42614
+ }
42615
+ }
42616
+ else if (type === "boolean") target[position++] = value ? 245 : 244;
42617
+ else if (type === "bigint") {
42618
+ if (value < BigInt(1) << BigInt(64) && value >= 0) {
42619
+ target[position++] = 27;
42620
+ targetView.setBigUint64(position, value);
42621
+ } else if (value > -(BigInt(1) << BigInt(64)) && value < 0) {
42622
+ target[position++] = 59;
42623
+ targetView.setBigUint64(position, -value - BigInt(1));
42624
+ } else if (this.largeBigIntToFloat) {
42625
+ target[position++] = 251;
42626
+ targetView.setFloat64(position, Number(value));
42627
+ } else {
42628
+ if (value >= BigInt(0)) target[position++] = 194;
42629
+ else {
42630
+ target[position++] = 195;
42631
+ value = BigInt(-1) - value;
42632
+ }
42633
+ let bytes = [];
42634
+ while (value) {
42635
+ bytes.push(Number(value & BigInt(255)));
42636
+ value >>= BigInt(8);
42637
+ }
42638
+ writeBuffer(new Uint8Array(bytes.reverse()), makeRoom);
42639
+ return;
42640
+ }
42641
+ position += 8;
42642
+ } else if (type === "undefined") target[position++] = 247;
42643
+ else throw new Error("Unknown type: " + type);
42644
+ };
42645
+ const writeObject = this.useRecords === false ? this.variableMapSize ? (object) => {
42646
+ let keys = Object.keys(object);
42647
+ let vals = Object.values(object);
42648
+ let length = keys.length;
42649
+ if (length < 24) target[position++] = 160 | length;
42650
+ else if (length < 256) {
42651
+ target[position++] = 184;
42652
+ target[position++] = length;
42653
+ } else if (length < 65536) {
42654
+ target[position++] = 185;
42655
+ target[position++] = length >> 8;
42656
+ target[position++] = length & 255;
42657
+ } else {
42658
+ target[position++] = 186;
42659
+ targetView.setUint32(position, length);
42660
+ position += 4;
42661
+ }
42662
+ if (encoder.keyMap) for (let i = 0; i < length; i++) {
42663
+ encode(encoder.encodeKey(keys[i]));
42664
+ encode(vals[i]);
42665
+ }
42666
+ else for (let i = 0; i < length; i++) {
42667
+ encode(keys[i]);
42668
+ encode(vals[i]);
42669
+ }
42670
+ } : (object) => {
42671
+ target[position++] = 185;
42672
+ let objectOffset = position - start;
42673
+ position += 2;
42674
+ let size = 0;
42675
+ if (encoder.keyMap) {
42676
+ for (let key in object) if (typeof object.hasOwnProperty !== "function" || object.hasOwnProperty(key)) {
42677
+ encode(encoder.encodeKey(key));
42678
+ encode(object[key]);
42679
+ size++;
42680
+ }
42681
+ } else for (let key in object) if (typeof object.hasOwnProperty !== "function" || object.hasOwnProperty(key)) {
42682
+ encode(key);
42683
+ encode(object[key]);
42684
+ size++;
42685
+ }
42686
+ target[objectOffset++ + start] = size >> 8;
42687
+ target[objectOffset + start] = size & 255;
42688
+ } : (object, skipValues) => {
42689
+ let nextTransition, transition = structures.transitions || (structures.transitions = Object.create(null));
42690
+ let newTransitions = 0;
42691
+ let length = 0;
42692
+ let parentRecordId;
42693
+ let keys;
42694
+ if (this.keyMap) {
42695
+ keys = Object.keys(object).map((k) => this.encodeKey(k));
42696
+ length = keys.length;
42697
+ for (let i = 0; i < length; i++) {
42698
+ let key = keys[i];
42699
+ nextTransition = transition[key];
42700
+ if (!nextTransition) {
42701
+ nextTransition = transition[key] = Object.create(null);
42702
+ newTransitions++;
42703
+ }
42704
+ transition = nextTransition;
42705
+ }
42706
+ } else for (let key in object) if (typeof object.hasOwnProperty !== "function" || object.hasOwnProperty(key)) {
42707
+ nextTransition = transition[key];
42708
+ if (!nextTransition) {
42709
+ if (transition[RECORD_SYMBOL] & 1048576) parentRecordId = transition[RECORD_SYMBOL] & 65535;
42710
+ nextTransition = transition[key] = Object.create(null);
42711
+ newTransitions++;
42712
+ }
42713
+ transition = nextTransition;
42714
+ length++;
42715
+ }
42716
+ let recordId = transition[RECORD_SYMBOL];
42717
+ if (recordId !== void 0) {
42718
+ recordId &= 65535;
42719
+ target[position++] = 217;
42720
+ target[position++] = recordId >> 8 | 224;
42721
+ target[position++] = recordId & 255;
42722
+ } else {
42723
+ if (!keys) keys = transition.__keys__ || (transition.__keys__ = Object.keys(object));
42724
+ if (parentRecordId === void 0) {
42725
+ recordId = structures.nextId++;
42726
+ if (!recordId) {
42727
+ recordId = 0;
42728
+ structures.nextId = 1;
42729
+ }
42730
+ if (recordId >= MAX_STRUCTURES) structures.nextId = (recordId = maxSharedStructures) + 1;
42731
+ } else recordId = parentRecordId;
42732
+ structures[recordId] = keys;
42733
+ if (recordId < maxSharedStructures) {
42734
+ target[position++] = 217;
42735
+ target[position++] = recordId >> 8 | 224;
42736
+ target[position++] = recordId & 255;
42737
+ transition = structures.transitions;
42738
+ for (let i = 0; i < length; i++) {
42739
+ if (transition[RECORD_SYMBOL] === void 0 || transition[RECORD_SYMBOL] & 1048576) transition[RECORD_SYMBOL] = recordId;
42740
+ transition = transition[keys[i]];
42741
+ }
42742
+ transition[RECORD_SYMBOL] = recordId | 1048576;
42743
+ hasSharedUpdate = true;
42744
+ } else {
42745
+ transition[RECORD_SYMBOL] = recordId;
42746
+ targetView.setUint32(position, 3655335680);
42747
+ position += 3;
42748
+ if (newTransitions) transitionsCount += serializationsSinceTransitionRebuild * newTransitions;
42749
+ if (recordIdsToRemove.length >= MAX_STRUCTURES - maxSharedStructures) recordIdsToRemove.shift()[RECORD_SYMBOL] = void 0;
42750
+ recordIdsToRemove.push(transition);
42751
+ writeArrayHeader(length + 2);
42752
+ encode(57344 + recordId);
42753
+ encode(keys);
42754
+ if (skipValues) return;
42755
+ for (let key in object) if (typeof object.hasOwnProperty !== "function" || object.hasOwnProperty(key)) encode(object[key]);
42756
+ return;
42757
+ }
42758
+ }
42759
+ if (length < 24) target[position++] = 128 | length;
42760
+ else writeArrayHeader(length);
42761
+ if (skipValues) return;
42762
+ for (let key in object) if (typeof object.hasOwnProperty !== "function" || object.hasOwnProperty(key)) encode(object[key]);
42763
+ };
42764
+ const makeRoom = (end) => {
42765
+ let newSize;
42766
+ if (end > 16777216) {
42767
+ if (end - start > MAX_BUFFER_SIZE) throw new Error("Encoded buffer would be larger than maximum buffer size");
42768
+ newSize = Math.min(MAX_BUFFER_SIZE, Math.round(Math.max((end - start) * (end > 67108864 ? 1.25 : 2), 4194304) / 4096) * 4096);
42769
+ } else newSize = (Math.max(end - start << 2, target.length - 1) >> 12) + 1 << 12;
42770
+ let newBuffer = new ByteArrayAllocate(newSize);
42771
+ targetView = new DataView(newBuffer.buffer, 0, newSize);
42772
+ if (target.copy) target.copy(newBuffer, 0, start, end);
42773
+ else newBuffer.set(target.slice(start, end));
42774
+ position -= start;
42775
+ start = 0;
42776
+ safeEnd = newBuffer.length - 10;
42777
+ return target = newBuffer;
42778
+ };
42779
+ let chunkThreshold = 100;
42780
+ let continuedChunkThreshold = 1e3;
42781
+ this.encodeAsIterable = function(value, options) {
42782
+ return startEncoding(value, options, encodeObjectAsIterable);
42783
+ };
42784
+ this.encodeAsAsyncIterable = function(value, options) {
42785
+ return startEncoding(value, options, encodeObjectAsAsyncIterable);
42786
+ };
42787
+ function* encodeObjectAsIterable(object, iterateProperties, finalIterable) {
42788
+ let constructor = object.constructor;
42789
+ if (constructor === Object) {
42790
+ let useRecords = encoder.useRecords !== false;
42791
+ if (useRecords) writeObject(object, true);
42792
+ else writeEntityLength(Object.keys(object).length, 160);
42793
+ for (let key in object) {
42794
+ let value = object[key];
42795
+ if (!useRecords) encode(key);
42796
+ if (value && typeof value === "object") if (iterateProperties[key]) yield* encodeObjectAsIterable(value, iterateProperties[key]);
42797
+ else yield* tryEncode(value, iterateProperties, key);
42798
+ else encode(value);
42799
+ }
42800
+ } else if (constructor === Array) {
42801
+ let length = object.length;
42802
+ writeArrayHeader(length);
42803
+ for (let i = 0; i < length; i++) {
42804
+ let value = object[i];
42805
+ if (value && (typeof value === "object" || position - start > chunkThreshold)) if (iterateProperties.element) yield* encodeObjectAsIterable(value, iterateProperties.element);
42806
+ else yield* tryEncode(value, iterateProperties, "element");
42807
+ else encode(value);
42808
+ }
42809
+ } else if (object[Symbol.iterator] && !object.buffer) {
42810
+ target[position++] = 159;
42811
+ for (let value of object) if (value && (typeof value === "object" || position - start > chunkThreshold)) if (iterateProperties.element) yield* encodeObjectAsIterable(value, iterateProperties.element);
42812
+ else yield* tryEncode(value, iterateProperties, "element");
42813
+ else encode(value);
42814
+ target[position++] = 255;
42815
+ } else if (isBlob(object)) {
42816
+ writeEntityLength(object.size, 64);
42817
+ yield target.subarray(start, position);
42818
+ yield object;
42819
+ restartEncoding();
42820
+ } else if (object[Symbol.asyncIterator]) {
42821
+ target[position++] = 159;
42822
+ yield target.subarray(start, position);
42823
+ yield object;
42824
+ restartEncoding();
42825
+ target[position++] = 255;
42826
+ } else encode(object);
42827
+ if (finalIterable && position > start) yield target.subarray(start, position);
42828
+ else if (position - start > chunkThreshold) {
42829
+ yield target.subarray(start, position);
42830
+ restartEncoding();
42831
+ }
42832
+ }
42833
+ function* tryEncode(value, iterateProperties, key) {
42834
+ let restart = position - start;
42835
+ try {
42836
+ encode(value);
42837
+ if (position - start > chunkThreshold) {
42838
+ yield target.subarray(start, position);
42839
+ restartEncoding();
42840
+ }
42841
+ } catch (error) {
42842
+ if (error.iteratorNotHandled) {
42843
+ iterateProperties[key] = {};
42844
+ position = start + restart;
42845
+ yield* encodeObjectAsIterable.call(this, value, iterateProperties[key]);
42846
+ } else throw error;
42847
+ }
42848
+ }
42849
+ function restartEncoding() {
42850
+ chunkThreshold = continuedChunkThreshold;
42851
+ encoder.encode(null, THROW_ON_ITERABLE);
42852
+ }
42853
+ function startEncoding(value, options, encodeIterable) {
42854
+ if (options && options.chunkThreshold) chunkThreshold = continuedChunkThreshold = options.chunkThreshold;
42855
+ else chunkThreshold = 100;
42856
+ if (value && typeof value === "object") {
42857
+ encoder.encode(null, THROW_ON_ITERABLE);
42858
+ return encodeIterable(value, encoder.iterateProperties || (encoder.iterateProperties = {}), true);
42859
+ }
42860
+ return [encoder.encode(value)];
42861
+ }
42862
+ async function* encodeObjectAsAsyncIterable(value, iterateProperties) {
42863
+ for (let encodedValue of encodeObjectAsIterable(value, iterateProperties, true)) {
42864
+ let constructor = encodedValue.constructor;
42865
+ if (constructor === ByteArray || constructor === Uint8Array) yield encodedValue;
42866
+ else if (isBlob(encodedValue)) {
42867
+ let reader = encodedValue.stream().getReader();
42868
+ let next;
42869
+ while (!(next = await reader.read()).done) yield next.value;
42870
+ } else if (encodedValue[Symbol.asyncIterator]) for await (let asyncValue of encodedValue) {
42871
+ restartEncoding();
42872
+ if (asyncValue) yield* encodeObjectAsAsyncIterable(asyncValue, iterateProperties.async || (iterateProperties.async = {}));
42873
+ else yield encoder.encode(asyncValue);
42874
+ }
42875
+ else yield encodedValue;
42876
+ }
42877
+ }
42878
+ }
42879
+ useBuffer(buffer) {
42880
+ target = buffer;
42881
+ targetView = new DataView(target.buffer, target.byteOffset, target.byteLength);
42882
+ position = 0;
42883
+ }
42884
+ clearSharedData() {
42885
+ if (this.structures) this.structures = [];
42886
+ if (this.sharedValues) this.sharedValues = void 0;
42887
+ }
42888
+ updateSharedData() {
42889
+ let lastVersion = this.sharedVersion || 0;
42890
+ this.sharedVersion = lastVersion + 1;
42891
+ let structuresCopy = this.structures.slice(0);
42892
+ let sharedData = new SharedData(structuresCopy, this.sharedValues, this.sharedVersion);
42893
+ let saveResults = this.saveShared(sharedData, (existingShared) => (existingShared && existingShared.version || 0) == lastVersion);
42894
+ if (saveResults === false) {
42895
+ sharedData = this.getShared() || {};
42896
+ this.structures = sharedData.structures || [];
42897
+ this.sharedValues = sharedData.packedValues;
42898
+ this.sharedVersion = sharedData.version;
42899
+ this.structures.nextId = this.structures.length;
42900
+ } else structuresCopy.forEach((structure, i) => this.structures[i] = structure);
42901
+ return saveResults;
42902
+ }
42903
+ };
42904
+ function writeEntityLength(length, majorValue) {
42905
+ if (length < 24) target[position++] = majorValue | length;
42906
+ else if (length < 256) {
42907
+ target[position++] = majorValue | 24;
42908
+ target[position++] = length;
42909
+ } else if (length < 65536) {
42910
+ target[position++] = majorValue | 25;
42911
+ target[position++] = length >> 8;
42912
+ target[position++] = length & 255;
42913
+ } else {
42914
+ target[position++] = majorValue | 26;
42915
+ targetView.setUint32(position, length);
42916
+ position += 4;
42917
+ }
42918
+ }
42919
+ var SharedData = class {
42920
+ constructor(structures, values, version) {
42921
+ this.structures = structures;
42922
+ this.packedValues = values;
42923
+ this.version = version;
42924
+ }
42925
+ };
42926
+ function writeArrayHeader(length) {
42927
+ if (length < 24) target[position++] = 128 | length;
42928
+ else if (length < 256) {
42929
+ target[position++] = 152;
42930
+ target[position++] = length;
42931
+ } else if (length < 65536) {
42932
+ target[position++] = 153;
42933
+ target[position++] = length >> 8;
42934
+ target[position++] = length & 255;
42935
+ } else {
42936
+ target[position++] = 154;
42937
+ targetView.setUint32(position, length);
42938
+ position += 4;
42939
+ }
42940
+ }
42941
+ var BlobConstructor = typeof Blob === "undefined" ? function() {} : Blob;
42942
+ function isBlob(object) {
42943
+ if (object instanceof BlobConstructor) return true;
42944
+ let tag = object[Symbol.toStringTag];
42945
+ return tag === "Blob" || tag === "File";
42946
+ }
42947
+ function findRepetitiveStrings(value, packedValues) {
42948
+ switch (typeof value) {
42949
+ case "string":
42950
+ if (value.length > 3) {
42951
+ if (packedValues.objectMap[value] > -1 || packedValues.values.length >= packedValues.maxValues) return;
42952
+ let packedStatus = packedValues.get(value);
42953
+ if (packedStatus) {
42954
+ if (++packedStatus.count == 2) packedValues.values.push(value);
42955
+ } else {
42956
+ packedValues.set(value, { count: 1 });
42957
+ if (packedValues.samplingPackedValues) {
42958
+ let status = packedValues.samplingPackedValues.get(value);
42959
+ if (status) status.count++;
42960
+ else packedValues.samplingPackedValues.set(value, { count: 1 });
42961
+ }
42962
+ }
42963
+ }
42964
+ break;
42965
+ case "object":
42966
+ if (value) if (value instanceof Array) for (let i = 0, l = value.length; i < l; i++) findRepetitiveStrings(value[i], packedValues);
42967
+ else {
42968
+ let includeKeys = !packedValues.encoder.useRecords;
42969
+ for (var key in value) if (value.hasOwnProperty(key)) {
42970
+ if (includeKeys) findRepetitiveStrings(key, packedValues);
42971
+ findRepetitiveStrings(value[key], packedValues);
42972
+ }
42973
+ }
42974
+ break;
42975
+ case "function": console.log(value);
42976
+ }
42977
+ }
42978
+ var isLittleEndianMachine = new Uint8Array(new Uint16Array([1]).buffer)[0] == 1;
42979
+ extensionClasses = [
42980
+ Date,
42981
+ Set,
42982
+ Error,
42983
+ RegExp,
42984
+ Tag,
42985
+ ArrayBuffer,
42986
+ Uint8Array,
42987
+ Uint8ClampedArray,
42988
+ Uint16Array,
42989
+ Uint32Array,
42990
+ typeof BigUint64Array == "undefined" ? function() {} : BigUint64Array,
42991
+ Int8Array,
42992
+ Int16Array,
42993
+ Int32Array,
42994
+ typeof BigInt64Array == "undefined" ? function() {} : BigInt64Array,
42995
+ Float32Array,
42996
+ Float64Array,
42997
+ SharedData
42998
+ ];
42999
+ extensions = [
43000
+ {
43001
+ tag: 1,
43002
+ encode(date, encode) {
43003
+ let seconds = date.getTime() / 1e3;
43004
+ if ((this.useTimestamp32 || date.getMilliseconds() === 0) && seconds >= 0 && seconds < 4294967296) {
43005
+ target[position++] = 26;
43006
+ targetView.setUint32(position, seconds);
43007
+ position += 4;
43008
+ } else {
43009
+ target[position++] = 251;
43010
+ targetView.setFloat64(position, seconds);
43011
+ position += 8;
43012
+ }
43013
+ }
43014
+ },
43015
+ {
43016
+ tag: 258,
43017
+ encode(set, encode) {
43018
+ encode(Array.from(set));
43019
+ }
43020
+ },
43021
+ {
43022
+ tag: 27,
43023
+ encode(error, encode) {
43024
+ encode([error.name, error.message]);
43025
+ }
43026
+ },
43027
+ {
43028
+ tag: 27,
43029
+ encode(regex, encode) {
43030
+ encode([
43031
+ "RegExp",
43032
+ regex.source,
43033
+ regex.flags
43034
+ ]);
43035
+ }
43036
+ },
43037
+ {
43038
+ getTag(tag) {
43039
+ return tag.tag;
43040
+ },
43041
+ encode(tag, encode) {
43042
+ encode(tag.value);
43043
+ }
43044
+ },
43045
+ { encode(arrayBuffer, encode, makeRoom) {
43046
+ writeBuffer(arrayBuffer, makeRoom);
43047
+ } },
43048
+ {
43049
+ getTag(typedArray) {
43050
+ if (typedArray.constructor === Uint8Array) {
43051
+ if (this.tagUint8Array || hasNodeBuffer && this.tagUint8Array !== false) return 64;
43052
+ }
43053
+ },
43054
+ encode(typedArray, encode, makeRoom) {
43055
+ writeBuffer(typedArray, makeRoom);
43056
+ }
43057
+ },
43058
+ typedArrayEncoder(68, 1),
43059
+ typedArrayEncoder(69, 2),
43060
+ typedArrayEncoder(70, 4),
43061
+ typedArrayEncoder(71, 8),
43062
+ typedArrayEncoder(72, 1),
43063
+ typedArrayEncoder(77, 2),
43064
+ typedArrayEncoder(78, 4),
43065
+ typedArrayEncoder(79, 8),
43066
+ typedArrayEncoder(85, 4),
43067
+ typedArrayEncoder(86, 8),
43068
+ { encode(sharedData, encode) {
43069
+ let packedValues = sharedData.packedValues || [];
43070
+ let sharedStructures = sharedData.structures || [];
43071
+ if (packedValues.values.length > 0) {
43072
+ target[position++] = 216;
43073
+ target[position++] = 51;
43074
+ writeArrayHeader(4);
43075
+ let valuesArray = packedValues.values;
43076
+ encode(valuesArray);
43077
+ writeArrayHeader(0);
43078
+ writeArrayHeader(0);
43079
+ packedObjectMap = Object.create(sharedPackedObjectMap || null);
43080
+ for (let i = 0, l = valuesArray.length; i < l; i++) packedObjectMap[valuesArray[i]] = i;
43081
+ }
43082
+ if (sharedStructures) {
43083
+ targetView.setUint32(position, 3655335424);
43084
+ position += 3;
43085
+ let definitions = sharedStructures.slice(0);
43086
+ definitions.unshift(57344);
43087
+ definitions.push(new Tag(sharedData.version, 1399353956));
43088
+ encode(definitions);
43089
+ } else encode(new Tag(sharedData.version, 1399353956));
43090
+ } }
43091
+ ];
43092
+ function typedArrayEncoder(tag, size) {
43093
+ if (!isLittleEndianMachine && size > 1) tag -= 4;
43094
+ return {
43095
+ tag,
43096
+ encode: function writeExtBuffer(typedArray, encode) {
43097
+ let length = typedArray.byteLength;
43098
+ let offset = typedArray.byteOffset || 0;
43099
+ let buffer = typedArray.buffer || typedArray;
43100
+ encode(hasNodeBuffer ? Buffer$1.from(buffer, offset, length) : new Uint8Array(buffer, offset, length));
43101
+ }
43102
+ };
43103
+ }
43104
+ function writeBuffer(buffer, makeRoom) {
43105
+ let length = buffer.byteLength;
43106
+ if (length < 24) target[position++] = 64 + length;
43107
+ else if (length < 256) {
43108
+ target[position++] = 88;
43109
+ target[position++] = length;
43110
+ } else if (length < 65536) {
43111
+ target[position++] = 89;
43112
+ target[position++] = length >> 8;
43113
+ target[position++] = length & 255;
43114
+ } else {
43115
+ target[position++] = 90;
43116
+ targetView.setUint32(position, length);
43117
+ position += 4;
43118
+ }
43119
+ if (position + length >= target.length) makeRoom(position + length);
43120
+ target.set(buffer.buffer ? buffer : new Uint8Array(buffer), position);
43121
+ position += length;
43122
+ }
43123
+ function insertIds(serialized, idsToInsert) {
43124
+ let nextId;
43125
+ let distanceToMove = idsToInsert.length * 2;
43126
+ let lastEnd = serialized.length - distanceToMove;
43127
+ idsToInsert.sort((a, b) => a.offset > b.offset ? 1 : -1);
43128
+ for (let id = 0; id < idsToInsert.length; id++) {
43129
+ let referee = idsToInsert[id];
43130
+ referee.id = id;
43131
+ for (let position of referee.references) {
43132
+ serialized[position++] = id >> 8;
43133
+ serialized[position] = id & 255;
43134
+ }
43135
+ }
43136
+ while (nextId = idsToInsert.pop()) {
43137
+ let offset = nextId.offset;
43138
+ serialized.copyWithin(offset + distanceToMove, offset, lastEnd);
43139
+ distanceToMove -= 2;
43140
+ let position = offset + distanceToMove;
43141
+ serialized[position++] = 216;
43142
+ serialized[position++] = 28;
43143
+ lastEnd = offset;
43144
+ }
43145
+ return serialized;
43146
+ }
43147
+ function writeBundles(start, encode) {
43148
+ targetView.setUint32(bundledStrings.position + start, position - bundledStrings.position - start + 1);
43149
+ let writeStrings = bundledStrings;
43150
+ bundledStrings = null;
43151
+ encode(writeStrings[0]);
43152
+ encode(writeStrings[1]);
43153
+ }
43154
+ function addExtension(extension) {
43155
+ if (extension.Class) {
43156
+ if (!extension.encode) throw new Error("Extension has no encode function");
43157
+ extensionClasses.unshift(extension.Class);
43158
+ extensions.unshift(extension);
43159
+ }
43160
+ addExtension$1(extension);
43161
+ }
43162
+ var defaultEncoder = new Encoder({ useRecords: false });
43163
+ var encode = defaultEncoder.encode;
43164
+ var encodeAsIterable = defaultEncoder.encodeAsIterable;
43165
+ var encodeAsAsyncIterable = defaultEncoder.encodeAsAsyncIterable;
43166
+ var { NEVER, ALWAYS, DECIMAL_ROUND, DECIMAL_FIT } = FLOAT32_OPTIONS;
43167
+ var REUSE_BUFFER_MODE = 512;
43168
+ var RESET_BUFFER_MODE = 1024;
43169
+ var THROW_ON_ITERABLE = 2048;
43170
+ var EncoderStream = class extends stream$1.Transform {
43171
+ constructor(options) {
43172
+ if (!options) options = {};
43173
+ options.writableObjectMode = true;
43174
+ super(options);
43175
+ options.sequential = true;
43176
+ this.encoder = options.encoder || new Encoder(options);
43177
+ }
43178
+ async _transform(value, encoding, callback) {
43179
+ try {
43180
+ for await (let chunk of this.encoder.encodeAsAsyncIterable(value)) this.push(chunk);
43181
+ callback();
43182
+ } catch (error) {
43183
+ callback(error);
43184
+ }
43185
+ }
43186
+ };
43187
+ var DecoderStream = class extends stream$1.Transform {
43188
+ constructor(options) {
43189
+ if (!options) options = {};
43190
+ options.objectMode = true;
43191
+ super(options);
43192
+ options.structures = [];
43193
+ this.decoder = options.decoder || new Decoder(options);
43194
+ }
43195
+ _transform(chunk, encoding, callback) {
43196
+ if (this.incompleteBuffer) {
43197
+ chunk = Buffer.concat([this.incompleteBuffer, chunk]);
43198
+ this.incompleteBuffer = null;
43199
+ }
43200
+ let values;
43201
+ try {
43202
+ values = this.decoder.decodeMultiple(chunk);
43203
+ } catch (error) {
43204
+ if (error.incomplete) {
43205
+ this.incompleteBuffer = chunk.slice(error.lastPosition);
43206
+ values = error.values;
43207
+ } else return callback(error);
43208
+ } finally {
43209
+ for (let value of values || []) {
43210
+ if (value === null) value = this.getNullValue();
43211
+ this.push(value);
43212
+ }
43213
+ }
43214
+ callback();
43215
+ }
43216
+ getNullValue() {
43217
+ return Symbol.for(null);
43218
+ }
43219
+ };
43220
+ /**
43221
+ * Given an Iterable first argument, returns an Iterable where each value is encoded as a Buffer
43222
+ * If the argument is only Async Iterable, the return value will be an Async Iterable.
43223
+ * @param {Iterable|Iterator|AsyncIterable|AsyncIterator} objectIterator - iterable source, like a Readable object stream, an array, Set, or custom object
43224
+ * @param {options} [options] - cbor-x Encoder options
43225
+ * @returns {IterableIterator|Promise.<AsyncIterableIterator>}
43226
+ */
43227
+ function encodeIter(objectIterator, options = {}) {
43228
+ if (!objectIterator || typeof objectIterator !== "object") throw new Error("first argument must be an Iterable, Async Iterable, or a Promise for an Async Iterable");
43229
+ else if (typeof objectIterator[Symbol.iterator] === "function") return encodeIterSync(objectIterator, options);
43230
+ else if (typeof objectIterator.then === "function" || typeof objectIterator[Symbol.asyncIterator] === "function") return encodeIterAsync(objectIterator, options);
43231
+ else throw new Error("first argument must be an Iterable, Async Iterable, Iterator, Async Iterator, or a Promise");
43232
+ }
43233
+ function* encodeIterSync(objectIterator, options) {
43234
+ const encoder = new Encoder(options);
43235
+ for (const value of objectIterator) yield encoder.encode(value);
43236
+ }
43237
+ async function* encodeIterAsync(objectIterator, options) {
43238
+ const encoder = new Encoder(options);
43239
+ for await (const value of objectIterator) yield encoder.encode(value);
43240
+ }
43241
+ /**
43242
+ * Given an Iterable/Iterator input which yields buffers, returns an IterableIterator which yields sync decoded objects
43243
+ * Or, given an Async Iterable/Iterator which yields promises resolving in buffers, returns an AsyncIterableIterator.
43244
+ * @param {Iterable|Iterator|AsyncIterable|AsyncIterableIterator} bufferIterator
43245
+ * @param {object} [options] - Decoder options
43246
+ * @returns {IterableIterator|Promise.<AsyncIterableIterator}
43247
+ */
43248
+ function decodeIter(bufferIterator, options = {}) {
43249
+ if (!bufferIterator || typeof bufferIterator !== "object") throw new Error("first argument must be an Iterable, Async Iterable, Iterator, Async Iterator, or a promise");
43250
+ const decoder = new Decoder(options);
43251
+ let incomplete;
43252
+ const parser = (chunk) => {
43253
+ let yields;
43254
+ if (incomplete) {
43255
+ chunk = Buffer.concat([incomplete, chunk]);
43256
+ incomplete = void 0;
43257
+ }
43258
+ try {
43259
+ yields = decoder.decodeMultiple(chunk);
43260
+ } catch (err) {
43261
+ if (err.incomplete) {
43262
+ incomplete = chunk.slice(err.lastPosition);
43263
+ yields = err.values;
43264
+ } else throw err;
43265
+ }
43266
+ return yields;
43267
+ };
43268
+ if (typeof bufferIterator[Symbol.iterator] === "function") return (function* iter() {
43269
+ for (const value of bufferIterator) yield* parser(value);
43270
+ })();
43271
+ else if (typeof bufferIterator[Symbol.asyncIterator] === "function") return (async function* iter() {
43272
+ for await (const value of bufferIterator) yield* parser(value);
43273
+ })();
43274
+ }
43275
+ var useRecords = false;
43276
+ var mapsAsObjects = true;
43277
+ if (!(process.env.CBOR_NATIVE_ACCELERATION_DISABLED !== void 0 && process.env.CBOR_NATIVE_ACCELERATION_DISABLED.toLowerCase() === "true")) {
43278
+ let extractor;
43279
+ try {
43280
+ if (typeof require == "function") extractor = require_cbor_extract();
43281
+ else extractor = module$1$1.createRequire(typeof document === "undefined" ? require("url").pathToFileURL(__filename).href : _documentCurrentScript && _documentCurrentScript.tagName.toUpperCase() === "SCRIPT" && _documentCurrentScript.src || new URL("node.cjs", document.baseURI).href)("cbor-extract");
43282
+ if (extractor) setExtractor(extractor.extractStrings);
43283
+ } catch (error) {}
43284
+ }
43285
+ exports.ALWAYS = ALWAYS;
43286
+ exports.DECIMAL_FIT = DECIMAL_FIT;
43287
+ exports.DECIMAL_ROUND = DECIMAL_ROUND;
43288
+ exports.Decoder = Decoder;
43289
+ exports.DecoderStream = DecoderStream;
43290
+ exports.Encoder = Encoder;
43291
+ exports.EncoderStream = EncoderStream;
43292
+ exports.FLOAT32_OPTIONS = FLOAT32_OPTIONS;
43293
+ exports.NEVER = NEVER;
43294
+ exports.REUSE_BUFFER_MODE = REUSE_BUFFER_MODE;
43295
+ exports.Tag = Tag;
43296
+ exports.addExtension = addExtension;
43297
+ exports.clearSource = clearSource;
43298
+ exports.decode = decode;
43299
+ exports.decodeIter = decodeIter;
43300
+ exports.decodeMultiple = decodeMultiple;
43301
+ exports.encode = encode;
43302
+ exports.encodeAsAsyncIterable = encodeAsAsyncIterable;
43303
+ exports.encodeAsIterable = encodeAsIterable;
43304
+ exports.encodeIter = encodeIter;
43305
+ exports.mapsAsObjects = mapsAsObjects;
43306
+ exports.roundFloat32 = roundFloat32;
43307
+ exports.setSizeLimits = setSizeLimits;
43308
+ exports.useRecords = useRecords;
40700
43309
  }));
40701
43310
  //#endregion
40702
43311
  //#region ../../node_modules/moleculer/src/serializers/cbor.js
@@ -40746,7 +43355,7 @@ var require_cbor = /* @__PURE__ */ require_chunk.__commonJSMin(((exports, module
40746
43355
  init(broker) {
40747
43356
  super.init(broker);
40748
43357
  try {
40749
- const Cbor = (init___vite_optional_peer_dep_cbor_x_moleculer(), require_chunk.__toCommonJS(__vite_optional_peer_dep_cbor_x_moleculer_exports));
43358
+ const Cbor = require_node$2();
40750
43359
  this.encoder = new Cbor.Encoder(this.opts);
40751
43360
  } catch (err) {
40752
43361
  /* istanbul ignore next */
@@ -46334,13 +48943,13 @@ var require_graceful_fs = /* @__PURE__ */ require_chunk.__commonJSMin(((exports,
46334
48943
  module.exports = patch(fs$15);
46335
48944
  fs$15.__patched = true;
46336
48945
  }
46337
- function patch(fs$23) {
46338
- polyfills(fs$23);
46339
- fs$23.gracefulify = patch;
46340
- fs$23.createReadStream = createReadStream;
46341
- fs$23.createWriteStream = createWriteStream;
46342
- var fs$readFile = fs$23.readFile;
46343
- fs$23.readFile = readFile;
48946
+ function patch(fs$25) {
48947
+ polyfills(fs$25);
48948
+ fs$25.gracefulify = patch;
48949
+ fs$25.createReadStream = createReadStream;
48950
+ fs$25.createWriteStream = createWriteStream;
48951
+ var fs$readFile = fs$25.readFile;
48952
+ fs$25.readFile = readFile;
46344
48953
  function readFile(path, options, cb) {
46345
48954
  if (typeof options === "function") cb = options, options = null;
46346
48955
  return go$readFile(path, options, cb);
@@ -46361,8 +48970,8 @@ var require_graceful_fs = /* @__PURE__ */ require_chunk.__commonJSMin(((exports,
46361
48970
  });
46362
48971
  }
46363
48972
  }
46364
- var fs$writeFile = fs$23.writeFile;
46365
- fs$23.writeFile = writeFile;
48973
+ var fs$writeFile = fs$25.writeFile;
48974
+ fs$25.writeFile = writeFile;
46366
48975
  function writeFile(path, data, options, cb) {
46367
48976
  if (typeof options === "function") cb = options, options = null;
46368
48977
  return go$writeFile(path, data, options, cb);
@@ -46384,8 +48993,8 @@ var require_graceful_fs = /* @__PURE__ */ require_chunk.__commonJSMin(((exports,
46384
48993
  });
46385
48994
  }
46386
48995
  }
46387
- var fs$appendFile = fs$23.appendFile;
46388
- if (fs$appendFile) fs$23.appendFile = appendFile;
48996
+ var fs$appendFile = fs$25.appendFile;
48997
+ if (fs$appendFile) fs$25.appendFile = appendFile;
46389
48998
  function appendFile(path, data, options, cb) {
46390
48999
  if (typeof options === "function") cb = options, options = null;
46391
49000
  return go$appendFile(path, data, options, cb);
@@ -46407,8 +49016,8 @@ var require_graceful_fs = /* @__PURE__ */ require_chunk.__commonJSMin(((exports,
46407
49016
  });
46408
49017
  }
46409
49018
  }
46410
- var fs$copyFile = fs$23.copyFile;
46411
- if (fs$copyFile) fs$23.copyFile = copyFile;
49019
+ var fs$copyFile = fs$25.copyFile;
49020
+ if (fs$copyFile) fs$25.copyFile = copyFile;
46412
49021
  function copyFile(src, dest, flags, cb) {
46413
49022
  if (typeof flags === "function") {
46414
49023
  cb = flags;
@@ -46433,8 +49042,8 @@ var require_graceful_fs = /* @__PURE__ */ require_chunk.__commonJSMin(((exports,
46433
49042
  });
46434
49043
  }
46435
49044
  }
46436
- var fs$readdir = fs$23.readdir;
46437
- fs$23.readdir = readdir;
49045
+ var fs$readdir = fs$25.readdir;
49046
+ fs$25.readdir = readdir;
46438
49047
  var noReaddirOptionVersions = /^v[0-5]\./;
46439
49048
  function readdir(path, options, cb) {
46440
49049
  if (typeof options === "function") cb = options, options = null;
@@ -46465,21 +49074,21 @@ var require_graceful_fs = /* @__PURE__ */ require_chunk.__commonJSMin(((exports,
46465
49074
  }
46466
49075
  }
46467
49076
  if (process.version.substr(0, 4) === "v0.8") {
46468
- var legStreams = legacy(fs$23);
49077
+ var legStreams = legacy(fs$25);
46469
49078
  ReadStream = legStreams.ReadStream;
46470
49079
  WriteStream = legStreams.WriteStream;
46471
49080
  }
46472
- var fs$ReadStream = fs$23.ReadStream;
49081
+ var fs$ReadStream = fs$25.ReadStream;
46473
49082
  if (fs$ReadStream) {
46474
49083
  ReadStream.prototype = Object.create(fs$ReadStream.prototype);
46475
49084
  ReadStream.prototype.open = ReadStream$open;
46476
49085
  }
46477
- var fs$WriteStream = fs$23.WriteStream;
49086
+ var fs$WriteStream = fs$25.WriteStream;
46478
49087
  if (fs$WriteStream) {
46479
49088
  WriteStream.prototype = Object.create(fs$WriteStream.prototype);
46480
49089
  WriteStream.prototype.open = WriteStream$open;
46481
49090
  }
46482
- Object.defineProperty(fs$23, "ReadStream", {
49091
+ Object.defineProperty(fs$25, "ReadStream", {
46483
49092
  get: function() {
46484
49093
  return ReadStream;
46485
49094
  },
@@ -46489,7 +49098,7 @@ var require_graceful_fs = /* @__PURE__ */ require_chunk.__commonJSMin(((exports,
46489
49098
  enumerable: true,
46490
49099
  configurable: true
46491
49100
  });
46492
- Object.defineProperty(fs$23, "WriteStream", {
49101
+ Object.defineProperty(fs$25, "WriteStream", {
46493
49102
  get: function() {
46494
49103
  return WriteStream;
46495
49104
  },
@@ -46500,7 +49109,7 @@ var require_graceful_fs = /* @__PURE__ */ require_chunk.__commonJSMin(((exports,
46500
49109
  configurable: true
46501
49110
  });
46502
49111
  var FileReadStream = ReadStream;
46503
- Object.defineProperty(fs$23, "FileReadStream", {
49112
+ Object.defineProperty(fs$25, "FileReadStream", {
46504
49113
  get: function() {
46505
49114
  return FileReadStream;
46506
49115
  },
@@ -46511,7 +49120,7 @@ var require_graceful_fs = /* @__PURE__ */ require_chunk.__commonJSMin(((exports,
46511
49120
  configurable: true
46512
49121
  });
46513
49122
  var FileWriteStream = WriteStream;
46514
- Object.defineProperty(fs$23, "FileWriteStream", {
49123
+ Object.defineProperty(fs$25, "FileWriteStream", {
46515
49124
  get: function() {
46516
49125
  return FileWriteStream;
46517
49126
  },
@@ -46555,13 +49164,13 @@ var require_graceful_fs = /* @__PURE__ */ require_chunk.__commonJSMin(((exports,
46555
49164
  });
46556
49165
  }
46557
49166
  function createReadStream(path, options) {
46558
- return new fs$23.ReadStream(path, options);
49167
+ return new fs$25.ReadStream(path, options);
46559
49168
  }
46560
49169
  function createWriteStream(path, options) {
46561
- return new fs$23.WriteStream(path, options);
49170
+ return new fs$25.WriteStream(path, options);
46562
49171
  }
46563
- var fs$open = fs$23.open;
46564
- fs$23.open = open;
49172
+ var fs$open = fs$25.open;
49173
+ fs$25.open = open;
46565
49174
  function open(path, flags, mode, cb) {
46566
49175
  if (typeof mode === "function") cb = mode, mode = null;
46567
49176
  return go$open(path, flags, mode, cb);
@@ -46583,7 +49192,7 @@ var require_graceful_fs = /* @__PURE__ */ require_chunk.__commonJSMin(((exports,
46583
49192
  });
46584
49193
  }
46585
49194
  }
46586
- return fs$23;
49195
+ return fs$25;
46587
49196
  }
46588
49197
  function enqueue(elem) {
46589
49198
  debug("ENQUEUE", elem[0].name, elem[1]);
@@ -46872,8 +49481,8 @@ var require_utimes = /* @__PURE__ */ require_chunk.__commonJSMin(((exports, modu
46872
49481
  else if (timestamp instanceof Date) return /* @__PURE__ */ new Date(Math.floor(timestamp.getTime() / 1e3) * 1e3);
46873
49482
  else throw new Error("fs-extra: timeRemoveMillis() unknown parameter type");
46874
49483
  }
46875
- function utimesMillis(path$41, atime, mtime, callback) {
46876
- fs.open(path$41, "r+", (err, fd) => {
49484
+ function utimesMillis(path$42, atime, mtime, callback) {
49485
+ fs.open(path$42, "r+", (err, fd) => {
46877
49486
  if (err) return callback(err);
46878
49487
  fs.futimes(fd, atime, mtime, (futimesErr) => {
46879
49488
  fs.close(fd, (closeErr) => {
@@ -46882,8 +49491,8 @@ var require_utimes = /* @__PURE__ */ require_chunk.__commonJSMin(((exports, modu
46882
49491
  });
46883
49492
  });
46884
49493
  }
46885
- function utimesMillisSync(path$42, atime, mtime) {
46886
- const fd = fs.openSync(path$42, "r+");
49494
+ function utimesMillisSync(path$43, atime, mtime) {
49495
+ const fd = fs.openSync(path$43, "r+");
46887
49496
  fs.futimesSync(fd, atime, mtime);
46888
49497
  return fs.closeSync(fd);
46889
49498
  }
@@ -47886,10 +50495,10 @@ var require_jsonfile$1 = /* @__PURE__ */ require_chunk.__commonJSMin(((exports,
47886
50495
  }
47887
50496
  if (typeof options === "string") options = { encoding: options };
47888
50497
  options = options || {};
47889
- var fs$19 = options.fs || _fs;
50498
+ var fs$21 = options.fs || _fs;
47890
50499
  var shouldThrow = true;
47891
50500
  if ("throws" in options) shouldThrow = options.throws;
47892
- fs$19.readFile(file, options, function(err, data) {
50501
+ fs$21.readFile(file, options, function(err, data) {
47893
50502
  if (err) return callback(err);
47894
50503
  data = stripBom(data);
47895
50504
  var obj;
@@ -47907,11 +50516,11 @@ var require_jsonfile$1 = /* @__PURE__ */ require_chunk.__commonJSMin(((exports,
47907
50516
  function readFileSync(file, options) {
47908
50517
  options = options || {};
47909
50518
  if (typeof options === "string") options = { encoding: options };
47910
- var fs$20 = options.fs || _fs;
50519
+ var fs$22 = options.fs || _fs;
47911
50520
  var shouldThrow = true;
47912
50521
  if ("throws" in options) shouldThrow = options.throws;
47913
50522
  try {
47914
- var content = fs$20.readFileSync(file, options);
50523
+ var content = fs$22.readFileSync(file, options);
47915
50524
  content = stripBom(content);
47916
50525
  return JSON.parse(content, options.reviver);
47917
50526
  } catch (err) {
@@ -47936,7 +50545,7 @@ var require_jsonfile$1 = /* @__PURE__ */ require_chunk.__commonJSMin(((exports,
47936
50545
  options = {};
47937
50546
  }
47938
50547
  options = options || {};
47939
- var fs$21 = options.fs || _fs;
50548
+ var fs$23 = options.fs || _fs;
47940
50549
  var str = "";
47941
50550
  try {
47942
50551
  str = stringify(obj, options);
@@ -47944,13 +50553,13 @@ var require_jsonfile$1 = /* @__PURE__ */ require_chunk.__commonJSMin(((exports,
47944
50553
  if (callback) callback(err, null);
47945
50554
  return;
47946
50555
  }
47947
- fs$21.writeFile(file, str, options, callback);
50556
+ fs$23.writeFile(file, str, options, callback);
47948
50557
  }
47949
50558
  function writeFileSync(file, obj, options) {
47950
50559
  options = options || {};
47951
- var fs$22 = options.fs || _fs;
50560
+ var fs$24 = options.fs || _fs;
47952
50561
  var str = stringify(obj, options);
47953
- return fs$22.writeFileSync(file, str, options);
50562
+ return fs$24.writeFileSync(file, str, options);
47954
50563
  }
47955
50564
  function stripBom(content) {
47956
50565
  if (Buffer.isBuffer(content)) content = content.toString("utf8");
@@ -90581,11 +93190,11 @@ var require_main = /* @__PURE__ */ require_chunk.__commonJSMin(((exports, module
90581
93190
  }
90582
93191
  let lastError;
90583
93192
  const parsedAll = {};
90584
- for (const path$40 of optionPaths) try {
90585
- const parsed = DotenvModule.parse(fs$4.readFileSync(path$40, { encoding }));
93193
+ for (const path$41 of optionPaths) try {
93194
+ const parsed = DotenvModule.parse(fs$4.readFileSync(path$41, { encoding }));
90586
93195
  DotenvModule.populate(parsedAll, parsed, options);
90587
93196
  } catch (e) {
90588
- if (debug) _debug(`failed to load ${path$40} ${e.message}`);
93197
+ if (debug) _debug(`failed to load ${path$41} ${e.message}`);
90589
93198
  lastError = e;
90590
93199
  }
90591
93200
  const populated = DotenvModule.populate(processEnv, parsedAll, options);
@@ -94358,6 +96967,17 @@ import_moleculer.default.Validator;
94358
96967
  import_moleculer.default.Validators;
94359
96968
  //#endregion
94360
96969
  //#region src/kernel/moleculer/broker-factory.ts
96970
+ /**
96971
+ * How many UDP discovery packets an agent in discovery mode sends (D802).
96972
+ *
96973
+ * Discovery exists so an agent finds the hub without an address: the HUB
96974
+ * broadcasts `<namespace>|hub|<port>` every 5 s and an agent that hears it
96975
+ * dials that address over TCP — the hub then learns the agent from the TCP
96976
+ * handshake, not from the agent's own broadcast. Nothing needs an agent to
96977
+ * announce itself on the LAN every 5 s forever, so it sends a few packets at
96978
+ * start (enough to be seen by a hub that is already up) and stops.
96979
+ */
96980
+ var AGENT_UDP_MAX_DISCOVERY = 3;
94361
96981
  /** Default fixed TCP port for hub-agent cluster traffic. */
94362
96982
  var DEFAULT_HUB_TCP_PORT = 6e3;
94363
96983
  var DEFAULT_UDP_PORT = 4445;
@@ -94455,6 +97075,7 @@ function createBroker(config) {
94455
97075
  debug: false
94456
97076
  }
94457
97077
  },
97078
+ ...config.middlewares !== void 0 ? { middlewares: [...config.middlewares] } : {},
94458
97079
  logger: {
94459
97080
  type: "Console",
94460
97081
  options: { level: {
@@ -94481,6 +97102,7 @@ function createBroker(config) {
94481
97102
  tcpOptions.udpDiscovery = true;
94482
97103
  tcpOptions.udpPort = udpPort;
94483
97104
  tcpOptions.udpPeriod = 5;
97105
+ tcpOptions.udpMaxDiscovery = AGENT_UDP_MAX_DISCOVERY;
94484
97106
  }
94485
97107
  return new ServiceBroker({
94486
97108
  nodeID,
@@ -94489,6 +97111,7 @@ function createBroker(config) {
94489
97111
  type: "TCP",
94490
97112
  options: tcpOptions
94491
97113
  },
97114
+ ...config.middlewares !== void 0 ? { middlewares: [...config.middlewares] } : {},
94492
97115
  logger: {
94493
97116
  type: "Console",
94494
97117
  options: { level: {
@@ -94642,6 +97265,9 @@ var HubLogForwarder = class {
94642
97265
  };
94643
97266
  //#endregion
94644
97267
  //#region src/kernel/moleculer/hub-service.ts
97268
+ function senderOf$1(ctx) {
97269
+ return typeof ctx.nodeID === "string" ? ctx.nodeID : "";
97270
+ }
94645
97271
  function createHubService(deps) {
94646
97272
  return {
94647
97273
  name: "$hub",
@@ -94663,7 +97289,20 @@ function createHubService(deps) {
94663
97289
  deps.onSetLogLevel?.(ctx.params.level);
94664
97290
  return true;
94665
97291
  } },
97292
+ joinChallenge: { handler(ctx) {
97293
+ if (deps.meshAuth === void 0) throw new Errors.MoleculerClientError("mesh join is not enabled on this node", 404);
97294
+ return deps.meshAuth.issueChallenge(senderOf$1(ctx));
97295
+ } },
97296
+ authenticateNode: { handler(ctx) {
97297
+ if (deps.meshAuth === void 0) throw new Errors.MoleculerClientError("mesh join is not enabled on this node", 404);
97298
+ return deps.meshAuth.authenticate(senderOf$1(ctx), ctx.params);
97299
+ } },
94666
97300
  registerNode: { handler(ctx) {
97301
+ if (deps.meshAuth !== void 0) {
97302
+ deps.meshAuth.admitRegistration(senderOf$1(ctx), ctx.params);
97303
+ deps.onRegisterNode?.(ctx.params);
97304
+ return { ok: true };
97305
+ }
94667
97306
  const verdict = require_cluster_secret.checkClusterSecret(deps.clusterSecretGate?.() ?? { kind: "off" }, ctx.params.clusterSecretHash);
94668
97307
  if (verdict === "mismatch") throw new Errors.MoleculerError(`cluster secret mismatch — node "${ctx.params.nodeId}" rejected`, 403, require_cluster_secret.CLUSTER_SECRET_MISMATCH_TYPE);
94669
97308
  if (verdict === "unavailable") throw new Errors.MoleculerRetryableError(`the hub cannot read its cluster secret yet — node "${ctx.params.nodeId}" must retry`, 503, require_cluster_secret.CLUSTER_SECRET_UNAVAILABLE_TYPE);
@@ -94882,6 +97521,580 @@ async function callRegisterNodeWithRetry(broker, params, opts) {
94882
97521
  }
94883
97522
  }
94884
97523
  //#endregion
97524
+ //#region src/kernel/moleculer/mesh-join-proof.ts
97525
+ /**
97526
+ * Mesh join — the challenge–response that authenticates a node to the hub
97527
+ * (D802). Shared by the hub (`$hub.joinChallenge` / `$hub.authenticateNode`)
97528
+ * and the agent (`MeshJoinClient`).
97529
+ *
97530
+ * The exchange, over the clear-text Moleculer transport:
97531
+ *
97532
+ * agent → hub `$hub.joinChallenge {}` → { nonce }
97533
+ * agent → hub `$hub.authenticateNode { nodeId, nonce,
97534
+ * clientNonce, proof }` → { hubProof }
97535
+ *
97536
+ * proof = HMAC-SHA256(K, "camstack-mesh-join/v1|node|<nodeId>|<nonce>")
97537
+ * hubProof = HMAC-SHA256(K, "camstack-mesh-join/v1|hub|<nodeId>|<nonce>|<clientNonce>")
97538
+ * K = SHA-256(cluster secret) — the value each side already holds
97539
+ *
97540
+ * What it buys over the D797 hash (`clusterSecretHash` in `registerNode`):
97541
+ * - nothing reusable crosses the wire: the nonce is the hub's, single use,
97542
+ * short-lived and bound to the SENDER node id, so a sniffed proof answers a
97543
+ * challenge that no longer exists;
97544
+ * - the agent authenticates the HUB too (`hubProof` over the agent's own
97545
+ * nonce): a rogue node answering to `hub` on the LAN — found through UDP
97546
+ * discovery — cannot prove it knows the secret, and the agent refuses it.
97547
+ *
97548
+ * What it does NOT buy: the transport stays clear text, and the sender node id
97549
+ * of every later packet is self-declared. A LAN host that watches a node join
97550
+ * can still spoof that node id afterwards. Only mutual TLS (the next step,
97551
+ * `docs/design/2026-10-09-mesh-mtls-plan.md`) closes that.
97552
+ */
97553
+ /** Protocol version carried by the challenge; the agent refuses one it does not speak. */
97554
+ var MESH_JOIN_PROTOCOL = 1;
97555
+ var DOMAIN = "camstack-mesh-join/v1";
97556
+ /** The hub's action that hands out a single-use nonce. */
97557
+ var MESH_JOIN_CHALLENGE_ACTION = "$hub.joinChallenge";
97558
+ /** The hub's action that verifies a node's proof and answers with its own. */
97559
+ var MESH_JOIN_AUTHENTICATE_ACTION = "$hub.authenticateNode";
97560
+ /** Moleculer error `type`: the sender has not authenticated and the hub enforces it. */
97561
+ var MESH_NODE_UNAUTHENTICATED_TYPE = "MESH_NODE_UNAUTHENTICATED";
97562
+ /** Moleculer error `type`: the action is never callable from another node. */
97563
+ var MESH_ACTION_FORBIDDEN_TYPE = "MESH_ACTION_FORBIDDEN";
97564
+ /** Moleculer error `type`: the challenge is unknown, used or expired — ask for a new one. */
97565
+ var MESH_JOIN_CHALLENGE_INVALID_TYPE = "MESH_JOIN_CHALLENGE_INVALID";
97566
+ /** A fresh 32-byte nonce, hex. */
97567
+ function createMeshNonce() {
97568
+ return (0, node_crypto.randomBytes)(32).toString("hex");
97569
+ }
97570
+ function hmacHex(secretHash, message) {
97571
+ return (0, node_crypto.createHmac)("sha256", Buffer.from(secretHash, "utf8")).update(message, "utf8").digest("hex");
97572
+ }
97573
+ /** The node's answer to the hub's nonce. `secretHash` is `hashClusterSecret(secret)`. */
97574
+ function computeNodeJoinProof(secretHash, nodeId, nonce) {
97575
+ return hmacHex(secretHash, `${DOMAIN}|node|${nodeId}|${nonce}`);
97576
+ }
97577
+ /** The hub's answer to the node's nonce — proves the hub holds the same secret. */
97578
+ function computeHubJoinProof(secretHash, nodeId, nonce, clientNonce) {
97579
+ return hmacHex(secretHash, `${DOMAIN}|hub|${nodeId}|${nonce}|${clientNonce}`);
97580
+ }
97581
+ /** Constant-time comparison of two hex proofs; any shape mismatch is `false`. */
97582
+ function proofsEqual(expected, presented) {
97583
+ if (typeof presented !== "string" || presented.length !== expected.length) return false;
97584
+ return (0, node_crypto.timingSafeEqual)(Buffer.from(expected, "utf8"), Buffer.from(presented, "utf8"));
97585
+ }
97586
+ /** Reads a Moleculer error's `type`, including after an RPC round-trip. */
97587
+ function meshErrorType(err) {
97588
+ if (typeof err !== "object" || err === null || !("type" in err)) return null;
97589
+ const { type } = err;
97590
+ return typeof type === "string" ? type : null;
97591
+ }
97592
+ //#endregion
97593
+ //#region src/kernel/moleculer/mesh-authenticator.ts
97594
+ /**
97595
+ * MeshAuthenticator — the hub's record of WHICH node is calling, and whether
97596
+ * it proved it (D802).
97597
+ *
97598
+ * Every remote Moleculer action and event reaching the hub passes through
97599
+ * {@link MeshAuthenticator.admitCall} (wired as a broker middleware,
97600
+ * `mesh-access-middleware.ts`). The sender node id Moleculer reports is
97601
+ * self-declared; this class binds it to a proof:
97602
+ *
97603
+ * - `$hub.joinChallenge` → a single-use nonce bound to the sender;
97604
+ * - `$hub.authenticateNode` → the node's HMAC over that nonce and its own id
97605
+ * (`mesh-join-proof.ts`). Success marks the node `authenticated` until its
97606
+ * connection drops (`forget`, on `$node.disconnected`).
97607
+ *
97608
+ * Policy, per remote action:
97609
+ * - the join actions and `registerNode` are open (they ARE the
97610
+ * authentication; `registerNode` applies its own rule below);
97611
+ * - {@link isRemoteForbiddenAction}: never from another node, whoever it is;
97612
+ * - otherwise an authenticated (or, in `transition`, legacy) node is allowed;
97613
+ * an unauthenticated one is refused in `enforced` and tolerated — with a
97614
+ * warning and a row on System → Cluster — in `transition`.
97615
+ *
97616
+ * `registerNode` (`admitRegistration`): a node registers only itself; an
97617
+ * authenticated node always may; the D797 hash is accepted as `legacy` in
97618
+ * `transition` only; no proof at all is tolerated in `transition` only.
97619
+ */
97620
+ /** A challenge is answered within this window or not at all. */
97621
+ var MESH_JOIN_CHALLENGE_TTL_MS = 6e4;
97622
+ /** Outstanding challenges kept at most — a flood of fake node ids evicts the oldest. */
97623
+ var MAX_PENDING_CHALLENGES = 256;
97624
+ /** Unauthenticated senders remembered for the status page — bounded the same way. */
97625
+ var MAX_TRACKED_NODES = 256;
97626
+ /** Actions any node may call before it has authenticated. */
97627
+ var PRE_AUTH_ACTIONS = new Set([
97628
+ MESH_JOIN_CHALLENGE_ACTION,
97629
+ MESH_JOIN_AUTHENTICATE_ACTION,
97630
+ "$hub.registerNode"
97631
+ ]);
97632
+ /**
97633
+ * Services and actions no other node ever calls on the hub. `$process` spawns
97634
+ * runners with an arbitrary environment (code execution); `$node` is
97635
+ * Moleculer's introspection; `setLogLevel` is an operator action the hub
97636
+ * issues itself. Nothing in the cluster calls them remotely, so refusing them
97637
+ * costs nothing and closes the cheapest routes to the hub.
97638
+ */
97639
+ var REMOTE_FORBIDDEN_SERVICES = new Set(["$process", "$node"]);
97640
+ var REMOTE_FORBIDDEN_ACTIONS = new Set(["$hub.setLogLevel"]);
97641
+ function isRemoteForbiddenAction(action) {
97642
+ if (REMOTE_FORBIDDEN_ACTIONS.has(action)) return true;
97643
+ const dot = action.indexOf(".");
97644
+ return dot > 0 && REMOTE_FORBIDDEN_SERVICES.has(action.slice(0, dot));
97645
+ }
97646
+ function refuse(message, type, code = 403) {
97647
+ return new Errors.MoleculerClientError(message, code, type);
97648
+ }
97649
+ var MeshAuthenticator = class {
97650
+ deps;
97651
+ challenges = /* @__PURE__ */ new Map();
97652
+ nodes = /* @__PURE__ */ new Map();
97653
+ /** Completed the challenge–response at least once since the hub started. */
97654
+ everAuthenticated = /* @__PURE__ */ new Set();
97655
+ /** Let in WITHOUT the challenge–response at least once since the hub started. */
97656
+ everTolerated = /* @__PURE__ */ new Set();
97657
+ now;
97658
+ constructor(deps) {
97659
+ this.deps = deps;
97660
+ this.now = deps.now ?? Date.now;
97661
+ }
97662
+ issueChallenge(sender) {
97663
+ const nonce = createMeshNonce();
97664
+ this.challenges.delete(sender);
97665
+ if (this.challenges.size >= MAX_PENDING_CHALLENGES) {
97666
+ const oldest = this.challenges.keys().next().value;
97667
+ if (oldest !== void 0) this.challenges.delete(oldest);
97668
+ }
97669
+ this.challenges.set(sender, {
97670
+ nonce,
97671
+ expiresAt: this.now() + MESH_JOIN_CHALLENGE_TTL_MS
97672
+ });
97673
+ return {
97674
+ protocol: 1,
97675
+ nonce
97676
+ };
97677
+ }
97678
+ authenticate(sender, params) {
97679
+ if (params.nodeId !== sender) throw refuse(`mesh join refused: node "${sender}" presented a proof for "${String(params.nodeId)}"`, MESH_NODE_UNAUTHENTICATED_TYPE);
97680
+ const pending = this.challenges.get(sender);
97681
+ this.challenges.delete(sender);
97682
+ if (pending === void 0 || pending.expiresAt < this.now() || typeof params.nonce !== "string" || !proofsEqual(pending.nonce, params.nonce)) throw refuse(`mesh join refused: no live challenge for node "${sender}" — ask for a new one`, MESH_JOIN_CHALLENGE_INVALID_TYPE);
97683
+ const hash = this.secretHashOrThrow(sender);
97684
+ if (!proofsEqual(computeNodeJoinProof(hash, sender, pending.nonce), params.proof)) throw refuse(`cluster secret mismatch — node "${sender}" rejected`, require_cluster_secret.CLUSTER_SECRET_MISMATCH_TYPE);
97685
+ this.record(sender, "authenticated");
97686
+ this.everAuthenticated.add(sender);
97687
+ this.deps.onAuthenticated?.(sender);
97688
+ const clientNonce = typeof params.clientNonce === "string" ? params.clientNonce : "";
97689
+ return {
97690
+ ok: true,
97691
+ hubProof: computeHubJoinProof(hash, sender, pending.nonce, clientNonce)
97692
+ };
97693
+ }
97694
+ /** The node's connection dropped: it authenticates again when it returns. */
97695
+ forget(nodeId) {
97696
+ this.nodes.delete(nodeId);
97697
+ this.challenges.delete(nodeId);
97698
+ }
97699
+ admitCall(sender, action) {
97700
+ if (sender === this.deps.ownNodeId) return { verdict: "allow" };
97701
+ if (isRemoteForbiddenAction(action)) return {
97702
+ verdict: "deny",
97703
+ errorType: MESH_ACTION_FORBIDDEN_TYPE,
97704
+ message: `"${action}" is not callable from another node (caller "${sender}")`
97705
+ };
97706
+ if (PRE_AUTH_ACTIONS.has(action)) return { verdict: "allow" };
97707
+ return this.admitSender(sender, action);
97708
+ }
97709
+ /** Same rule as a call, for an inbound event. */
97710
+ admitEvent(sender, eventName) {
97711
+ if (sender === this.deps.ownNodeId) return { verdict: "allow" };
97712
+ return this.admitSender(sender, `event:${eventName}`);
97713
+ }
97714
+ admitSender(sender, what) {
97715
+ const state = this.stateOf(sender);
97716
+ if (state === "authenticated") return { verdict: "allow" };
97717
+ if (this.deps.mode() === "enforced") return {
97718
+ verdict: "deny",
97719
+ errorType: MESH_NODE_UNAUTHENTICATED_TYPE,
97720
+ message: `node "${sender}" has not authenticated to this hub — enter the hub cluster secret (System → Cluster) in the agent and restart it`
97721
+ };
97722
+ if (state === "legacy") return { verdict: "allow" };
97723
+ if (!this.nodes.has(sender)) {
97724
+ this.record(sender, "unauthenticated");
97725
+ this.noteTolerated(sender);
97726
+ this.deps.onTolerated?.(sender, what);
97727
+ }
97728
+ return { verdict: "tolerate" };
97729
+ }
97730
+ /** Throws when `sender` may not register `params`; returns when it may. */
97731
+ admitRegistration(sender, params) {
97732
+ if (sender === this.deps.ownNodeId) return;
97733
+ if (params.nodeId !== sender) throw refuse(`registration refused: node "${sender}" may register only itself, not "${params.nodeId}"`, MESH_NODE_UNAUTHENTICATED_TYPE);
97734
+ if (this.stateOf(sender) === "authenticated") return;
97735
+ if (this.deps.mode() === "enforced") throw refuse(`cluster secret mismatch — node "${sender}" rejected: this hub requires agents to authenticate with the cluster secret (System → Cluster); update the agent and enter it`, require_cluster_secret.CLUSTER_SECRET_MISMATCH_TYPE);
97736
+ if (params.clusterSecretHash === void 0) {
97737
+ this.admitSender(sender, "$hub.registerNode");
97738
+ return;
97739
+ }
97740
+ const verdict = require_cluster_secret.checkClusterSecret(this.deps.gate(), params.clusterSecretHash);
97741
+ if (verdict === "mismatch") throw refuse(`cluster secret mismatch — node "${sender}" rejected`, require_cluster_secret.CLUSTER_SECRET_MISMATCH_TYPE);
97742
+ if (verdict === "unavailable") throw new Errors.MoleculerRetryableError(`the hub cannot read its cluster secret yet — node "${sender}" must retry`, 503, require_cluster_secret.CLUSTER_SECRET_UNAVAILABLE_TYPE);
97743
+ this.record(sender, this.deps.gate().kind === "on" ? "legacy" : "unauthenticated");
97744
+ this.noteTolerated(sender);
97745
+ }
97746
+ noteTolerated(nodeId) {
97747
+ if (this.everTolerated.size >= MAX_TRACKED_NODES) return;
97748
+ this.everTolerated.add(nodeId);
97749
+ }
97750
+ stateOf(nodeId) {
97751
+ return this.nodes.get(nodeId)?.state ?? "unauthenticated";
97752
+ }
97753
+ /** Node ids that completed the challenge–response on their current connection. */
97754
+ authenticatedNodeIds() {
97755
+ return [...this.nodes].filter(([, r]) => r.state === "authenticated").map(([id]) => id);
97756
+ }
97757
+ /** Node ids that ever completed the challenge–response since the hub started. */
97758
+ everAuthenticatedNodeIds() {
97759
+ return this.everAuthenticated;
97760
+ }
97761
+ /**
97762
+ * Node ids let in without the challenge–response since the hub started.
97763
+ * Bounded: past {@link MAX_TRACKED_NODES} a flood of fake ids stops adding,
97764
+ * and the ones already here keep the transition open (the operator can still
97765
+ * switch to `enforced` by hand).
97766
+ */
97767
+ everToleratedNodeIds() {
97768
+ return [...this.everTolerated];
97769
+ }
97770
+ snapshot() {
97771
+ const nodes = [...this.nodes].map(([nodeId, r]) => ({
97772
+ nodeId,
97773
+ state: r.state,
97774
+ since: r.since
97775
+ })).toSorted((a, b) => a.nodeId.localeCompare(b.nodeId));
97776
+ return {
97777
+ mode: this.deps.mode(),
97778
+ nodes
97779
+ };
97780
+ }
97781
+ record(nodeId, state) {
97782
+ this.nodes.delete(nodeId);
97783
+ if (this.nodes.size >= MAX_TRACKED_NODES) {
97784
+ const oldestTolerated = [...this.nodes].find(([, r]) => r.state === "unauthenticated");
97785
+ if (oldestTolerated !== void 0) this.nodes.delete(oldestTolerated[0]);
97786
+ }
97787
+ this.nodes.set(nodeId, {
97788
+ state,
97789
+ since: this.now()
97790
+ });
97791
+ }
97792
+ secretHashOrThrow(sender) {
97793
+ const gate = this.deps.gate();
97794
+ if (gate.kind === "on") return gate.hash;
97795
+ throw new Errors.MoleculerRetryableError(gate.kind === "off" ? `the hub has no cluster secret yet — node "${sender}" must retry` : `the hub cannot read its cluster secret yet — node "${sender}" must retry`, 503, require_cluster_secret.CLUSTER_SECRET_UNAVAILABLE_TYPE);
97796
+ }
97797
+ };
97798
+ //#endregion
97799
+ //#region src/kernel/moleculer/mesh-access-middleware.ts
97800
+ /**
97801
+ * The hub broker's mesh gate (D802): a Moleculer middleware wrapping every
97802
+ * LOCAL action and event handler, so it sees each request another node sends
97803
+ * to the hub with `ctx.nodeID` = the sender.
97804
+ *
97805
+ * For a request from another node it:
97806
+ * 1. asks {@link MeshAuthenticator.admitCall} — refuse, tolerate or allow;
97807
+ * 2. strips a forged identity from the params ({@link stripForgedIdentity}).
97808
+ *
97809
+ * Calls the hub makes to itself (`ctx.nodeID` = the hub) pass untouched: a
97810
+ * hub-local runner reaches the hub over UDS, and the hub's own code is the
97811
+ * trust boundary (D787).
97812
+ */
97813
+ /** Identity fields only the hub's own router / transport may set (D787, D-1). */
97814
+ var IDENTITY_KEYS = ["caller", "callerAddonId"];
97815
+ function withoutIdentity(value) {
97816
+ if (value === null || typeof value !== "object" || Array.isArray(value)) return value;
97817
+ if (!IDENTITY_KEYS.some((k) => Object.prototype.hasOwnProperty.call(value, k))) return value;
97818
+ const rest = {};
97819
+ for (const [key, v] of Object.entries(value)) if (!IDENTITY_KEYS.includes(key)) rest[key] = v;
97820
+ return rest;
97821
+ }
97822
+ /**
97823
+ * The params of a request from another node, with every identity it claimed
97824
+ * removed:
97825
+ * - a cap action's input loses `caller` (the user identity the hub's tRPC
97826
+ * router injects for `caller: 'required'` methods — `keychainAdmin.reveal`
97827
+ * reads it) and `callerAddonId` (the transport's addon stamp the keychain
97828
+ * owner-checks);
97829
+ * - `$hub-cap-fwd.forward` keeps its envelope `callerAddonId` — the forward
97830
+ * service checks it against the sender's registered manifest — but the
97831
+ * forwarded `args` lose both.
97832
+ */
97833
+ function stripForgedIdentity(action, params) {
97834
+ if (action === require_hub_cap_forward.HUB_CAP_FWD_ACTION) {
97835
+ if (params === null || typeof params !== "object" || Array.isArray(params)) return params;
97836
+ const args = Reflect.get(params, "args");
97837
+ const cleaned = withoutIdentity(args);
97838
+ return cleaned === args ? params : {
97839
+ ...params,
97840
+ args: cleaned
97841
+ };
97842
+ }
97843
+ return withoutIdentity(params);
97844
+ }
97845
+ function senderOf(ctx) {
97846
+ const nodeID = ctx.nodeID;
97847
+ return typeof nodeID === "string" && nodeID.length > 0 ? nodeID : null;
97848
+ }
97849
+ function paramNodeId(params) {
97850
+ return params !== null && typeof params === "object" ? Reflect.get(params, "nodeId") : void 0;
97851
+ }
97852
+ /**
97853
+ * Build the middleware. Pass it in `ServiceBroker({ middlewares: [...] })`
97854
+ * so it wraps every service, including the ones Moleculer creates itself.
97855
+ */
97856
+ function createMeshAccessMiddleware(options) {
97857
+ const { ownNodeId, authenticator, logger } = options;
97858
+ return {
97859
+ name: "CamstackMeshAccess",
97860
+ localAction(next, action) {
97861
+ const name = action.name ?? "";
97862
+ return function meshGatedAction(ctx) {
97863
+ const sender = senderOf(ctx);
97864
+ if (sender === null || sender === ownNodeId) return next.call(this, ctx);
97865
+ const verdict = authenticator.admitCall(sender, name);
97866
+ if (verdict.verdict === "deny") {
97867
+ logger?.warn("mesh call refused", {
97868
+ sender,
97869
+ action: name,
97870
+ reason: verdict.errorType
97871
+ });
97872
+ return Promise.reject(new Errors.MoleculerClientError(verdict.message, 403, verdict.errorType));
97873
+ }
97874
+ if (name === "$hub.unregisterNode" && paramNodeId(ctx.params) !== sender) return Promise.reject(new Errors.MoleculerClientError(`node "${sender}" may unregister only itself`, 403, MESH_ACTION_FORBIDDEN_TYPE));
97875
+ ctx.params = stripForgedIdentity(name, ctx.params);
97876
+ return next.call(this, ctx);
97877
+ };
97878
+ },
97879
+ localEvent(next, event) {
97880
+ const name = event.name ?? "";
97881
+ return function meshGatedEvent(ctx) {
97882
+ const sender = senderOf(ctx);
97883
+ if (sender === null || sender === ownNodeId) return next.call(this, ctx);
97884
+ if (authenticator.admitEvent(sender, name).verdict === "deny") return void 0;
97885
+ return next.call(this, ctx);
97886
+ };
97887
+ }
97888
+ };
97889
+ }
97890
+ //#endregion
97891
+ //#region src/kernel/moleculer/mesh-join-client.ts
97892
+ /** States in which a call to the hub is refused locally. */
97893
+ var BLOCKING = new Set(["secret-mismatch", "hub-unverified"]);
97894
+ /** Error `type`s meaning "the hub has no such action": it predates D802. */
97895
+ var UNSUPPORTED = new Set(["SERVICE_NOT_FOUND", "SERVICE_NOT_AVAILABLE"]);
97896
+ function errText(err) {
97897
+ return err instanceof Error ? err.message : String(err);
97898
+ }
97899
+ function errCode(err) {
97900
+ if (typeof err !== "object" || err === null || !("code" in err)) return null;
97901
+ const { code } = err;
97902
+ return typeof code === "number" ? code : null;
97903
+ }
97904
+ function readString(value, key) {
97905
+ if (value === null || typeof value !== "object") return null;
97906
+ const v = Reflect.get(value, key);
97907
+ return typeof v === "string" ? v : null;
97908
+ }
97909
+ var MeshJoinClient = class {
97910
+ opts;
97911
+ current = "pending";
97912
+ settledWaiters = [];
97913
+ inFlight = null;
97914
+ hubNodeId;
97915
+ constructor(opts) {
97916
+ this.opts = opts;
97917
+ this.hubNodeId = opts.hubNodeId ?? "hub";
97918
+ }
97919
+ get state() {
97920
+ return this.current;
97921
+ }
97922
+ /** Did this agent prove itself on the current connection? */
97923
+ get authenticated() {
97924
+ return this.current === "authenticated";
97925
+ }
97926
+ /**
97927
+ * Run the join. Concurrent callers share one attempt. Resolves with the
97928
+ * settled state; never rejects.
97929
+ */
97930
+ join() {
97931
+ if (this.inFlight !== null) return this.inFlight;
97932
+ const attempt = this.runJoin().then((state) => {
97933
+ this.inFlight = null;
97934
+ this.settle(state);
97935
+ return state;
97936
+ });
97937
+ this.inFlight = attempt;
97938
+ return attempt;
97939
+ }
97940
+ /** The hub connection dropped: the next connection authenticates again. */
97941
+ reset() {
97942
+ this.current = "pending";
97943
+ }
97944
+ /** Resolves when a call to the hub may go out; rejects when it must not. */
97945
+ async whenCallable() {
97946
+ if (this.current === "pending") {
97947
+ let timer;
97948
+ const settled = await Promise.race([new Promise((resolve) => this.settledWaiters.push(() => resolve(true))), new Promise((resolve) => {
97949
+ timer = setTimeout(() => resolve(false), this.opts.pendingWaitMs ?? 3e4);
97950
+ timer.unref?.();
97951
+ })]);
97952
+ if (timer !== void 0) clearTimeout(timer);
97953
+ if (!settled) throw new Error(`the mesh join with "${this.hubNodeId}" has not completed — the call was not sent`);
97954
+ }
97955
+ if (!BLOCKING.has(this.current)) return;
97956
+ if (this.current === "secret-mismatch") throw new Error("the hub refused this agent: cluster secret mismatch — copy the cluster secret from the hub's System → Cluster page into this agent's setup");
97957
+ throw new Error(`the node answering as "${this.hubNodeId}" could not prove it holds the cluster secret — refusing to talk to it (check the hub address and the secret)`);
97958
+ }
97959
+ /**
97960
+ * Moleculer middleware for the AGENT broker: every call to the hub node waits
97961
+ * for the join; a hub answer "not authenticated" (the hub restarted and lost
97962
+ * us) triggers a new join.
97963
+ */
97964
+ middleware(onUnauthenticated) {
97965
+ const hubNodeId = this.hubNodeId;
97966
+ const whenCallable = () => this.whenCallable();
97967
+ const secretPresent = () => this.secretPresent();
97968
+ return {
97969
+ name: "CamstackMeshJoin",
97970
+ remoteAction(next, action) {
97971
+ const name = action.name ?? "";
97972
+ if (name === "$hub.joinChallenge" || name === "$hub.authenticateNode") return next;
97973
+ return async function meshJoinGated(ctx) {
97974
+ if (ctx.nodeID !== hubNodeId) return next.call(this, ctx);
97975
+ await whenCallable();
97976
+ try {
97977
+ return await next.call(this, ctx);
97978
+ } catch (err) {
97979
+ if (meshErrorType(err) === "MESH_NODE_UNAUTHENTICATED" && secretPresent()) onUnauthenticated?.();
97980
+ throw err;
97981
+ }
97982
+ };
97983
+ }
97984
+ };
97985
+ }
97986
+ secretPresent() {
97987
+ const s = this.opts.secret();
97988
+ return s !== null && s.length > 0;
97989
+ }
97990
+ settle(state) {
97991
+ this.current = state;
97992
+ this.opts.onSettled?.(state);
97993
+ const waiters = this.settledWaiters;
97994
+ this.settledWaiters = [];
97995
+ for (const w of waiters) w();
97996
+ }
97997
+ async runJoin() {
97998
+ const secret = this.opts.secret();
97999
+ if (secret === null || secret.length === 0) return "no-secret";
98000
+ const hash = require_cluster_secret.hashClusterSecret(secret);
98001
+ const maxAttempts = this.opts.maxAttempts ?? 5;
98002
+ let last = "unavailable";
98003
+ for (let attempt = 1; attempt <= maxAttempts; attempt++) {
98004
+ const outcome = await this.attempt(hash);
98005
+ if (outcome !== "retry") return outcome;
98006
+ last = "unavailable";
98007
+ await new Promise((r) => setTimeout(r, (this.opts.retryDelayMs ?? 1e3) * attempt));
98008
+ }
98009
+ return last;
98010
+ }
98011
+ async attempt(hash) {
98012
+ const callOpts = {
98013
+ nodeID: this.hubNodeId,
98014
+ timeout: this.opts.callTimeoutMs ?? 1e4
98015
+ };
98016
+ const nodeId = this.opts.nodeId;
98017
+ try {
98018
+ const challenge = await this.opts.call(MESH_JOIN_CHALLENGE_ACTION, {}, callOpts);
98019
+ const nonce = readString(challenge, "nonce");
98020
+ const protocol = challenge !== null && typeof challenge === "object" ? Reflect.get(challenge, "protocol") : void 0;
98021
+ if (nonce === null || protocol !== 1) {
98022
+ this.opts.log?.(`[mesh-join] the hub sent a challenge this agent does not speak`);
98023
+ return "unsupported";
98024
+ }
98025
+ const clientNonce = createMeshNonce();
98026
+ const answer = await this.opts.call(MESH_JOIN_AUTHENTICATE_ACTION, {
98027
+ nodeId,
98028
+ nonce,
98029
+ clientNonce,
98030
+ proof: computeNodeJoinProof(hash, nodeId, nonce)
98031
+ }, callOpts);
98032
+ if (!proofsEqual(computeHubJoinProof(hash, nodeId, nonce, clientNonce), readString(answer, "hubProof"))) {
98033
+ this.opts.log?.(`[mesh-join] the hub could not prove it holds the cluster secret — refused`);
98034
+ return "hub-unverified";
98035
+ }
98036
+ this.opts.log?.(`[mesh-join] authenticated to the hub (mutual)`);
98037
+ return "authenticated";
98038
+ } catch (err) {
98039
+ const type = meshErrorType(err);
98040
+ if (type === "CLUSTER_SECRET_MISMATCH") {
98041
+ this.opts.log?.(`[mesh-join] the hub refused our proof: cluster secret mismatch`);
98042
+ return "secret-mismatch";
98043
+ }
98044
+ if (type !== null && UNSUPPORTED.has(type) || errCode(err) === 404) {
98045
+ this.opts.log?.(`[mesh-join] the hub predates the mesh join — legacy registration`);
98046
+ return "unsupported";
98047
+ }
98048
+ this.opts.log?.(`[mesh-join] join attempt failed (${type ?? "error"}): ${errText(err)}`);
98049
+ return "retry";
98050
+ }
98051
+ }
98052
+ };
98053
+ //#endregion
98054
+ //#region src/kernel/moleculer/mesh-auto-enforce.ts
98055
+ /** Boot grace before an empty or partial roster can end the transition. */
98056
+ var MESH_AUTO_ENFORCE_GRACE_MS = 5 * 6e4;
98057
+ function isAgentId(id, ownNodeId) {
98058
+ return id !== ownNodeId && !id.includes("/");
98059
+ }
98060
+ function decideMeshAutoEnforce(input) {
98061
+ if (input.mode !== "transition") return {
98062
+ enforce: false,
98063
+ waitingFor: [],
98064
+ why: "not in transition"
98065
+ };
98066
+ if (input.gate !== "on") return {
98067
+ enforce: false,
98068
+ waitingFor: [],
98069
+ why: "no readable cluster secret"
98070
+ };
98071
+ if (input.knownAgents === null) return {
98072
+ enforce: false,
98073
+ waitingFor: [],
98074
+ why: "the cluster-node history has not answered"
98075
+ };
98076
+ if (input.uptimeMs < (input.graceMs ?? 3e5)) return {
98077
+ enforce: false,
98078
+ waitingFor: [],
98079
+ why: "boot grace period"
98080
+ };
98081
+ const known = new Set([
98082
+ ...input.knownAgents,
98083
+ ...input.connected,
98084
+ ...input.toleratedEver
98085
+ ].filter((id) => isAgentId(id, input.ownNodeId)));
98086
+ const waitingFor = [...known].filter((id) => !input.authenticatedEver.has(id)).toSorted();
98087
+ if (waitingFor.length > 0) return {
98088
+ enforce: false,
98089
+ waitingFor,
98090
+ why: "agents have not authenticated yet"
98091
+ };
98092
+ return {
98093
+ enforce: true,
98094
+ reason: known.size === 0 ? "no agent has ever joined this hub" : `every known agent has authenticated (${[...known].toSorted().join(", ")})`
98095
+ };
98096
+ }
98097
+ //#endregion
94885
98098
  //#region src/kernel/moleculer/readiness-service.ts
94886
98099
  /**
94887
98100
  * Service name AGENTS register their own readiness snapshot under.
@@ -96439,6 +99652,8 @@ var LifecycleJobEngine = class {
96439
99652
  }
96440
99653
  };
96441
99654
  //#endregion
99655
+ exports.ADMIN_TOKEN_MAX_LIFETIME_MS = require_builtins_local_auth_local_auth_addon.ADMIN_TOKEN_MAX_LIFETIME_MS;
99656
+ exports.ADMIN_TOKEN_PREFIX = require_builtins_local_auth_local_auth_addon.ADMIN_TOKEN_PREFIX;
96442
99657
  exports.AGENT_CAP_FWD_ACTION = require_child_cap_dispatch.AGENT_CAP_FWD_ACTION;
96443
99658
  exports.AGENT_CAP_FWD_SERVICE = require_child_cap_dispatch.AGENT_CAP_FWD_SERVICE;
96444
99659
  exports.AGENT_READINESS_SERVICE_NAME = AGENT_READINESS_SERVICE_NAME;
@@ -96455,9 +99670,15 @@ exports.AddonInstaller = AddonInstaller;
96455
99670
  exports.AddonLoader = AddonLoader;
96456
99671
  exports.AddonManifest = AddonManifest;
96457
99672
  exports.AddonRouteRegistry = AddonRouteRegistry;
99673
+ exports.AdminTokenManager = require_builtins_local_auth_local_auth_addon.AdminTokenManager;
96458
99674
  exports.AlertCenterAddon = require_builtins_alerts_alerts_addon.AlertCenterAddon;
96459
99675
  exports.ApiKeyManager = require_builtins_local_auth_local_auth_addon.ApiKeyManager;
99676
+ exports.AuthAuditLog = require_builtins_local_auth_local_auth_addon.AuthAuditLog;
96460
99677
  exports.AuthManager = require_builtins_local_auth_local_auth_addon.AuthManager;
99678
+ exports.BackupDecryptError = require_restore_archive.BackupDecryptError;
99679
+ exports.BackupKeyFormatError = require_restore_archive.BackupKeyFormatError;
99680
+ exports.BackupKeyMismatchError = require_restore_archive.BackupKeyMismatchError;
99681
+ exports.BackupKeyRequiredError = require_restore_archive.BackupKeyRequiredError;
96461
99682
  exports.CAP_ACTION_OVERFLOW_LABEL = require_child_cap_dispatch.CAP_ACTION_OVERFLOW_LABEL;
96462
99683
  exports.CAP_ACTION_UNLABELLED = require_child_cap_dispatch.CAP_ACTION_UNLABELLED;
96463
99684
  exports.CAP_METHOD_NOT_IMPLEMENTED = require_child_cap_dispatch.CAP_METHOD_NOT_IMPLEMENTED;
@@ -96541,12 +99762,24 @@ exports.LocalChildRegistry = require_child_cap_dispatch.LocalChildRegistry;
96541
99762
  exports.LogManager = LogManager;
96542
99763
  exports.LogRingBuffer = LogRingBuffer;
96543
99764
  exports.LoggingGate = LoggingGate;
99765
+ exports.LoginSessionManager = require_builtins_local_auth_local_auth_addon.LoginSessionManager;
96544
99766
  exports.LokiDestination = require_builtins_loki_logging_index.LokiDestination$1;
96545
99767
  exports.LokiLoggingAddon = require_builtins_loki_logging_index.LokiLoggingAddon$1;
96546
99768
  exports.MAX_CAP_ACTIONS_PER_PEER = require_child_cap_dispatch.MAX_CAP_ACTIONS_PER_PEER;
96547
99769
  exports.MAX_LEAF_VALIDITY_DAYS = require_tls$1.MAX_LEAF_VALIDITY_DAYS;
99770
+ exports.MESH_ACTION_FORBIDDEN_TYPE = MESH_ACTION_FORBIDDEN_TYPE;
99771
+ exports.MESH_AUTH_MODE_FIELD = require_builtins_system_config_system_config_addon.MESH_AUTH_MODE_FIELD;
99772
+ exports.MESH_AUTO_ENFORCE_GRACE_MS = MESH_AUTO_ENFORCE_GRACE_MS;
99773
+ exports.MESH_JOIN_AUTHENTICATE_ACTION = MESH_JOIN_AUTHENTICATE_ACTION;
99774
+ exports.MESH_JOIN_CHALLENGE_ACTION = MESH_JOIN_CHALLENGE_ACTION;
99775
+ exports.MESH_JOIN_CHALLENGE_INVALID_TYPE = MESH_JOIN_CHALLENGE_INVALID_TYPE;
99776
+ exports.MESH_JOIN_CHALLENGE_TTL_MS = MESH_JOIN_CHALLENGE_TTL_MS;
99777
+ exports.MESH_JOIN_PROTOCOL = MESH_JOIN_PROTOCOL;
99778
+ exports.MESH_NODE_UNAUTHENTICATED_TYPE = MESH_NODE_UNAUTHENTICATED_TYPE;
96548
99779
  exports.MESH_QUEUE_TOP_N = require_child_cap_dispatch.MESH_QUEUE_TOP_N;
96549
99780
  exports.METHOD_ACCESS_MAP = require_dist.METHOD_ACCESS_MAP;
99781
+ exports.MeshAuthenticator = MeshAuthenticator;
99782
+ exports.MeshJoinClient = MeshJoinClient;
96550
99783
  exports.ModelDownloadService = require_event_loop_stall_monitor.ModelDownloadService;
96551
99784
  exports.NATIVE_PROVIDER_SERVICE_INFIX = require_child_cap_dispatch.NATIVE_PROVIDER_SERVICE_INFIX;
96552
99785
  exports.NATIVE_SCAN_DEPTH = NATIVE_SCAN_DEPTH;
@@ -96569,6 +99802,7 @@ exports.PipelineRunner = PipelineRunner;
96569
99802
  exports.PipelineValidator = PipelineValidator;
96570
99803
  exports.PythonEnvManager = PythonEnvManager;
96571
99804
  exports.QUARANTINE_DIRNAME = QUARANTINE_DIRNAME;
99805
+ exports.REFRESH_TOKEN_PREFIX = require_builtins_local_auth_local_auth_addon.REFRESH_TOKEN_PREFIX;
96572
99806
  exports.RESTART_MARKER_FILE = RESTART_MARKER_FILE;
96573
99807
  exports.RSS_BUDGET_REANNOUNCE_MIN_MS = require_child_cap_dispatch.RSS_BUDGET_REANNOUNCE_MIN_MS;
96574
99808
  exports.RSS_BUDGET_RELEASE_RATIO = require_child_cap_dispatch.RSS_BUDGET_RELEASE_RATIO;
@@ -96597,6 +99831,7 @@ exports.StorageLocationManager = StorageLocationManager;
96597
99831
  exports.StorageManager = StorageManager;
96598
99832
  exports.StorageOrchestratorAddon = require_builtins_storage_orchestrator_storage_orchestrator_addon.StorageOrchestratorAddon;
96599
99833
  exports.StorageOrchestratorService = require_builtins_storage_orchestrator_storage_orchestrator_addon.StorageOrchestratorService;
99834
+ exports.SystemBackupService = require_restore_archive.SystemBackupService;
96600
99835
  exports.SystemConfigAddon = require_builtins_system_config_system_config_addon.SystemConfigAddon;
96601
99836
  exports.SystemEventBus = SystemEventBus;
96602
99837
  exports.TRADITIONAL_NATIVE_PACKAGES = TRADITIONAL_NATIVE_PACKAGES;
@@ -96604,6 +99839,7 @@ exports.ToastService = ToastService;
96604
99839
  exports.UDS_NO_ROUTE_PREFIX = require_child_cap_dispatch.UDS_NO_ROUTE_PREFIX;
96605
99840
  exports.UNCLAIMED = UNCLAIMED;
96606
99841
  exports.UPLOADED_CA_FILE = require_tls$1.UPLOADED_CA_FILE;
99842
+ exports.USER_MANAGEMENT_INTERNAL = require_builtins_local_auth_local_auth_addon.USER_MANAGEMENT_INTERNAL;
96607
99843
  exports.UdsLocalTransportClient = require_child_cap_dispatch.UdsLocalTransportClient;
96608
99844
  exports.UdsLocalTransportServer = require_child_cap_dispatch.UdsLocalTransportServer;
96609
99845
  exports.UserManager = require_builtins_local_auth_local_auth_addon.UserManager;
@@ -96620,6 +99856,7 @@ exports.allFamiliesListenHost = require_tls$1.allFamiliesListenHost;
96620
99856
  exports.answerClaimedGetStatus = require_child_cap_dispatch.answerClaimedGetStatus;
96621
99857
  exports.applyCertificateToListener = require_tls$1.applyCertificateToListener;
96622
99858
  exports.applyLanHttp = require_tls$1.applyLanHttp;
99859
+ exports.attachUserManagementInternal = require_builtins_local_auth_local_auth_addon.attachUserManagementInternal;
96623
99860
  exports.attributeStall = require_event_loop_stall_monitor.attributeStall;
96624
99861
  exports.bindPendingLanHttp = require_tls$1.bindPendingLanHttp;
96625
99862
  exports.bootstrapSchema = bootstrapSchema;
@@ -96658,6 +99895,8 @@ exports.clusterEventTopic = require_child_cap_dispatch.clusterEventTopic;
96658
99895
  exports.clusterSecretMatches = require_cluster_secret.clusterSecretMatches;
96659
99896
  exports.collectCertIdentity = require_tls$1.collectCertIdentity;
96660
99897
  exports.collectModelFiles = require_event_loop_stall_monitor.collectModelFiles;
99898
+ exports.computeHubJoinProof = computeHubJoinProof;
99899
+ exports.computeNodeJoinProof = computeNodeJoinProof;
96661
99900
  exports.contentTypeFor = require_event_loop_stall_monitor.contentTypeFor;
96662
99901
  exports.copyDirRecursive = copyDirRecursive;
96663
99902
  exports.copyExtraFileDirs = copyExtraFileDirs;
@@ -96670,6 +99909,7 @@ exports.createAuthenticatedFileServer = require_event_loop_stall_monitor.createA
96670
99909
  exports.createBroker = createBroker;
96671
99910
  exports.createBrokerDeviceManagerApi = require_child_cap_dispatch.createBrokerDeviceManagerApi;
96672
99911
  exports.createCapActionCensus = require_child_cap_dispatch.createCapActionCensus;
99912
+ exports.createCidrMatcher = require_builtins_system_config_system_config_addon.createCidrMatcher;
96673
99913
  exports.createCoreCapService = createCoreCapService;
96674
99914
  exports.createDeferredHeapWatchSink = require_child_cap_dispatch.createDeferredHeapWatchSink;
96675
99915
  exports.createDoorSettingsView = createDoorSettingsView;
@@ -96682,6 +99922,7 @@ exports.createInspectorArrayBufferCensus = require_child_cap_dispatch.createInsp
96682
99922
  exports.createKernelHwAccel = require_child_cap_dispatch.createKernelHwAccel;
96683
99923
  exports.createLocalTransport = require_child_cap_dispatch.createLocalTransport;
96684
99924
  exports.createLoopDelayMeter = require_child_cap_dispatch.createLoopDelayMeter;
99925
+ exports.createMeshAccessMiddleware = createMeshAccessMiddleware;
96685
99926
  exports.createMeshQueueReader = require_child_cap_dispatch.createMeshQueueReader;
96686
99927
  exports.createOutboundQueueGate = require_child_cap_dispatch.createOutboundQueueGate;
96687
99928
  exports.createParentUnownedCallHandler = require_child_cap_dispatch.createParentUnownedCallHandler;
@@ -96699,6 +99940,7 @@ exports.createUdsEventBus = require_child_cap_dispatch.createUdsEventBus;
96699
99940
  exports.createUdsLogger = require_child_cap_dispatch.createUdsLogger;
96700
99941
  exports.createUdsLoggerWithControl = require_child_cap_dispatch.createUdsLoggerWithControl;
96701
99942
  exports.createV8Reclaimer = require_child_cap_dispatch.createV8Reclaimer;
99943
+ exports.decideMeshAutoEnforce = decideMeshAutoEnforce;
96702
99944
  exports.deleteModelFromDisk = require_event_loop_stall_monitor.deleteModelFromDisk;
96703
99945
  exports.deriveAgentListenPort = deriveAgentListenPort;
96704
99946
  exports.describeProviderKindDrift = describeProviderKindDrift;
@@ -96760,6 +100002,7 @@ exports.formatLogLine = require_formatter.formatLogLine;
96760
100002
  exports.formatMeshQueue = require_child_cap_dispatch.formatMeshQueue;
96761
100003
  exports.formatOutboundQueueVerdict = require_child_cap_dispatch.formatOutboundQueueVerdict;
96762
100004
  exports.formatSocketPlane = require_child_cap_dispatch.formatSocketPlane;
100005
+ exports.generateBackupKeyPair = require_restore_archive.generateBackupKeyPair;
96763
100006
  exports.getBrokerEventBus = require_child_cap_dispatch.getBrokerEventBus;
96764
100007
  exports.getCapUsageRegistry = require_child_cap_dispatch.getCapUsageRegistry;
96765
100008
  Object.defineProperty(exports, "getFfmpegDownloadUrl", {
@@ -96783,6 +100026,8 @@ Object.defineProperty(exports, "getPlatformInfo", {
96783
100026
  exports.getPlatformKeychainKey = require_platform_key_source.getPlatformKeychainKey;
96784
100027
  exports.getProcessClusterSecretGate = require_cluster_secret.getProcessClusterSecretGate;
96785
100028
  exports.getProcessJwtSigningKeyState = require_jwt_signing_key.getProcessJwtSigningKeyState;
100029
+ exports.getProcessMeshAuthMode = require_builtins_system_config_system_config_addon.getProcessMeshAuthMode;
100030
+ exports.getProcessMeshAuthStatus = require_builtins_system_config_system_config_addon.getProcessMeshAuthStatus;
96786
100031
  Object.defineProperty(exports, "getPythonDownloadUrl", {
96787
100032
  enumerable: true,
96788
100033
  get: function() {
@@ -96791,6 +100036,7 @@ Object.defineProperty(exports, "getPythonDownloadUrl", {
96791
100036
  });
96792
100037
  exports.getRestartMarkerPath = getRestartMarkerPath;
96793
100038
  exports.getSinglePidStats = require_resource_monitor.getSinglePidStats;
100039
+ exports.getUserManagementInternal = require_builtins_local_auth_local_auth_addon.getUserManagementInternal;
96794
100040
  exports.getWorkerDeviceRegistry = require_child_cap_dispatch.getWorkerDeviceRegistry;
96795
100041
  exports.hasDotNode = hasDotNode;
96796
100042
  exports.hashClusterSecret = require_cluster_secret.hashClusterSecret;
@@ -96821,7 +100067,9 @@ exports.isClusterSecretMismatchError = require_cluster_secret.isClusterSecretMis
96821
100067
  exports.isCollectionArrayMethod = require_dist.isCollectionArrayMethod;
96822
100068
  exports.isCredentialKeyName = require_child_cap_dispatch.isCredentialKeyName;
96823
100069
  exports.isInfraCapability = isInfraCapability;
100070
+ exports.isMeshAuthMode = require_builtins_system_config_system_config_addon.isMeshAuthMode;
96824
100071
  exports.isModelDownloaded = require_event_loop_stall_monitor.isModelDownloaded;
100072
+ exports.isRemoteForbiddenAction = isRemoteForbiddenAction;
96825
100073
  exports.isSettingsReadUnavailable = require_builtins_local_auth_local_auth_addon.isSettingsReadUnavailable;
96826
100074
  exports.isSourceNewer = isSourceNewer;
96827
100075
  exports.isolatedBuiltinPhase = isolatedBuiltinPhase;
@@ -96829,18 +100077,26 @@ exports.leafFingerprintOf = require_tls$1.leafFingerprintOf;
96829
100077
  exports.loadTlsCert = require_tls$1.loadTlsCert;
96830
100078
  exports.localEndpointPath = require_child_cap_dispatch.localEndpointPath;
96831
100079
  exports.localProviderLink = require_child_cap_dispatch.localProviderLink;
100080
+ exports.meshErrorType = meshErrorType;
96832
100081
  exports.mountNativeCapService = require_child_cap_dispatch.mountNativeCapService;
96833
100082
  exports.nextRssBudgetState = require_child_cap_dispatch.nextRssBudgetState;
100083
+ exports.normalizeIp = require_builtins_system_config_system_config_addon.normalizeIp;
96834
100084
  exports.overlayGetStatus = overlayGetStatus;
96835
100085
  exports.parseCapAction = require_child_cap_dispatch.parseCapAction;
100086
+ exports.parseCidrList = require_builtins_system_config_system_config_addon.parseCidrList;
100087
+ exports.parseMeshAuthMode = require_builtins_system_config_system_config_addon.parseMeshAuthMode;
96836
100088
  exports.parseRangeHeader = require_event_loop_stall_monitor.parseRangeHeader;
96837
100089
  exports.parseRssBudgetMb = require_child_cap_dispatch.parseRssBudgetMb;
100090
+ exports.parseTokenExpiry = require_builtins_local_auth_local_auth_addon.parseTokenExpiry;
96838
100091
  exports.parseTokenizedUrl = require_event_loop_stall_monitor.parseTokenizedUrl;
96839
100092
  exports.partitionIsolatedBuiltinIds = partitionIsolatedBuiltinIds;
96840
100093
  exports.prepareBootTls = require_tls$1.prepareBootTls;
100094
+ exports.prepareRestoreArchive = require_restore_archive.prepareRestoreArchive;
96841
100095
  exports.processJwtSigningKey = require_jwt_signing_key.processJwtSigningKey;
96842
100096
  exports.proxyToUpstream = proxyToUpstream;
96843
100097
  exports.quarantineAddonResidue = quarantineAddonResidue;
100098
+ exports.readBackupEncryptionHeader = require_restore_archive.readBackupEncryptionHeader;
100099
+ exports.readCidrSetting = require_builtins_system_config_system_config_addon.readCidrSetting;
96844
100100
  exports.readExtraSans = require_tls$1.readExtraSans;
96845
100101
  exports.readHeapSpaces = require_child_cap_dispatch.readHeapSpaces;
96846
100102
  exports.readLanHttpState = require_tls$1.readLanHttpState;
@@ -96860,6 +100116,7 @@ exports.registerHttpsListener = require_tls$1.registerHttpsListener;
96860
100116
  exports.registerLanHttpHandler = require_tls$1.registerLanHttpHandler;
96861
100117
  exports.reissueTlsLeaf = require_tls$1.reissueTlsLeaf;
96862
100118
  exports.reloadHttpsListener = require_tls$1.reloadHttpsListener;
100119
+ exports.requestProcessMeshEnforcement = require_builtins_system_config_system_config_addon.requestProcessMeshEnforcement;
96863
100120
  exports.resolveFilePath = require_event_loop_stall_monitor.resolveFilePath;
96864
100121
  exports.resolveFormatRevision = require_event_loop_stall_monitor.resolveFormatRevision;
96865
100122
  exports.resolveHwAccel = require_child_cap_dispatch.resolveHwAccel;
@@ -96881,6 +100138,9 @@ exports.setHubConnected = require_child_cap_dispatch.setHubConnected;
96881
100138
  exports.setNodeEventInterest = require_child_cap_dispatch.setNodeEventInterest;
96882
100139
  exports.setPlatformKeychainKey = require_platform_key_source.setPlatformKeychainKey;
96883
100140
  exports.setProcessClusterSecretGate = require_cluster_secret.setProcessClusterSecretGate;
100141
+ exports.setProcessMeshAuthMode = require_builtins_system_config_system_config_addon.setProcessMeshAuthMode;
100142
+ exports.setProcessMeshAuthStatusSource = require_builtins_system_config_system_config_addon.setProcessMeshAuthStatusSource;
100143
+ exports.setProcessMeshEnforcer = require_builtins_system_config_system_config_addon.setProcessMeshEnforcer;
96884
100144
  exports.setWrapperActive = require_builtins_device_manager_device_manager_addon.setWrapperActive;
96885
100145
  exports.shouldReclaim = require_child_cap_dispatch.shouldReclaim;
96886
100146
  exports.signalAllRunnerGroups = require_child_cap_dispatch.signalAllRunnerGroups;
@@ -96896,6 +100156,8 @@ exports.storeMayAnswer = storeMayAnswer;
96896
100156
  exports.storeUploadedCertificate = require_tls$1.storeUploadedCertificate;
96897
100157
  exports.strandedMb = require_child_cap_dispatch.strandedMb;
96898
100158
  exports.stripCamstackDeps = stripCamstackDeps;
100159
+ exports.stripForgedIdentity = stripForgedIdentity;
100160
+ exports.stripForwardedCaller = require_hub_cap_forward.stripForwardedCaller;
96899
100161
  exports.subscribePassthrough = require_child_cap_dispatch.subscribePassthrough;
96900
100162
  exports.udsChildLogToWorkerEntry = require_child_cap_dispatch.udsChildLogToWorkerEntry;
96901
100163
  exports.validateProviderRegistrations = require_child_cap_dispatch.validateProviderRegistrations;