@camstack/server 1.2.926 → 1.2.928

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 (96) hide show
  1. package/CHANGELOG.md +14 -0
  2. package/package.json +10 -17
  3. package/system/dist/addon-utils.mjs +1 -1
  4. package/system/dist/builtins/addon-pages-aggregator/addon-pages-aggregator.addon.js +1 -1
  5. package/system/dist/builtins/addon-pages-aggregator/addon-pages-aggregator.addon.mjs +4 -4
  6. package/system/dist/builtins/addon-widgets-aggregator/addon-widgets-aggregator.addon.js +1 -1
  7. package/system/dist/builtins/addon-widgets-aggregator/addon-widgets-aggregator.addon.mjs +5 -5
  8. package/system/dist/builtins/alerts/alerts.addon.js +1 -1
  9. package/system/dist/builtins/alerts/alerts.addon.mjs +3 -3
  10. package/system/dist/builtins/autotrack/index.js +1 -1
  11. package/system/dist/builtins/autotrack/index.mjs +1 -1
  12. package/system/dist/builtins/backup-orchestrator/backup-orchestrator.addon.js +2 -2
  13. package/system/dist/builtins/backup-orchestrator/backup-orchestrator.addon.mjs +5 -5
  14. package/system/dist/builtins/calendars/calendars.addon.js +1 -1
  15. package/system/dist/builtins/calendars/calendars.addon.mjs +1 -1
  16. package/system/dist/builtins/camera-grid/index.js +1 -1
  17. package/system/dist/builtins/camera-grid/index.mjs +1 -1
  18. package/system/dist/builtins/composer/composer.addon.js +4 -4
  19. package/system/dist/builtins/composer/composer.addon.mjs +4 -4
  20. package/system/dist/builtins/console-logging/index.js +1 -1
  21. package/system/dist/builtins/console-logging/index.mjs +1 -1
  22. package/system/dist/builtins/core-blocks/core-blocks.addon.js +4 -4
  23. package/system/dist/builtins/core-blocks/core-blocks.addon.mjs +4 -4
  24. package/system/dist/builtins/core-notifier/core-notifier.addon.js +1 -1
  25. package/system/dist/builtins/core-notifier/core-notifier.addon.mjs +1 -1
  26. package/system/dist/builtins/device-history/device-history.addon.js +2 -2
  27. package/system/dist/builtins/device-history/device-history.addon.mjs +2 -2
  28. package/system/dist/builtins/device-manager/device-manager.addon.js +103 -55
  29. package/system/dist/builtins/device-manager/device-manager.addon.mjs +103 -55
  30. package/system/dist/builtins/device-manager/transitions/transition-correlator.d.ts +24 -11
  31. package/system/dist/builtins/hub-forwarder/index.js +1 -1
  32. package/system/dist/builtins/hub-forwarder/index.mjs +1 -1
  33. package/system/dist/builtins/keychain/index.js +4 -4
  34. package/system/dist/builtins/keychain/index.mjs +4 -4
  35. package/system/dist/builtins/liveness-monitor/liveness-monitor.addon.js +1 -1
  36. package/system/dist/builtins/liveness-monitor/liveness-monitor.addon.mjs +1 -1
  37. package/system/dist/builtins/local-auth/local-auth.addon.js +2 -2
  38. package/system/dist/builtins/local-auth/local-auth.addon.mjs +5 -5
  39. package/system/dist/builtins/local-network/local-network.addon.d.ts +13 -0
  40. package/system/dist/builtins/local-network/local-network.addon.js +47 -10
  41. package/system/dist/builtins/local-network/local-network.addon.mjs +47 -10
  42. package/system/dist/builtins/loki-logging/index.js +1 -1
  43. package/system/dist/builtins/loki-logging/index.mjs +1 -1
  44. package/system/dist/builtins/native-metrics/native-metrics.addon.js +1 -1
  45. package/system/dist/builtins/native-metrics/native-metrics.addon.mjs +10 -10
  46. package/system/dist/builtins/platform-probe/index.js +1 -1
  47. package/system/dist/builtins/platform-probe/index.mjs +10 -10
  48. package/system/dist/builtins/record-entries/index.js +1 -1
  49. package/system/dist/builtins/record-entries/index.mjs +1 -1
  50. package/system/dist/builtins/remote-access-orchestrator/remote-access-orchestrator.addon.js +1 -1
  51. package/system/dist/builtins/remote-access-orchestrator/remote-access-orchestrator.addon.mjs +1 -1
  52. package/system/dist/builtins/snapshot/index.js +1 -1
  53. package/system/dist/builtins/snapshot/index.mjs +1 -1
  54. package/system/dist/builtins/sqlite-storage/filesystem-storage.addon.js +1 -1
  55. package/system/dist/builtins/sqlite-storage/filesystem-storage.addon.mjs +20 -20
  56. package/system/dist/builtins/sqlite-storage/index.js +1 -1
  57. package/system/dist/builtins/sqlite-storage/index.mjs +1 -1
  58. package/system/dist/builtins/sqlite-storage/sqlite-settings.addon.js +3 -3
  59. package/system/dist/builtins/sqlite-storage/sqlite-settings.addon.mjs +3 -3
  60. package/system/dist/builtins/storage-orchestrator/storage-orchestrator.addon.js +1 -1
  61. package/system/dist/builtins/storage-orchestrator/storage-orchestrator.addon.mjs +1 -1
  62. package/system/dist/builtins/system-config/system-config.addon.js +3 -3
  63. package/system/dist/builtins/system-config/system-config.addon.mjs +115 -115
  64. package/system/dist/builtins/winston-logging/index.js +1 -1
  65. package/system/dist/builtins/winston-logging/index.mjs +1 -1
  66. package/system/dist/{capture-engine-BEXh051r.js → capture-engine-BcuwOSXv.js} +1 -1
  67. package/system/dist/{capture-engine-CWfylyT8.mjs → capture-engine-Bz7eXFjT.mjs} +1 -1
  68. package/system/dist/{composition-sources-CcpMUxus.mjs → composition-sources-BI614LJx.mjs} +1 -1
  69. package/system/dist/{composition-sources-B3_FuKde.js → composition-sources-v_kkb8A9.js} +1 -1
  70. package/system/dist/{constants-fPesBGmF.mjs → constants-BcUTQd1M.mjs} +1 -1
  71. package/system/dist/{constants-B0tqNa2l.js → constants-D2etJ02O.js} +1 -1
  72. package/system/dist/{coral-accelerators-DBlgWB8k.mjs → coral-accelerators-BW3OcrLD.mjs} +6 -6
  73. package/system/dist/{custom-action-registry-B9zFBNVa.mjs → custom-action-registry-N7flBDwT.mjs} +37 -37
  74. package/system/dist/{device-ca-Bh0GEstW.js → device-ca-CU8zh9Pi.js} +1 -1
  75. package/system/dist/{device-ca-B98SR8Xf.mjs → device-ca-ExMN3xW3.mjs} +1 -1
  76. package/system/dist/{device-row-store-CfWN8mLZ.js → device-row-store-BMIR-n3m.js} +1 -1
  77. package/system/dist/{device-row-store-BBByy029.mjs → device-row-store-CeW_GWh9.mjs} +1 -1
  78. package/system/dist/{dist-CH-iCceM.mjs → dist-BCHMSqzc.mjs} +325 -2
  79. package/system/dist/{dist-CVjsCA7D.js → dist-BZfvhfS1.js} +325 -2
  80. package/system/dist/file-host-worker.js +1 -1
  81. package/system/dist/file-host-worker.mjs +1 -1
  82. package/system/dist/{hub-identity-DCqJbSVn.mjs → hub-identity-CYC1820R.mjs} +10 -10
  83. package/system/dist/{hub-identity-BU4XzogT.js → hub-identity-Csxx2Q8k.js} +1 -1
  84. package/system/dist/{hub-mdns-ciao-BNzmwsIH.js → hub-mdns-ciao-By5577HM.js} +2 -2
  85. package/system/dist/{hub-mdns-ciao-IOM82NRd.mjs → hub-mdns-ciao-CCDxM5qz.mjs} +2 -2
  86. package/system/dist/index.js +8 -8
  87. package/system/dist/index.mjs +217 -217
  88. package/system/dist/{legacy-integration-rows-door-CRcvhOWb.js → legacy-integration-rows-door-CVwOo5aq.js} +1 -1
  89. package/system/dist/{legacy-integration-rows-door-nQzjUyPU.mjs → legacy-integration-rows-door-D9tQOUzh.mjs} +1 -1
  90. package/system/dist/{rename-composition-block-oOfXrUWs.js → rename-composition-block-C9HuBrKS.js} +1 -1
  91. package/system/dist/{rename-composition-block-CJ-C9HoY.mjs → rename-composition-block-DtaYmYAR.mjs} +1 -1
  92. package/system/dist/{restore-archive-DaYf1tQb.mjs → restore-archive-BJfyu0sG.mjs} +94 -94
  93. package/system/dist/{restore-archive-BSdudYif.js → restore-archive-CIFvqOze.js} +1 -1
  94. package/system/dist/{wal-maintenance-CyOVe3E1.mjs → wal-maintenance-CTrCPzds.mjs} +0 -0
  95. package/system/dist/{wal-maintenance-BRc_MNtZ.js → wal-maintenance-dq7T3quB.js} +0 -0
  96. package/system/package.json +1 -1
@@ -1,14 +1,14 @@
1
1
  import { i as __require, o as __toESM, t as __commonJSMin } from "../../chunk-CNf5ZN-e.mjs";
2
- import { $r as deviceCredentialsCapability, $t as PREFERENCES_MAX_VALUE_BYTES, Ai as formatDeviceRevoker, H as DEVICE_ENROLLMENT_TTL_MS, In as UserRecordSchema, K as DEVICE_NONCE_TTL_MS, Lc as BaseAddon, O as CREDENTIAL_TOKEN_AUDIENCE, P as CredentialTokenClaimsSchema, Pn as TokenScopeSchema, Pu as userError, Qn as authProviderCapability, Rs as userManagementCapability, Sn as ScopedTokenSchema, Tn as SsoBridgeClaimsSchema, an as PreferenceDeviceIdSchema, ar as buildDeviceSignatureMessage, ir as buildDeviceEnrollmentLink, lu as makeSecretMarker, on as PreferenceNamespaceSchema, ou as isSecretMarker, sn as PreferenceValueSchema, ta as isCredentialTokenPayload, zl as defineRecordKinds } from "../../dist-CH-iCceM.mjs";
2
+ import { $r as deviceCredentialsCapability, $t as PREFERENCES_MAX_VALUE_BYTES, Ai as formatDeviceRevoker, H as DEVICE_ENROLLMENT_TTL_MS, In as UserRecordSchema, K as DEVICE_NONCE_TTL_MS, Lc as BaseAddon, O as CREDENTIAL_TOKEN_AUDIENCE, P as CredentialTokenClaimsSchema, Pn as TokenScopeSchema, Pu as userError, Qn as authProviderCapability, Rs as userManagementCapability, Sn as ScopedTokenSchema, Tn as SsoBridgeClaimsSchema, an as PreferenceDeviceIdSchema, ar as buildDeviceSignatureMessage, ir as buildDeviceEnrollmentLink, lu as makeSecretMarker, on as PreferenceNamespaceSchema, ou as isSecretMarker, sn as PreferenceValueSchema, ta as isCredentialTokenPayload, zl as defineRecordKinds } from "../../dist-BCHMSqzc.mjs";
3
3
  import { t as require_safe_buffer } from "../../safe-buffer-B1OjL1I9.mjs";
4
4
  import { t as require_ms } from "../../ms-CgH2OFlD.mjs";
5
- import { _ as setProcessJwtSigningKey, a as importDevicePublicKey, c as rebuildDeviceCaCertificate, d as JWT_SIGNING_KEY_REF, g as processJwtSigningKey, h as loadJwtSigningKey, i as generateDeviceCa, l as verifyDeviceLeaf, m as getProcessJwtSigningKeyState, n as DEVICE_CA_KEY_REF, o as issueDeviceLeaf, r as DEVICE_CA_SETTINGS_SECTION, s as loadDeviceCa, t as DEVICE_CA_FIELD, u as verifyDeviceSignature } from "../../device-ca-B98SR8Xf.mjs";
5
+ import { _ as setProcessJwtSigningKey, a as importDevicePublicKey, c as rebuildDeviceCaCertificate, d as JWT_SIGNING_KEY_REF, g as processJwtSigningKey, h as loadJwtSigningKey, i as generateDeviceCa, l as verifyDeviceLeaf, m as getProcessJwtSigningKeyState, n as DEVICE_CA_KEY_REF, o as issueDeviceLeaf, r as DEVICE_CA_SETTINGS_SECTION, s as loadDeviceCa, t as DEVICE_CA_FIELD, u as verifyDeviceSignature } from "../../device-ca-ExMN3xW3.mjs";
6
6
  import { t as require_read_all_rows } from "../../read-all-rows-TaPqdWNF.mjs";
7
7
  import { z } from "zod";
8
8
  import * as crypto$1 from "node:crypto";
9
9
  import { X509Certificate, createHash, randomUUID, timingSafeEqual } from "node:crypto";
10
10
  import nodeCrypto from "crypto";
11
- import * as fs$1 from "node:fs";
11
+ import * as fs from "node:fs";
12
12
  import * as path$1 from "node:path";
13
13
  //#region ../../node_modules/bcryptjs/index.js
14
14
  /**
@@ -11925,8 +11925,8 @@ var LocalAuthAddon = class extends BaseAddon {
11925
11925
  users: this.userManager,
11926
11926
  dataDir: this.ctx.nodeDataDir,
11927
11927
  fs: {
11928
- exists: (filePath) => fs$1.existsSync(filePath),
11929
- remove: (filePath) => fs$1.rmSync(filePath, { force: true })
11928
+ exists: (filePath) => fs.existsSync(filePath),
11929
+ remove: (filePath) => fs.rmSync(filePath, { force: true })
11930
11930
  },
11931
11931
  logger: this.ctx.logger
11932
11932
  });
@@ -97,6 +97,7 @@ export declare class LocalNetworkAddon extends BaseAddon<LocalNetworkConfig> {
97
97
  * `null` when no mesh provider is joined.
98
98
  */
99
99
  private meshEndpoint;
100
+ private lastTunnelReconcileAt;
100
101
  private mdns;
101
102
  private discoveryWatcher;
102
103
  private watcherPassive;
@@ -182,6 +183,18 @@ export declare class LocalNetworkAddon extends BaseAddon<LocalNetworkConfig> {
182
183
  */
183
184
  setPublicHostname(hostname: string, stable?: boolean): void;
184
185
  /**
186
+ * Adopt a tunnel URL as the public hostname. Ignores the pre-FQDN placeholders a tunnel
187
+ * reports before its real name is known, and a malformed URL (cache left as-is).
188
+ */
189
+ private adoptTunnelUrl;
190
+ /**
191
+ * Pull-reconcile the public tunnel hostname from the `network-access` provider (the start
192
+ * event is lossy — D8/D49). `connected` + endpoint adopts it, `connected: false` clears it, a
193
+ * FAILED read (throw, no provider, timeout) changes nothing. Throttled and time-boxed so a
194
+ * slow provider cannot hold up a palette build.
195
+ */
196
+ private reconcileTunnelHostname;
197
+ /**
185
198
  * Replace the cached mesh endpoint. Set from the `MeshNetworkChanged`
186
199
  * event-tail + the pull-reconcile; exposed for tests + future direct
187
200
  * callers. Pass `null` to clear (mesh left / no provider joined).
@@ -1,9 +1,9 @@
1
1
  Object.defineProperty(exports, Symbol.toStringTag, { value: "Module" });
2
2
  const require_chunk = require("../../chunk-Cek0wNdY.js");
3
- const require_dist = require("../../dist-CVjsCA7D.js");
3
+ const require_dist = require("../../dist-BZfvhfS1.js");
4
4
  const require_dns_wire = require("../../dns-wire-B1BvF9Ao.js");
5
- const require_hub_identity = require("../../hub-identity-BU4XzogT.js");
6
- const require_hub_mdns_ciao = require("../../hub-mdns-ciao-BNzmwsIH.js");
5
+ const require_hub_identity = require("../../hub-identity-Csxx2Q8k.js");
6
+ const require_hub_mdns_ciao = require("../../hub-mdns-ciao-By5577HM.js");
7
7
  let zod = require("zod");
8
8
  let node_net = require("node:net");
9
9
  let node_fs = require("node:fs");
@@ -1634,6 +1634,10 @@ var StringListSchema = zod.z.array(zod.z.string());
1634
1634
  */
1635
1635
  var MESH_PROVIDER_ADDON_IDS = ["tailscale-client"];
1636
1636
  var POLL_INTERVAL_MS = 3e4;
1637
+ /** A tunnel-status pull is skipped when one ran this recently (the event is the fast path). */
1638
+ var TUNNEL_RECONCILE_MIN_INTERVAL_MS = 5e3;
1639
+ /** A tunnel-status pull that does not answer in this time changes nothing. */
1640
+ var TUNNEL_RECONCILE_TIMEOUT_MS = 2e3;
1637
1641
  /** Drop rotated IPv6 / dead extras from the persisted allowlist. */
1638
1642
  var ALLOWLIST_RECONCILE_INTERVAL_MS = 3600 * 1e3;
1639
1643
  /**
@@ -1659,6 +1663,7 @@ var LocalNetworkAddon = class extends require_dist.BaseAddon {
1659
1663
  * `null` when no mesh provider is joined.
1660
1664
  */
1661
1665
  meshEndpoint = null;
1666
+ lastTunnelReconcileAt = 0;
1662
1667
  mdns = null;
1663
1668
  discoveryWatcher = null;
1664
1669
  watcherPassive = true;
@@ -1688,6 +1693,7 @@ var LocalNetworkAddon = class extends require_dist.BaseAddon {
1688
1693
  async palettes() {
1689
1694
  const port = (await this.resolveAdvertisedListenPort(null)).port;
1690
1695
  await this.reconcileMeshEndpoint();
1696
+ await this.reconcileTunnelHostname();
1691
1697
  const http = this.endpointsNow(false, false, "http", port);
1692
1698
  const https = this.endpointsNow(false, false, "https", port);
1693
1699
  return {
@@ -1820,6 +1826,7 @@ var LocalNetworkAddon = class extends require_dist.BaseAddon {
1820
1826
  */
1821
1827
  async buildAdvertisedEndpoints(includeLoopback, ipv4Only, scheme, httpsPort) {
1822
1828
  await this.reconcileMeshEndpoint();
1829
+ await this.reconcileTunnelHostname();
1823
1830
  const detected = withLanHttpsCounterparts(this.endpointsNow(includeLoopback, ipv4Only, scheme, httpsPort), httpsPort);
1824
1831
  return withAppConnectionCustomEndpoints(detected, this.addressState(detected));
1825
1832
  }
@@ -2018,13 +2025,7 @@ var LocalNetworkAddon = class extends require_dist.BaseAddon {
2018
2025
  this.allowlistTimer.unref?.();
2019
2026
  this.ctx.eventBus?.subscribe({ category: require_dist.EventCategory.NetworkTunnelStarted }, (event) => {
2020
2027
  const parsed = require_dist.NetworkTunnelStartedDataSchema.safeParse(event.data ?? {});
2021
- if (parsed.success) {
2022
- const data = parsed.data;
2023
- try {
2024
- const hostname = new URL(data.url).hostname;
2025
- if (hostname && !hostname.endsWith(".placeholder") && !hostname.startsWith("pending.")) this.setPublicHostname(hostname, data.stable !== false);
2026
- } catch {}
2027
- }
2028
+ if (parsed.success) this.adoptTunnelUrl(parsed.data.url, parsed.data.stable);
2028
2029
  });
2029
2030
  this.ctx.eventBus?.subscribe({ category: require_dist.EventCategory.NetworkTunnelStopped }, () => this.setPublicHostname(""));
2030
2031
  this.ctx.eventBus?.subscribe({ category: require_dist.EventCategory.MeshNetworkChanged }, (event) => {
@@ -2225,6 +2226,42 @@ var LocalNetworkAddon = class extends require_dist.BaseAddon {
2225
2226
  } });
2226
2227
  }
2227
2228
  /**
2229
+ * Adopt a tunnel URL as the public hostname. Ignores the pre-FQDN placeholders a tunnel
2230
+ * reports before its real name is known, and a malformed URL (cache left as-is).
2231
+ */
2232
+ adoptTunnelUrl(url, stable) {
2233
+ try {
2234
+ const hostname = new URL(url).hostname;
2235
+ if (hostname && !hostname.endsWith(".placeholder") && !hostname.startsWith("pending.")) this.setPublicHostname(hostname, stable !== false);
2236
+ } catch {}
2237
+ }
2238
+ /**
2239
+ * Pull-reconcile the public tunnel hostname from the `network-access` provider (the start
2240
+ * event is lossy — D8/D49). `connected` + endpoint adopts it, `connected: false` clears it, a
2241
+ * FAILED read (throw, no provider, timeout) changes nothing. Throttled and time-boxed so a
2242
+ * slow provider cannot hold up a palette build.
2243
+ */
2244
+ async reconcileTunnelHostname() {
2245
+ const api = this.ctx.api;
2246
+ if (api === void 0) return;
2247
+ const now = Date.now();
2248
+ if (now - this.lastTunnelReconcileAt < TUNNEL_RECONCILE_MIN_INTERVAL_MS) return;
2249
+ this.lastTunnelReconcileAt = now;
2250
+ let timer;
2251
+ try {
2252
+ const timeout = new Promise((_, reject) => {
2253
+ timer = setTimeout(() => reject(/* @__PURE__ */ new Error("timeout")), TUNNEL_RECONCILE_TIMEOUT_MS);
2254
+ });
2255
+ const status = await Promise.race([api.networkAccess.getStatus.query(), timeout]);
2256
+ if (!status.connected) this.setPublicHostname("");
2257
+ else if (status.endpoint) this.adoptTunnelUrl(status.endpoint.url, status.endpoint.stable);
2258
+ } catch (err) {
2259
+ this.ctx.logger.debug("local-network: tunnel reconcile skipped", { meta: { error: err instanceof Error ? err.message : String(err) } });
2260
+ } finally {
2261
+ if (timer) clearTimeout(timer);
2262
+ }
2263
+ }
2264
+ /**
2228
2265
  * Replace the cached mesh endpoint. Set from the `MeshNetworkChanged`
2229
2266
  * event-tail + the pull-reconcile; exposed for tests + future direct
2230
2267
  * callers. Pass `null` to clear (mesh left / no provider joined).
@@ -1,7 +1,7 @@
1
- import { Bo as resolveHubAddressRoles, Bs as validateCustomAddress, Dt as HUB_MDNS_TXT_KEYS, Et as HUB_MDNS_SERVICE_TYPE, Hu as errMsg, Il as defineAddonMigrations, Lc as BaseAddon, Po as resolveAppConnections, Wo as resolveNotificationTapAddress, Wu as EventCategory, Yt as NetworkTunnelStartedDataSchema, Zi as isAppLinkBase, _r as checkRoleAddress, ba as localNetworkCapability, fs as shortHostname, io as pickAppLinkHub, na as isDefaultAppConnectionEndpoint, uo as preconditionOf, x as CAMSTACK_APP_LINK_ORIGIN } from "../../dist-CH-iCceM.mjs";
1
+ import { Bo as resolveHubAddressRoles, Bs as validateCustomAddress, Dt as HUB_MDNS_TXT_KEYS, Et as HUB_MDNS_SERVICE_TYPE, Hu as errMsg, Il as defineAddonMigrations, Lc as BaseAddon, Po as resolveAppConnections, Wo as resolveNotificationTapAddress, Wu as EventCategory, Yt as NetworkTunnelStartedDataSchema, Zi as isAppLinkBase, _r as checkRoleAddress, ba as localNetworkCapability, fs as shortHostname, io as pickAppLinkHub, na as isDefaultAppConnectionEndpoint, uo as preconditionOf, x as CAMSTACK_APP_LINK_ORIGIN } from "../../dist-BCHMSqzc.mjs";
2
2
  import { a as emptyMdnsRecords, c as parseMdnsMessage, i as buildRecordQuery, l as parseMdnsRecords, n as MDNS_PORT, o as mergeMdnsRecords, r as buildPtrQuery, s as normalizeServiceType, t as MDNS_GROUP } from "../../dns-wire-Dm3H_7ST.mjs";
3
- import { i as loadOrCreateHubId, r as isAnnouncedHubId } from "../../hub-identity-DCqJbSVn.mjs";
4
- import { E as ensureTlsCert, I as readLanHttpState, N as applyLanHttp, _ as readTlsMode, a as storeUploadedCertificate, b as writeTlsEnabled, d as servedHttpsLeafFingerprint, h as readTlsAccessStatus, i as revertToGeneratedCertificate, j as DEFAULT_LAN_HTTP_PORT, m as readExtraSans, n as applyCertificateToListener, o as useStoredUploadedCertificate, r as regenerateCertificate, t as createCiaoPublisher, y as writeExtraSans } from "../../hub-mdns-ciao-IOM82NRd.mjs";
3
+ import { i as loadOrCreateHubId, r as isAnnouncedHubId } from "../../hub-identity-CYC1820R.mjs";
4
+ import { E as ensureTlsCert, I as readLanHttpState, N as applyLanHttp, _ as readTlsMode, a as storeUploadedCertificate, b as writeTlsEnabled, d as servedHttpsLeafFingerprint, h as readTlsAccessStatus, i as revertToGeneratedCertificate, j as DEFAULT_LAN_HTTP_PORT, m as readExtraSans, n as applyCertificateToListener, o as useStoredUploadedCertificate, r as regenerateCertificate, t as createCiaoPublisher, y as writeExtraSans } from "../../hub-mdns-ciao-CCDxM5qz.mjs";
5
5
  import { z } from "zod";
6
6
  import { isIP } from "node:net";
7
7
  import { readFileSync } from "node:fs";
@@ -1629,6 +1629,10 @@ var StringListSchema = z.array(z.string());
1629
1629
  */
1630
1630
  var MESH_PROVIDER_ADDON_IDS = ["tailscale-client"];
1631
1631
  var POLL_INTERVAL_MS = 3e4;
1632
+ /** A tunnel-status pull is skipped when one ran this recently (the event is the fast path). */
1633
+ var TUNNEL_RECONCILE_MIN_INTERVAL_MS = 5e3;
1634
+ /** A tunnel-status pull that does not answer in this time changes nothing. */
1635
+ var TUNNEL_RECONCILE_TIMEOUT_MS = 2e3;
1632
1636
  /** Drop rotated IPv6 / dead extras from the persisted allowlist. */
1633
1637
  var ALLOWLIST_RECONCILE_INTERVAL_MS = 3600 * 1e3;
1634
1638
  /**
@@ -1654,6 +1658,7 @@ var LocalNetworkAddon = class extends BaseAddon {
1654
1658
  * `null` when no mesh provider is joined.
1655
1659
  */
1656
1660
  meshEndpoint = null;
1661
+ lastTunnelReconcileAt = 0;
1657
1662
  mdns = null;
1658
1663
  discoveryWatcher = null;
1659
1664
  watcherPassive = true;
@@ -1683,6 +1688,7 @@ var LocalNetworkAddon = class extends BaseAddon {
1683
1688
  async palettes() {
1684
1689
  const port = (await this.resolveAdvertisedListenPort(null)).port;
1685
1690
  await this.reconcileMeshEndpoint();
1691
+ await this.reconcileTunnelHostname();
1686
1692
  const http = this.endpointsNow(false, false, "http", port);
1687
1693
  const https = this.endpointsNow(false, false, "https", port);
1688
1694
  return {
@@ -1815,6 +1821,7 @@ var LocalNetworkAddon = class extends BaseAddon {
1815
1821
  */
1816
1822
  async buildAdvertisedEndpoints(includeLoopback, ipv4Only, scheme, httpsPort) {
1817
1823
  await this.reconcileMeshEndpoint();
1824
+ await this.reconcileTunnelHostname();
1818
1825
  const detected = withLanHttpsCounterparts(this.endpointsNow(includeLoopback, ipv4Only, scheme, httpsPort), httpsPort);
1819
1826
  return withAppConnectionCustomEndpoints(detected, this.addressState(detected));
1820
1827
  }
@@ -2013,13 +2020,7 @@ var LocalNetworkAddon = class extends BaseAddon {
2013
2020
  this.allowlistTimer.unref?.();
2014
2021
  this.ctx.eventBus?.subscribe({ category: EventCategory.NetworkTunnelStarted }, (event) => {
2015
2022
  const parsed = NetworkTunnelStartedDataSchema.safeParse(event.data ?? {});
2016
- if (parsed.success) {
2017
- const data = parsed.data;
2018
- try {
2019
- const hostname = new URL(data.url).hostname;
2020
- if (hostname && !hostname.endsWith(".placeholder") && !hostname.startsWith("pending.")) this.setPublicHostname(hostname, data.stable !== false);
2021
- } catch {}
2022
- }
2023
+ if (parsed.success) this.adoptTunnelUrl(parsed.data.url, parsed.data.stable);
2023
2024
  });
2024
2025
  this.ctx.eventBus?.subscribe({ category: EventCategory.NetworkTunnelStopped }, () => this.setPublicHostname(""));
2025
2026
  this.ctx.eventBus?.subscribe({ category: EventCategory.MeshNetworkChanged }, (event) => {
@@ -2220,6 +2221,42 @@ var LocalNetworkAddon = class extends BaseAddon {
2220
2221
  } });
2221
2222
  }
2222
2223
  /**
2224
+ * Adopt a tunnel URL as the public hostname. Ignores the pre-FQDN placeholders a tunnel
2225
+ * reports before its real name is known, and a malformed URL (cache left as-is).
2226
+ */
2227
+ adoptTunnelUrl(url, stable) {
2228
+ try {
2229
+ const hostname = new URL(url).hostname;
2230
+ if (hostname && !hostname.endsWith(".placeholder") && !hostname.startsWith("pending.")) this.setPublicHostname(hostname, stable !== false);
2231
+ } catch {}
2232
+ }
2233
+ /**
2234
+ * Pull-reconcile the public tunnel hostname from the `network-access` provider (the start
2235
+ * event is lossy — D8/D49). `connected` + endpoint adopts it, `connected: false` clears it, a
2236
+ * FAILED read (throw, no provider, timeout) changes nothing. Throttled and time-boxed so a
2237
+ * slow provider cannot hold up a palette build.
2238
+ */
2239
+ async reconcileTunnelHostname() {
2240
+ const api = this.ctx.api;
2241
+ if (api === void 0) return;
2242
+ const now = Date.now();
2243
+ if (now - this.lastTunnelReconcileAt < TUNNEL_RECONCILE_MIN_INTERVAL_MS) return;
2244
+ this.lastTunnelReconcileAt = now;
2245
+ let timer;
2246
+ try {
2247
+ const timeout = new Promise((_, reject) => {
2248
+ timer = setTimeout(() => reject(/* @__PURE__ */ new Error("timeout")), TUNNEL_RECONCILE_TIMEOUT_MS);
2249
+ });
2250
+ const status = await Promise.race([api.networkAccess.getStatus.query(), timeout]);
2251
+ if (!status.connected) this.setPublicHostname("");
2252
+ else if (status.endpoint) this.adoptTunnelUrl(status.endpoint.url, status.endpoint.stable);
2253
+ } catch (err) {
2254
+ this.ctx.logger.debug("local-network: tunnel reconcile skipped", { meta: { error: err instanceof Error ? err.message : String(err) } });
2255
+ } finally {
2256
+ if (timer) clearTimeout(timer);
2257
+ }
2258
+ }
2259
+ /**
2223
2260
  * Replace the cached mesh endpoint. Set from the `MeshNetworkChanged`
2224
2261
  * event-tail + the pull-reconcile; exposed for tests + future direct
2225
2262
  * callers. Pass `null` to clear (mesh left / no provider joined).
@@ -3,7 +3,7 @@ Object.defineProperties(exports, {
3
3
  [Symbol.toStringTag]: { value: "Module" }
4
4
  });
5
5
  require("../../chunk-Cek0wNdY.js");
6
- const require_dist = require("../../dist-CVjsCA7D.js");
6
+ const require_dist = require("../../dist-BZfvhfS1.js");
7
7
  const require_log_read_filter = require("../../log-read-filter-Bi066jwU.js");
8
8
  let zod = require("zod");
9
9
  //#region src/builtins/loki-logging/loki-payload.ts
@@ -1,4 +1,4 @@
1
- import { Gi as integrationInstancesCapability, Il as defineAddonMigrations, Lc as BaseAddon, Rl as defineEntryKind, au as isSecretFieldView, ca as isSameAddonId, er as bareAddonId, fl as RevConflictError, ou as isSecretMarker, sl as RecordIntegrationInstances, tu as isInstanceOn, uo as preconditionOf, wa as logDestinationCapability } from "../../dist-CH-iCceM.mjs";
1
+ import { Gi as integrationInstancesCapability, Il as defineAddonMigrations, Lc as BaseAddon, Rl as defineEntryKind, au as isSecretFieldView, ca as isSameAddonId, er as bareAddonId, fl as RevConflictError, ou as isSecretMarker, sl as RecordIntegrationInstances, tu as isInstanceOn, uo as preconditionOf, wa as logDestinationCapability } from "../../dist-BCHMSqzc.mjs";
2
2
  import { n as compileLogFilter, o as lineMatches } from "../../log-read-filter-D7Ev3zm-.mjs";
3
3
  import { z } from "zod";
4
4
  //#region src/builtins/loki-logging/loki-payload.ts
@@ -3,7 +3,7 @@ Object.defineProperties(exports, {
3
3
  [Symbol.toStringTag]: { value: "Module" }
4
4
  });
5
5
  const require_chunk = require("../../chunk-Cek0wNdY.js");
6
- const require_dist = require("../../dist-CVjsCA7D.js");
6
+ const require_dist = require("../../dist-BZfvhfS1.js");
7
7
  let node_fs = require("node:fs");
8
8
  node_fs = require_chunk.__toESM(node_fs);
9
9
  let node_fs_promises = require("node:fs/promises");
@@ -1,5 +1,5 @@
1
- import { Co as reducePoints, Fn as UNATTRIBUTED_BUCKET_KEY, Fo as resolveBucketMs, Hu as errMsg, Ia as metricsProviderCapability, Lc as BaseAddon, Pl as createEvent, Wu as EventCategory, dn as ROOT_BUCKET_KEY, ki as foldSnapshotByFunction } from "../../dist-CH-iCceM.mjs";
2
- import * as fs$1 from "node:fs";
1
+ import { Co as reducePoints, Fn as UNATTRIBUTED_BUCKET_KEY, Fo as resolveBucketMs, Hu as errMsg, Ia as metricsProviderCapability, Lc as BaseAddon, Pl as createEvent, Wu as EventCategory, dn as ROOT_BUCKET_KEY, ki as foldSnapshotByFunction } from "../../dist-BCHMSqzc.mjs";
2
+ import * as fs from "node:fs";
3
3
  import { constants, readFileSync } from "node:fs";
4
4
  import { access, readFile, readdir } from "node:fs/promises";
5
5
  import { promisify } from "node:util";
@@ -1686,7 +1686,7 @@ var NativeMetricsProvider = class {
1686
1686
  let swapUsedBytes = 0;
1687
1687
  let swapTotalBytes = 0;
1688
1688
  if (IS_LINUX) try {
1689
- const meminfo = fs$1.readFileSync("/proc/meminfo", "utf-8");
1689
+ const meminfo = fs.readFileSync("/proc/meminfo", "utf-8");
1690
1690
  const availKb = meminfo.match(/MemAvailable:\s+(\d+)/)?.[1];
1691
1691
  if (availKb !== void 0) available = parseInt(availKb, 10) * 1024;
1692
1692
  const swapTotal = parseInt(meminfo.match(/SwapTotal:\s+(\d+)/)?.[1] ?? "0", 10) * 1024;
@@ -1779,7 +1779,7 @@ async function sampleMacMemory(provider) {
1779
1779
  }
1780
1780
  function getDiskSpaceInternal(dirPath) {
1781
1781
  return new Promise((resolve, reject) => {
1782
- fs$1.statfs(dirPath, (err, stats) => {
1782
+ fs.statfs(dirPath, (err, stats) => {
1783
1783
  if (err) return reject(err);
1784
1784
  const totalBytes = stats.blocks * stats.bsize;
1785
1785
  const availableBytes = stats.bavail * stats.bsize;
@@ -1797,7 +1797,7 @@ function getDiskSpaceInternal(dirPath) {
1797
1797
  async function takeDiskIoSnapshot() {
1798
1798
  const now = Date.now();
1799
1799
  if (IS_LINUX) try {
1800
- const data = fs$1.readFileSync("/proc/diskstats", "utf-8");
1800
+ const data = fs.readFileSync("/proc/diskstats", "utf-8");
1801
1801
  let readOps = 0, readBytes = 0, writeOps = 0, writeBytes = 0;
1802
1802
  for (const line of data.split("\n")) {
1803
1803
  const parts = line.trim().split(/\s+/);
@@ -1828,7 +1828,7 @@ async function takeDiskIoSnapshot() {
1828
1828
  async function takeNetworkIoSnapshot() {
1829
1829
  const now = Date.now();
1830
1830
  if (IS_LINUX) try {
1831
- const data = fs$1.readFileSync("/proc/net/dev", "utf-8");
1831
+ const data = fs.readFileSync("/proc/net/dev", "utf-8");
1832
1832
  let rxBytes = 0, txBytes = 0, rxPackets = 0, txPackets = 0, rxErrors = 0, txErrors = 0;
1833
1833
  for (const line of data.split("\n")) {
1834
1834
  const match = line.match(/^\s*(\w+):\s+(.+)$/);
@@ -1889,7 +1889,7 @@ async function takeNetworkIoSnapshot() {
1889
1889
  }
1890
1890
  async function getCpuTemperatureInternal() {
1891
1891
  if (IS_LINUX) for (const p of ["/sys/class/thermal/thermal_zone0/temp", "/sys/class/hwmon/hwmon0/temp1_input"]) try {
1892
- const raw = fs$1.readFileSync(p, "utf-8").trim();
1892
+ const raw = fs.readFileSync(p, "utf-8").trim();
1893
1893
  const millideg = parseInt(raw, 10);
1894
1894
  if (!isNaN(millideg)) return Math.round(millideg / 100) / 10;
1895
1895
  } catch {
@@ -1940,10 +1940,10 @@ function getProcessResources() {
1940
1940
  let threadCount = 0;
1941
1941
  if (IS_LINUX) {
1942
1942
  try {
1943
- openFds = fs$1.readdirSync(`/proc/${process.pid}/fd`).length;
1943
+ openFds = fs.readdirSync(`/proc/${process.pid}/fd`).length;
1944
1944
  } catch {}
1945
1945
  try {
1946
- const match = fs$1.readFileSync(`/proc/${process.pid}/status`, "utf-8").match(/Threads:\s+(\d+)/);
1946
+ const match = fs.readFileSync(`/proc/${process.pid}/status`, "utf-8").match(/Threads:\s+(\d+)/);
1947
1947
  if (match) threadCount = parseInt(match[1], 10);
1948
1948
  } catch {}
1949
1949
  }
@@ -1958,7 +1958,7 @@ function getProcessResources() {
1958
1958
  function getPressure(resource) {
1959
1959
  if (!IS_LINUX) return null;
1960
1960
  try {
1961
- const data = fs$1.readFileSync(`/proc/pressure/${resource}`, "utf-8");
1961
+ const data = fs.readFileSync(`/proc/pressure/${resource}`, "utf-8");
1962
1962
  const parseLine = (prefix) => {
1963
1963
  const match = data.match(new RegExp(`${prefix} avg10=(\\d+\\.\\d+) avg60=(\\d+\\.\\d+) avg300=(\\d+\\.\\d+)`));
1964
1964
  if (!match) return null;
@@ -3,7 +3,7 @@ Object.defineProperties(exports, {
3
3
  [Symbol.toStringTag]: { value: "Module" }
4
4
  });
5
5
  const require_chunk = require("../../chunk-Cek0wNdY.js");
6
- const require_dist = require("../../dist-CVjsCA7D.js");
6
+ const require_dist = require("../../dist-BZfvhfS1.js");
7
7
  const require_coral_accelerators = require("../../coral-accelerators-BSVsBVzt.js");
8
8
  let node_fs = require("node:fs");
9
9
  node_fs = require_chunk.__toESM(node_fs);
@@ -1,7 +1,7 @@
1
1
  import { o as __toESM, r as __exportAll } from "../../chunk-CNf5ZN-e.mjs";
2
- import { $a as parseAcceleratorFactsJson, Bl as describeNvidia, Hl as emitReadiness, Hu as errMsg, Lc as BaseAddon, Tu as scoreRuntimes, Wl as enumerateInferenceDevices, Wu as EventCategory, oo as platformProbeCapability } from "../../dist-CH-iCceM.mjs";
3
- import { n as detectCoralAccelerator, r as nodeCoralFs } from "../../coral-accelerators-DBlgWB8k.mjs";
4
- import * as fs$1 from "node:fs";
2
+ import { $a as parseAcceleratorFactsJson, Bl as describeNvidia, Hl as emitReadiness, Hu as errMsg, Lc as BaseAddon, Tu as scoreRuntimes, Wl as enumerateInferenceDevices, Wu as EventCategory, oo as platformProbeCapability } from "../../dist-BCHMSqzc.mjs";
3
+ import { n as detectCoralAccelerator, r as nodeCoralFs } from "../../coral-accelerators-BW3OcrLD.mjs";
4
+ import * as fs from "node:fs";
5
5
  import * as path$1 from "node:path";
6
6
  import { promisify } from "node:util";
7
7
  import * as os$1 from "node:os";
@@ -501,14 +501,14 @@ var PlatformScorer = class {
501
501
  nvidiaProbe = await this.probeNvidiaSmi();
502
502
  const listRenderNodes = () => {
503
503
  try {
504
- return fs$1.readdirSync("/dev/dri").filter((n) => n.startsWith("renderD")).map((n) => `/dev/dri/${n}`);
504
+ return fs.readdirSync("/dev/dri").filter((n) => n.startsWith("renderD")).map((n) => `/dev/dri/${n}`);
505
505
  } catch {
506
506
  return [];
507
507
  }
508
508
  };
509
509
  const readDrmAttr = (node, attr) => {
510
510
  try {
511
- return fs$1.readFileSync(`/sys/class/drm/${node.split("/").pop()}/device/${attr}`, "utf8");
511
+ return fs.readFileSync(`/sys/class/drm/${node.split("/").pop()}/device/${attr}`, "utf8");
512
512
  } catch {
513
513
  return "";
514
514
  }
@@ -534,12 +534,12 @@ var PlatformScorer = class {
534
534
  }
535
535
  const listDir = (p) => {
536
536
  try {
537
- return fs$1.readdirSync(p);
537
+ return fs.readdirSync(p);
538
538
  } catch {
539
539
  return [];
540
540
  }
541
541
  };
542
- const exists = (p) => fs$1.existsSync(p);
542
+ const exists = (p) => fs.existsSync(p);
543
543
  if (!npu) {
544
544
  const { classifyIntelNpu } = await import("../../intel-npu-C8HKvRQF.mjs");
545
545
  npu = classifyIntelNpu({
@@ -567,7 +567,7 @@ var PlatformScorer = class {
567
567
  exists,
568
568
  readFile: (p) => {
569
569
  try {
570
- return fs$1.readFileSync(p, "utf8");
570
+ return fs.readFileSync(p, "utf8");
571
571
  } catch {
572
572
  return "";
573
573
  }
@@ -871,7 +871,7 @@ function jsonValue(text) {
871
871
  function readPublishedAcceleratorFacts(filePath) {
872
872
  let text;
873
873
  try {
874
- text = fs$1.readFileSync(filePath, "utf8");
874
+ text = fs.readFileSync(filePath, "utf8");
875
875
  } catch {
876
876
  return null;
877
877
  }
@@ -886,7 +886,7 @@ function findAcceleratorFactsScript(dataDir, cwd = process.cwd()) {
886
886
  const candidates = [];
887
887
  if (typeof dataDir === "string" && dataDir !== "") candidates.push(path$1.join(dataDir, "addons", "@camstack", "addon-pipeline", "python", "accelerator_facts.py"));
888
888
  candidates.push(path$1.join(cwd, "packages", "addon-pipeline", "python", "accelerator_facts.py"));
889
- for (const candidate of candidates) if (fs$1.existsSync(candidate)) return candidate;
889
+ for (const candidate of candidates) if (fs.existsSync(candidate)) return candidate;
890
890
  return null;
891
891
  }
892
892
  async function defaultExec(command, args, timeoutMs) {
@@ -3,7 +3,7 @@ Object.defineProperties(exports, {
3
3
  [Symbol.toStringTag]: { value: "Module" }
4
4
  });
5
5
  require("../../chunk-Cek0wNdY.js");
6
- const require_dist = require("../../dist-CVjsCA7D.js");
6
+ const require_dist = require("../../dist-BZfvhfS1.js");
7
7
  let zod = require("zod");
8
8
  let node_crypto = require("node:crypto");
9
9
  //#region src/builtins/record-entries/entries-service.ts
@@ -1,4 +1,4 @@
1
- import { Jc as InvalidRecordError, Lc as BaseAddon, Ou as secretViewsOf, _l as UnknownRecordKindError, xo as recordEntriesCapability } from "../../dist-CH-iCceM.mjs";
1
+ import { Jc as InvalidRecordError, Lc as BaseAddon, Ou as secretViewsOf, _l as UnknownRecordKindError, xo as recordEntriesCapability } from "../../dist-BCHMSqzc.mjs";
2
2
  import { z } from "zod";
3
3
  import { randomUUID } from "node:crypto";
4
4
  //#region src/builtins/record-entries/entries-service.ts
@@ -3,7 +3,7 @@ Object.defineProperties(exports, {
3
3
  [Symbol.toStringTag]: { value: "Module" }
4
4
  });
5
5
  require("../../chunk-Cek0wNdY.js");
6
- const require_dist = require("../../dist-CVjsCA7D.js");
6
+ const require_dist = require("../../dist-BZfvhfS1.js");
7
7
  let zod = require("zod");
8
8
  //#region src/builtins/remote-access-orchestrator/enabled-providers-reconcile.ts
9
9
  /**
@@ -1,4 +1,4 @@
1
- import { Lc as BaseAddon, Wu as EventCategory } from "../../dist-CH-iCceM.mjs";
1
+ import { Lc as BaseAddon, Wu as EventCategory } from "../../dist-BCHMSqzc.mjs";
2
2
  import { z } from "zod";
3
3
  //#region src/builtins/remote-access-orchestrator/enabled-providers-reconcile.ts
4
4
  /**
@@ -3,7 +3,7 @@ Object.defineProperties(exports, {
3
3
  [Symbol.toStringTag]: { value: "Module" }
4
4
  });
5
5
  const require_chunk = require("../../chunk-Cek0wNdY.js");
6
- const require_dist = require("../../dist-CVjsCA7D.js");
6
+ const require_dist = require("../../dist-BZfvhfS1.js");
7
7
  const require_snapshot_courtesy = require("../../snapshot-courtesy-D_C5-nC0.js");
8
8
  let zod = require("zod");
9
9
  let node_crypto = require("node:crypto");
@@ -1,4 +1,4 @@
1
- import { Da as lowPowerSleepCapability, Hu as errMsg, Lc as BaseAddon, Ma as memoizePinnedFfmpeg, Rt as LowPowerSleepStatusSchema, Vu as DeviceType, Wu as EventCategory, Xr as deriveBatteryPresence, er as bareAddonId, fu as nodePin, hs as snapshotCapability, si as deviceSleeps, ws as streamQualityLabel } from "../../dist-CH-iCceM.mjs";
1
+ import { Da as lowPowerSleepCapability, Hu as errMsg, Lc as BaseAddon, Ma as memoizePinnedFfmpeg, Rt as LowPowerSleepStatusSchema, Vu as DeviceType, Wu as EventCategory, Xr as deriveBatteryPresence, er as bareAddonId, fu as nodePin, hs as snapshotCapability, si as deviceSleeps, ws as streamQualityLabel } from "../../dist-BCHMSqzc.mjs";
2
2
  import { i as renderCourtesyOverlayJpeg, n as courtesyCacheKey, r as renderCourtesyJpeg } from "../../snapshot-courtesy-CyFs1M3I.mjs";
3
3
  import { z } from "zod";
4
4
  import { randomUUID } from "node:crypto";
@@ -3,7 +3,7 @@ Object.defineProperties(exports, {
3
3
  [Symbol.toStringTag]: { value: "Module" }
4
4
  });
5
5
  const require_chunk = require("../../chunk-Cek0wNdY.js");
6
- const require_dist = require("../../dist-CVjsCA7D.js");
6
+ const require_dist = require("../../dist-BZfvhfS1.js");
7
7
  let node_crypto = require("node:crypto");
8
8
  let node_fs = require("node:fs");
9
9
  node_fs = require_chunk.__toESM(node_fs);
@@ -1,6 +1,6 @@
1
- import { Di as filesystemBrowseCapability, Lc as BaseAddon, Ss as storageProviderCapability } from "../../dist-CH-iCceM.mjs";
1
+ import { Di as filesystemBrowseCapability, Lc as BaseAddon, Ss as storageProviderCapability } from "../../dist-BCHMSqzc.mjs";
2
2
  import { randomUUID } from "node:crypto";
3
- import * as fs$1 from "node:fs";
3
+ import * as fs from "node:fs";
4
4
  import * as path$1 from "node:path";
5
5
  import { basename, dirname, isAbsolute, join, resolve, sep } from "node:path";
6
6
  import { mkdir, readdir, realpath, statfs } from "node:fs/promises";
@@ -169,16 +169,16 @@ var FilesystemStorageProvider = class FilesystemStorageProvider {
169
169
  error: "config.basePath must be a non-empty string"
170
170
  };
171
171
  try {
172
- const stat = await fs$1.promises.stat(basePath).catch(() => null);
172
+ const stat = await fs.promises.stat(basePath).catch(() => null);
173
173
  if (stat) {
174
174
  if (!stat.isDirectory()) return {
175
175
  ok: false,
176
176
  error: `Path "${basePath}" exists but is not a directory`
177
177
  };
178
- await fs$1.promises.access(basePath, fs$1.constants.W_OK);
178
+ await fs.promises.access(basePath, fs.constants.W_OK);
179
179
  return { ok: true };
180
180
  }
181
- await fs$1.promises.mkdir(basePath, { recursive: true });
181
+ await fs.promises.mkdir(basePath, { recursive: true });
182
182
  return { ok: true };
183
183
  } catch (err) {
184
184
  return {
@@ -192,12 +192,12 @@ var FilesystemStorageProvider = class FilesystemStorageProvider {
192
192
  }
193
193
  async write({ location, relativePath, data }) {
194
194
  const filePath = safeResolve(getBasePath(location), relativePath);
195
- await fs$1.promises.mkdir(path$1.dirname(filePath), { recursive: true });
196
- await fs$1.promises.writeFile(filePath, data);
195
+ await fs.promises.mkdir(path$1.dirname(filePath), { recursive: true });
196
+ await fs.promises.writeFile(filePath, data);
197
197
  }
198
198
  async read({ location, relativePath }) {
199
199
  const filePath = safeResolve(getBasePath(location), relativePath);
200
- const buf = await fs$1.promises.readFile(filePath);
200
+ const buf = await fs.promises.readFile(filePath);
201
201
  const out = new Uint8Array(new ArrayBuffer(buf.byteLength));
202
202
  out.set(buf);
203
203
  return out;
@@ -205,7 +205,7 @@ var FilesystemStorageProvider = class FilesystemStorageProvider {
205
205
  async exists({ location, relativePath }) {
206
206
  const filePath = safeResolve(getBasePath(location), relativePath);
207
207
  try {
208
- await fs$1.promises.access(filePath);
208
+ await fs.promises.access(filePath);
209
209
  return true;
210
210
  } catch {
211
211
  return false;
@@ -215,25 +215,25 @@ var FilesystemStorageProvider = class FilesystemStorageProvider {
215
215
  const base = getBasePath(location);
216
216
  const dir = prefix ? safeResolve(base, prefix) : path$1.resolve(base);
217
217
  try {
218
- return (await fs$1.promises.readdir(dir, { withFileTypes: true })).map((e) => prefix ? `${prefix}/${e.name}` : e.name);
218
+ return (await fs.promises.readdir(dir, { withFileTypes: true })).map((e) => prefix ? `${prefix}/${e.name}` : e.name);
219
219
  } catch {
220
220
  return [];
221
221
  }
222
222
  }
223
223
  async delete({ location, relativePath }) {
224
224
  const filePath = safeResolve(getBasePath(location), relativePath);
225
- await fs$1.promises.rm(filePath, { force: true });
225
+ await fs.promises.rm(filePath, { force: true });
226
226
  }
227
227
  async getAvailableSpace({ location }) {
228
228
  const base = path$1.resolve(getBasePath(location));
229
229
  try {
230
230
  let target = base;
231
- while (!fs$1.existsSync(target)) {
231
+ while (!fs.existsSync(target)) {
232
232
  const parent = path$1.dirname(target);
233
233
  if (!parent || parent === target) return null;
234
234
  target = parent;
235
235
  }
236
- const stats = await fs$1.promises.statfs(target);
236
+ const stats = await fs.promises.statfs(target);
237
237
  return stats.bavail * stats.bsize;
238
238
  } catch {
239
239
  return null;
@@ -242,9 +242,9 @@ var FilesystemStorageProvider = class FilesystemStorageProvider {
242
242
  async beginUpload({ location, relativePath }) {
243
243
  const target = safeResolve(getBasePath(location), relativePath);
244
244
  const partial = `${target}.partial`;
245
- await fs$1.promises.mkdir(path$1.dirname(target), { recursive: true });
246
- await fs$1.promises.unlink(partial).catch(() => {});
247
- const stream = fs$1.createWriteStream(partial);
245
+ await fs.promises.mkdir(path$1.dirname(target), { recursive: true });
246
+ await fs.promises.unlink(partial).catch(() => {});
247
+ const stream = fs.createWriteStream(partial);
248
248
  const uploadId = randomUUID();
249
249
  const session = {
250
250
  stream,
@@ -285,7 +285,7 @@ var FilesystemStorageProvider = class FilesystemStorageProvider {
285
285
  session.stream.end(() => resolve());
286
286
  session.stream.on("error", reject);
287
287
  });
288
- await fs$1.promises.rename(session.partial, session.target);
288
+ await fs.promises.rename(session.partial, session.target);
289
289
  clearTimeout(session.timer);
290
290
  this.uploads.delete(uploadId);
291
291
  }
@@ -295,14 +295,14 @@ var FilesystemStorageProvider = class FilesystemStorageProvider {
295
295
  try {
296
296
  session.stream.destroy();
297
297
  } catch {}
298
- await fs$1.promises.unlink(session.partial).catch(() => {});
298
+ await fs.promises.unlink(session.partial).catch(() => {});
299
299
  clearTimeout(session.timer);
300
300
  this.uploads.delete(uploadId);
301
301
  }
302
302
  async beginDownload({ location, relativePath }) {
303
303
  const target = safeResolve(getBasePath(location), relativePath);
304
- const stat = await fs$1.promises.stat(target);
305
- const fd = await fs$1.promises.open(target, "r");
304
+ const stat = await fs.promises.stat(target);
305
+ const fd = await fs.promises.open(target, "r");
306
306
  const downloadId = randomUUID();
307
307
  const session = {
308
308
  fd,