@camstack/server 1.2.926 → 1.2.927
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/CHANGELOG.md +8 -0
- package/package.json +15 -17
- package/system/dist/builtins/addon-pages-aggregator/addon-pages-aggregator.addon.js +1 -1
- package/system/dist/builtins/addon-pages-aggregator/addon-pages-aggregator.addon.mjs +1 -1
- package/system/dist/builtins/addon-widgets-aggregator/addon-widgets-aggregator.addon.js +1 -1
- package/system/dist/builtins/addon-widgets-aggregator/addon-widgets-aggregator.addon.mjs +1 -1
- package/system/dist/builtins/alerts/alerts.addon.js +1 -1
- package/system/dist/builtins/alerts/alerts.addon.mjs +1 -1
- package/system/dist/builtins/autotrack/index.js +1 -1
- package/system/dist/builtins/autotrack/index.mjs +1 -1
- package/system/dist/builtins/backup-orchestrator/backup-orchestrator.addon.js +2 -2
- package/system/dist/builtins/backup-orchestrator/backup-orchestrator.addon.mjs +2 -2
- package/system/dist/builtins/calendars/calendars.addon.js +1 -1
- package/system/dist/builtins/calendars/calendars.addon.mjs +1 -1
- package/system/dist/builtins/camera-grid/index.js +1 -1
- package/system/dist/builtins/camera-grid/index.mjs +1 -1
- package/system/dist/builtins/composer/composer.addon.js +4 -4
- package/system/dist/builtins/composer/composer.addon.mjs +4 -4
- package/system/dist/builtins/console-logging/index.js +1 -1
- package/system/dist/builtins/console-logging/index.mjs +1 -1
- package/system/dist/builtins/core-blocks/core-blocks.addon.js +4 -4
- package/system/dist/builtins/core-blocks/core-blocks.addon.mjs +4 -4
- package/system/dist/builtins/core-notifier/core-notifier.addon.js +1 -1
- package/system/dist/builtins/core-notifier/core-notifier.addon.mjs +1 -1
- package/system/dist/builtins/device-history/device-history.addon.js +2 -2
- package/system/dist/builtins/device-history/device-history.addon.mjs +2 -2
- package/system/dist/builtins/device-manager/device-manager.addon.js +103 -55
- package/system/dist/builtins/device-manager/device-manager.addon.mjs +103 -55
- package/system/dist/builtins/device-manager/transitions/transition-correlator.d.ts +24 -11
- package/system/dist/builtins/hub-forwarder/index.js +1 -1
- package/system/dist/builtins/hub-forwarder/index.mjs +1 -1
- package/system/dist/builtins/keychain/index.js +4 -4
- package/system/dist/builtins/keychain/index.mjs +4 -4
- package/system/dist/builtins/liveness-monitor/liveness-monitor.addon.js +1 -1
- package/system/dist/builtins/liveness-monitor/liveness-monitor.addon.mjs +1 -1
- package/system/dist/builtins/local-auth/local-auth.addon.js +2 -2
- package/system/dist/builtins/local-auth/local-auth.addon.mjs +2 -2
- package/system/dist/builtins/local-network/local-network.addon.d.ts +13 -0
- package/system/dist/builtins/local-network/local-network.addon.js +47 -10
- package/system/dist/builtins/local-network/local-network.addon.mjs +47 -10
- package/system/dist/builtins/loki-logging/index.js +1 -1
- package/system/dist/builtins/loki-logging/index.mjs +1 -1
- package/system/dist/builtins/native-metrics/native-metrics.addon.js +1 -1
- package/system/dist/builtins/native-metrics/native-metrics.addon.mjs +1 -1
- package/system/dist/builtins/platform-probe/index.js +1 -1
- package/system/dist/builtins/platform-probe/index.mjs +1 -1
- package/system/dist/builtins/record-entries/index.js +1 -1
- package/system/dist/builtins/record-entries/index.mjs +1 -1
- package/system/dist/builtins/remote-access-orchestrator/remote-access-orchestrator.addon.js +1 -1
- package/system/dist/builtins/remote-access-orchestrator/remote-access-orchestrator.addon.mjs +1 -1
- package/system/dist/builtins/snapshot/index.js +1 -1
- package/system/dist/builtins/snapshot/index.mjs +1 -1
- package/system/dist/builtins/sqlite-storage/filesystem-storage.addon.js +1 -1
- package/system/dist/builtins/sqlite-storage/filesystem-storage.addon.mjs +1 -1
- package/system/dist/builtins/sqlite-storage/index.js +1 -1
- package/system/dist/builtins/sqlite-storage/index.mjs +1 -1
- package/system/dist/builtins/sqlite-storage/sqlite-settings.addon.js +3 -3
- package/system/dist/builtins/sqlite-storage/sqlite-settings.addon.mjs +3 -3
- package/system/dist/builtins/storage-orchestrator/storage-orchestrator.addon.js +1 -1
- package/system/dist/builtins/storage-orchestrator/storage-orchestrator.addon.mjs +1 -1
- package/system/dist/builtins/system-config/system-config.addon.js +3 -3
- package/system/dist/builtins/system-config/system-config.addon.mjs +3 -3
- package/system/dist/builtins/winston-logging/index.js +1 -1
- package/system/dist/builtins/winston-logging/index.mjs +1 -1
- package/system/dist/{capture-engine-BEXh051r.js → capture-engine-BcuwOSXv.js} +1 -1
- package/system/dist/{capture-engine-CWfylyT8.mjs → capture-engine-Bz7eXFjT.mjs} +1 -1
- package/system/dist/{composition-sources-CcpMUxus.mjs → composition-sources-BI614LJx.mjs} +1 -1
- package/system/dist/{composition-sources-B3_FuKde.js → composition-sources-v_kkb8A9.js} +1 -1
- package/system/dist/{constants-fPesBGmF.mjs → constants-BcUTQd1M.mjs} +1 -1
- package/system/dist/{constants-B0tqNa2l.js → constants-D2etJ02O.js} +1 -1
- package/system/dist/{device-ca-Bh0GEstW.js → device-ca-CU8zh9Pi.js} +1 -1
- package/system/dist/{device-ca-B98SR8Xf.mjs → device-ca-ExMN3xW3.mjs} +1 -1
- package/system/dist/{device-row-store-CfWN8mLZ.js → device-row-store-BMIR-n3m.js} +1 -1
- package/system/dist/{device-row-store-BBByy029.mjs → device-row-store-CeW_GWh9.mjs} +1 -1
- package/system/dist/{dist-CH-iCceM.mjs → dist-BCHMSqzc.mjs} +325 -2
- package/system/dist/{dist-CVjsCA7D.js → dist-BZfvhfS1.js} +325 -2
- package/system/dist/file-host-worker.js +1 -1
- package/system/dist/file-host-worker.mjs +1 -1
- package/system/dist/{hub-identity-DCqJbSVn.mjs → hub-identity-BBXzP6Ve.mjs} +1 -1
- package/system/dist/{hub-identity-BU4XzogT.js → hub-identity-Csxx2Q8k.js} +1 -1
- package/system/dist/{hub-mdns-ciao-BNzmwsIH.js → hub-mdns-ciao-By5577HM.js} +2 -2
- package/system/dist/{hub-mdns-ciao-IOM82NRd.mjs → hub-mdns-ciao-DG17NbGU.mjs} +2 -2
- package/system/dist/index.js +8 -8
- package/system/dist/index.mjs +8 -8
- package/system/dist/{legacy-integration-rows-door-CRcvhOWb.js → legacy-integration-rows-door-CVwOo5aq.js} +1 -1
- package/system/dist/{legacy-integration-rows-door-nQzjUyPU.mjs → legacy-integration-rows-door-D9tQOUzh.mjs} +1 -1
- package/system/dist/{rename-composition-block-oOfXrUWs.js → rename-composition-block-C9HuBrKS.js} +1 -1
- package/system/dist/{rename-composition-block-CJ-C9HoY.mjs → rename-composition-block-DtaYmYAR.mjs} +1 -1
- package/system/dist/{restore-archive-BSdudYif.js → restore-archive-CIFvqOze.js} +1 -1
- package/system/dist/{restore-archive-DaYf1tQb.mjs → restore-archive-kwtBd00M.mjs} +1 -1
- package/system/dist/{wal-maintenance-CyOVe3E1.mjs → wal-maintenance-CTrCPzds.mjs} +0 -0
- package/system/dist/{wal-maintenance-BRc_MNtZ.js → wal-maintenance-dq7T3quB.js} +0 -0
- package/system/package.json +1 -1
|
@@ -1,11 +1,11 @@
|
|
|
1
|
-
import { $ as DEVICE_TEMPLATE_VALUES_CAP, $l as isDeviceConfigCap, $o as sameIdentifiers, Br as createDeviceExtensionProvider, Bu as DeviceRole, El as auditedFields, Eu as secretTreeFromPaths, Fu as vocabActionIdFor, Ga as normalizeTags, Gl as expandCapMethods$1, Hi as identityLinkId, Hu as errMsg$1, Io as resolveCommandHold, Jo as resolveTemplateRef, Ka as normalizeUnit, Lc as BaseAddon, Ln as WORKLOAD_TRANSITION_CATEGORY, Ml as commandEffect, Mu as toSecretFieldView, Na as mergeIdentifiers, Nu as transformSecretWrite, Pi as generateDeviceAlias, Pu as userError, Qo as runtimeStatePolicyFor, Rn as WorkloadStateSchema, S as CAP_NAMES_WITH_STATUS, Su as resolveSecretMarkers, Ui as identityLinkSidesRefusal, Vi as identifierStrength, Vt as MINUTES_PER_DAY, Vu as DeviceType$1, W as DEVICE_IDENTIFIER_KEYS, Wu as EventCategory$1, X as DEVICE_TEMPLATE_MAX_LENGTH, Xs as workloadTransition, Y as DEVICE_TEMPLATE_FILTERS, Yr as defineExtensionSlotProvider, Ys as workloadCapability, Z as DEVICE_TEMPLATE_MAX_OUTPUT, Zl as isCommand$1, Zo as runtimeFieldUnit, aa as isKernelDerivedFeature, b as CAMERA_SWITCH_ORDER, bo as reconcileReportedFeatures, bt as FieldClaimModeSchema, ci as deviceStateCapability, cr as buildStreamParamsConfigSchema, di as effectiveRefreshIntervalMs, ei as deviceExtensionCapability, fi as enumerateItemArrayFields, fr as canonicalIconKey, ft as ExportNameRefusedError, gr as checkDeviceAlias, ii as deviceOffersActions, it as DeviceIdentifiersSchema, iu as isSecretClear, j as ConditionMirror, ji as formatMinutes, jl as collectZodSecretPaths$1, ku as sleep$2, li as deviceStatusCapability, ma as legacyAutoLinkIds, ms as siteZoneKey, nu as isKeychainStoredField, ot as DeviceStatusSchema, ou as isSecretMarker, pi as enumerateSchemaFields, pl as SECRET_CLEAR, ra as isEmptyIdentifiers, ri as deviceManagerCapability, rs as searchRank, s as ALL_CAPABILITY_DEFINITIONS, ss as settleDeviceFeatures, su as isSecretMarkerLike, tn as PUSH_CONFIRM_WINDOW_MS, to as parseStreamParamsFormPatch, ua as isWorkloadSettled, uc as capAppliesToDeviceKind, vi as expandContainer, vn as STREAM_PROFILE_META, wc as implementedMethodsOf$1, wr as commandBurstOffsets, xa as locationIconKey, xi as extractSourceInfoFromMetadata, xt as FieldClaimSchema, yl as WELL_KNOWN_TAB_MAP, z as DAY_NAMES, zu as DeviceFeature } from "../../dist-
|
|
1
|
+
import { $ as DEVICE_TEMPLATE_VALUES_CAP, $l as isDeviceConfigCap, $o as sameIdentifiers, Br as createDeviceExtensionProvider, Bu as DeviceRole, El as auditedFields, Eu as secretTreeFromPaths, Fu as vocabActionIdFor, Ga as normalizeTags, Gl as expandCapMethods$1, Hi as identityLinkId, Hu as errMsg$1, Io as resolveCommandHold, Jo as resolveTemplateRef, Ka as normalizeUnit, Lc as BaseAddon, Ln as WORKLOAD_TRANSITION_CATEGORY, Ml as commandEffect, Mu as toSecretFieldView, Na as mergeIdentifiers, Nu as transformSecretWrite, Pi as generateDeviceAlias, Pu as userError, Qo as runtimeStatePolicyFor, Rn as WorkloadStateSchema, S as CAP_NAMES_WITH_STATUS, Su as resolveSecretMarkers, Ui as identityLinkSidesRefusal, Vi as identifierStrength, Vt as MINUTES_PER_DAY, Vu as DeviceType$1, W as DEVICE_IDENTIFIER_KEYS, Wu as EventCategory$1, X as DEVICE_TEMPLATE_MAX_LENGTH, Xs as workloadTransition, Y as DEVICE_TEMPLATE_FILTERS, Yr as defineExtensionSlotProvider, Ys as workloadCapability, Z as DEVICE_TEMPLATE_MAX_OUTPUT, Zl as isCommand$1, Zo as runtimeFieldUnit, aa as isKernelDerivedFeature, b as CAMERA_SWITCH_ORDER, bo as reconcileReportedFeatures, bt as FieldClaimModeSchema, ci as deviceStateCapability, cr as buildStreamParamsConfigSchema, di as effectiveRefreshIntervalMs, ei as deviceExtensionCapability, fi as enumerateItemArrayFields, fr as canonicalIconKey, ft as ExportNameRefusedError, gr as checkDeviceAlias, ii as deviceOffersActions, it as DeviceIdentifiersSchema, iu as isSecretClear, j as ConditionMirror, ji as formatMinutes, jl as collectZodSecretPaths$1, ku as sleep$2, li as deviceStatusCapability, ma as legacyAutoLinkIds, ms as siteZoneKey, nu as isKeychainStoredField, ot as DeviceStatusSchema, ou as isSecretMarker, pi as enumerateSchemaFields, pl as SECRET_CLEAR, ra as isEmptyIdentifiers, ri as deviceManagerCapability, rs as searchRank, s as ALL_CAPABILITY_DEFINITIONS, ss as settleDeviceFeatures, su as isSecretMarkerLike, tn as PUSH_CONFIRM_WINDOW_MS, to as parseStreamParamsFormPatch, ua as isWorkloadSettled, uc as capAppliesToDeviceKind, vi as expandContainer, vn as STREAM_PROFILE_META, wc as implementedMethodsOf$1, wr as commandBurstOffsets, xa as locationIconKey, xi as extractSourceInfoFromMetadata, xt as FieldClaimSchema, yl as WELL_KNOWN_TAB_MAP, z as DAY_NAMES, zu as DeviceFeature } from "../../dist-BCHMSqzc.mjs";
|
|
2
2
|
import { t as require_read_all_rows } from "../../read-all-rows-TaPqdWNF.mjs";
|
|
3
3
|
import { a as redactLogText, i as redactLogMeta, n as isSecretArgumentKey } from "../../log-redactor-XLDrPzOi.mjs";
|
|
4
|
-
import { n as renameCompositionBlock, t as composedBlockIdOf } from "../../rename-composition-block-
|
|
4
|
+
import { n as renameCompositionBlock, t as composedBlockIdOf } from "../../rename-composition-block-DtaYmYAR.mjs";
|
|
5
5
|
import { t as prefixRange } from "../../prefix-range-Dl0znowN.mjs";
|
|
6
6
|
import { t as loadPrefixed } from "../../prefix-walk-DAOBSyH1.mjs";
|
|
7
7
|
import { n as purgeRetiredSettingsRows } from "../../retired-settings-keys-u6xQA6r7.mjs";
|
|
8
|
-
import { a as MigrationRefusedError, i as deviceManagerRecordKinds, n as DeviceRowStore, r as deviceRowBackendOf } from "../../device-row-store-
|
|
8
|
+
import { a as MigrationRefusedError, i as deviceManagerRecordKinds, n as DeviceRowStore, r as deviceRowBackendOf } from "../../device-row-store-CeW_GWh9.mjs";
|
|
9
9
|
import { n as isRenderResponse, r as analyzeTemplate } from "../../template-protocol-SgPDx3Hw.mjs";
|
|
10
10
|
import { s as normalizeServiceType } from "../../dns-wire-Dm3H_7ST.mjs";
|
|
11
11
|
import { createRequire } from "node:module";
|
|
@@ -13689,7 +13689,7 @@ var TransitionCorrelator = class {
|
|
|
13689
13689
|
deps;
|
|
13690
13690
|
pending = /* @__PURE__ */ new Map();
|
|
13691
13691
|
seq = 0;
|
|
13692
|
-
|
|
13692
|
+
held = /* @__PURE__ */ new Map();
|
|
13693
13693
|
constructor(deps) {
|
|
13694
13694
|
this.deps = deps;
|
|
13695
13695
|
}
|
|
@@ -13726,7 +13726,7 @@ var TransitionCorrelator = class {
|
|
|
13726
13726
|
const fields = auditedFields(capName);
|
|
13727
13727
|
if (fields.size === 0) return;
|
|
13728
13728
|
const now = this.deps.now();
|
|
13729
|
-
|
|
13729
|
+
const changes = [];
|
|
13730
13730
|
for (const field of fields) {
|
|
13731
13731
|
const hadBefore = prior !== void 0 && Object.hasOwn(prior, field);
|
|
13732
13732
|
const has = Object.hasOwn(slice, field);
|
|
@@ -13734,13 +13734,96 @@ var TransitionCorrelator = class {
|
|
|
13734
13734
|
const before = hadBefore ? prior[field] : void 0;
|
|
13735
13735
|
const after = has ? slice[field] : void 0;
|
|
13736
13736
|
if (sameValue(before, after)) continue;
|
|
13737
|
-
|
|
13737
|
+
changes.push({
|
|
13738
|
+
field,
|
|
13739
|
+
before,
|
|
13740
|
+
after,
|
|
13741
|
+
neverHeld: !hadBefore
|
|
13742
|
+
});
|
|
13738
13743
|
}
|
|
13744
|
+
if (changes.length === 0) return;
|
|
13745
|
+
const key = this.keyOf(deviceId, capName);
|
|
13746
|
+
const burst = this.held.get(key) ?? {
|
|
13747
|
+
deviceId,
|
|
13748
|
+
capName,
|
|
13749
|
+
fields: /* @__PURE__ */ new Map(),
|
|
13750
|
+
firstAt: now,
|
|
13751
|
+
lastAt: now
|
|
13752
|
+
};
|
|
13753
|
+
burst.lastAt = now;
|
|
13754
|
+
const claimable = this.hasLiveCommand(deviceId, capName, now);
|
|
13755
|
+
for (const change of changes) {
|
|
13756
|
+
const earlier = burst.fields.get(change.field);
|
|
13757
|
+
if (change.neverHeld && earlier === void 0 && !claimable) continue;
|
|
13758
|
+
burst.fields.set(change.field, {
|
|
13759
|
+
before: earlier !== void 0 ? earlier.before : change.before,
|
|
13760
|
+
after: change.after,
|
|
13761
|
+
neverHeld: earlier !== void 0 ? earlier.neverHeld : change.neverHeld
|
|
13762
|
+
});
|
|
13763
|
+
}
|
|
13764
|
+
if (burst.fields.size === 0) return;
|
|
13765
|
+
this.held.set(key, burst);
|
|
13766
|
+
if (this.commandMatchedBy(deviceId, capName, changes, now) !== void 0) this.flushBurst(key, burst);
|
|
13767
|
+
}
|
|
13768
|
+
hasLiveCommand(deviceId, capName, now) {
|
|
13769
|
+
return (this.pending.get(this.keyOf(deviceId, capName)) ?? []).some((e) => !e.settled && e.expiresAt > now);
|
|
13770
|
+
}
|
|
13771
|
+
/** Write every held burst now (shutdown): a held change must not be lost (D49). */
|
|
13772
|
+
flush() {
|
|
13773
|
+
for (const [key, burst] of [...this.held]) this.flushBurst(key, burst);
|
|
13774
|
+
}
|
|
13775
|
+
/** The fields of a burst that ended somewhere other than where they started. */
|
|
13776
|
+
netChanges(burst) {
|
|
13777
|
+
return [...burst.fields].filter(([, f]) => !sameValue(f.before, f.after)).map(([field, f]) => ({
|
|
13778
|
+
field,
|
|
13779
|
+
...f
|
|
13780
|
+
}));
|
|
13781
|
+
}
|
|
13782
|
+
flushBurst(key, burst) {
|
|
13783
|
+
this.held.delete(key);
|
|
13784
|
+
const net = this.netChanges(burst);
|
|
13785
|
+
const { deviceId, capName } = burst;
|
|
13786
|
+
for (const field of burst.fields.keys()) {
|
|
13787
|
+
if (net.some((c) => c.field === field)) continue;
|
|
13788
|
+
this.deps.logger?.debug(`device-transitions: ${capName}.${field} went and came back inside one burst; no row`, { tags: { deviceId } });
|
|
13789
|
+
}
|
|
13790
|
+
const touched = [...burst.fields].map(([field, f]) => ({
|
|
13791
|
+
field,
|
|
13792
|
+
...f
|
|
13793
|
+
}));
|
|
13794
|
+
let claimed = this.commandMatchedBy(deviceId, capName, touched, burst.lastAt);
|
|
13795
|
+
for (const change of net) claimed = this.attribute(deviceId, capName, change.field, toTransitionValue(change.before), toTransitionValue(change.after), burst.lastAt, claimed, change.neverHeld);
|
|
13796
|
+
const effect = claimed?.effect;
|
|
13797
|
+
if (claimed !== void 0 && effect !== null && effect !== void 0) {
|
|
13798
|
+
if (!net.some((c) => c.field === effect.field)) {
|
|
13799
|
+
const before = burst.fields.get(effect.field)?.before;
|
|
13800
|
+
this.confirmWithoutNet(key, claimed, effect.field, toTransitionValue(before), toTransitionValue(effect.value), burst.lastAt);
|
|
13801
|
+
}
|
|
13802
|
+
}
|
|
13803
|
+
}
|
|
13804
|
+
confirmWithoutNet(key, entry, field, from, to, at) {
|
|
13805
|
+
entry.settled = true;
|
|
13806
|
+
this.emit(entry, "confirmed", field, from, to, at - entry.obs.at, void 0, at);
|
|
13807
|
+
this.pruneSettled(key);
|
|
13808
|
+
}
|
|
13809
|
+
pruneSettled(key) {
|
|
13810
|
+
const ring = this.pending.get(key);
|
|
13811
|
+
if (ring === void 0) return;
|
|
13812
|
+
const rest = ring.filter((e) => !e.settled);
|
|
13813
|
+
if (rest.length === 0) this.pending.delete(key);
|
|
13814
|
+
else this.pending.set(key, rest);
|
|
13815
|
+
}
|
|
13816
|
+
flushDue(now) {
|
|
13817
|
+
for (const [key, burst] of [...this.held]) if (now - burst.lastAt >= 5e3 || now - burst.firstAt >= 6e4) this.flushBurst(key, burst);
|
|
13818
|
+
}
|
|
13819
|
+
/** The newest live command whose effect one of `changes` fulfils, if any. */
|
|
13820
|
+
commandMatchedBy(deviceId, capName, changes, now) {
|
|
13821
|
+
return [...(this.pending.get(this.keyOf(deviceId, capName)) ?? []).filter((e) => !e.settled && e.expiresAt > now)].reverse().find((e) => e.effect !== null && changes.some((c) => e.effect !== null && e.effect.field === c.field && sameValue(e.effect.value, toTransitionValue(c.after))));
|
|
13739
13822
|
}
|
|
13740
13823
|
/** Expire every pending command past its window. Driven by the sender's tick. */
|
|
13741
13824
|
sweep() {
|
|
13742
13825
|
const now = this.deps.now();
|
|
13743
|
-
this.
|
|
13826
|
+
this.flushDue(now);
|
|
13744
13827
|
for (const [key, ring] of this.pending) {
|
|
13745
13828
|
const live = [];
|
|
13746
13829
|
for (const entry of ring) {
|
|
@@ -13761,26 +13844,25 @@ var TransitionCorrelator = class {
|
|
|
13761
13844
|
/** Forget a removed device's pending commands. */
|
|
13762
13845
|
forgetDevice(deviceId) {
|
|
13763
13846
|
const prefix = `${deviceId}|`;
|
|
13764
|
-
for (const key of [...this.
|
|
13847
|
+
for (const key of [...this.held.keys()]) {
|
|
13848
|
+
if (!key.startsWith(prefix)) continue;
|
|
13849
|
+
this.deps.logger?.debug(`device-transitions: device removed with a held ${key.slice(prefix.length)} burst; dropped`, { tags: { deviceId } });
|
|
13850
|
+
this.held.delete(key);
|
|
13851
|
+
}
|
|
13765
13852
|
for (const key of [...this.pending.keys()]) if (key.startsWith(prefix)) this.pending.delete(key);
|
|
13766
13853
|
}
|
|
13767
13854
|
attribute(deviceId, capName, field, from, to, now, claimedByThisWrite, neverHeld) {
|
|
13768
13855
|
const key = this.keyOf(deviceId, capName);
|
|
13769
|
-
const
|
|
13770
|
-
const live = (ring ?? []).filter((e) => !e.settled && e.expiresAt > now);
|
|
13856
|
+
const live = (this.pending.get(key) ?? []).filter((e) => !e.settled && e.expiresAt > now);
|
|
13771
13857
|
const matched = [...live].reverse().find((e) => e.effect !== null && e.effect.field === field && sameValue(e.effect.value, to)) ?? claimedByThisWrite ?? [...live].reverse().find((e) => e.effect === null);
|
|
13772
13858
|
if (matched === void 0) {
|
|
13773
13859
|
if (neverHeld) return void 0;
|
|
13774
|
-
this.
|
|
13860
|
+
this.writeDevice(deviceId, capName, field, from, to, now);
|
|
13775
13861
|
return;
|
|
13776
13862
|
}
|
|
13777
13863
|
matched.settled = true;
|
|
13778
|
-
this.emit(matched, "confirmed", field, from, to, now - matched.obs.at);
|
|
13779
|
-
|
|
13780
|
-
const rest = ring.filter((e) => !e.settled);
|
|
13781
|
-
if (rest.length === 0) this.pending.delete(key);
|
|
13782
|
-
else this.pending.set(key, rest);
|
|
13783
|
-
}
|
|
13864
|
+
this.emit(matched, "confirmed", field, from, to, now - matched.obs.at, void 0, now);
|
|
13865
|
+
this.pruneSettled(key);
|
|
13784
13866
|
return matched;
|
|
13785
13867
|
}
|
|
13786
13868
|
expire(entry) {
|
|
@@ -13796,9 +13878,8 @@ var TransitionCorrelator = class {
|
|
|
13796
13878
|
const field = entry.effect?.field ?? "*";
|
|
13797
13879
|
this.emit(entry, "failed", field, entry.fromAtCommand, entry.fromAtCommand, null, message);
|
|
13798
13880
|
}
|
|
13799
|
-
emit(entry, outcome, field, from, to, matchedAfterMs, error) {
|
|
13881
|
+
emit(entry, outcome, field, from, to, matchedAfterMs, error, at = this.deps.now()) {
|
|
13800
13882
|
const { obs } = entry;
|
|
13801
|
-
const at = this.deps.now();
|
|
13802
13883
|
this.deps.emit({
|
|
13803
13884
|
id: this.nextId(obs.deviceId, at),
|
|
13804
13885
|
deviceId: obs.deviceId,
|
|
@@ -13819,27 +13900,7 @@ var TransitionCorrelator = class {
|
|
|
13819
13900
|
}
|
|
13820
13901
|
});
|
|
13821
13902
|
}
|
|
13822
|
-
/** A change nobody asked for
|
|
13823
|
-
emitDevice(deviceId, capName, field, from, to, at) {
|
|
13824
|
-
const key = `${deviceId}|${capName}|${field}`;
|
|
13825
|
-
const window = this.deviceRows.get(key);
|
|
13826
|
-
if (window === void 0 || at - window.lastEmitAt >= 1e4) {
|
|
13827
|
-
if (window?.held !== void 0 && !sameValue(window.held.from, window.held.to)) this.writeDevice(deviceId, capName, field, window.held.from, window.held.to, window.held.at);
|
|
13828
|
-
this.writeDevice(deviceId, capName, field, from, to, at);
|
|
13829
|
-
this.deviceRows.set(key, {
|
|
13830
|
-
deviceId,
|
|
13831
|
-
capName,
|
|
13832
|
-
field,
|
|
13833
|
-
lastEmitAt: at
|
|
13834
|
-
});
|
|
13835
|
-
return;
|
|
13836
|
-
}
|
|
13837
|
-
window.held = {
|
|
13838
|
-
from: window.held?.from ?? from,
|
|
13839
|
-
to,
|
|
13840
|
-
at
|
|
13841
|
-
};
|
|
13842
|
-
}
|
|
13903
|
+
/** A change nobody asked for. */
|
|
13843
13904
|
writeDevice(deviceId, capName, field, from, to, at) {
|
|
13844
13905
|
this.deps.emit({
|
|
13845
13906
|
id: this.nextId(deviceId, at),
|
|
@@ -13853,21 +13914,6 @@ var TransitionCorrelator = class {
|
|
|
13853
13914
|
actor: { kind: "device" }
|
|
13854
13915
|
});
|
|
13855
13916
|
}
|
|
13856
|
-
/** Release coalesced device rows whose window has closed; forget windows nothing is held in. */
|
|
13857
|
-
releaseDeviceRows(now) {
|
|
13858
|
-
for (const [key, window] of this.deviceRows) {
|
|
13859
|
-
if (now - window.lastEmitAt < 1e4) continue;
|
|
13860
|
-
const held = window.held;
|
|
13861
|
-
this.deviceRows.delete(key);
|
|
13862
|
-
if (held === void 0 || sameValue(held.from, held.to)) continue;
|
|
13863
|
-
this.writeDevice(window.deviceId, window.capName, window.field, held.from, held.to, held.at);
|
|
13864
|
-
this.deviceRows.set(key, {
|
|
13865
|
-
...window,
|
|
13866
|
-
held: void 0,
|
|
13867
|
-
lastEmitAt: now
|
|
13868
|
-
});
|
|
13869
|
-
}
|
|
13870
|
-
}
|
|
13871
13917
|
keyOf(deviceId, capName) {
|
|
13872
13918
|
return `${deviceId}|${capName}`;
|
|
13873
13919
|
}
|
|
@@ -13983,6 +14029,7 @@ function startDeviceTransitions(deps) {
|
|
|
13983
14029
|
};
|
|
13984
14030
|
const correlator = new TransitionCorrelator({
|
|
13985
14031
|
now,
|
|
14032
|
+
logger: deps.logger,
|
|
13986
14033
|
currentSlice: (deviceId, capName) => deps.mirror.currentSlice(deviceId, capName),
|
|
13987
14034
|
emit: (row) => {
|
|
13988
14035
|
sender.enqueue(row);
|
|
@@ -14015,6 +14062,7 @@ function startDeviceTransitions(deps) {
|
|
|
14015
14062
|
unsubscribe();
|
|
14016
14063
|
deps.mirror.setTransitionTap(null);
|
|
14017
14064
|
stopTicker();
|
|
14065
|
+
correlator.flush();
|
|
14018
14066
|
await sender.flush();
|
|
14019
14067
|
sender.abandon();
|
|
14020
14068
|
}
|
|
@@ -13,22 +13,27 @@
|
|
|
13
13
|
* mirror's current slice. Nothing here does I/O, so a state write never waits on
|
|
14
14
|
* the audit; what it produces is handed to `emit`, whose queue is bounded.
|
|
15
15
|
*/
|
|
16
|
-
import { type DeviceCommandObservation, type DeviceTransition, type TransitionValue } from "@camstack/types";
|
|
16
|
+
import { type DeviceCommandObservation, type DeviceTransition, type IScopedLogger, type TransitionValue } from "@camstack/types";
|
|
17
17
|
/** How long a command waits for the change it should cause. */
|
|
18
18
|
export declare const COMMAND_MATCH_WINDOW_MS = 3e4;
|
|
19
19
|
/** Pending commands kept per (device, cap); the oldest is expired when a ninth arrives. */
|
|
20
20
|
export declare const PENDING_RING_MAX = 8;
|
|
21
21
|
/**
|
|
22
|
-
* A
|
|
23
|
-
*
|
|
24
|
-
*
|
|
25
|
-
*
|
|
22
|
+
* A cap's audited fields are SETTLED before they are written: changes are held as one burst per
|
|
23
|
+
* (device, cap) and written, one row per field, when the burst ends. It ends when a pending
|
|
24
|
+
* command is matched by its effect (written at once, credited to the command), or when the cap
|
|
25
|
+
* has been quiet for this long. A cover that reports `open`, `position 6`, `opening`, then `open`
|
|
26
|
+
* and `position 100` is one change per field (`closed -> open`, `0 -> 100`), not five.
|
|
26
27
|
*/
|
|
27
|
-
export declare const
|
|
28
|
+
export declare const SETTLE_QUIET_MS = 5e3;
|
|
29
|
+
/** A burst that never goes quiet (a flapping sensor) is written anyway after this long. */
|
|
30
|
+
export declare const SETTLE_MAX_HOLD_MS = 6e4;
|
|
28
31
|
/** The field of a row whose command named none (a toggle that changed nothing we saw). */
|
|
29
32
|
export declare const NO_FIELD = "*";
|
|
30
33
|
export type CurrentSlice = (deviceId: number, capName: string) => Readonly<Record<string, unknown>> | undefined;
|
|
31
34
|
export interface CorrelatorDeps {
|
|
35
|
+
/** Optional: names the branches that write nothing (a there-and-back field, a dropped burst). */
|
|
36
|
+
readonly logger?: IScopedLogger;
|
|
32
37
|
readonly now: () => number;
|
|
33
38
|
readonly currentSlice: CurrentSlice;
|
|
34
39
|
readonly emit: (transition: DeviceTransition) => void;
|
|
@@ -41,12 +46,23 @@ export declare class TransitionCorrelator {
|
|
|
41
46
|
private readonly deps;
|
|
42
47
|
private readonly pending;
|
|
43
48
|
private seq;
|
|
44
|
-
private readonly
|
|
49
|
+
private readonly held;
|
|
45
50
|
constructor(deps: CorrelatorDeps);
|
|
46
51
|
/** A command left its caller. */
|
|
47
52
|
recordCommand(obs: DeviceCommandObservation): void;
|
|
48
53
|
/** The mirror stored a new native slice for `capName` (the previous one, if any, is `prior`). */
|
|
49
54
|
onSliceChange(deviceId: number, capName: string, prior: Readonly<Record<string, unknown>> | undefined, slice: Readonly<Record<string, unknown>>): void;
|
|
55
|
+
private hasLiveCommand;
|
|
56
|
+
/** Write every held burst now (shutdown): a held change must not be lost (D49). */
|
|
57
|
+
flush(): void;
|
|
58
|
+
/** The fields of a burst that ended somewhere other than where they started. */
|
|
59
|
+
private netChanges;
|
|
60
|
+
private flushBurst;
|
|
61
|
+
private confirmWithoutNet;
|
|
62
|
+
private pruneSettled;
|
|
63
|
+
private flushDue;
|
|
64
|
+
/** The newest live command whose effect one of `changes` fulfils, if any. */
|
|
65
|
+
private commandMatchedBy;
|
|
50
66
|
/** Expire every pending command past its window. Driven by the sender's tick. */
|
|
51
67
|
sweep(): void;
|
|
52
68
|
/** Commands still waiting, for a status read. */
|
|
@@ -57,11 +73,8 @@ export declare class TransitionCorrelator {
|
|
|
57
73
|
private expire;
|
|
58
74
|
private fail;
|
|
59
75
|
private emit;
|
|
60
|
-
/** A change nobody asked for
|
|
61
|
-
private emitDevice;
|
|
76
|
+
/** A change nobody asked for. */
|
|
62
77
|
private writeDevice;
|
|
63
|
-
/** Release coalesced device rows whose window has closed; forget windows nothing is held in. */
|
|
64
|
-
private releaseDeviceRows;
|
|
65
78
|
private keyOf;
|
|
66
79
|
private nextId;
|
|
67
80
|
private nextCommandId;
|
|
@@ -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-
|
|
6
|
+
const require_dist = require("../../dist-BZfvhfS1.js");
|
|
7
7
|
const require_formatter = require("../../formatter-xbxeV4GD.js");
|
|
8
8
|
//#region src/builtins/hub-forwarder/hub-forwarder-destination.ts
|
|
9
9
|
var DEFAULT_OUTBOUND_BUFFER_SIZE = 500;
|
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import { Lc as BaseAddon, wa as logDestinationCapability } from "../../dist-
|
|
1
|
+
import { Lc as BaseAddon, wa as logDestinationCapability } from "../../dist-BCHMSqzc.mjs";
|
|
2
2
|
import { t as formatLogLine } from "../../formatter-DkYZ4LXp.mjs";
|
|
3
3
|
//#region src/builtins/hub-forwarder/hub-forwarder-destination.ts
|
|
4
4
|
var DEFAULT_OUTBOUND_BUFFER_SIZE = 500;
|
|
@@ -3,11 +3,11 @@ 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-
|
|
7
|
-
const require_device_ca = require("../../device-ca-
|
|
6
|
+
const require_dist = require("../../dist-BZfvhfS1.js");
|
|
7
|
+
const require_device_ca = require("../../device-ca-CU8zh9Pi.js");
|
|
8
8
|
const require_read_all_rows$1 = require("../../read-all-rows-CVoO1ONM.js");
|
|
9
|
-
const require_legacy_integration_rows_door = require("../../legacy-integration-rows-door-
|
|
10
|
-
const require_constants = require("../../constants-
|
|
9
|
+
const require_legacy_integration_rows_door = require("../../legacy-integration-rows-door-CVwOo5aq.js");
|
|
10
|
+
const require_constants = require("../../constants-D2etJ02O.js");
|
|
11
11
|
const require_platform_key_source = require("../../platform-key-source-Di7HrlGR.js");
|
|
12
12
|
let node_crypto = require("node:crypto");
|
|
13
13
|
let _camstack_types_node = require("@camstack/types/node");
|
|
@@ -1,8 +1,8 @@
|
|
|
1
|
-
import { Ft as KeychainAuditEntrySchema, It as KeychainResetRecordSchema, Kl as formatSecretScope, Lc as BaseAddon, Pt as KEYCHAIN_RESET_TRIGGER_ACTOR, Wu as EventCategory, fa as keychainAdminCapability, mu as normalizeSecretOwner, pa as keychainCapability, vu as parseSecretRef, zl as defineRecordKinds } from "../../dist-
|
|
2
|
-
import { d as JWT_SIGNING_KEY_REF, n as DEVICE_CA_KEY_REF, p as SYSTEM_SECRET_OWNER } from "../../device-ca-
|
|
1
|
+
import { Ft as KeychainAuditEntrySchema, It as KeychainResetRecordSchema, Kl as formatSecretScope, Lc as BaseAddon, Pt as KEYCHAIN_RESET_TRIGGER_ACTOR, Wu as EventCategory, fa as keychainAdminCapability, mu as normalizeSecretOwner, pa as keychainCapability, vu as parseSecretRef, zl as defineRecordKinds } from "../../dist-BCHMSqzc.mjs";
|
|
2
|
+
import { d as JWT_SIGNING_KEY_REF, n as DEVICE_CA_KEY_REF, p as SYSTEM_SECRET_OWNER } from "../../device-ca-ExMN3xW3.mjs";
|
|
3
3
|
import { t as require_read_all_rows } from "../../read-all-rows-TaPqdWNF.mjs";
|
|
4
|
-
import { t as LEGACY_INTEGRATION_ROWS_TABLE } from "../../legacy-integration-rows-door-
|
|
5
|
-
import { a as MESH_CA_KEY_REF } from "../../constants-
|
|
4
|
+
import { t as LEGACY_INTEGRATION_ROWS_TABLE } from "../../legacy-integration-rows-door-D9tQOUzh.mjs";
|
|
5
|
+
import { a as MESH_CA_KEY_REF } from "../../constants-BcUTQd1M.mjs";
|
|
6
6
|
import { n as getPlatformKeychainKey } from "../../platform-key-source-BWlq0jjn.mjs";
|
|
7
7
|
import { createCipheriv, createDecipheriv, createHmac, randomBytes, randomUUID, timingSafeEqual } from "node:crypto";
|
|
8
8
|
import { restrictDirToOwnerSync, restrictFileToOwnerSync, writeOwnerOnlyFileSync } from "@camstack/types/node";
|
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
Object.defineProperty(exports, Symbol.toStringTag, { value: "Module" });
|
|
2
2
|
const require_chunk = require("../../chunk-Cek0wNdY.js");
|
|
3
|
-
const require_dist = require("../../dist-
|
|
3
|
+
const require_dist = require("../../dist-BZfvhfS1.js");
|
|
4
4
|
let node_fs = require("node:fs");
|
|
5
5
|
let node_path = require("node:path");
|
|
6
6
|
node_path = require_chunk.__toESM(node_path);
|
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import { Hu as errMsg, Lc as BaseAddon, Pl as createEvent, Wu as EventCategory, fn as RecordingStatusSchema, ka as mayWriteToLocation, ln as RECORDING_SOURCE_CAMSTACK_ADDON } from "../../dist-
|
|
1
|
+
import { Hu as errMsg, Lc as BaseAddon, Pl as createEvent, Wu as EventCategory, fn as RecordingStatusSchema, ka as mayWriteToLocation, ln as RECORDING_SOURCE_CAMSTACK_ADDON } from "../../dist-BCHMSqzc.mjs";
|
|
2
2
|
import { constants } from "node:fs";
|
|
3
3
|
import path from "node:path";
|
|
4
4
|
import * as fsp from "node:fs/promises";
|
|
@@ -3,10 +3,10 @@ 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-
|
|
6
|
+
const require_dist = require("../../dist-BZfvhfS1.js");
|
|
7
7
|
const require_safe_buffer$1 = require("../../safe-buffer-D3aoa-7X.js");
|
|
8
8
|
const require_ms$1 = require("../../ms-LB3giGoU.js");
|
|
9
|
-
const require_device_ca = require("../../device-ca-
|
|
9
|
+
const require_device_ca = require("../../device-ca-CU8zh9Pi.js");
|
|
10
10
|
const require_read_all_rows$1 = require("../../read-all-rows-CVoO1ONM.js");
|
|
11
11
|
let zod = require("zod");
|
|
12
12
|
let node_crypto = require("node:crypto");
|
|
@@ -1,8 +1,8 @@
|
|
|
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-
|
|
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-
|
|
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";
|
|
@@ -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-
|
|
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-
|
|
6
|
-
const require_hub_mdns_ciao = require("../../hub-mdns-ciao-
|
|
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).
|