@camstack/server 1.2.728 → 1.2.730
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 +19 -0
- package/dist/agent/main.js +2 -14
- package/dist/api/core/cap-providers.js +0 -7
- package/dist/api/trpc/generated-cap-mounts.js +4 -1
- package/dist/api/trpc/generated-cap-routers.js +1923 -1839
- package/dist/boot/boot-config.js +1 -1
- package/dist/core/addon/addon-package.service.js +3 -105
- package/dist/core/addon-bridge/addon-bridge.service.js +1 -5
- package/dist/launcher.js +12 -124
- package/package.json +19 -17
- package/system/dist/addon-runner.js +1 -2
- package/system/dist/addon-runner.mjs +1 -2
- package/system/dist/{agent-https-B1XLr4nm.js → agent-https-C8Gz2jjS.js} +1 -1
- package/system/dist/{agent-https-BsedJhrb.mjs → agent-https-DZq8uf8L.mjs} +1 -1
- 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 +3 -3
- package/system/dist/builtins/composer/composer.addon.mjs +3 -3
- 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.d.ts +6 -0
- package/system/dist/builtins/core-blocks/core-blocks.addon.js +1361 -440
- package/system/dist/builtins/core-blocks/core-blocks.addon.mjs +1360 -440
- package/system/dist/builtins/core-blocks/fan-presets-action-source.d.ts +35 -0
- package/system/dist/builtins/core-blocks/fan-presets-service.d.ts +83 -0
- package/system/dist/builtins/core-blocks/fan-presets-wiring.d.ts +31 -0
- package/system/dist/builtins/core-blocks/record-kinds.d.ts +15 -0
- package/system/dist/builtins/core-blocks/timed-run/timed-run-service.d.ts +84 -0
- package/system/dist/builtins/core-blocks/timed-run/timed-run-wiring.d.ts +21 -0
- package/system/dist/builtins/device-history/device-history.addon.d.ts +4 -0
- package/system/dist/builtins/device-history/device-history.addon.js +769 -17
- package/system/dist/builtins/device-history/device-history.addon.mjs +769 -17
- package/system/dist/builtins/device-history/runs/device-runs-provider.d.ts +7 -0
- package/system/dist/builtins/device-history/runs/device-runs-record-kinds.d.ts +15 -0
- package/system/dist/builtins/device-history/runs/device-runs-service.d.ts +42 -0
- package/system/dist/builtins/device-history/runs/energy-from-history.d.ts +22 -0
- package/system/dist/builtins/device-history/runs/run-recorder.d.ts +111 -0
- package/system/dist/builtins/device-history/runs/slice-readers.d.ts +9 -0
- package/system/dist/builtins/device-manager/device-manager.addon.js +1 -1
- package/system/dist/builtins/device-manager/device-manager.addon.mjs +1 -1
- 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 +47 -38
- package/system/dist/builtins/keychain/index.mjs +47 -38
- package/system/dist/builtins/keychain/key-sources.d.ts +12 -7
- 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 +3 -3
- package/system/dist/builtins/local-auth/local-auth.addon.mjs +3 -3
- package/system/dist/builtins/local-network/local-network.addon.js +2 -2
- package/system/dist/builtins/local-network/local-network.addon.mjs +2 -2
- 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 +2 -2
- package/system/dist/builtins/sqlite-storage/sqlite-settings.addon.mjs +2 -2
- 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/{composition-sources-BjuQ3xot.mjs → composition-sources-4M_NnTnV.mjs} +1 -1
- package/system/dist/{composition-sources-C5r8i46e.js → composition-sources-hokiaS3J.js} +1 -1
- package/system/dist/{constants-Bh5wQoTg.js → constants-B0L3suFC.js} +1 -1
- package/system/dist/{constants-GnxjCxT3.mjs → constants-DTVU00LZ.mjs} +1 -1
- package/system/dist/{device-ca-OWEYAYaG.mjs → device-ca-C_y2GrU5.mjs} +2 -2
- package/system/dist/{device-ca-oM-nuINR.js → device-ca-DaTT1Y9v.js} +2 -2
- package/system/dist/{dist-Cw8KtuQY.mjs → dist-9lvgpcnm.mjs} +43394 -42706
- package/system/dist/{dist-B9xpybTG.js → dist-B3S0ruBa.js} +43217 -42457
- package/system/dist/file-host-worker.js +1 -1
- package/system/dist/file-host-worker.mjs +1 -1
- package/system/dist/{hub-mdns-ciao-BPENkOKX.js → hub-mdns-ciao-Dkw38L-g.js} +2 -2
- package/system/dist/{hub-mdns-ciao-C3qMZFP0.mjs → hub-mdns-ciao-xgLfZIVx.mjs} +2 -2
- package/system/dist/index.js +40 -186
- package/system/dist/index.mjs +41 -185
- package/system/dist/kernel/addon-installer.d.ts +9 -60
- package/system/dist/kernel/bootstrap-config.d.ts +3 -1
- package/system/dist/kernel/config-schema.d.ts +2 -11
- package/system/dist/kernel/fs-utils.d.ts +0 -6
- package/system/dist/kernel/index.d.ts +2 -3
- package/system/dist/{restore-archive-DJv5ATV8.mjs → restore-archive-cxnuWxQM.mjs} +1 -1
- package/system/dist/{restore-archive-BiN1yKZV.js → restore-archive-orP6eHBd.js} +1 -1
- package/system/dist/{retention-BT7TgsUn.js → retention-CB2cyW9k.js} +1 -1
- package/system/dist/{retention-DQje-V4I.mjs → retention-Me4u6zMp.mjs} +1 -1
- package/system/dist/{wal-maintenance-DM08Htuy.mjs → wal-maintenance-De7Ifvph.mjs} +0 -0
- package/system/dist/{wal-maintenance-BLwgOIXb.js → wal-maintenance-_PXj626-.js} +0 -0
- package/system/package.json +11 -2
- package/system/dist/kernel/workspace-detect.d.ts +0 -9
|
@@ -0,0 +1,7 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* The `device-runs` capability over the run ledger. Reads go to the store, never
|
|
3
|
+
* to the recorder's mirror: an answered empty page is "no runs", and the open
|
|
4
|
+
* run is what is on disk (the open row is written through).
|
|
5
|
+
*/
|
|
6
|
+
import type { DeviceRun, IDeviceRunsProvider, RecordKindHandle } from "@camstack/types";
|
|
7
|
+
export declare function createDeviceRunsProvider(runs: RecordKindHandle<DeviceRun>): IDeviceRunsProvider;
|
|
@@ -0,0 +1,15 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* The record kind of the run ledger (D992). Declared by the device-history
|
|
3
|
+
* addon (owner stamp `device-history`) in the `events` file: a ring of the
|
|
4
|
+
* newest runs per device, with one row per run and the open row written
|
|
5
|
+
* through at the instant the run opens.
|
|
6
|
+
*
|
|
7
|
+
* Kept in a module with no side effects: the records guards import it.
|
|
8
|
+
*/
|
|
9
|
+
import type { z } from "zod";
|
|
10
|
+
import { DeviceRunSchema, type DefinedRecordKind } from "@camstack/types";
|
|
11
|
+
export declare const DEVICE_RUNS_MAX_ROWS_PER_DEVICE = 500;
|
|
12
|
+
export type DeviceRunsRecordKindsMap = {
|
|
13
|
+
readonly "device-runs": DefinedRecordKind<z.ZodType<z.infer<typeof DeviceRunSchema>>>;
|
|
14
|
+
};
|
|
15
|
+
export declare const deviceRunsRecordKinds: DeviceRunsRecordKindsMap;
|
|
@@ -0,0 +1,42 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* The run ledger as the addon shell sees it: the declared kind, the recorder,
|
|
3
|
+
* the capability provider, the timer and the device-removal hook body (D865).
|
|
4
|
+
* The shell only forwards (`onHubReachable` -> {@link DeviceRunsService.open},
|
|
5
|
+
* the bus -> {@link DeviceRunsService.handleState}); everything with a rule is
|
|
6
|
+
* in the files beside this one.
|
|
7
|
+
*/
|
|
8
|
+
import { type DeviceRun, type DeviceType, type EventCategory, type IDeviceRunsProvider, type IScopedLogger, type RecordsAccess } from "@camstack/types";
|
|
9
|
+
import type { SnapshotMap } from "../capture/capture-engine.js";
|
|
10
|
+
import type { Slice } from "./slice-readers.js";
|
|
11
|
+
export interface DeviceRunsServiceDeps {
|
|
12
|
+
readonly records: RecordsAccess;
|
|
13
|
+
readonly readSnapshots: () => Promise<SnapshotMap>;
|
|
14
|
+
readonly readCapSlice: (deviceId: number, capName: string) => Promise<Slice | null>;
|
|
15
|
+
readonly deviceTypeOf: (deviceId: number) => Promise<DeviceType | undefined>;
|
|
16
|
+
readonly energyFromHistory: (deviceId: number, from: number, to: number) => Promise<number | null>;
|
|
17
|
+
readonly emit: (category: EventCategory, run: DeviceRun) => void;
|
|
18
|
+
readonly logger: IScopedLogger;
|
|
19
|
+
readonly clock: () => number;
|
|
20
|
+
}
|
|
21
|
+
export declare class DeviceRunsService {
|
|
22
|
+
private readonly deps;
|
|
23
|
+
private recorder;
|
|
24
|
+
private handle;
|
|
25
|
+
private timer;
|
|
26
|
+
private provider;
|
|
27
|
+
constructor(deps: DeviceRunsServiceDeps);
|
|
28
|
+
/** Declare the kind, then the first reconcile; an unanswered one is retried by the timer. */
|
|
29
|
+
open(): Promise<{
|
|
30
|
+
readonly provider: IDeviceRunsProvider;
|
|
31
|
+
}>;
|
|
32
|
+
startTimer(): void;
|
|
33
|
+
handleState(deviceId: number, capName: string, slice: Slice, at: number): void;
|
|
34
|
+
stop(): Promise<void>;
|
|
35
|
+
/** The D865 hook body: how many run rows the removal deleted. */
|
|
36
|
+
removeDevice(deviceId: number): Promise<number>;
|
|
37
|
+
/** Run rows per device, for the admin clean-up listing. */
|
|
38
|
+
countByDevice(): Promise<readonly {
|
|
39
|
+
deviceId: number;
|
|
40
|
+
count: number;
|
|
41
|
+
}[]>;
|
|
42
|
+
}
|
|
@@ -0,0 +1,22 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* The energy of a window from device-history's OWN stored series - the
|
|
3
|
+
* fallback when the meter counter could not give `end - start` (D992).
|
|
4
|
+
*
|
|
5
|
+
* It sums the per-bucket `delta` of the derived energy key. Buckets are five
|
|
6
|
+
* minutes wide, so a window shorter than {@link MIN_HISTORY_WINDOW_MS} is never
|
|
7
|
+
* answered from them: a number built from one partial bucket would be a guess.
|
|
8
|
+
*/
|
|
9
|
+
import { type DeviceHistorySubject, type DeviceHistoryQueryResult } from "@camstack/types";
|
|
10
|
+
export declare const MIN_HISTORY_WINDOW_MS: number;
|
|
11
|
+
export interface EnergyHistoryQuery {
|
|
12
|
+
(input: {
|
|
13
|
+
readonly key: string;
|
|
14
|
+
readonly subject: DeviceHistorySubject;
|
|
15
|
+
readonly from: number;
|
|
16
|
+
readonly to: number;
|
|
17
|
+
readonly resolution: "5m";
|
|
18
|
+
readonly maxPoints: number;
|
|
19
|
+
}): Promise<DeviceHistoryQueryResult>;
|
|
20
|
+
}
|
|
21
|
+
/** kWh over `[from, to]`, or `null` when the series cannot say (no meter, no points, too short). */
|
|
22
|
+
export declare function energyKwhFromHistory(query: EnergyHistoryQuery, deviceId: number, from: number, to: number): Promise<number | null>;
|
|
@@ -0,0 +1,111 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* The run recorder (D992): turns the `running-state` flips of a device into one
|
|
3
|
+
* durable `device-runs` row per run.
|
|
4
|
+
*
|
|
5
|
+
* - open: `running` false -> true writes the OPEN row through, so a run that
|
|
6
|
+
* outlives this process is on disk from its first instant;
|
|
7
|
+
* - close: true -> false closes it, with the energy of the run and its outcome;
|
|
8
|
+
* - boot reconcile: the open rows are compared with the live snapshots - a
|
|
9
|
+
* device still running keeps its row, one that stopped while nobody watched
|
|
10
|
+
* closes `unknown`, one running with no row opens late. A run is never
|
|
11
|
+
* duplicated: a device has at most one open run, in the mirror and on disk.
|
|
12
|
+
*
|
|
13
|
+
* Nothing one-shot gates on a fallible read (D49): a failed load or snapshot
|
|
14
|
+
* read changes nothing and the next pass tries again; events that arrive before
|
|
15
|
+
* the first answered load wait in a bounded buffer and replay after it.
|
|
16
|
+
*
|
|
17
|
+
* Energy comes from device-history's own data: the meter counter at open minus
|
|
18
|
+
* the counter at close, else the stored history of the window. Both unknown is
|
|
19
|
+
* `null` - never `0`.
|
|
20
|
+
*/
|
|
21
|
+
import { type DeviceRun, DeviceType, EventCategory, type IScopedLogger, type RecordKindHandle } from "@camstack/types";
|
|
22
|
+
import type { SnapshotMap } from "../capture/capture-engine.js";
|
|
23
|
+
import { type Slice } from "./slice-readers.js";
|
|
24
|
+
export declare const RUNNING_STATE_CAP = "running-state";
|
|
25
|
+
export declare const POWER_METER_CAP = "power-meter";
|
|
26
|
+
export declare const DISHWASHER_CAP = "dishwasher";
|
|
27
|
+
/** A run shorter than this that never reported a finishing phase is a dwell flap, not a cycle. */
|
|
28
|
+
export declare const ABORTED_BELOW_MS: number;
|
|
29
|
+
/** Events held before the first answered load; beyond it the oldest are dropped, counted and logged. */
|
|
30
|
+
export declare const MAX_BUFFERED_EVENTS = 2e3;
|
|
31
|
+
export declare const RECORDER_TICK_MS: number;
|
|
32
|
+
export declare const RECONCILE_EVERY_TICKS = 5;
|
|
33
|
+
export declare const FLUSH_EVERY_TICKS = 5;
|
|
34
|
+
export interface RunRecorderDeps {
|
|
35
|
+
readonly runs: RecordKindHandle<DeviceRun>;
|
|
36
|
+
readonly readSnapshots: () => Promise<SnapshotMap>;
|
|
37
|
+
readonly readCapSlice: (deviceId: number, capName: string) => Promise<Slice | null>;
|
|
38
|
+
readonly deviceTypeOf: (deviceId: number) => Promise<DeviceType | undefined>;
|
|
39
|
+
/** kWh of a window from the stored history, or `null`. */
|
|
40
|
+
readonly energyFromHistory: (deviceId: number, from: number, to: number) => Promise<number | null>;
|
|
41
|
+
readonly emit: (category: EventCategory, run: DeviceRun) => void;
|
|
42
|
+
readonly logger: IScopedLogger;
|
|
43
|
+
readonly clock: () => number;
|
|
44
|
+
}
|
|
45
|
+
export declare class RunRecorder {
|
|
46
|
+
private readonly deps;
|
|
47
|
+
private readonly open;
|
|
48
|
+
private readonly lastEnergy;
|
|
49
|
+
private readonly lastPower;
|
|
50
|
+
private readonly lastDishwasher;
|
|
51
|
+
private readonly chains;
|
|
52
|
+
private buffered;
|
|
53
|
+
private loaded;
|
|
54
|
+
private droppedWhileBuffering;
|
|
55
|
+
private ticks;
|
|
56
|
+
constructor(deps: RunRecorderDeps);
|
|
57
|
+
/**
|
|
58
|
+
* One minute of the owner's clock: retry the load until it answers, then
|
|
59
|
+
* compare against the snapshots every {@link RECONCILE_EVERY_TICKS} and save
|
|
60
|
+
* the open totals every {@link FLUSH_EVERY_TICKS}.
|
|
61
|
+
*/
|
|
62
|
+
tick(): Promise<void>;
|
|
63
|
+
/** Has a load of the open rows ANSWERED? Until then flips are buffered. */
|
|
64
|
+
isLoaded(): boolean;
|
|
65
|
+
/** Resolves when every queued flip has been handled (specs, shutdown). */
|
|
66
|
+
idle(): Promise<void>;
|
|
67
|
+
/** The open run of a device, from the mirror. */
|
|
68
|
+
openRunOf(deviceId: number): DeviceRun | null;
|
|
69
|
+
/** Feed one `DeviceStateChanged` slice. Never throws; a failure is logged with the device. */
|
|
70
|
+
handleState(deviceId: number, capName: string, slice: Slice, at: number): void;
|
|
71
|
+
private buffer;
|
|
72
|
+
private enqueue;
|
|
73
|
+
private apply;
|
|
74
|
+
private notePower;
|
|
75
|
+
/** Close the interval since the previous reading at the watts it held. */
|
|
76
|
+
private accrue;
|
|
77
|
+
private powerOf;
|
|
78
|
+
private energyNow;
|
|
79
|
+
private measureEnergy;
|
|
80
|
+
private notePhase;
|
|
81
|
+
private openRun;
|
|
82
|
+
private closeRun;
|
|
83
|
+
private outcomeOf;
|
|
84
|
+
private announce;
|
|
85
|
+
/**
|
|
86
|
+
* Write the power totals of every open run (a crash then loses at most one
|
|
87
|
+
* interval of peak/mean, never the run). Timer-driven; a failed write leaves
|
|
88
|
+
* the run dirty for the next pass.
|
|
89
|
+
*/
|
|
90
|
+
flushOpen(): Promise<void>;
|
|
91
|
+
/**
|
|
92
|
+
* Compare the open rows on disk with the live snapshots. Returns `false` when
|
|
93
|
+
* either read failed - nothing changed and the caller tries again (D49).
|
|
94
|
+
* Only the FIRST answered pass reads the rows (the mirror is the truth after
|
|
95
|
+
* it) and replays the flips buffered while it was pending; later passes
|
|
96
|
+
* compare the mirror with the snapshots, so a row read a moment before a
|
|
97
|
+
* close can never bring a closed run back.
|
|
98
|
+
*/
|
|
99
|
+
reconcile(): Promise<boolean>;
|
|
100
|
+
private loadOpenRows;
|
|
101
|
+
private settleAgainst;
|
|
102
|
+
/** A mirrored run whose device now says it stopped closes `unknown` (a later pass, flips missed). */
|
|
103
|
+
private settleMirror;
|
|
104
|
+
/** A device running with no open run: open it late, from its own `since`. */
|
|
105
|
+
private openLate;
|
|
106
|
+
/** One device at a time; a failure is logged with the device and never aborts the pass. */
|
|
107
|
+
private exclusive;
|
|
108
|
+
private seedPower;
|
|
109
|
+
/** Put a stored open row back in the mirror, its power totals resumed from the row. */
|
|
110
|
+
private adopt;
|
|
111
|
+
}
|
|
@@ -0,0 +1,9 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Typed reads of a device-state slice, which arrives as an untyped record.
|
|
3
|
+
* A field of the wrong type is "not said" (`null`), never coerced (D393).
|
|
4
|
+
*/
|
|
5
|
+
export type Slice = Readonly<Record<string, unknown>>;
|
|
6
|
+
export declare function numberField(slice: Slice | null, key: string): number | null;
|
|
7
|
+
export declare function stringField(slice: Slice | null, key: string): string | null;
|
|
8
|
+
export declare function booleanField(slice: Slice | null, key: string): boolean | null;
|
|
9
|
+
export declare function isSlice(value: unknown): value is Slice;
|
|
@@ -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-B3S0ruBa.js");
|
|
7
7
|
const require_read_all_rows$1 = require("../../read-all-rows-CVoO1ONM.js");
|
|
8
8
|
const require_prefix_range = require("../../prefix-range-D_KueXbQ.js");
|
|
9
9
|
const require_prefix_walk = require("../../prefix-walk-Dv6MLZlM.js");
|
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import { $ as
|
|
1
|
+
import { $o as collectZodSecretPaths, As as resolveSecretMarkers, Bn as createDeviceExtensionProvider, Bs as DeviceFeature, Cn as canonicalIconKey, F as DAY_NAMES, Hs as DeviceType, Is as toSecretFieldView, J as DeviceStatusSchema, Ji as runtimeStatePolicyFor, Jn as defineExtensionSlotProvider, Kr as locationIconKey, Ls as transformSecretWrite, Ms as secretTreeFromPaths, Ps as sleep$1, Qn as deviceExtensionCapability, Ro as SECRET_CLEAR, Rs as userError, Rt as STREAM_PROFILE_META, Uo as WELL_KNOWN_TAB_MAP, Us as errMsg, Vr as legacyAutoLinkIds, Vs as DeviceRole, Ws as EventCategory, Y as DeviceTombstoneSchema, _s as isSecretMarkerLike, aa as siteZoneKey, at as FieldClaimSchema, bn as buildStreamParamsConfigSchema, bt as MINUTES_PER_DAY, dr as expandContainer, ds as isDeviceConfigCap, er as deviceManagerCapability, fi as normalizeUnit, g as CAMERA_SWITCH_ORDER, gs as isSecretMarker, hs as isSecretClear, ir as deviceStatusCapability, it as FieldClaimModeSchema, o as ALL_CAPABILITY_DEFINITIONS, or as enumerateItemArrayFields, ps as isKeychainStoredField, rr as deviceStateCapability, rs as defineRecordKinds, sr as enumerateSchemaFields, uo as BaseAddon, v as CAP_NAMES_WITH_STATUS, xr as formatMinutes, yi as parseStreamParamsFormPatch } from "../../dist-9lvgpcnm.mjs";
|
|
2
2
|
import { t as require_read_all_rows } from "../../read-all-rows-TaPqdWNF.mjs";
|
|
3
3
|
import { t as prefixRange } from "../../prefix-range-Dl0znowN.mjs";
|
|
4
4
|
import { t as loadPrefixed } from "../../prefix-walk-DAOBSyH1.mjs";
|
|
@@ -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-B3S0ruBa.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 {
|
|
1
|
+
import { Yr as logDestinationCapability, uo as BaseAddon } from "../../dist-9lvgpcnm.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,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-
|
|
7
|
-
const require_device_ca = require("../../device-ca-
|
|
6
|
+
const require_dist = require("../../dist-B3S0ruBa.js");
|
|
7
|
+
const require_device_ca = require("../../device-ca-DaTT1Y9v.js");
|
|
8
8
|
const require_read_all_rows$1 = require("../../read-all-rows-CVoO1ONM.js");
|
|
9
|
-
const require_constants = require("../../constants-
|
|
9
|
+
const require_constants = require("../../constants-B0L3suFC.js");
|
|
10
10
|
const require_platform_key_source = require("../../platform-key-source-Di7HrlGR.js");
|
|
11
11
|
let node_crypto = require("node:crypto");
|
|
12
12
|
let _camstack_types_node = require("@camstack/types/node");
|
|
@@ -115,24 +115,35 @@ function decryptValue(dek, ref, envelope) {
|
|
|
115
115
|
//#endregion
|
|
116
116
|
//#region src/builtins/keychain/key-sources.ts
|
|
117
117
|
/**
|
|
118
|
-
* Where the master key comes from (D788).
|
|
119
|
-
* carries a key or a key path:
|
|
118
|
+
* Where the master key comes from (D788, amended by D991). FIXED paths only —
|
|
119
|
+
* no config key, NO env var carries a key or a key path:
|
|
120
120
|
*
|
|
121
|
-
* 1. `
|
|
122
|
-
* (
|
|
123
|
-
*
|
|
121
|
+
* 1. `/run/secrets/camstack-master-key` — primary when the file EXISTS at boot
|
|
122
|
+
* (the Docker / Compose secrets convention; Unraid and Proxmox bind-mount a
|
|
123
|
+
* file there). A file outside the data volume: a whole-volume backup then
|
|
124
|
+
* holds the ciphertext but not the key. CamStack only READS it — it is
|
|
125
|
+
* never written and never created.
|
|
124
126
|
* 2. The desktop app's OS keychain (`safeStorage`), handed to the hub over an
|
|
125
|
-
* inherited pipe. Primary on a desktop hub with no key file
|
|
127
|
+
* inherited pipe. Primary on a desktop hub with no mounted key file.
|
|
126
128
|
* 3. `<dataDir>/.keychain/master.key` (0600, directory 0700), generated on
|
|
127
129
|
* first boot. The fallback: it protects CamStack's own backups and stray
|
|
128
130
|
* database copies (it is NOT in `DEFAULT_BACKUP_LOCATIONS`), but a tar of
|
|
129
131
|
* the whole data directory carries key and database together, and the
|
|
130
132
|
* Secrets page says so.
|
|
131
133
|
*
|
|
132
|
-
*
|
|
133
|
-
* key to another is a restart plus `rotateMasterKey`,
|
|
134
|
-
* neither key works.
|
|
134
|
+
* `/run/secrets/camstack-master-key.previous` is consulted only to UNLOCK — so a
|
|
135
|
+
* move from one external key to another is a restart plus `rotateMasterKey`,
|
|
136
|
+
* with no window where neither key works.
|
|
135
137
|
*/
|
|
138
|
+
/** The directory the mounted key files live in (injectable for specs, never an env var). */
|
|
139
|
+
var DEFAULT_SECRETS_DIR = "/run/secrets";
|
|
140
|
+
/** The mounted primary key file, under the secrets directory. */
|
|
141
|
+
var MOUNTED_KEY_FILE_NAME = "camstack-master-key";
|
|
142
|
+
/** The mounted unlock-only key file, under the secrets directory. */
|
|
143
|
+
var PREVIOUS_MOUNTED_KEY_FILE_NAME = "camstack-master-key.previous";
|
|
144
|
+
/** Absolute form of both, for messages. */
|
|
145
|
+
var MOUNTED_KEY_FILE_PATH = `${DEFAULT_SECRETS_DIR}/${MOUNTED_KEY_FILE_NAME}`;
|
|
146
|
+
var PREVIOUS_MOUNTED_KEY_FILE_PATH = `${DEFAULT_SECRETS_DIR}/${PREVIOUS_MOUNTED_KEY_FILE_NAME}`;
|
|
136
147
|
/** The default key file's location under the data root. */
|
|
137
148
|
function defaultKeyFilePath(dataDir) {
|
|
138
149
|
return node_path.join(dataDir, ".keychain", "master.key");
|
|
@@ -164,23 +175,34 @@ function fileSource(kind, file, sharesBackupWithDatabase) {
|
|
|
164
175
|
sharesBackupWithDatabase
|
|
165
176
|
};
|
|
166
177
|
}
|
|
178
|
+
async function fileExists(file) {
|
|
179
|
+
try {
|
|
180
|
+
await node_fs.promises.access(file);
|
|
181
|
+
return true;
|
|
182
|
+
} catch {
|
|
183
|
+
return false;
|
|
184
|
+
}
|
|
185
|
+
}
|
|
167
186
|
/** Every candidate, primary first. */
|
|
168
|
-
function buildKeySourceCandidates(opts) {
|
|
187
|
+
async function buildKeySourceCandidates(opts) {
|
|
169
188
|
const out = [];
|
|
189
|
+
const secretsDir = opts.secretsDir ?? "/run/secrets";
|
|
190
|
+
const mountedFile = node_path.join(secretsDir, MOUNTED_KEY_FILE_NAME);
|
|
191
|
+
const previousFile = node_path.join(secretsDir, PREVIOUS_MOUNTED_KEY_FILE_NAME);
|
|
170
192
|
const defaultFile = defaultKeyFilePath(opts.dataDir);
|
|
171
193
|
const platform = require_platform_key_source.getPlatformKeychainKey();
|
|
172
|
-
const
|
|
173
|
-
const
|
|
174
|
-
const primaryKind =
|
|
175
|
-
if (
|
|
176
|
-
source: fileSource("
|
|
194
|
+
const hasMounted = await fileExists(mountedFile);
|
|
195
|
+
const hasPrevious = await fileExists(previousFile);
|
|
196
|
+
const primaryKind = hasMounted ? "mounted-file" : platform !== null ? "platform" : "default-file";
|
|
197
|
+
if (hasMounted) out.push({
|
|
198
|
+
source: fileSource("mounted-file", mountedFile, false),
|
|
177
199
|
primary: true,
|
|
178
|
-
load: () => loadKeyFile(
|
|
200
|
+
load: () => loadKeyFile(mountedFile)
|
|
179
201
|
});
|
|
180
|
-
if (
|
|
181
|
-
source: fileSource("previous-
|
|
202
|
+
if (hasPrevious) out.push({
|
|
203
|
+
source: fileSource("previous-mounted-file", previousFile, false),
|
|
182
204
|
primary: false,
|
|
183
|
-
load: () => loadKeyFile(
|
|
205
|
+
load: () => loadKeyFile(previousFile)
|
|
184
206
|
});
|
|
185
207
|
if (platform !== null) out.push({
|
|
186
208
|
source: {
|
|
@@ -914,7 +936,7 @@ var KeychainService = class {
|
|
|
914
936
|
replace: true,
|
|
915
937
|
nowMs: this.now()
|
|
916
938
|
});
|
|
917
|
-
} else throw new Error(`keychain: the ${primary.source.kind} key is already in use.
|
|
939
|
+
} else throw new Error(`keychain: the ${primary.source.kind} key is already in use. To move to a new external source: put the new key at ${MOUNTED_KEY_FILE_PATH}, the old one at ${PREVIOUS_MOUNTED_KEY_FILE_PATH}, restart, then rotate.`);
|
|
918
940
|
const fingerprint = kekFingerprint(newKek);
|
|
919
941
|
if (constantTimeEquals(fingerprint, unlocked.fingerprint)) throw new Error("keychain: the new master key is the one already in use");
|
|
920
942
|
const wrap = {
|
|
@@ -1033,7 +1055,7 @@ var KeychainService = class {
|
|
|
1033
1055
|
const loaded = await primary.load();
|
|
1034
1056
|
if (loaded.kind === "loaded") return;
|
|
1035
1057
|
const where = primary.source.path ?? primary.source.kind;
|
|
1036
|
-
throw new KeychainResetRefusedError(loaded.kind === "absent" ? `the
|
|
1058
|
+
throw new KeychainResetRefusedError(loaded.kind === "absent" ? `the mounted master key ${where} does not exist — put a new 32-byte key there (or unmount it to use the default file) first` : `the mounted master key ${where} cannot be read (${loaded.error})`);
|
|
1037
1059
|
}
|
|
1038
1060
|
/** What the last reset left to re-enter (see `keychain-admin.resetReport`). */
|
|
1039
1061
|
async resetReport() {
|
|
@@ -1948,14 +1970,6 @@ function callerOf(input) {
|
|
|
1948
1970
|
const raw = Reflect.get(input, "callerAddonId");
|
|
1949
1971
|
return typeof raw === "string" && raw.length > 0 ? raw : null;
|
|
1950
1972
|
}
|
|
1951
|
-
function readKeyConfig(section) {
|
|
1952
|
-
const keyFile = section["keyFile"];
|
|
1953
|
-
const previousKeyFile = section["previousKeyFile"];
|
|
1954
|
-
return {
|
|
1955
|
-
keyFile: typeof keyFile === "string" && keyFile.length > 0 ? keyFile : void 0,
|
|
1956
|
-
previousKeyFile: typeof previousKeyFile === "string" && previousKeyFile.length > 0 ? previousKeyFile : void 0
|
|
1957
|
-
};
|
|
1958
|
-
}
|
|
1959
1973
|
var KeychainAddon = class extends require_dist.BaseAddon {
|
|
1960
1974
|
id = "keychain";
|
|
1961
1975
|
pruneTimer = null;
|
|
@@ -1984,12 +1998,7 @@ var KeychainAddon = class extends require_dist.BaseAddon {
|
|
|
1984
1998
|
if (records !== void 0) await records.declare(keychainRecordKinds);
|
|
1985
1999
|
const service = new KeychainService({
|
|
1986
2000
|
repo: new KeychainRepository(door, records !== void 0 ? KeychainRepository.recordStoresOf(records) : void 0),
|
|
1987
|
-
candidates:
|
|
1988
|
-
return buildKeySourceCandidates({
|
|
1989
|
-
config: readKeyConfig(await ctx.settings?.getSection("keychain") ?? {}),
|
|
1990
|
-
dataDir
|
|
1991
|
-
});
|
|
1992
|
-
},
|
|
2001
|
+
candidates: () => buildKeySourceCandidates({ dataDir }),
|
|
1993
2002
|
dataDir,
|
|
1994
2003
|
events: { emit: (payload) => {
|
|
1995
2004
|
ctx.eventBus.emit({
|
|
@@ -1,7 +1,7 @@
|
|
|
1
|
-
import {
|
|
2
|
-
import { d as JWT_SIGNING_KEY_REF, n as DEVICE_CA_KEY_REF, p as SYSTEM_SECRET_OWNER } from "../../device-ca-
|
|
1
|
+
import { Br as keychainCapability, Cs as normalizeSecretOwner, Es as parseSecretRef, Ws as EventCategory, gt as KeychainResetRecordSchema, ht as KeychainAuditEntrySchema, mt as KEYCHAIN_RESET_TRIGGER_ACTOR, rs as defineRecordKinds, ss as formatSecretScope, uo as BaseAddon, zr as keychainAdminCapability } from "../../dist-9lvgpcnm.mjs";
|
|
2
|
+
import { d as JWT_SIGNING_KEY_REF, n as DEVICE_CA_KEY_REF, p as SYSTEM_SECRET_OWNER } from "../../device-ca-C_y2GrU5.mjs";
|
|
3
3
|
import { t as require_read_all_rows } from "../../read-all-rows-TaPqdWNF.mjs";
|
|
4
|
-
import { a as MESH_CA_KEY_REF } from "../../constants-
|
|
4
|
+
import { a as MESH_CA_KEY_REF } from "../../constants-DTVU00LZ.mjs";
|
|
5
5
|
import { n as getPlatformKeychainKey } from "../../platform-key-source-BWlq0jjn.mjs";
|
|
6
6
|
import { createCipheriv, createDecipheriv, createHmac, randomBytes, randomUUID, timingSafeEqual } from "node:crypto";
|
|
7
7
|
import { restrictDirToOwnerSync, restrictFileToOwnerSync, writeOwnerOnlyFileSync } from "@camstack/types/node";
|
|
@@ -109,24 +109,35 @@ function decryptValue(dek, ref, envelope) {
|
|
|
109
109
|
//#endregion
|
|
110
110
|
//#region src/builtins/keychain/key-sources.ts
|
|
111
111
|
/**
|
|
112
|
-
* Where the master key comes from (D788).
|
|
113
|
-
* carries a key or a key path:
|
|
112
|
+
* Where the master key comes from (D788, amended by D991). FIXED paths only —
|
|
113
|
+
* no config key, NO env var carries a key or a key path:
|
|
114
114
|
*
|
|
115
|
-
* 1. `
|
|
116
|
-
* (
|
|
117
|
-
*
|
|
115
|
+
* 1. `/run/secrets/camstack-master-key` — primary when the file EXISTS at boot
|
|
116
|
+
* (the Docker / Compose secrets convention; Unraid and Proxmox bind-mount a
|
|
117
|
+
* file there). A file outside the data volume: a whole-volume backup then
|
|
118
|
+
* holds the ciphertext but not the key. CamStack only READS it — it is
|
|
119
|
+
* never written and never created.
|
|
118
120
|
* 2. The desktop app's OS keychain (`safeStorage`), handed to the hub over an
|
|
119
|
-
* inherited pipe. Primary on a desktop hub with no key file
|
|
121
|
+
* inherited pipe. Primary on a desktop hub with no mounted key file.
|
|
120
122
|
* 3. `<dataDir>/.keychain/master.key` (0600, directory 0700), generated on
|
|
121
123
|
* first boot. The fallback: it protects CamStack's own backups and stray
|
|
122
124
|
* database copies (it is NOT in `DEFAULT_BACKUP_LOCATIONS`), but a tar of
|
|
123
125
|
* the whole data directory carries key and database together, and the
|
|
124
126
|
* Secrets page says so.
|
|
125
127
|
*
|
|
126
|
-
*
|
|
127
|
-
* key to another is a restart plus `rotateMasterKey`,
|
|
128
|
-
* neither key works.
|
|
128
|
+
* `/run/secrets/camstack-master-key.previous` is consulted only to UNLOCK — so a
|
|
129
|
+
* move from one external key to another is a restart plus `rotateMasterKey`,
|
|
130
|
+
* with no window where neither key works.
|
|
129
131
|
*/
|
|
132
|
+
/** The directory the mounted key files live in (injectable for specs, never an env var). */
|
|
133
|
+
var DEFAULT_SECRETS_DIR = "/run/secrets";
|
|
134
|
+
/** The mounted primary key file, under the secrets directory. */
|
|
135
|
+
var MOUNTED_KEY_FILE_NAME = "camstack-master-key";
|
|
136
|
+
/** The mounted unlock-only key file, under the secrets directory. */
|
|
137
|
+
var PREVIOUS_MOUNTED_KEY_FILE_NAME = "camstack-master-key.previous";
|
|
138
|
+
/** Absolute form of both, for messages. */
|
|
139
|
+
var MOUNTED_KEY_FILE_PATH = `${DEFAULT_SECRETS_DIR}/${MOUNTED_KEY_FILE_NAME}`;
|
|
140
|
+
var PREVIOUS_MOUNTED_KEY_FILE_PATH = `${DEFAULT_SECRETS_DIR}/${PREVIOUS_MOUNTED_KEY_FILE_NAME}`;
|
|
130
141
|
/** The default key file's location under the data root. */
|
|
131
142
|
function defaultKeyFilePath(dataDir) {
|
|
132
143
|
return path$1.join(dataDir, ".keychain", "master.key");
|
|
@@ -158,23 +169,34 @@ function fileSource(kind, file, sharesBackupWithDatabase) {
|
|
|
158
169
|
sharesBackupWithDatabase
|
|
159
170
|
};
|
|
160
171
|
}
|
|
172
|
+
async function fileExists(file) {
|
|
173
|
+
try {
|
|
174
|
+
await promises.access(file);
|
|
175
|
+
return true;
|
|
176
|
+
} catch {
|
|
177
|
+
return false;
|
|
178
|
+
}
|
|
179
|
+
}
|
|
161
180
|
/** Every candidate, primary first. */
|
|
162
|
-
function buildKeySourceCandidates(opts) {
|
|
181
|
+
async function buildKeySourceCandidates(opts) {
|
|
163
182
|
const out = [];
|
|
183
|
+
const secretsDir = opts.secretsDir ?? "/run/secrets";
|
|
184
|
+
const mountedFile = path$1.join(secretsDir, MOUNTED_KEY_FILE_NAME);
|
|
185
|
+
const previousFile = path$1.join(secretsDir, PREVIOUS_MOUNTED_KEY_FILE_NAME);
|
|
164
186
|
const defaultFile = defaultKeyFilePath(opts.dataDir);
|
|
165
187
|
const platform = getPlatformKeychainKey();
|
|
166
|
-
const
|
|
167
|
-
const
|
|
168
|
-
const primaryKind =
|
|
169
|
-
if (
|
|
170
|
-
source: fileSource("
|
|
188
|
+
const hasMounted = await fileExists(mountedFile);
|
|
189
|
+
const hasPrevious = await fileExists(previousFile);
|
|
190
|
+
const primaryKind = hasMounted ? "mounted-file" : platform !== null ? "platform" : "default-file";
|
|
191
|
+
if (hasMounted) out.push({
|
|
192
|
+
source: fileSource("mounted-file", mountedFile, false),
|
|
171
193
|
primary: true,
|
|
172
|
-
load: () => loadKeyFile(
|
|
194
|
+
load: () => loadKeyFile(mountedFile)
|
|
173
195
|
});
|
|
174
|
-
if (
|
|
175
|
-
source: fileSource("previous-
|
|
196
|
+
if (hasPrevious) out.push({
|
|
197
|
+
source: fileSource("previous-mounted-file", previousFile, false),
|
|
176
198
|
primary: false,
|
|
177
|
-
load: () => loadKeyFile(
|
|
199
|
+
load: () => loadKeyFile(previousFile)
|
|
178
200
|
});
|
|
179
201
|
if (platform !== null) out.push({
|
|
180
202
|
source: {
|
|
@@ -908,7 +930,7 @@ var KeychainService = class {
|
|
|
908
930
|
replace: true,
|
|
909
931
|
nowMs: this.now()
|
|
910
932
|
});
|
|
911
|
-
} else throw new Error(`keychain: the ${primary.source.kind} key is already in use.
|
|
933
|
+
} else throw new Error(`keychain: the ${primary.source.kind} key is already in use. To move to a new external source: put the new key at ${MOUNTED_KEY_FILE_PATH}, the old one at ${PREVIOUS_MOUNTED_KEY_FILE_PATH}, restart, then rotate.`);
|
|
912
934
|
const fingerprint = kekFingerprint(newKek);
|
|
913
935
|
if (constantTimeEquals(fingerprint, unlocked.fingerprint)) throw new Error("keychain: the new master key is the one already in use");
|
|
914
936
|
const wrap = {
|
|
@@ -1027,7 +1049,7 @@ var KeychainService = class {
|
|
|
1027
1049
|
const loaded = await primary.load();
|
|
1028
1050
|
if (loaded.kind === "loaded") return;
|
|
1029
1051
|
const where = primary.source.path ?? primary.source.kind;
|
|
1030
|
-
throw new KeychainResetRefusedError(loaded.kind === "absent" ? `the
|
|
1052
|
+
throw new KeychainResetRefusedError(loaded.kind === "absent" ? `the mounted master key ${where} does not exist — put a new 32-byte key there (or unmount it to use the default file) first` : `the mounted master key ${where} cannot be read (${loaded.error})`);
|
|
1031
1053
|
}
|
|
1032
1054
|
/** What the last reset left to re-enter (see `keychain-admin.resetReport`). */
|
|
1033
1055
|
async resetReport() {
|
|
@@ -1942,14 +1964,6 @@ function callerOf(input) {
|
|
|
1942
1964
|
const raw = Reflect.get(input, "callerAddonId");
|
|
1943
1965
|
return typeof raw === "string" && raw.length > 0 ? raw : null;
|
|
1944
1966
|
}
|
|
1945
|
-
function readKeyConfig(section) {
|
|
1946
|
-
const keyFile = section["keyFile"];
|
|
1947
|
-
const previousKeyFile = section["previousKeyFile"];
|
|
1948
|
-
return {
|
|
1949
|
-
keyFile: typeof keyFile === "string" && keyFile.length > 0 ? keyFile : void 0,
|
|
1950
|
-
previousKeyFile: typeof previousKeyFile === "string" && previousKeyFile.length > 0 ? previousKeyFile : void 0
|
|
1951
|
-
};
|
|
1952
|
-
}
|
|
1953
1967
|
var KeychainAddon = class extends BaseAddon {
|
|
1954
1968
|
id = "keychain";
|
|
1955
1969
|
pruneTimer = null;
|
|
@@ -1978,12 +1992,7 @@ var KeychainAddon = class extends BaseAddon {
|
|
|
1978
1992
|
if (records !== void 0) await records.declare(keychainRecordKinds);
|
|
1979
1993
|
const service = new KeychainService({
|
|
1980
1994
|
repo: new KeychainRepository(door, records !== void 0 ? KeychainRepository.recordStoresOf(records) : void 0),
|
|
1981
|
-
candidates:
|
|
1982
|
-
return buildKeySourceCandidates({
|
|
1983
|
-
config: readKeyConfig(await ctx.settings?.getSection("keychain") ?? {}),
|
|
1984
|
-
dataDir
|
|
1985
|
-
});
|
|
1986
|
-
},
|
|
1995
|
+
candidates: () => buildKeySourceCandidates({ dataDir }),
|
|
1987
1996
|
dataDir,
|
|
1988
1997
|
events: { emit: (payload) => {
|
|
1989
1998
|
ctx.eventBus.emit({
|
|
@@ -1,9 +1,13 @@
|
|
|
1
1
|
import type { KeychainKeySource } from "@camstack/types";
|
|
2
|
-
/** The
|
|
3
|
-
export
|
|
4
|
-
|
|
5
|
-
|
|
6
|
-
|
|
2
|
+
/** The directory the mounted key files live in (injectable for specs, never an env var). */
|
|
3
|
+
export declare const DEFAULT_SECRETS_DIR = "/run/secrets";
|
|
4
|
+
/** The mounted primary key file, under the secrets directory. */
|
|
5
|
+
export declare const MOUNTED_KEY_FILE_NAME = "camstack-master-key";
|
|
6
|
+
/** The mounted unlock-only key file, under the secrets directory. */
|
|
7
|
+
export declare const PREVIOUS_MOUNTED_KEY_FILE_NAME = "camstack-master-key.previous";
|
|
8
|
+
/** Absolute form of both, for messages. */
|
|
9
|
+
export declare const MOUNTED_KEY_FILE_PATH: string;
|
|
10
|
+
export declare const PREVIOUS_MOUNTED_KEY_FILE_PATH: string;
|
|
7
11
|
export type KeyLoadResult = {
|
|
8
12
|
readonly kind: "loaded";
|
|
9
13
|
readonly key: Buffer;
|
|
@@ -21,11 +25,12 @@ export interface KeySourceCandidate {
|
|
|
21
25
|
/** The default key file's location under the data root. */
|
|
22
26
|
export declare function defaultKeyFilePath(dataDir: string): string;
|
|
23
27
|
export interface KeySourceOptions {
|
|
24
|
-
readonly config: KeychainKeyConfig;
|
|
25
28
|
readonly dataDir: string;
|
|
29
|
+
/** Where the mounted key files live. Defaults to {@link DEFAULT_SECRETS_DIR}. */
|
|
30
|
+
readonly secretsDir?: string | undefined;
|
|
26
31
|
}
|
|
27
32
|
/** Every candidate, primary first. */
|
|
28
|
-
export declare function buildKeySourceCandidates(opts: KeySourceOptions): readonly KeySourceCandidate[]
|
|
33
|
+
export declare function buildKeySourceCandidates(opts: KeySourceOptions): Promise<readonly KeySourceCandidate[]>;
|
|
29
34
|
/**
|
|
30
35
|
* Write a master key to the default location: directory 0700, file 0600,
|
|
31
36
|
* atomically (temp + rename), never over an existing file unless `replace`.
|
|
@@ -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-B3S0ruBa.js");
|
|
4
4
|
let node_fs_promises = require("node:fs/promises");
|
|
5
5
|
node_fs_promises = require_chunk.__toESM(node_fs_promises);
|
|
6
6
|
let node_path = require("node:path");
|
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import {
|
|
1
|
+
import { $r as mayWriteToLocation, Nt as RecordingStatusSchema, Us as errMsg, Ws as EventCategory, es as createEvent, jt as RECORDING_SOURCE_CAMSTACK_ADDON, uo as BaseAddon } from "../../dist-9lvgpcnm.mjs";
|
|
2
2
|
import * as fsp from "node:fs/promises";
|
|
3
3
|
import path from "node:path";
|
|
4
4
|
import { constants } from "node:fs";
|
|
@@ -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-B3S0ruBa.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-DaTT1Y9v.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");
|
|
@@ -8894,7 +8894,7 @@ var JwtSigningKeyKeeper = class {
|
|
|
8894
8894
|
}
|
|
8895
8895
|
if (previous.state === "ready") return;
|
|
8896
8896
|
require_device_ca.setProcessJwtSigningKey(next);
|
|
8897
|
-
this.deps.logger.error("Sessions are UNAVAILABLE: the session signing key cannot be read from the keychain. No one can sign in and no session token verifies until the keychain unlocks (Data → Secrets; or fix
|
|
8897
|
+
this.deps.logger.error("Sessions are UNAVAILABLE: the session signing key cannot be read from the keychain. No one can sign in and no session token verifies until the keychain unlocks (Data → Secrets; or fix the mounted key at /run/secrets/camstack-master-key and restart). No fallback key is used.", { meta: {
|
|
8898
8898
|
reason: next.reason,
|
|
8899
8899
|
ref: require_device_ca.JWT_SIGNING_KEY_REF
|
|
8900
8900
|
} });
|