@camstack/server 1.2.928 → 1.2.929
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 +6 -0
- package/package.json +10 -8
- package/system/dist/addon-id-CVg1_r5E.mjs +39 -0
- package/system/dist/addon-id-Di0lNJ89.js +50 -0
- package/system/dist/addon-pages.cap-Df9FQwN1.js +49 -0
- package/system/dist/addon-pages.cap-DksUlE8j.mjs +44 -0
- package/system/dist/addon-settings.cap-3-TIIMq_.mjs +592 -0
- package/system/dist/addon-settings.cap-DAiE0Nb0.js +651 -0
- package/system/dist/addon-utils.mjs +1 -1
- package/system/dist/addon-widgets.cap-C4jxflbF.js +200 -0
- package/system/dist/addon-widgets.cap-D9m48X78.mjs +183 -0
- package/system/dist/base-addon-DD5dIfcZ.js +4624 -0
- package/system/dist/base-addon-Md14i7pe.mjs +4505 -0
- package/system/dist/base-device-2sL1DMm1.js +1103 -0
- package/system/dist/base-device-IuM1AwXZ.mjs +1098 -0
- package/system/dist/builtins/addon-pages-aggregator/addon-pages-aggregator.addon.js +8 -6
- package/system/dist/builtins/addon-pages-aggregator/addon-pages-aggregator.addon.mjs +6 -4
- package/system/dist/builtins/addon-widgets-aggregator/addon-widgets-aggregator.addon.js +8 -6
- package/system/dist/builtins/addon-widgets-aggregator/addon-widgets-aggregator.addon.mjs +7 -5
- package/system/dist/builtins/alerts/alerts.addon.js +113 -56
- package/system/dist/builtins/alerts/alerts.addon.mjs +60 -3
- package/system/dist/builtins/autotrack/index.js +21 -17
- package/system/dist/builtins/autotrack/index.mjs +5 -1
- package/system/dist/builtins/backup-orchestrator/backup-orchestrator.addon.js +14 -11
- package/system/dist/builtins/backup-orchestrator/backup-orchestrator.addon.mjs +8 -5
- package/system/dist/builtins/calendars/calendars.addon.js +8 -6
- package/system/dist/builtins/calendars/calendars.addon.mjs +3 -1
- package/system/dist/builtins/camera-grid/index.js +615 -58
- package/system/dist/builtins/camera-grid/index.mjs +558 -1
- package/system/dist/builtins/composer/composer.addon.js +788 -209
- package/system/dist/builtins/composer/composer.addon.mjs +583 -4
- package/system/dist/builtins/console-logging/index.js +4 -3
- package/system/dist/builtins/console-logging/index.mjs +2 -1
- package/system/dist/builtins/core-blocks/core-blocks.addon.js +7887 -381
- package/system/dist/builtins/core-blocks/core-blocks.addon.mjs +7511 -5
- package/system/dist/builtins/core-notifier/core-notifier.addon.js +731 -21
- package/system/dist/builtins/core-notifier/core-notifier.addon.mjs +711 -1
- package/system/dist/builtins/device-history/device-history.addon.js +110 -31
- package/system/dist/builtins/device-history/device-history.addon.mjs +81 -2
- package/system/dist/builtins/device-manager/device-manager.addon.js +12806 -227
- package/system/dist/builtins/device-manager/device-manager.addon.mjs +12583 -5
- package/system/dist/builtins/hub-forwarder/index.js +4 -3
- package/system/dist/builtins/hub-forwarder/index.mjs +2 -1
- package/system/dist/builtins/keychain/index.js +31 -28
- package/system/dist/builtins/keychain/index.mjs +7 -4
- package/system/dist/builtins/liveness-monitor/liveness-monitor.addon.js +15 -12
- package/system/dist/builtins/liveness-monitor/liveness-monitor.addon.mjs +4 -1
- package/system/dist/builtins/local-auth/local-auth.addon.js +140 -39
- package/system/dist/builtins/local-auth/local-auth.addon.mjs +106 -6
- package/system/dist/builtins/local-network/local-network.addon.js +43 -39
- package/system/dist/builtins/local-network/local-network.addon.mjs +7 -3
- package/system/dist/builtins/loki-logging/index.js +23 -17
- package/system/dist/builtins/loki-logging/index.mjs +7 -1
- package/system/dist/builtins/native-metrics/native-metrics.addon.js +156 -15
- package/system/dist/builtins/native-metrics/native-metrics.addon.mjs +151 -10
- package/system/dist/builtins/platform-probe/index.js +25 -23
- package/system/dist/builtins/platform-probe/index.mjs +12 -10
- package/system/dist/builtins/record-entries/index.js +9 -7
- package/system/dist/builtins/record-entries/index.mjs +3 -1
- package/system/dist/builtins/remote-access-orchestrator/remote-access-orchestrator.addon.js +4 -4
- package/system/dist/builtins/remote-access-orchestrator/remote-access-orchestrator.addon.mjs +1 -1
- package/system/dist/builtins/snapshot/index.js +97 -44
- package/system/dist/builtins/snapshot/index.mjs +54 -1
- package/system/dist/builtins/sqlite-storage/filesystem-storage.addon.js +5 -4
- package/system/dist/builtins/sqlite-storage/filesystem-storage.addon.mjs +21 -20
- 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 +87 -61
- package/system/dist/builtins/sqlite-storage/sqlite-settings.addon.mjs +29 -3
- package/system/dist/builtins/storage-orchestrator/storage-orchestrator.addon.js +81 -72
- package/system/dist/builtins/storage-orchestrator/storage-orchestrator.addon.mjs +10 -1
- package/system/dist/builtins/system-config/system-config.addon.js +17 -14
- package/system/dist/builtins/system-config/system-config.addon.mjs +118 -115
- package/system/dist/builtins/winston-logging/index.js +7 -5
- package/system/dist/builtins/winston-logging/index.mjs +3 -1
- package/system/dist/calendars.cap-CaFlShS9.js +155 -0
- package/system/dist/calendars.cap-_C4eD4fi.mjs +138 -0
- package/system/dist/camstack-error-DJ-TUAi1.js +23 -0
- package/system/dist/camstack-error-viZYfcj9.mjs +18 -0
- package/system/dist/cap-call-context-Bd76CbOW.js +95 -0
- package/system/dist/cap-call-context-DNwdgGSQ.mjs +78 -0
- package/system/dist/capability-definition-C2rJdVeX.mjs +177 -0
- package/system/dist/capability-definition-HCmTem8c.js +242 -0
- package/system/dist/{capture-engine-BcuwOSXv.js → capture-engine-DZ0LIUqA.js} +5 -4
- package/system/dist/{capture-engine-Bz7eXFjT.mjs → capture-engine-DiwbjoWp.mjs} +2 -1
- package/system/dist/command-origin-claim-Cief660O.js +35 -0
- package/system/dist/command-origin-claim-D1Wy7Qld.mjs +24 -0
- package/system/dist/composition-sources-Caqv7O7z.mjs +391 -0
- package/system/dist/composition-sources-CgnHjm8Q.js +408 -0
- package/system/dist/{constants-D2etJ02O.js → constants-Ba3FTIHl.js} +1 -1
- package/system/dist/constants-C860Y6U4.js +26 -0
- package/system/dist/{constants-BcUTQd1M.mjs → constants-DB4piTD5.mjs} +1 -1
- package/system/dist/constants-DCLpoF4L.mjs +21 -0
- package/system/dist/coral-accelerators-7o8hqvcN.js +564 -0
- package/system/dist/coral-accelerators-BKcXP59c.mjs +521 -0
- package/system/dist/core-blocks.cap-C6iKAZ-x.mjs +17986 -0
- package/system/dist/core-blocks.cap-LEMqVwxO.js +18705 -0
- package/system/dist/{custom-action-registry-N7flBDwT.mjs → custom-action-registry-B9zFBNVa.mjs} +37 -37
- package/system/dist/custom-actions-BFUSalC9.mjs +25 -0
- package/system/dist/custom-actions-D92NRi2c.js +36 -0
- package/system/dist/database-snapshot.cap-DF38e-0P.js +162 -0
- package/system/dist/database-snapshot.cap-dhrc9xnY.mjs +133 -0
- package/system/dist/declared-device-BWphj9WE.js +303 -0
- package/system/dist/declared-device-CKERA1Hi.mjs +286 -0
- package/system/dist/{device-ca-ExMN3xW3.mjs → device-ca-BLM6fccc.mjs} +2 -1
- package/system/dist/{device-ca-CU8zh9Pi.js → device-ca-C5kJE6mL.js} +7 -6
- package/system/dist/device-certificate-Cddm4Idn.mjs +91 -0
- package/system/dist/device-certificate-CguVACQO.js +162 -0
- package/system/dist/device-identifiers-BQg9EQi1.js +600 -0
- package/system/dist/device-identifiers-iSuQCKmK.mjs +529 -0
- package/system/dist/device-kind-BJ2pfsjw.mjs +78 -0
- package/system/dist/device-kind-CsSiv_YF.js +101 -0
- package/system/dist/device-manager.cap-2abwVLCM.js +2874 -0
- package/system/dist/device-manager.cap-CFZSPfUh.mjs +2749 -0
- package/system/dist/device-provider.cap-3Uvk6f5-.mjs +331 -0
- package/system/dist/device-provider.cap-D7TV2kVH.js +366 -0
- package/system/dist/{device-row-store-CeW_GWh9.mjs → device-row-store-YF3jtmkk.mjs} +4 -1
- package/system/dist/{device-row-store-BMIR-n3m.js → device-row-store-doTfMOqn.js} +12 -9
- package/system/dist/device-transitions.cap-B5w5PYU_.js +860 -0
- package/system/dist/device-transitions.cap-DojcwEuX.mjs +819 -0
- package/system/dist/device-type-CbQsnFdC.js +477 -0
- package/system/dist/device-type-DgEvK3ch.mjs +454 -0
- package/system/dist/entry-kind-D9MuVJCK.mjs +44 -0
- package/system/dist/entry-kind-cq90c--V.js +55 -0
- package/system/dist/error.cap-CSM_SRfR.mjs +3423 -0
- package/system/dist/error.cap-DBhgPeWK.js +3848 -0
- package/system/dist/file-host-worker.js +1 -1
- package/system/dist/file-host-worker.mjs +1 -1
- package/system/dist/history-catalog-BKRarIL_.js +831 -0
- package/system/dist/history-catalog-BwTeQ4Mr.mjs +802 -0
- package/system/dist/{hub-identity-Csxx2Q8k.js → hub-identity-BMdR3Mw9.js} +2 -2
- package/system/dist/{hub-identity-CYC1820R.mjs → hub-identity-DjMN9Ac2.mjs} +10 -10
- package/system/dist/{hub-mdns-ciao-By5577HM.js → hub-mdns-ciao--0v1TKME.js} +5 -5
- package/system/dist/{hub-mdns-ciao-CCDxM5qz.mjs → hub-mdns-ciao-DBrtHOcc.mjs} +2 -2
- package/system/dist/index.js +763 -151
- package/system/dist/index.mjs +832 -220
- package/system/dist/integration-instances.cap-Cl9O-k4h.mjs +538 -0
- package/system/dist/integration-instances.cap-dJIxg2_s.js +549 -0
- package/system/dist/keychain-admin.cap-Db_oFX4H.js +425 -0
- package/system/dist/keychain-admin.cap-GtM7gVGG.mjs +396 -0
- package/system/dist/l10n-Bu6aUvSY.mjs +10 -0
- package/system/dist/l10n-CGMvp7NF.js +15 -0
- package/system/dist/labels-DX5S8deC.js +81 -0
- package/system/dist/labels-DsBcU7md.mjs +64 -0
- package/system/dist/{legacy-integration-rows-door-CVwOo5aq.js → legacy-integration-rows-door-B1nzxxr5.js} +2 -2
- package/system/dist/{legacy-integration-rows-door-D9tQOUzh.mjs → legacy-integration-rows-door-nTvo_6jQ.mjs} +1 -1
- package/system/dist/log-destination.cap-CxZzAVaR.mjs +143 -0
- package/system/dist/log-destination.cap-DELPJkZ0.js +148 -0
- package/system/dist/low-power-sleep.cap-7lfVU41N.js +103 -0
- package/system/dist/low-power-sleep.cap-tGPmaZ_V.mjs +92 -0
- package/system/dist/mask-shape-Ci8Co9w0.mjs +57 -0
- package/system/dist/mask-shape-CmPA2fst.js +92 -0
- package/system/dist/metrics-provider.cap-BNmcHDkQ.mjs +405 -0
- package/system/dist/metrics-provider.cap-BcmQUt6l.js +410 -0
- package/system/dist/migration-BMjgkyG2.js +380 -0
- package/system/dist/migration-DRJAtdy7.mjs +321 -0
- package/system/dist/network-access.cap-B5TWLDCC.js +1099 -0
- package/system/dist/network-access.cap-BJnGbE6n.mjs +1004 -0
- package/system/dist/notification-rules.cap-B__YBgnG.js +3422 -0
- package/system/dist/notification-rules.cap-D9ArZlwx.mjs +3357 -0
- package/system/dist/ops-log-CB4pIdqi.mjs +64 -0
- package/system/dist/ops-log-pxt9176Z.js +81 -0
- package/system/dist/pinned-binary-BOhOSNff.js +28 -0
- package/system/dist/pinned-binary-CrIRAi4G.mjs +23 -0
- package/system/dist/platform-probe.cap-1WrMhWHx.js +250 -0
- package/system/dist/platform-probe.cap-BFeqFLtQ.mjs +233 -0
- package/system/dist/prefix-walk-B4b2-9aK.mjs +790 -0
- package/system/dist/prefix-walk-DC0ljmbB.js +843 -0
- package/system/dist/ptz-autotrack.cap-BW7w0zHD.js +229 -0
- package/system/dist/ptz-autotrack.cap-DT2GypXw.mjs +224 -0
- package/system/dist/quantity-D3g5SxsZ.mjs +114 -0
- package/system/dist/quantity-lY1KiTSZ.js +143 -0
- package/system/dist/raw-secret-migration-DxuBFtvi.js +50 -0
- package/system/dist/raw-secret-migration-iv88mLoc.mjs +39 -0
- package/system/dist/record-entries.cap-sMUhTvTU.mjs +75 -0
- package/system/dist/record-entries.cap-ti1C046R.js +80 -0
- package/system/dist/record-kind-DoBfYHCs.js +203 -0
- package/system/dist/record-kind-ub6NXqfh.mjs +162 -0
- package/system/dist/recording-archive.cap-7OrIn9e5.mjs +1299 -0
- package/system/dist/recording-archive.cap-D7bo-QSM.js +1328 -0
- package/system/dist/records.cap-ClcWV64i.js +329 -0
- package/system/dist/records.cap-CwLT2ByG.mjs +294 -0
- package/system/dist/relocate-CdVQAk-w.js +804 -0
- package/system/dist/relocate-CoZZTui1.mjs +661 -0
- package/system/dist/rename-composition-block-7WIICIDq.mjs +33525 -0
- package/system/dist/rename-composition-block-CcWLwVhG.js +34692 -0
- package/system/dist/{restore-archive-BJfyu0sG.mjs → restore-archive-CjAyKpgX.mjs} +96 -94
- package/system/dist/{restore-archive-CIFvqOze.js → restore-archive-CkTkv3Ss.js} +6 -4
- package/system/dist/scoped-settings-CylSSq_8.js +955 -0
- package/system/dist/scoped-settings-DVWUIP7Z.mjs +650 -0
- package/system/dist/server-name-BIhLuHvX.mjs +35 -0
- package/system/dist/server-name-OALNvpqC.js +52 -0
- package/system/dist/settings-store.cap-Ci4F2zul.mjs +569 -0
- package/system/dist/settings-store.cap-wlJhCspr.js +640 -0
- package/system/dist/snapshot.cap-3suPdBHV.js +250 -0
- package/system/dist/snapshot.cap-Bs8Oyaqh.mjs +245 -0
- package/system/dist/source-info-DGB7SdB_.mjs +190 -0
- package/system/dist/source-info-DtWf4k2j.js +225 -0
- package/system/dist/storage-admin.cap-BSv1NjKJ.mjs +883 -0
- package/system/dist/storage-admin.cap-he0OqvVM.js +906 -0
- package/system/dist/storage-location-CBT8GCD6.mjs +163 -0
- package/system/dist/storage-location-CTweDMZf.js +198 -0
- package/system/dist/storage-location-mode-B21UVRRX.mjs +167 -0
- package/system/dist/storage-location-mode-CS4sMzo-.js +232 -0
- package/system/dist/storage-migration.cap-CyyATY_p.js +330 -0
- package/system/dist/storage-migration.cap-D7QqGobp.mjs +313 -0
- package/system/dist/storage-occupancy.cap-2rmnS58Z.js +622 -0
- package/system/dist/storage-occupancy.cap-CqBztTl9.mjs +611 -0
- package/system/dist/storage-provider.cap-Bw0CfxVc.js +213 -0
- package/system/dist/storage-provider.cap-CMeck2w4.mjs +202 -0
- package/system/dist/stream-catalog.cap-Bp7SkgIf.mjs +6560 -0
- package/system/dist/stream-catalog.cap-D3uwePiA.js +6763 -0
- package/system/dist/streaming-shared-B8cXatuU.mjs +431 -0
- package/system/dist/streaming-shared-DQwFZOSi.js +526 -0
- package/system/dist/system-reasons-Be_k1W8g.js +25 -0
- package/system/dist/system-reasons-CYj4qwyS.mjs +20 -0
- package/system/dist/tag-BxLazvVb.js +2138 -0
- package/system/dist/tag-uZBAq6ox.mjs +2073 -0
- package/system/dist/user-management.cap-B9QDu8NE.js +825 -0
- package/system/dist/user-management.cap-DBIi77sB.mjs +766 -0
- package/system/dist/vector-store.cap-DnyfrYDn.js +330 -0
- package/system/dist/vector-store.cap-h2GHWQ1t.mjs +319 -0
- package/system/dist/{wal-maintenance-CTrCPzds.mjs → wal-maintenance-BG01rOn9.mjs} +0 -0
- package/system/dist/{wal-maintenance-dq7T3quB.js → wal-maintenance-DyrebYKF.js} +0 -0
- package/system/dist/zod-secret-DS7mj1bk.js +78 -0
- package/system/dist/zod-secret-zY4nM61M.mjs +73 -0
- package/system/package.json +1 -1
- package/system/dist/composition-sources-BI614LJx.mjs +0 -141
- package/system/dist/composition-sources-v_kkb8A9.js +0 -152
- package/system/dist/coral-accelerators-BSVsBVzt.js +0 -250
- package/system/dist/coral-accelerators-BW3OcrLD.mjs +0 -231
- package/system/dist/dist-BCHMSqzc.mjs +0 -143467
- package/system/dist/dist-BZfvhfS1.js +0 -146970
- package/system/dist/prefix-walk-DAOBSyH1.mjs +0 -88
- package/system/dist/prefix-walk-Dv6MLZlM.js +0 -99
- package/system/dist/rename-composition-block-C9HuBrKS.js +0 -112
- package/system/dist/rename-composition-block-DtaYmYAR.mjs +0 -101
|
@@ -0,0 +1,600 @@
|
|
|
1
|
+
let zod = require("zod");
|
|
2
|
+
//#region ../types/dist/esm/interfaces/camera-switches.mjs
|
|
3
|
+
/**
|
|
4
|
+
* Per-camera FUNCTION SWITCHES.
|
|
5
|
+
*
|
|
6
|
+
* ## The aggregate group is being withdrawn — the BADGE is not (D113)
|
|
7
|
+
*
|
|
8
|
+
* This file shipped as "the one coherent on/off surface over the pipeline
|
|
9
|
+
* functions an operator thinks in terms of". The operator's verdict on
|
|
10
|
+
* 2026-08-12 was that the coherent surface bought complexity and no clarity:
|
|
11
|
+
* every function already had a settings page of its own, and a second place to
|
|
12
|
+
* turn it off is a second place to look. Each switch is going back to its own
|
|
13
|
+
* component's original options — detection to the detection-pipeline wrapper
|
|
14
|
+
* binding, audio analysis to its own, recording to `RecordingConfig.enabled`
|
|
15
|
+
* (which was always first-class; the switch was a veneer over
|
|
16
|
+
* `recordingArchive.setDeviceConfig`), notifications to a notification-center
|
|
17
|
+
* per-device setting, the two camera planes to their own components.
|
|
18
|
+
*
|
|
19
|
+
* What survives is {@link composeSwitchedOff}: `CameraStatus.switchedOff`, the
|
|
20
|
+
* thing that lets a status surface say DISABLED instead of BROKEN, recomposed
|
|
21
|
+
* straight from the authorities with no group in the middle. That rule was
|
|
22
|
+
* never about a control panel.
|
|
23
|
+
*
|
|
24
|
+
* Everything else here — {@link CAMERA_SWITCH_CATALOG}, {@link CameraSwitch},
|
|
25
|
+
* {@link deriveCameraSwitches}, the `pipelineOrchestrator.getCameraSwitches` /
|
|
26
|
+
* `setCameraSwitch` pair — is a COMPATIBILITY surface for as long as deployed
|
|
27
|
+
* viewers (v1.0.305) and the admin UI still call it. It is deleted when they
|
|
28
|
+
* stop; nothing new may be built on it.
|
|
29
|
+
*
|
|
30
|
+
* ## This file adds no state
|
|
31
|
+
*
|
|
32
|
+
* Every switch here is a VIEW onto an authority that already existed
|
|
33
|
+
* ([D62](../../../../docs/decisions/adr-0062.md)). The whole point of the
|
|
34
|
+
* group is that there is exactly one place each function is turned off, and
|
|
35
|
+
* the group routes to it:
|
|
36
|
+
*
|
|
37
|
+
* | Switch | Authority | Proven "off stops the work" gate |
|
|
38
|
+
* | --- | --- | --- |
|
|
39
|
+
* | `stream-broker` | `deviceManager.setDisabled` | `StreamBrokerManager.reconcileAllCatalogs` releases the brokers; `ensureBroker` refuses re-creation |
|
|
40
|
+
* | `object-detection` | `deviceManager.setWrapperActive('detection-pipeline')` | `PipelineSettingsStore.resolvePipelineForDevice` returns `{ steps: [], audio: null }` |
|
|
41
|
+
* | `audio-analysis` | `deviceManager.setWrapperActive('audio-analysis')` | `AudioSubscriptionController.subscribeAudioStream` returns `null` before opening the stream |
|
|
42
|
+
* | `recording` | `recordingArchive.setDeviceConfig` → `RecordingConfig.enabled` | `band-decision.shouldRecord` returns false; the controller detaches the device |
|
|
43
|
+
* | `notifications` | `notificationRules.setDeviceMuted` | `NotificationCenter.evaluateAndEnqueue` returns before any rule is evaluated |
|
|
44
|
+
* | `privacy-mask` | `privacyMask.setMask({ enabled })` → the CAMERA | the camera blanks the masked regions itself; every stream and recording carries the black boxes |
|
|
45
|
+
* | `device-audio` | `privacyMask.setAudioEnabled` → the CAMERA | the camera stops encoding an audio track at all; every consumer sees silent video |
|
|
46
|
+
* | `broker-audio` | `streamBroker.setDeviceAudioMute` → `DeviceOverride.audioMuted` | `StreamBroker.setAudioMuted` drops the audio plane at the source: no `type:'audio'` packet leaves `fanOutEncoded`, no RTP reaches the restreamer, and the restreamer serves the video-only SDP |
|
|
47
|
+
*
|
|
48
|
+
* ## `device-audio` and `broker-audio` are two functions, not two knobs
|
|
49
|
+
*
|
|
50
|
+
* They look adjacent and they are not the same control ([D83](../../../../docs/decisions/adr-0083.md)):
|
|
51
|
+
* `device-audio` writes the CAMERA, so it is hardware privacy — the microphone
|
|
52
|
+
* genuinely stops, it survives CamStack entirely, and it costs a multi-second
|
|
53
|
+
* encoder restart on every flip. `broker-audio` writes THIS server, so it is
|
|
54
|
+
* instant, vendor-independent and reversible without touching the camera, and
|
|
55
|
+
* a camera that ignores or lacks the ISAPI/Reolink control is still silenced.
|
|
56
|
+
* D62 forbids a second switch that *disagrees* with the first; these two
|
|
57
|
+
* cannot disagree, because neither reads the other's store — the camera holds
|
|
58
|
+
* one, the broker holds the other, and each reports its own fact.
|
|
59
|
+
*
|
|
60
|
+
* ## The two switches whose authority is not on this server
|
|
61
|
+
*
|
|
62
|
+
* `privacy-mask` and `device-audio` write the CAMERA. That is not a loophole
|
|
63
|
+
* in "the group stores nothing" — it is the purest form of it: the camera
|
|
64
|
+
* holds the fact, every read is a read-through, and there is no server-side
|
|
65
|
+
* copy that could drift. Their availability therefore cannot come from
|
|
66
|
+
* `listBindableCapsForDeviceType` (a device-NATIVE cap carries no wrappers and
|
|
67
|
+
* is filtered out there); it comes from the cap's own camera-probed
|
|
68
|
+
* `privacyMask.getOptions()`, which is strictly more honest — it answers for
|
|
69
|
+
* THIS camera rather than for the device type
|
|
70
|
+
* ([D74](../../../../docs/decisions/adr-0074.md)).
|
|
71
|
+
*
|
|
72
|
+
* ## `privacy-mask` is the one row whose ON is not "the function is working"
|
|
73
|
+
*
|
|
74
|
+
* Every other switch means *this camera's function is doing its job*, so
|
|
75
|
+
* `enabled: false` is a thing an operator took away. `privacy-mask` means **the
|
|
76
|
+
* MASK is active** — `enabled: true` is video deliberately obscured. The
|
|
77
|
+
* polarity is not a choice made here: `addon-export-hap`'s privacy `Switch`
|
|
78
|
+
* (`builders/privacy-switch.ts`) already mirrors `patch.enabled` verbatim, and
|
|
79
|
+
* a HomeKit toggle that disagreed with the app's toggle for the same camera is
|
|
80
|
+
* worse than either surface not having one.
|
|
81
|
+
*
|
|
82
|
+
* Two consequences follow and both are load-bearing:
|
|
83
|
+
*
|
|
84
|
+
* - **It never counts as `switchedOff`.** `countsAsSwitchedOff` is `false` for
|
|
85
|
+
* exactly this row. With the polarity above, every camera that has NOT drawn
|
|
86
|
+
* a privacy mask would otherwise report `switchedOff: ['privacy-mask']` — the
|
|
87
|
+
* normal, healthy state of most cameras rendered as an operator disablement.
|
|
88
|
+
* - **Its cost line names BOTH directions.** `costWhenOff` is rendered
|
|
89
|
+
* unconditionally by both clients, so for this row it has to read correctly
|
|
90
|
+
* whichever way the switch is sitting.
|
|
91
|
+
*
|
|
92
|
+
* The wrapper-binding pair is not a new idea: `legacy-migrations.ts` already
|
|
93
|
+
* migrated the legacy `audioEnabled` / `pipelineEnabled` /
|
|
94
|
+
* `motionDetectionEnabled` booleans ONTO `setWrapperActive`. The group is the
|
|
95
|
+
* surface that decision never got.
|
|
96
|
+
*
|
|
97
|
+
* ## Two rules that are load-bearing
|
|
98
|
+
*
|
|
99
|
+
* - **Recording's switch is `enabled`, never the bands.** `bands` is the only
|
|
100
|
+
* authored intent and `mode` is derived from it (`deriveRecordingMode`).
|
|
101
|
+
* Expressing "off" by clearing bands destroys the operator's schedule and
|
|
102
|
+
* turning the camera back on would then silently record nothing.
|
|
103
|
+
* - **A switch that is off must be reported as off**, not merely produce
|
|
104
|
+
* nothing. {@link CameraSwitch.enabled} is what a status surface renders as
|
|
105
|
+
* "disabled by an operator" instead of "broken" — see
|
|
106
|
+
* `CameraStatus.switchedOff`.
|
|
107
|
+
*/
|
|
108
|
+
/**
|
|
109
|
+
* The functions the operator named — five on 2026-08-05, plus the camera's own
|
|
110
|
+
* microphone on 2026-08-07. Deliberately NOT one id per pipeline step: face
|
|
111
|
+
* recognition and plate/LPR are per-step toggles on
|
|
112
|
+
* `pipelineOrchestrator.setCameraStepToggle` and belong in the pipeline
|
|
113
|
+
* editor, not in a safety group.
|
|
114
|
+
*/
|
|
115
|
+
var CameraSwitchIdSchema = /* @__PURE__ */ zod.z.enum([
|
|
116
|
+
"stream-broker",
|
|
117
|
+
"object-detection",
|
|
118
|
+
"privacy-mask",
|
|
119
|
+
"device-audio",
|
|
120
|
+
"broker-audio",
|
|
121
|
+
"audio-analysis",
|
|
122
|
+
"event-saving",
|
|
123
|
+
"recording",
|
|
124
|
+
"notifications"
|
|
125
|
+
]);
|
|
126
|
+
/**
|
|
127
|
+
* Stable render order — broadest blast radius first, and a source before the
|
|
128
|
+
* thing that consumes it. `device-audio` sits ABOVE `audio-analysis` because
|
|
129
|
+
* turning the microphone off leaves the analyzer with nothing to analyse; the
|
|
130
|
+
* reverse is not true.
|
|
131
|
+
*
|
|
132
|
+
* `privacy-mask` sits directly ABOVE `device-audio` because they are literal
|
|
133
|
+
* siblings — one cap, one device plane, video then audio — and NOT above
|
|
134
|
+
* `object-detection` despite feeding it: a mask blanks REGIONS, so its blast
|
|
135
|
+
* radius is partial, and the "broadest first" rule does not rank a partial
|
|
136
|
+
* control above a whole-function one.
|
|
137
|
+
*
|
|
138
|
+
* `broker-audio` sits directly BELOW `device-audio` by the same source-first
|
|
139
|
+
* rule: the camera's microphone feeds the broker, so silencing the camera
|
|
140
|
+
* leaves the broker's mute with nothing to suppress; the reverse is not true.
|
|
141
|
+
*/
|
|
142
|
+
var CAMERA_SWITCH_ORDER = [
|
|
143
|
+
"stream-broker",
|
|
144
|
+
"object-detection",
|
|
145
|
+
"privacy-mask",
|
|
146
|
+
"device-audio",
|
|
147
|
+
"broker-audio",
|
|
148
|
+
"audio-analysis",
|
|
149
|
+
"event-saving",
|
|
150
|
+
"recording",
|
|
151
|
+
"notifications"
|
|
152
|
+
];
|
|
153
|
+
/**
|
|
154
|
+
* WHERE the switch's state actually lives. A discriminated union rather than a
|
|
155
|
+
* string so both the writer (the orchestrator's `setCameraSwitch`) and any
|
|
156
|
+
* reader can exhaustively narrow — and so "the group added a parallel map" is
|
|
157
|
+
* a compile error rather than a review comment.
|
|
158
|
+
*/
|
|
159
|
+
var CameraSwitchAuthoritySchema = /* @__PURE__ */ zod.z.discriminatedUnion("kind", [
|
|
160
|
+
/* @__PURE__ */ zod.z.object({ kind: /* @__PURE__ */ zod.z.literal("device-disabled") }),
|
|
161
|
+
/* @__PURE__ */ zod.z.object({
|
|
162
|
+
kind: /* @__PURE__ */ zod.z.literal("wrapper-binding"),
|
|
163
|
+
capName: /* @__PURE__ */ zod.z.string()
|
|
164
|
+
}),
|
|
165
|
+
/* @__PURE__ */ zod.z.object({ kind: /* @__PURE__ */ zod.z.literal("recording-config") }),
|
|
166
|
+
/* @__PURE__ */ zod.z.object({ kind: /* @__PURE__ */ zod.z.literal("notification-mute") }),
|
|
167
|
+
/* @__PURE__ */ zod.z.object({
|
|
168
|
+
kind: /* @__PURE__ */ zod.z.literal("camera-audio"),
|
|
169
|
+
capName: /* @__PURE__ */ zod.z.string()
|
|
170
|
+
}),
|
|
171
|
+
/* @__PURE__ */ zod.z.object({
|
|
172
|
+
kind: /* @__PURE__ */ zod.z.literal("camera-mask"),
|
|
173
|
+
capName: /* @__PURE__ */ zod.z.string()
|
|
174
|
+
}),
|
|
175
|
+
/* @__PURE__ */ zod.z.object({ kind: /* @__PURE__ */ zod.z.literal("broker-audio-mute") })
|
|
176
|
+
]);
|
|
177
|
+
/**
|
|
178
|
+
* Why a switch is not offered for this camera. Rendered instead of the
|
|
179
|
+
* control, never as a dead control — an absent function and a broken one must
|
|
180
|
+
* not look the same.
|
|
181
|
+
*/
|
|
182
|
+
var CameraSwitchUnavailableReasonSchema = /* @__PURE__ */ zod.z.enum([
|
|
183
|
+
"no-provider",
|
|
184
|
+
"source-unreachable",
|
|
185
|
+
"device-disabled"
|
|
186
|
+
]);
|
|
187
|
+
/**
|
|
188
|
+
* Something true about a switch that is nonetheless OFFERED.
|
|
189
|
+
*
|
|
190
|
+
* The distinction from {@link CameraSwitchUnavailableReasonSchema} is the
|
|
191
|
+
* whole point: a reason replaces the control, a warning travels WITH it. The
|
|
192
|
+
* privacy mask taught us the difference — greying the one button that starts
|
|
193
|
+
* the feature teaches the operator the feature is broken, while a live toggle
|
|
194
|
+
* that flips nothing teaches them the switch is broken. Neither is true; the
|
|
195
|
+
* honest surface is a working toggle that says what is missing.
|
|
196
|
+
*/
|
|
197
|
+
var CameraSwitchWarningSchema = /* @__PURE__ */ zod.z.enum(["no-privacy-zones"]);
|
|
198
|
+
/**
|
|
199
|
+
* One switch, resolved for one camera.
|
|
200
|
+
*
|
|
201
|
+
* `label` and `costWhenOff` travel ON THE WIRE rather than being looked up
|
|
202
|
+
* client-side: the viewer is a separate repository that does not import
|
|
203
|
+
* `@camstack/types`, and a cost line duplicated in two clients is a cost line
|
|
204
|
+
* that will disagree with itself. Five rows per camera is nothing.
|
|
205
|
+
*/
|
|
206
|
+
var CameraSwitchSchema = /* @__PURE__ */ zod.z.object({
|
|
207
|
+
id: CameraSwitchIdSchema,
|
|
208
|
+
label: /* @__PURE__ */ zod.z.string(),
|
|
209
|
+
/**
|
|
210
|
+
* What the operator LOSES while this is off, in one sentence. Required, not
|
|
211
|
+
* optional: a switch that cannot say what it costs should not ship.
|
|
212
|
+
*/
|
|
213
|
+
costWhenOff: /* @__PURE__ */ zod.z.string(),
|
|
214
|
+
/** False = do not render a control. `unavailableReason` says why. */
|
|
215
|
+
available: /* @__PURE__ */ zod.z.boolean(),
|
|
216
|
+
unavailableReason: /* @__PURE__ */ CameraSwitchUnavailableReasonSchema.optional(),
|
|
217
|
+
/**
|
|
218
|
+
* Present on an AVAILABLE switch only. Rendered beside the live control;
|
|
219
|
+
* never a substitute for one.
|
|
220
|
+
*/
|
|
221
|
+
warning: /* @__PURE__ */ CameraSwitchWarningSchema.optional(),
|
|
222
|
+
/** Current state. Meaningless when `available` is false — read it as `true`. */
|
|
223
|
+
enabled: /* @__PURE__ */ zod.z.boolean(),
|
|
224
|
+
authority: CameraSwitchAuthoritySchema
|
|
225
|
+
});
|
|
226
|
+
/** The whole group for one camera. */
|
|
227
|
+
var CameraSwitchGroupSchema = /* @__PURE__ */ zod.z.object({
|
|
228
|
+
deviceId: /* @__PURE__ */ zod.z.number().int(),
|
|
229
|
+
switches: /* @__PURE__ */ zod.z.array(CameraSwitchSchema).readonly(),
|
|
230
|
+
/** Unix ms when the group was composed server-side. */
|
|
231
|
+
fetchedAt: /* @__PURE__ */ zod.z.number()
|
|
232
|
+
});
|
|
233
|
+
/**
|
|
234
|
+
* Every analyser a camera CamStack BUILDS is created with switched off.
|
|
235
|
+
*
|
|
236
|
+
* A grid and a Terminal camera are `DeviceType.Camera`, so every wrapper that
|
|
237
|
+
* declares `defaultActive: true` for a camera binds to them the instant they
|
|
238
|
+
* exist — the whole analysis family included. There is nothing there to
|
|
239
|
+
* analyse: a grid's subjects are already counted on the cameras it composes (a
|
|
240
|
+
* person in the bottom-right cell is a person on THAT camera, not on the grid),
|
|
241
|
+
* and a Terminal camera shows a shell.
|
|
242
|
+
*
|
|
243
|
+
* ONE list, in the package both already depend on, because there were two and
|
|
244
|
+
* they had already drifted: the Terminal's and the grid's each named three caps
|
|
245
|
+
* and neither named `pipeline-analytics` — which has no gate of its own except
|
|
246
|
+
* this binding, so a grid that forwards its sources' motion (so the viewer can
|
|
247
|
+
* light its tile) would open a motion EPISODE per forwarded event, duplicating
|
|
248
|
+
* the rows those sources already write.
|
|
249
|
+
*
|
|
250
|
+
* `motion-detection` sits first deliberately: it is the one that holds the
|
|
251
|
+
* decode session open, so its absence is the difference between a derived
|
|
252
|
+
* camera costing a composition and costing a full decode pipeline.
|
|
253
|
+
*
|
|
254
|
+
* Applied ONLY at creation. An operator who deliberately turns analysis back on
|
|
255
|
+
* for a grid must win, and a reconcile that re-asserted this every pass would
|
|
256
|
+
* silently overrule them once a minute.
|
|
257
|
+
*/
|
|
258
|
+
var DERIVED_CAMERA_SILENCED_CAP_NAMES = [
|
|
259
|
+
"motion-detection",
|
|
260
|
+
"detection-pipeline",
|
|
261
|
+
"audio-analysis",
|
|
262
|
+
"pipeline-analytics",
|
|
263
|
+
"scene-monitor"
|
|
264
|
+
];
|
|
265
|
+
//#endregion
|
|
266
|
+
//#region ../types/dist/esm/device/device-identifiers.mjs
|
|
267
|
+
/**
|
|
268
|
+
* Provider-declared device identifiers (D1059, planning#590).
|
|
269
|
+
*
|
|
270
|
+
* What a device IS, as its owning provider read it from the hardware: the keys a
|
|
271
|
+
* later step matches across integrations to tell that two devices are the same
|
|
272
|
+
* physical object. Separate from `DeviceMetadata` on purpose — metadata is a
|
|
273
|
+
* free-form blob the operator can edit, identifiers are typed, normalised and
|
|
274
|
+
* written ONLY by the provider that owns the device (`device-manager.
|
|
275
|
+
* setIdentifiers`, owner-checked on the transport's caller stamp).
|
|
276
|
+
*
|
|
277
|
+
* | Key | Stored form | Strength |
|
|
278
|
+
* | -------------- | ----------------------------------- | -------- |
|
|
279
|
+
* | `mac` | `aa:bb:cc:dd:ee:ff`, several | strong |
|
|
280
|
+
* | `serial` | `<manufacturer>:<serial>` | strong |
|
|
281
|
+
* | `machine-uuid` | SMBIOS / VM / container uuid | strong |
|
|
282
|
+
* | `vendor-uid` | `<vendor>:<id>` | strong |
|
|
283
|
+
* | `hostname` | lower-case, no domain | weak |
|
|
284
|
+
* | `ip` | IPv4 / IPv6 | weak |
|
|
285
|
+
*
|
|
286
|
+
* Strength is a property of the KEY, derived by {@link identifierStrength} —
|
|
287
|
+
* never stored, so it cannot drift from the table above. A weak key never links
|
|
288
|
+
* two devices on its own.
|
|
289
|
+
*
|
|
290
|
+
* The schema refuses a value that is not in its stored form, so whatever is
|
|
291
|
+
* persisted is already normalised. Build a declaration with
|
|
292
|
+
* {@link normaliseIdentifiers}, which turns the raw values a driver read into
|
|
293
|
+
* that form and names every value it refused.
|
|
294
|
+
*/
|
|
295
|
+
var DEVICE_IDENTIFIER_KEYS = [
|
|
296
|
+
"mac",
|
|
297
|
+
"serial",
|
|
298
|
+
"machine-uuid",
|
|
299
|
+
"vendor-uid",
|
|
300
|
+
"hostname",
|
|
301
|
+
"ip"
|
|
302
|
+
];
|
|
303
|
+
var DeviceIdentifierKeySchema = /* @__PURE__ */ zod.z.enum(DEVICE_IDENTIFIER_KEYS);
|
|
304
|
+
/** `read` — the provider read it from the device; `derived` — computed from something else it read. */
|
|
305
|
+
var DeviceIdentifierOriginSchema = /* @__PURE__ */ zod.z.enum(["read", "derived"]);
|
|
306
|
+
var MAC_PATTERN = /^[0-9a-f]{2}(?::[0-9a-f]{2}){5}$/;
|
|
307
|
+
/** `<prefix>:<value>` — prefix a lower-case slug, value lower-case and non-blank. */
|
|
308
|
+
var PREFIXED_PATTERN = /^[a-z0-9][a-z0-9._-]*:[^\sA-Z]+$/;
|
|
309
|
+
var MACHINE_UUID_PATTERN = /^[0-9a-f][0-9a-f-]{7,}$/;
|
|
310
|
+
var HOSTNAME_PATTERN = /^[a-z0-9](?:[a-z0-9-]{0,61}[a-z0-9])?$/;
|
|
311
|
+
function entrySchema(value) {
|
|
312
|
+
return zod.z.object({
|
|
313
|
+
value,
|
|
314
|
+
origin: DeviceIdentifierOriginSchema,
|
|
315
|
+
/** Epoch ms of the FIRST read that produced this value (and origin). A later
|
|
316
|
+
* read of the same value does not move it — see {@link mergeIdentifiers}. */
|
|
317
|
+
readAt: zod.z.number().int().nonnegative()
|
|
318
|
+
}).strict();
|
|
319
|
+
}
|
|
320
|
+
var MacEntrySchema = /* @__PURE__ */ entrySchema(/* @__PURE__ */ zod.z.string().regex(MAC_PATTERN));
|
|
321
|
+
var SerialEntrySchema = /* @__PURE__ */ entrySchema(/* @__PURE__ */ zod.z.string().regex(PREFIXED_PATTERN));
|
|
322
|
+
var MachineUuidEntrySchema = /* @__PURE__ */ entrySchema(/* @__PURE__ */ zod.z.string().regex(MACHINE_UUID_PATTERN));
|
|
323
|
+
var VendorUidEntrySchema = /* @__PURE__ */ entrySchema(/* @__PURE__ */ zod.z.string().regex(PREFIXED_PATTERN));
|
|
324
|
+
var HostnameEntrySchema = /* @__PURE__ */ entrySchema(/* @__PURE__ */ zod.z.string().regex(HOSTNAME_PATTERN));
|
|
325
|
+
var IpEntrySchema = /* @__PURE__ */ entrySchema(/* @__PURE__ */ zod.z.union([/* @__PURE__ */ zod.z.ipv4(), /* @__PURE__ */ zod.z.ipv6()]));
|
|
326
|
+
/** The typed declaration. Every key optional; `mac` the only one that holds several. */
|
|
327
|
+
var DeviceIdentifiersSchema = /* @__PURE__ */ zod.z.object({
|
|
328
|
+
mac: /* @__PURE__ */ zod.z.array(MacEntrySchema).min(1).readonly().optional(),
|
|
329
|
+
serial: /* @__PURE__ */ SerialEntrySchema.optional(),
|
|
330
|
+
"machine-uuid": /* @__PURE__ */ MachineUuidEntrySchema.optional(),
|
|
331
|
+
"vendor-uid": /* @__PURE__ */ VendorUidEntrySchema.optional(),
|
|
332
|
+
hostname: /* @__PURE__ */ HostnameEntrySchema.optional(),
|
|
333
|
+
ip: /* @__PURE__ */ IpEntrySchema.optional()
|
|
334
|
+
}).strict();
|
|
335
|
+
var STRENGTH = {
|
|
336
|
+
mac: "strong",
|
|
337
|
+
serial: "strong",
|
|
338
|
+
"machine-uuid": "strong",
|
|
339
|
+
"vendor-uid": "strong",
|
|
340
|
+
hostname: "weak",
|
|
341
|
+
ip: "weak"
|
|
342
|
+
};
|
|
343
|
+
/** How much a match on this key says about two devices being the same object. */
|
|
344
|
+
function identifierStrength(key) {
|
|
345
|
+
return STRENGTH[key];
|
|
346
|
+
}
|
|
347
|
+
/** True when the declaration carries no key at all. */
|
|
348
|
+
function isEmptyIdentifiers(identifiers) {
|
|
349
|
+
return DEVICE_IDENTIFIER_KEYS.every((key) => identifiers[key] === void 0);
|
|
350
|
+
}
|
|
351
|
+
/** Values devices report when they do not know: never an identity. */
|
|
352
|
+
var PLACEHOLDER_PATTERN = /^(?:unknown|none|n\/?a|null|undefined|default|0+|-+)$/i;
|
|
353
|
+
var NULL_MACS = /* @__PURE__ */ new Set(["00:00:00:00:00:00", "ff:ff:ff:ff:ff:ff"]);
|
|
354
|
+
function rejected(reason) {
|
|
355
|
+
return {
|
|
356
|
+
ok: false,
|
|
357
|
+
reason
|
|
358
|
+
};
|
|
359
|
+
}
|
|
360
|
+
/** `AA-BB-CC-DD-EE-FF`, `aabb.ccdd.eeff`, `AABBCCDDEEFF` → `aa:bb:cc:dd:ee:ff`. */
|
|
361
|
+
function normaliseMac(raw) {
|
|
362
|
+
const hex = raw.trim().toLowerCase().replace(/[\s:.-]/g, "");
|
|
363
|
+
if (!/^[0-9a-f]{12}$/.test(hex)) return rejected("not a 48-bit MAC");
|
|
364
|
+
const mac = (hex.match(/../g) ?? []).join(":");
|
|
365
|
+
if (NULL_MACS.has(mac)) return rejected("placeholder MAC");
|
|
366
|
+
return {
|
|
367
|
+
ok: true,
|
|
368
|
+
value: mac
|
|
369
|
+
};
|
|
370
|
+
}
|
|
371
|
+
function slug(raw) {
|
|
372
|
+
return raw.trim().toLowerCase().replace(/[^a-z0-9._-]+/g, "-").replace(/^[-._]+|[-._]+$/g, "");
|
|
373
|
+
}
|
|
374
|
+
function normalisePrefixed(prefixRaw, valueRaw, what) {
|
|
375
|
+
const prefix = slug(prefixRaw);
|
|
376
|
+
if (prefix.length === 0) return rejected(`no ${what}`);
|
|
377
|
+
const value = valueRaw.trim().toLowerCase().replace(/\s+/g, "");
|
|
378
|
+
if (value.length === 0) return rejected("blank value");
|
|
379
|
+
if (PLACEHOLDER_PATTERN.test(value)) return rejected("placeholder value");
|
|
380
|
+
return {
|
|
381
|
+
ok: true,
|
|
382
|
+
value: `${prefix}:${value}`
|
|
383
|
+
};
|
|
384
|
+
}
|
|
385
|
+
function normaliseMachineUuid(raw) {
|
|
386
|
+
const value = raw.trim().toLowerCase().replace(/^\{|\}$/g, "");
|
|
387
|
+
if (!MACHINE_UUID_PATTERN.test(value)) return rejected("not a uuid");
|
|
388
|
+
if (/^[0-]+$/.test(value) || /^[f-]+$/.test(value)) return rejected("placeholder uuid");
|
|
389
|
+
return {
|
|
390
|
+
ok: true,
|
|
391
|
+
value
|
|
392
|
+
};
|
|
393
|
+
}
|
|
394
|
+
function isIp(value) {
|
|
395
|
+
return zod.z.union([zod.z.ipv4(), zod.z.ipv6()]).safeParse(value).success;
|
|
396
|
+
}
|
|
397
|
+
function normaliseHostname(raw) {
|
|
398
|
+
const full = raw.trim().toLowerCase().replace(/\.$/, "");
|
|
399
|
+
if (full.length === 0) return rejected("blank hostname");
|
|
400
|
+
if (isIp(full)) return rejected("an address, not a hostname");
|
|
401
|
+
const label = full.split(".")[0] ?? "";
|
|
402
|
+
if (!HOSTNAME_PATTERN.test(label)) return rejected("not a hostname");
|
|
403
|
+
if (label === "localhost") return rejected("placeholder hostname");
|
|
404
|
+
return {
|
|
405
|
+
ok: true,
|
|
406
|
+
value: label
|
|
407
|
+
};
|
|
408
|
+
}
|
|
409
|
+
function normaliseIp(raw) {
|
|
410
|
+
const value = raw.trim().toLowerCase().replace(/^\[|\]$/g, "");
|
|
411
|
+
if (!isIp(value)) return rejected("not an IP address");
|
|
412
|
+
if (value === "0.0.0.0" || value === "::" || value === "::1" || value.startsWith("127.")) return rejected("loopback or unspecified address");
|
|
413
|
+
return {
|
|
414
|
+
ok: true,
|
|
415
|
+
value
|
|
416
|
+
};
|
|
417
|
+
}
|
|
418
|
+
function isBlank(value) {
|
|
419
|
+
return value === null || value === void 0 || value.trim().length === 0;
|
|
420
|
+
}
|
|
421
|
+
/**
|
|
422
|
+
* Turn what a driver read into a valid {@link DeviceIdentifiers}: MACs lower-case
|
|
423
|
+
* with colons and de-duplicated, a hostname without its domain, an IP validated,
|
|
424
|
+
* a serial prefixed by its manufacturer, a vendor uid by its vendor. A value that
|
|
425
|
+
* cannot be normalised is left out and listed in `rejected` — the caller logs it
|
|
426
|
+
* (with `tags: { deviceId }`), it is never dropped in silence.
|
|
427
|
+
*/
|
|
428
|
+
function normaliseIdentifiers(raw, options = {}) {
|
|
429
|
+
const readAt = options.readAt ?? Date.now();
|
|
430
|
+
const originOf = (key) => options.originByKey?.[key] ?? options.origin ?? "read";
|
|
431
|
+
const entry = (key, value) => ({
|
|
432
|
+
value,
|
|
433
|
+
origin: originOf(key),
|
|
434
|
+
readAt
|
|
435
|
+
});
|
|
436
|
+
const refused = [];
|
|
437
|
+
const take = (key, input, result) => {
|
|
438
|
+
if (result.ok) return entry(key, result.value);
|
|
439
|
+
refused.push({
|
|
440
|
+
key,
|
|
441
|
+
value: input,
|
|
442
|
+
reason: result.reason
|
|
443
|
+
});
|
|
444
|
+
};
|
|
445
|
+
const macInputs = raw.mac === null || raw.mac === void 0 ? [] : [raw.mac].flat();
|
|
446
|
+
const macs = [];
|
|
447
|
+
for (const input of macInputs) {
|
|
448
|
+
if (isBlank(input)) continue;
|
|
449
|
+
const taken = take("mac", input, normaliseMac(input));
|
|
450
|
+
if (taken !== void 0 && !macs.some((m) => m.value === taken.value)) macs.push(taken);
|
|
451
|
+
}
|
|
452
|
+
const serial = raw.serial === null || raw.serial === void 0 || isBlank(raw.serial.serial) ? void 0 : take("serial", `${raw.serial.manufacturer}:${raw.serial.serial}`, normalisePrefixed(raw.serial.manufacturer, raw.serial.serial, "manufacturer"));
|
|
453
|
+
const vendorUid = raw.vendorUid === null || raw.vendorUid === void 0 || isBlank(raw.vendorUid.id) ? void 0 : take("vendor-uid", `${raw.vendorUid.vendor}:${raw.vendorUid.id}`, normalisePrefixed(raw.vendorUid.vendor, raw.vendorUid.id, "vendor"));
|
|
454
|
+
const machineUuid = isBlank(raw.machineUuid) ? void 0 : take("machine-uuid", raw.machineUuid, normaliseMachineUuid(raw.machineUuid));
|
|
455
|
+
const host = isBlank(raw.host) ? null : raw.host.trim();
|
|
456
|
+
const hostIsIp = host !== null && isIp(host.toLowerCase().replace(/^\[|\]$/g, ""));
|
|
457
|
+
const hostnameInput = isBlank(raw.hostname) ? hostIsIp ? null : host : raw.hostname;
|
|
458
|
+
const ipInput = isBlank(raw.ip) ? hostIsIp ? host : null : raw.ip;
|
|
459
|
+
const hostname = hostnameInput === null ? void 0 : take("hostname", hostnameInput, normaliseHostname(hostnameInput));
|
|
460
|
+
const ip = ipInput === null ? void 0 : take("ip", ipInput, normaliseIp(ipInput));
|
|
461
|
+
return {
|
|
462
|
+
identifiers: {
|
|
463
|
+
...macs.length > 0 ? { mac: macs } : {},
|
|
464
|
+
...serial !== void 0 ? { serial } : {},
|
|
465
|
+
...machineUuid !== void 0 ? { "machine-uuid": machineUuid } : {},
|
|
466
|
+
...vendorUid !== void 0 ? { "vendor-uid": vendorUid } : {},
|
|
467
|
+
...hostname !== void 0 ? { hostname } : {},
|
|
468
|
+
...ip !== void 0 ? { ip } : {}
|
|
469
|
+
},
|
|
470
|
+
rejected: refused
|
|
471
|
+
};
|
|
472
|
+
}
|
|
473
|
+
function sameEntry(a, b) {
|
|
474
|
+
return a.value === b.value && a.origin === b.origin;
|
|
475
|
+
}
|
|
476
|
+
/** `next`, but with the stored entry wherever value and origin are unchanged. */
|
|
477
|
+
function keepStoredEntry(next, stored) {
|
|
478
|
+
return stored !== void 0 && sameEntry(next, stored) ? stored : next;
|
|
479
|
+
}
|
|
480
|
+
/**
|
|
481
|
+
* The declaration to store when the owning provider declares `next` over
|
|
482
|
+
* `stored` (D1059).
|
|
483
|
+
*
|
|
484
|
+
* - A kind in `unread` — the provider TRIED to read it and the read failed —
|
|
485
|
+
* keeps its stored entry: a failed read changes nothing (D49).
|
|
486
|
+
* - Every other kind is what `next` says: a kind absent from `next` was read and
|
|
487
|
+
* found absent, so it is removed.
|
|
488
|
+
* - An entry whose value and origin are unchanged keeps its stored `readAt`:
|
|
489
|
+
* `readAt` is when that value was FIRST read, so a provider re-declaring on every
|
|
490
|
+
* boot writes nothing and emits nothing.
|
|
491
|
+
*
|
|
492
|
+
* Returns `null` when nothing is left.
|
|
493
|
+
*/
|
|
494
|
+
function mergeIdentifiers(stored, next, unread = []) {
|
|
495
|
+
const before = stored ?? {};
|
|
496
|
+
const after = next ?? {};
|
|
497
|
+
const failed = new Set(unread);
|
|
498
|
+
const macs = failed.has("mac") ? before.mac : after.mac?.map((m) => keepStoredEntry(m, before.mac?.find((s) => sameEntry(s, m))));
|
|
499
|
+
const single = (key) => {
|
|
500
|
+
if (failed.has(key)) return before[key];
|
|
501
|
+
const entry = after[key];
|
|
502
|
+
return entry === void 0 ? void 0 : keepStoredEntry(entry, before[key]);
|
|
503
|
+
};
|
|
504
|
+
const serial = single("serial");
|
|
505
|
+
const machineUuid = single("machine-uuid");
|
|
506
|
+
const vendorUid = single("vendor-uid");
|
|
507
|
+
const hostname = single("hostname");
|
|
508
|
+
const ip = single("ip");
|
|
509
|
+
const merged = {
|
|
510
|
+
...macs !== void 0 && macs.length > 0 ? { mac: macs } : {},
|
|
511
|
+
...serial !== void 0 ? { serial } : {},
|
|
512
|
+
...machineUuid !== void 0 ? { "machine-uuid": machineUuid } : {},
|
|
513
|
+
...vendorUid !== void 0 ? { "vendor-uid": vendorUid } : {},
|
|
514
|
+
...hostname !== void 0 ? { hostname } : {},
|
|
515
|
+
...ip !== void 0 ? { ip } : {}
|
|
516
|
+
};
|
|
517
|
+
return isEmptyIdentifiers(merged) ? null : merged;
|
|
518
|
+
}
|
|
519
|
+
/** True when two declarations hold the same entries, `readAt` included (key order ignored). */
|
|
520
|
+
function sameIdentifiers(a, b) {
|
|
521
|
+
const canonical = (v) => v === null || v === void 0 || isEmptyIdentifiers(v) ? "" : JSON.stringify(DEVICE_IDENTIFIER_KEYS.map((key) => [key, v[key] ?? null]).map(([key, e]) => [key, e === null ? null : [e].flat().map((x) => [
|
|
522
|
+
x.value,
|
|
523
|
+
x.origin,
|
|
524
|
+
x.readAt
|
|
525
|
+
])]));
|
|
526
|
+
return canonical(a) === canonical(b);
|
|
527
|
+
}
|
|
528
|
+
//#endregion
|
|
529
|
+
Object.defineProperty(exports, "CAMERA_SWITCH_ORDER", {
|
|
530
|
+
enumerable: true,
|
|
531
|
+
get: function() {
|
|
532
|
+
return CAMERA_SWITCH_ORDER;
|
|
533
|
+
}
|
|
534
|
+
});
|
|
535
|
+
Object.defineProperty(exports, "CameraSwitchGroupSchema", {
|
|
536
|
+
enumerable: true,
|
|
537
|
+
get: function() {
|
|
538
|
+
return CameraSwitchGroupSchema;
|
|
539
|
+
}
|
|
540
|
+
});
|
|
541
|
+
Object.defineProperty(exports, "CameraSwitchIdSchema", {
|
|
542
|
+
enumerable: true,
|
|
543
|
+
get: function() {
|
|
544
|
+
return CameraSwitchIdSchema;
|
|
545
|
+
}
|
|
546
|
+
});
|
|
547
|
+
Object.defineProperty(exports, "DERIVED_CAMERA_SILENCED_CAP_NAMES", {
|
|
548
|
+
enumerable: true,
|
|
549
|
+
get: function() {
|
|
550
|
+
return DERIVED_CAMERA_SILENCED_CAP_NAMES;
|
|
551
|
+
}
|
|
552
|
+
});
|
|
553
|
+
Object.defineProperty(exports, "DEVICE_IDENTIFIER_KEYS", {
|
|
554
|
+
enumerable: true,
|
|
555
|
+
get: function() {
|
|
556
|
+
return DEVICE_IDENTIFIER_KEYS;
|
|
557
|
+
}
|
|
558
|
+
});
|
|
559
|
+
Object.defineProperty(exports, "DeviceIdentifierKeySchema", {
|
|
560
|
+
enumerable: true,
|
|
561
|
+
get: function() {
|
|
562
|
+
return DeviceIdentifierKeySchema;
|
|
563
|
+
}
|
|
564
|
+
});
|
|
565
|
+
Object.defineProperty(exports, "DeviceIdentifiersSchema", {
|
|
566
|
+
enumerable: true,
|
|
567
|
+
get: function() {
|
|
568
|
+
return DeviceIdentifiersSchema;
|
|
569
|
+
}
|
|
570
|
+
});
|
|
571
|
+
Object.defineProperty(exports, "identifierStrength", {
|
|
572
|
+
enumerable: true,
|
|
573
|
+
get: function() {
|
|
574
|
+
return identifierStrength;
|
|
575
|
+
}
|
|
576
|
+
});
|
|
577
|
+
Object.defineProperty(exports, "isEmptyIdentifiers", {
|
|
578
|
+
enumerable: true,
|
|
579
|
+
get: function() {
|
|
580
|
+
return isEmptyIdentifiers;
|
|
581
|
+
}
|
|
582
|
+
});
|
|
583
|
+
Object.defineProperty(exports, "mergeIdentifiers", {
|
|
584
|
+
enumerable: true,
|
|
585
|
+
get: function() {
|
|
586
|
+
return mergeIdentifiers;
|
|
587
|
+
}
|
|
588
|
+
});
|
|
589
|
+
Object.defineProperty(exports, "normaliseIdentifiers", {
|
|
590
|
+
enumerable: true,
|
|
591
|
+
get: function() {
|
|
592
|
+
return normaliseIdentifiers;
|
|
593
|
+
}
|
|
594
|
+
});
|
|
595
|
+
Object.defineProperty(exports, "sameIdentifiers", {
|
|
596
|
+
enumerable: true,
|
|
597
|
+
get: function() {
|
|
598
|
+
return sameIdentifiers;
|
|
599
|
+
}
|
|
600
|
+
});
|