@camstack/server 1.2.928 → 1.2.930

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (241) hide show
  1. package/CHANGELOG.md +12 -0
  2. package/package.json +10 -10
  3. package/system/dist/addon-id-CVg1_r5E.mjs +39 -0
  4. package/system/dist/addon-id-Di0lNJ89.js +50 -0
  5. package/system/dist/addon-pages.cap-Df9FQwN1.js +49 -0
  6. package/system/dist/addon-pages.cap-DksUlE8j.mjs +44 -0
  7. package/system/dist/addon-settings.cap-3-TIIMq_.mjs +592 -0
  8. package/system/dist/addon-settings.cap-DAiE0Nb0.js +651 -0
  9. package/system/dist/addon-utils.mjs +1 -1
  10. package/system/dist/addon-widgets.cap-C4jxflbF.js +200 -0
  11. package/system/dist/addon-widgets.cap-D9m48X78.mjs +183 -0
  12. package/system/dist/base-addon-DD5dIfcZ.js +4624 -0
  13. package/system/dist/base-addon-Md14i7pe.mjs +4505 -0
  14. package/system/dist/base-device-2sL1DMm1.js +1103 -0
  15. package/system/dist/base-device-IuM1AwXZ.mjs +1098 -0
  16. package/system/dist/builtins/addon-pages-aggregator/addon-pages-aggregator.addon.js +8 -6
  17. package/system/dist/builtins/addon-pages-aggregator/addon-pages-aggregator.addon.mjs +6 -4
  18. package/system/dist/builtins/addon-widgets-aggregator/addon-widgets-aggregator.addon.js +8 -6
  19. package/system/dist/builtins/addon-widgets-aggregator/addon-widgets-aggregator.addon.mjs +7 -5
  20. package/system/dist/builtins/alerts/alerts.addon.js +113 -56
  21. package/system/dist/builtins/alerts/alerts.addon.mjs +60 -3
  22. package/system/dist/builtins/autotrack/index.js +21 -17
  23. package/system/dist/builtins/autotrack/index.mjs +5 -1
  24. package/system/dist/builtins/backup-orchestrator/backup-orchestrator.addon.js +14 -11
  25. package/system/dist/builtins/backup-orchestrator/backup-orchestrator.addon.mjs +8 -5
  26. package/system/dist/builtins/calendars/calendars.addon.js +8 -6
  27. package/system/dist/builtins/calendars/calendars.addon.mjs +3 -1
  28. package/system/dist/builtins/camera-grid/index.js +615 -58
  29. package/system/dist/builtins/camera-grid/index.mjs +558 -1
  30. package/system/dist/builtins/composer/composer.addon.js +788 -209
  31. package/system/dist/builtins/composer/composer.addon.mjs +583 -4
  32. package/system/dist/builtins/console-logging/index.js +4 -3
  33. package/system/dist/builtins/console-logging/index.mjs +2 -1
  34. package/system/dist/builtins/core-blocks/actions-service.d.ts +18 -1
  35. package/system/dist/builtins/core-blocks/core-blocks.addon.js +8670 -386
  36. package/system/dist/builtins/core-blocks/core-blocks.addon.mjs +8294 -11
  37. package/system/dist/builtins/core-blocks/tcp-connect.d.ts +3 -0
  38. package/system/dist/builtins/core-notifier/core-notifier.addon.js +250 -21
  39. package/system/dist/builtins/core-notifier/core-notifier.addon.mjs +230 -1
  40. package/system/dist/builtins/device-history/device-history.addon.js +110 -31
  41. package/system/dist/builtins/device-history/device-history.addon.mjs +81 -2
  42. package/system/dist/builtins/device-manager/device-manager.addon.js +12806 -227
  43. package/system/dist/builtins/device-manager/device-manager.addon.mjs +12583 -5
  44. package/system/dist/builtins/hub-forwarder/index.js +4 -3
  45. package/system/dist/builtins/hub-forwarder/index.mjs +2 -1
  46. package/system/dist/builtins/keychain/index.js +31 -28
  47. package/system/dist/builtins/keychain/index.mjs +7 -4
  48. package/system/dist/builtins/liveness-monitor/liveness-monitor.addon.js +15 -12
  49. package/system/dist/builtins/liveness-monitor/liveness-monitor.addon.mjs +4 -1
  50. package/system/dist/builtins/local-auth/local-auth.addon.js +140 -39
  51. package/system/dist/builtins/local-auth/local-auth.addon.mjs +106 -6
  52. package/system/dist/builtins/local-network/local-network.addon.js +43 -39
  53. package/system/dist/builtins/local-network/local-network.addon.mjs +7 -3
  54. package/system/dist/builtins/loki-logging/index.js +23 -17
  55. package/system/dist/builtins/loki-logging/index.mjs +7 -1
  56. package/system/dist/builtins/native-metrics/native-metrics.addon.js +156 -15
  57. package/system/dist/builtins/native-metrics/native-metrics.addon.mjs +151 -10
  58. package/system/dist/builtins/platform-probe/index.js +25 -23
  59. package/system/dist/builtins/platform-probe/index.mjs +12 -10
  60. package/system/dist/builtins/record-entries/index.js +9 -7
  61. package/system/dist/builtins/record-entries/index.mjs +3 -1
  62. package/system/dist/builtins/remote-access-orchestrator/remote-access-orchestrator.addon.js +4 -4
  63. package/system/dist/builtins/remote-access-orchestrator/remote-access-orchestrator.addon.mjs +1 -1
  64. package/system/dist/builtins/snapshot/index.js +97 -44
  65. package/system/dist/builtins/snapshot/index.mjs +54 -1
  66. package/system/dist/builtins/sqlite-storage/filesystem-storage.addon.js +5 -4
  67. package/system/dist/builtins/sqlite-storage/filesystem-storage.addon.mjs +21 -20
  68. package/system/dist/builtins/sqlite-storage/index.js +1 -1
  69. package/system/dist/builtins/sqlite-storage/index.mjs +1 -1
  70. package/system/dist/builtins/sqlite-storage/sqlite-settings.addon.js +87 -61
  71. package/system/dist/builtins/sqlite-storage/sqlite-settings.addon.mjs +29 -3
  72. package/system/dist/builtins/storage-orchestrator/storage-orchestrator.addon.js +81 -72
  73. package/system/dist/builtins/storage-orchestrator/storage-orchestrator.addon.mjs +10 -1
  74. package/system/dist/builtins/system-config/system-config.addon.js +17 -14
  75. package/system/dist/builtins/system-config/system-config.addon.mjs +118 -115
  76. package/system/dist/builtins/winston-logging/index.js +7 -5
  77. package/system/dist/builtins/winston-logging/index.mjs +3 -1
  78. package/system/dist/calendars.cap-CaFlShS9.js +155 -0
  79. package/system/dist/calendars.cap-_C4eD4fi.mjs +138 -0
  80. package/system/dist/camstack-error-DJ-TUAi1.js +23 -0
  81. package/system/dist/camstack-error-viZYfcj9.mjs +18 -0
  82. package/system/dist/cap-call-context-Bd76CbOW.js +95 -0
  83. package/system/dist/cap-call-context-DNwdgGSQ.mjs +78 -0
  84. package/system/dist/capability-definition-C2rJdVeX.mjs +177 -0
  85. package/system/dist/capability-definition-HCmTem8c.js +242 -0
  86. package/system/dist/{capture-engine-BcuwOSXv.js → capture-engine-DZ0LIUqA.js} +5 -4
  87. package/system/dist/{capture-engine-Bz7eXFjT.mjs → capture-engine-DiwbjoWp.mjs} +2 -1
  88. package/system/dist/command-origin-claim-Cief660O.js +35 -0
  89. package/system/dist/command-origin-claim-D1Wy7Qld.mjs +24 -0
  90. package/system/dist/composition-sources-BEUWn2s_.mjs +391 -0
  91. package/system/dist/composition-sources-acfR4hDq.js +408 -0
  92. package/system/dist/{constants-D2etJ02O.js → constants-Ba3FTIHl.js} +1 -1
  93. package/system/dist/constants-C860Y6U4.js +26 -0
  94. package/system/dist/{constants-BcUTQd1M.mjs → constants-DB4piTD5.mjs} +1 -1
  95. package/system/dist/constants-DCLpoF4L.mjs +21 -0
  96. package/system/dist/coral-accelerators-7o8hqvcN.js +564 -0
  97. package/system/dist/coral-accelerators-BKcXP59c.mjs +521 -0
  98. package/system/dist/core-blocks.cap-BMeMCBrx.js +18733 -0
  99. package/system/dist/core-blocks.cap-BRPsLAij.mjs +18008 -0
  100. package/system/dist/{custom-action-registry-N7flBDwT.mjs → custom-action-registry-B9zFBNVa.mjs} +37 -37
  101. package/system/dist/custom-actions-BFUSalC9.mjs +25 -0
  102. package/system/dist/custom-actions-D92NRi2c.js +36 -0
  103. package/system/dist/database-snapshot.cap-DF38e-0P.js +162 -0
  104. package/system/dist/database-snapshot.cap-dhrc9xnY.mjs +133 -0
  105. package/system/dist/declared-device-BWphj9WE.js +303 -0
  106. package/system/dist/declared-device-CKERA1Hi.mjs +286 -0
  107. package/system/dist/{device-ca-ExMN3xW3.mjs → device-ca-BLM6fccc.mjs} +2 -1
  108. package/system/dist/{device-ca-CU8zh9Pi.js → device-ca-C5kJE6mL.js} +7 -6
  109. package/system/dist/device-certificate-Cddm4Idn.mjs +91 -0
  110. package/system/dist/device-certificate-CguVACQO.js +162 -0
  111. package/system/dist/device-identifiers-BQg9EQi1.js +600 -0
  112. package/system/dist/device-identifiers-iSuQCKmK.mjs +529 -0
  113. package/system/dist/device-kind-BJ2pfsjw.mjs +78 -0
  114. package/system/dist/device-kind-CsSiv_YF.js +101 -0
  115. package/system/dist/device-manager.cap-2abwVLCM.js +2874 -0
  116. package/system/dist/device-manager.cap-CFZSPfUh.mjs +2749 -0
  117. package/system/dist/device-provider.cap-3Uvk6f5-.mjs +331 -0
  118. package/system/dist/device-provider.cap-D7TV2kVH.js +366 -0
  119. package/system/dist/{device-row-store-CeW_GWh9.mjs → device-row-store-YF3jtmkk.mjs} +4 -1
  120. package/system/dist/{device-row-store-BMIR-n3m.js → device-row-store-doTfMOqn.js} +12 -9
  121. package/system/dist/device-transitions.cap-B5w5PYU_.js +860 -0
  122. package/system/dist/device-transitions.cap-DojcwEuX.mjs +819 -0
  123. package/system/dist/device-type-CbQsnFdC.js +477 -0
  124. package/system/dist/device-type-DgEvK3ch.mjs +454 -0
  125. package/system/dist/entry-kind-D9MuVJCK.mjs +44 -0
  126. package/system/dist/entry-kind-cq90c--V.js +55 -0
  127. package/system/dist/error.cap-CSM_SRfR.mjs +3423 -0
  128. package/system/dist/error.cap-DBhgPeWK.js +3848 -0
  129. package/system/dist/file-host-worker.js +1 -1
  130. package/system/dist/file-host-worker.mjs +1 -1
  131. package/system/dist/history-catalog-BKRarIL_.js +831 -0
  132. package/system/dist/history-catalog-BwTeQ4Mr.mjs +802 -0
  133. package/system/dist/{hub-identity-Csxx2Q8k.js → hub-identity-BMdR3Mw9.js} +2 -2
  134. package/system/dist/{hub-identity-CYC1820R.mjs → hub-identity-DjMN9Ac2.mjs} +10 -10
  135. package/system/dist/{hub-mdns-ciao-By5577HM.js → hub-mdns-ciao--0v1TKME.js} +5 -5
  136. package/system/dist/{hub-mdns-ciao-CCDxM5qz.mjs → hub-mdns-ciao-DBrtHOcc.mjs} +2 -2
  137. package/system/dist/index.js +763 -151
  138. package/system/dist/index.mjs +832 -220
  139. package/system/dist/integration-instances.cap-Cl9O-k4h.mjs +538 -0
  140. package/system/dist/integration-instances.cap-dJIxg2_s.js +549 -0
  141. package/system/dist/keychain-admin.cap-Db_oFX4H.js +425 -0
  142. package/system/dist/keychain-admin.cap-GtM7gVGG.mjs +396 -0
  143. package/system/dist/l10n-Bu6aUvSY.mjs +10 -0
  144. package/system/dist/l10n-CGMvp7NF.js +15 -0
  145. package/system/dist/labels-DX5S8deC.js +81 -0
  146. package/system/dist/labels-DsBcU7md.mjs +64 -0
  147. package/system/dist/{legacy-integration-rows-door-CVwOo5aq.js → legacy-integration-rows-door-B1nzxxr5.js} +2 -2
  148. package/system/dist/{legacy-integration-rows-door-D9tQOUzh.mjs → legacy-integration-rows-door-nTvo_6jQ.mjs} +1 -1
  149. package/system/dist/log-destination.cap-CxZzAVaR.mjs +143 -0
  150. package/system/dist/log-destination.cap-DELPJkZ0.js +148 -0
  151. package/system/dist/low-power-sleep.cap-7lfVU41N.js +103 -0
  152. package/system/dist/low-power-sleep.cap-tGPmaZ_V.mjs +92 -0
  153. package/system/dist/mask-shape-Ci8Co9w0.mjs +57 -0
  154. package/system/dist/mask-shape-CmPA2fst.js +92 -0
  155. package/system/dist/metrics-provider.cap-BNmcHDkQ.mjs +405 -0
  156. package/system/dist/metrics-provider.cap-BcmQUt6l.js +410 -0
  157. package/system/dist/migration-BMjgkyG2.js +380 -0
  158. package/system/dist/migration-DRJAtdy7.mjs +321 -0
  159. package/system/dist/network-access.cap-B5TWLDCC.js +1099 -0
  160. package/system/dist/network-access.cap-BJnGbE6n.mjs +1004 -0
  161. package/system/dist/notification-rules.cap-BDh0LDhV.js +3428 -0
  162. package/system/dist/notification-rules.cap-DUmiMBQB.mjs +3357 -0
  163. package/system/dist/notification-targets-CRH-9Dy5.js +509 -0
  164. package/system/dist/notification-targets-DaNE-pIt.mjs +486 -0
  165. package/system/dist/ops-log-CB4pIdqi.mjs +64 -0
  166. package/system/dist/ops-log-pxt9176Z.js +81 -0
  167. package/system/dist/pinned-binary-BOhOSNff.js +28 -0
  168. package/system/dist/pinned-binary-CrIRAi4G.mjs +23 -0
  169. package/system/dist/platform-probe.cap-1WrMhWHx.js +250 -0
  170. package/system/dist/platform-probe.cap-BFeqFLtQ.mjs +233 -0
  171. package/system/dist/prefix-walk-BkMxoXpL.js +843 -0
  172. package/system/dist/prefix-walk-ifwg_ukx.mjs +790 -0
  173. package/system/dist/ptz-autotrack.cap-BW7w0zHD.js +229 -0
  174. package/system/dist/ptz-autotrack.cap-DT2GypXw.mjs +224 -0
  175. package/system/dist/quantity-D3g5SxsZ.mjs +114 -0
  176. package/system/dist/quantity-lY1KiTSZ.js +143 -0
  177. package/system/dist/raw-secret-migration-DxuBFtvi.js +50 -0
  178. package/system/dist/raw-secret-migration-iv88mLoc.mjs +39 -0
  179. package/system/dist/record-entries.cap-sMUhTvTU.mjs +75 -0
  180. package/system/dist/record-entries.cap-ti1C046R.js +80 -0
  181. package/system/dist/record-kind-DoBfYHCs.js +203 -0
  182. package/system/dist/record-kind-ub6NXqfh.mjs +162 -0
  183. package/system/dist/recording-archive.cap-7OrIn9e5.mjs +1299 -0
  184. package/system/dist/recording-archive.cap-D7bo-QSM.js +1328 -0
  185. package/system/dist/records.cap-ClcWV64i.js +329 -0
  186. package/system/dist/records.cap-CwLT2ByG.mjs +294 -0
  187. package/system/dist/relocate-CdVQAk-w.js +804 -0
  188. package/system/dist/relocate-CoZZTui1.mjs +661 -0
  189. package/system/dist/rename-composition-block-BJsL58Ih.js +34798 -0
  190. package/system/dist/rename-composition-block-OAtErZgq.mjs +33631 -0
  191. package/system/dist/{restore-archive-BJfyu0sG.mjs → restore-archive-CjAyKpgX.mjs} +96 -94
  192. package/system/dist/{restore-archive-CIFvqOze.js → restore-archive-CkTkv3Ss.js} +6 -4
  193. package/system/dist/scoped-settings-CylSSq_8.js +955 -0
  194. package/system/dist/scoped-settings-DVWUIP7Z.mjs +650 -0
  195. package/system/dist/server-name-BIhLuHvX.mjs +35 -0
  196. package/system/dist/server-name-OALNvpqC.js +52 -0
  197. package/system/dist/settings-store.cap-Ci4F2zul.mjs +569 -0
  198. package/system/dist/settings-store.cap-wlJhCspr.js +640 -0
  199. package/system/dist/snapshot.cap-3suPdBHV.js +250 -0
  200. package/system/dist/snapshot.cap-Bs8Oyaqh.mjs +245 -0
  201. package/system/dist/source-info-DGB7SdB_.mjs +190 -0
  202. package/system/dist/source-info-DtWf4k2j.js +225 -0
  203. package/system/dist/storage-admin.cap-BSv1NjKJ.mjs +883 -0
  204. package/system/dist/storage-admin.cap-he0OqvVM.js +906 -0
  205. package/system/dist/storage-location-CBT8GCD6.mjs +163 -0
  206. package/system/dist/storage-location-CTweDMZf.js +198 -0
  207. package/system/dist/storage-location-mode-B21UVRRX.mjs +167 -0
  208. package/system/dist/storage-location-mode-CS4sMzo-.js +232 -0
  209. package/system/dist/storage-migration.cap-CyyATY_p.js +330 -0
  210. package/system/dist/storage-migration.cap-D7QqGobp.mjs +313 -0
  211. package/system/dist/storage-occupancy.cap-2rmnS58Z.js +622 -0
  212. package/system/dist/storage-occupancy.cap-CqBztTl9.mjs +611 -0
  213. package/system/dist/storage-provider.cap-Bw0CfxVc.js +213 -0
  214. package/system/dist/storage-provider.cap-CMeck2w4.mjs +202 -0
  215. package/system/dist/stream-catalog.cap-Bp7SkgIf.mjs +6560 -0
  216. package/system/dist/stream-catalog.cap-D3uwePiA.js +6763 -0
  217. package/system/dist/streaming-shared-B8cXatuU.mjs +431 -0
  218. package/system/dist/streaming-shared-DQwFZOSi.js +526 -0
  219. package/system/dist/system-reasons-Be_k1W8g.js +25 -0
  220. package/system/dist/system-reasons-CYj4qwyS.mjs +20 -0
  221. package/system/dist/tag-BxLazvVb.js +2138 -0
  222. package/system/dist/tag-uZBAq6ox.mjs +2073 -0
  223. package/system/dist/user-management.cap-B9QDu8NE.js +825 -0
  224. package/system/dist/user-management.cap-DBIi77sB.mjs +766 -0
  225. package/system/dist/vector-store.cap-DnyfrYDn.js +330 -0
  226. package/system/dist/vector-store.cap-h2GHWQ1t.mjs +319 -0
  227. package/system/dist/{wal-maintenance-CTrCPzds.mjs → wal-maintenance-BG01rOn9.mjs} +0 -0
  228. package/system/dist/{wal-maintenance-dq7T3quB.js → wal-maintenance-DyrebYKF.js} +0 -0
  229. package/system/dist/zod-secret-DS7mj1bk.js +78 -0
  230. package/system/dist/zod-secret-zY4nM61M.mjs +73 -0
  231. package/system/package.json +1 -1
  232. package/system/dist/composition-sources-BI614LJx.mjs +0 -141
  233. package/system/dist/composition-sources-v_kkb8A9.js +0 -152
  234. package/system/dist/coral-accelerators-BSVsBVzt.js +0 -250
  235. package/system/dist/coral-accelerators-BW3OcrLD.mjs +0 -231
  236. package/system/dist/dist-BCHMSqzc.mjs +0 -143467
  237. package/system/dist/dist-BZfvhfS1.js +0 -146970
  238. package/system/dist/prefix-walk-DAOBSyH1.mjs +0 -88
  239. package/system/dist/prefix-walk-Dv6MLZlM.js +0 -99
  240. package/system/dist/rename-composition-block-C9HuBrKS.js +0 -112
  241. package/system/dist/rename-composition-block-DtaYmYAR.mjs +0 -101
@@ -0,0 +1,825 @@
1
+ const require_capability_definition = require("./capability-definition-HCmTem8c.js");
2
+ const require_system_reasons = require("./system-reasons-Be_k1W8g.js");
3
+ const require_device_type = require("./device-type-CbQsnFdC.js");
4
+ const require_device_kind = require("./device-kind-CsSiv_YF.js");
5
+ const require_device_certificate = require("./device-certificate-CguVACQO.js");
6
+ const require_raw_secret_migration = require("./raw-secret-migration-DxuBFtvi.js");
7
+ let zod = require("zod");
8
+ var ViewerFeatureIdSchema = /* @__PURE__ */ zod.z.enum([
9
+ "face-assignment",
10
+ "plate-assignment",
11
+ "retrain",
12
+ "scenes"
13
+ ]);
14
+ /** Which devices a viewer reaches: `allow` minus `block`. */
15
+ var ViewerDeviceAllowSchema = /* @__PURE__ */ zod.z.union([/* @__PURE__ */ zod.z.literal("*"), /* @__PURE__ */ zod.z.array(/* @__PURE__ */ zod.z.number().int().nonnegative())]);
16
+ /**
17
+ * The viewer grant, stored as ONE row of a user's `scopes`. A principal that
18
+ * holds it is decided by the viewer rules ALONE — any other row it carries is
19
+ * ignored, so a viewer can never be widened by a leftover grant.
20
+ */
21
+ var ViewerTokenScopeSchema = /* @__PURE__ */ zod.z.object({
22
+ type: /* @__PURE__ */ zod.z.literal("viewer"),
23
+ allow: ViewerDeviceAllowSchema,
24
+ block: /* @__PURE__ */ zod.z.array(/* @__PURE__ */ zod.z.number().int().nonnegative()),
25
+ features: /* @__PURE__ */ zod.z.array(ViewerFeatureIdSchema)
26
+ });
27
+ //#endregion
28
+ //#region ../types/dist/esm/schemas/auth-records.mjs
29
+ /**
30
+ * Zod schemas for persisted record types.
31
+ *
32
+ * These schemas serve as the single source of truth for types that are
33
+ * stored in the settings-store backend and retrieved via tRPC. They
34
+ * replace the manual TypeScript interfaces with schema-derived types,
35
+ * enabling runtime validation when reading from the backend.
36
+ *
37
+ * Convention: each schema is named `<Type>Schema`, the inferred TS type
38
+ * keeps the original name for backward compatibility.
39
+ */
40
+ /**
41
+ * Auth model (v2 — 2026-05-12 caps-only):
42
+ *
43
+ * Two principals:
44
+ * - `isAdmin: true` — full bypass. Admin scope set is ignored.
45
+ * - `isAdmin: false` — every call gated by `scopes` (see TokenScope).
46
+ *
47
+ * No role enum. There used to be `viewer / agent / scoped` and earlier
48
+ * `super_admin` — collapsed onto the single boolean because every
49
+ * non-admin caller is governed by the same scope-check rules; the
50
+ * distinction was only ever used to route role-specific procedures
51
+ * which we no longer have. CLI / webhook integrations are tokens (`auth.mintToken`)
52
+ * with `isAdmin: false` + an explicit scope list.
53
+ */
54
+ /** Per-method access flavour. Materialised on every cap method via codegen. */
55
+ var MethodAccessSchema = /* @__PURE__ */ zod.z.enum([
56
+ "view",
57
+ "create",
58
+ "delete"
59
+ ]);
60
+ /**
61
+ * A single scope grant. Three forms — checked in matcher with OR
62
+ * semantics; the first match decides whether the call passes:
63
+ *
64
+ * - `category` — broadest. `target: 'device' | 'system'` selects every
65
+ * cap with the matching `scope` declaration. New caps inherit grants
66
+ * automatically — adding a device cap to the codebase makes it
67
+ * reachable to every user with `category:device [...]` without a
68
+ * re-grant. Use this for "family viewer" / "operator" tiers.
69
+ *
70
+ * - `addon` — every cap that ships inside a given addon id. Niche;
71
+ * useful when an integration needs to interact with one specific
72
+ * addon's surface regardless of how many caps it exports.
73
+ *
74
+ * - `capability` — the most precise form. Single cap name. Use for
75
+ * integration tokens where you want to grant `addons.installPackage`
76
+ * and nothing else.
77
+ *
78
+ * `access` is REQUIRED with min 1 element. `admin` bypass is the
79
+ * "give me everything" escape; there is no wildcard scope.
80
+ */
81
+ var AllowedProviderSchema = /* @__PURE__ */ zod.z.union([/* @__PURE__ */ zod.z.literal("*"), /* @__PURE__ */ zod.z.array(/* @__PURE__ */ zod.z.string())]);
82
+ var AllowedDevicesSchema = /* @__PURE__ */ zod.z.record(/* @__PURE__ */ zod.z.string(), /* @__PURE__ */ zod.z.union([/* @__PURE__ */ zod.z.literal("*"), /* @__PURE__ */ zod.z.array(/* @__PURE__ */ zod.z.string())]));
83
+ var CapScopeSchema = /* @__PURE__ */ zod.z.enum(["device", "system"]);
84
+ /**
85
+ * DeviceSelector (scope model v3 — 2026-08-12).
86
+ *
87
+ * A `device` grant no longer carries a frozen list of deviceIds. It carries
88
+ * a SELECTOR the matcher resolves against the live fleet, so the grant can be
89
+ * DYNAMIC: a `types:['camera']` selector automatically covers a camera added
90
+ * AFTER the grant was minted — no re-grant, no re-login.
91
+ *
92
+ * - `all` — every device in the deployment. The broad viewer/operator
93
+ * lever without a `category` grant (a `category` grant also covers device
94
+ * caps that carry no deviceId; `all` is specifically the device set).
95
+ * - `ids` — an explicit deviceId list. This is what a v2 `device:[…]`
96
+ * grant migrates to (see {@link TokenScopeSchema}); STATIC — a new camera
97
+ * is NOT covered until the grant is edited.
98
+ * - `types` — every device of a `DeviceType` (e.g. every `camera`).
99
+ * DYNAMIC. A device that changes type, or a new device of the type,
100
+ * re-resolves on the next request.
101
+ * - `locations` — every device whose operator-assigned `location` label is
102
+ * in the set (e.g. "Garden", "Front door"). DYNAMIC. A device with a
103
+ * null/unset location matches NO `locations` selector.
104
+ */
105
+ var DeviceSelectorSchema = /* @__PURE__ */ zod.z.discriminatedUnion("kind", [
106
+ /* @__PURE__ */ zod.z.object({ kind: /* @__PURE__ */ zod.z.literal("all") }),
107
+ /* @__PURE__ */ zod.z.object({
108
+ kind: /* @__PURE__ */ zod.z.literal("ids"),
109
+ ids: /* @__PURE__ */ zod.z.array(/* @__PURE__ */ zod.z.number().int()).min(1)
110
+ }),
111
+ /* @__PURE__ */ zod.z.object({
112
+ kind: /* @__PURE__ */ zod.z.literal("types"),
113
+ types: /* @__PURE__ */ zod.z.array(/* @__PURE__ */ zod.z.enum(require_device_type.DeviceType)).min(1)
114
+ }),
115
+ /* @__PURE__ */ zod.z.object({
116
+ kind: /* @__PURE__ */ zod.z.literal("locations"),
117
+ locations: /* @__PURE__ */ zod.z.array(/* @__PURE__ */ zod.z.string().min(1)).min(1)
118
+ })
119
+ ]);
120
+ var DeviceTokenScopeSchema = /* @__PURE__ */ zod.z.object({
121
+ type: /* @__PURE__ */ zod.z.literal("device"),
122
+ /** The device SET this grant covers — resolved against the live fleet. */
123
+ selector: DeviceSelectorSchema,
124
+ access: /* @__PURE__ */ zod.z.array(MethodAccessSchema).min(1),
125
+ /**
126
+ * Whether a grant on a PARENT device transparently covers its accessory
127
+ * CHILDREN (siren / floodlight / PIR) via the persisted-parentage walk.
128
+ * Direction is parent → children ONLY.
129
+ *
130
+ * Absent → the matcher DERIVES it from the access flavour: `view`
131
+ * inherits (a camera viewer sees the camera's accessories), `create` /
132
+ * `delete` do NOT (actuating/removing a child is an explicit act the
133
+ * operator must grant on the child, not inherit from the parent). Set it
134
+ * explicitly to override that default per grant.
135
+ */
136
+ includeLinked: /* @__PURE__ */ zod.z.boolean().optional()
137
+ });
138
+ /**
139
+ * v2 → v3 lazy migration. A pre-v3 `device` grant carried
140
+ * `targets: string[]` (stringified deviceIds); it rewrites to the equivalent
141
+ * `selector: {kind:'ids', ids}`. Applied as a `preprocess` so it runs on
142
+ * EVERY parse path — stored records AND the JWT-carried scope arrays
143
+ * normalised at the request boundary ({@link normalizeTokenScopes} in
144
+ * `device-selector.ts`). Chosen over a one-time DB migration because a
145
+ * migration cannot reach a JWT already in a client's hands; parse-time
146
+ * migration covers both without a flag day. No cast — the raw object is read
147
+ * through `Reflect.get` (its static type is `unknown`).
148
+ */
149
+ function migrateLegacyTokenScope(raw) {
150
+ if (raw === null || typeof raw !== "object" || Array.isArray(raw)) return raw;
151
+ if (Reflect.get(raw, "type") !== "device") return raw;
152
+ if (Reflect.get(raw, "selector") !== void 0) return canonicalSelectorTypes(raw);
153
+ const targets = Reflect.get(raw, "targets");
154
+ if (!Array.isArray(targets)) return raw;
155
+ return {
156
+ type: "device",
157
+ selector: {
158
+ kind: "ids",
159
+ ids: targets.map((t) => typeof t === "string" ? Number(t) : t).filter((n) => typeof n === "number" && Number.isInteger(n))
160
+ },
161
+ access: Reflect.get(raw, "access")
162
+ };
163
+ }
164
+ /**
165
+ * A stored `types` selector may name a type D1033 retired (`thermostat`). The
166
+ * grant is read back through this same preprocess, so the retired name is
167
+ * rewritten to its canonical type here and {@link DeviceSelectorSchema} itself
168
+ * stays a strict enum on the wire.
169
+ */
170
+ function canonicalSelectorTypes(raw) {
171
+ const selector = Reflect.get(raw, "selector");
172
+ if (selector === null || typeof selector !== "object") return raw;
173
+ if (Reflect.get(selector, "kind") !== "types") return raw;
174
+ const types = Reflect.get(selector, "types");
175
+ if (!Array.isArray(types)) return raw;
176
+ const canonical = types.map((t) => typeof t === "string" ? require_device_kind.canonicalStoredDeviceType(t) : t);
177
+ return {
178
+ ...raw,
179
+ selector: {
180
+ ...selector,
181
+ types: canonical
182
+ }
183
+ };
184
+ }
185
+ var TokenScopeSchema = /* @__PURE__ */ zod.z.preprocess(migrateLegacyTokenScope, /* @__PURE__ */ zod.z.discriminatedUnion("type", [
186
+ /* @__PURE__ */ zod.z.object({
187
+ type: /* @__PURE__ */ zod.z.literal("category"),
188
+ target: CapScopeSchema,
189
+ access: /* @__PURE__ */ zod.z.array(MethodAccessSchema).min(1)
190
+ }),
191
+ /* @__PURE__ */ zod.z.object({
192
+ type: /* @__PURE__ */ zod.z.literal("capability"),
193
+ target: /* @__PURE__ */ zod.z.string(),
194
+ access: /* @__PURE__ */ zod.z.array(MethodAccessSchema).min(1)
195
+ }),
196
+ /* @__PURE__ */ zod.z.object({
197
+ type: /* @__PURE__ */ zod.z.literal("addon"),
198
+ target: /* @__PURE__ */ zod.z.string(),
199
+ access: /* @__PURE__ */ zod.z.array(MethodAccessSchema).min(1)
200
+ }),
201
+ DeviceTokenScopeSchema
202
+ ]));
203
+ /**
204
+ * What a PERSON's grant set holds (D921): the capability rows above (legacy
205
+ * users, integration-style tokens) or the viewer row, which is decided by its
206
+ * own rules alone. Kept apart from {@link TokenScope} so every surface that
207
+ * edits capability rows (the scope picker, token minting) keeps its shape.
208
+ */
209
+ var UserScopeSchema = /* @__PURE__ */ zod.z.union([ViewerTokenScopeSchema, TokenScopeSchema]);
210
+ var UserRecordSchema = /* @__PURE__ */ zod.z.object({
211
+ id: /* @__PURE__ */ zod.z.string(),
212
+ username: /* @__PURE__ */ zod.z.string(),
213
+ passwordHash: /* @__PURE__ */ zod.z.string(),
214
+ /**
215
+ * Admin bypass. When true, the middleware skips the scope-access
216
+ * check entirely. There is no other axis of privilege; the legacy
217
+ * role enum collapsed onto this boolean in v2.
218
+ */
219
+ isAdmin: /* @__PURE__ */ zod.z.boolean().default(false),
220
+ allowedProviders: AllowedProviderSchema,
221
+ allowedDevices: AllowedDevicesSchema,
222
+ /**
223
+ * Scopes granted to this user. Admins bypass; their `scopes` is
224
+ * ignored. Non-admins without scopes are locked out of every
225
+ * protected call.
226
+ */
227
+ scopes: /* @__PURE__ */ zod.z.array(UserScopeSchema).default([]),
228
+ createdAt: /* @__PURE__ */ zod.z.number(),
229
+ updatedAt: /* @__PURE__ */ zod.z.number()
230
+ });
231
+ var ScopedTokenSchema = /* @__PURE__ */ zod.z.object({
232
+ id: /* @__PURE__ */ zod.z.string(),
233
+ userId: /* @__PURE__ */ zod.z.string(),
234
+ name: /* @__PURE__ */ zod.z.string(),
235
+ tokenHash: /* @__PURE__ */ zod.z.string(),
236
+ tokenPrefix: /* @__PURE__ */ zod.z.string(),
237
+ scopes: /* @__PURE__ */ zod.z.array(TokenScopeSchema),
238
+ expiresAt: /* @__PURE__ */ zod.z.number().nullish(),
239
+ lastUsedAt: /* @__PURE__ */ zod.z.number().nullish(),
240
+ createdAt: /* @__PURE__ */ zod.z.number()
241
+ });
242
+ //#endregion
243
+ //#region ../types/dist/esm/capabilities/auth-provider.cap.mjs
244
+ var AuthResultSchema = /* @__PURE__ */ zod.z.object({
245
+ userId: /* @__PURE__ */ zod.z.string(),
246
+ username: /* @__PURE__ */ zod.z.string(),
247
+ email: /* @__PURE__ */ zod.z.string().optional(),
248
+ displayName: /* @__PURE__ */ zod.z.string().optional(),
249
+ /**
250
+ * Whether the authenticating user is an admin. The auth-provider
251
+ * surface returns this so the server's login flow can mint a JWT
252
+ * with the correct bypass flag. Non-admin users authenticated via
253
+ * an external IdP still need their scopes assigned by an admin via
254
+ * `setUserScopes` — the SSO flow doesn't carry permissions.
255
+ */
256
+ isAdmin: /* @__PURE__ */ zod.z.boolean().default(false)
257
+ });
258
+ var authProviderCapability = {
259
+ name: "auth-provider",
260
+ scope: "system",
261
+ mode: "collection",
262
+ internal: true,
263
+ methods: {
264
+ validateCredentials: /* @__PURE__ */ require_capability_definition.method(/* @__PURE__ */ zod.z.object({
265
+ username: /* @__PURE__ */ zod.z.string(),
266
+ password: /* @__PURE__ */ zod.z.string()
267
+ }), /* @__PURE__ */ AuthResultSchema.nullable(), { kind: "mutation" }),
268
+ getLoginUrl: /* @__PURE__ */ require_capability_definition.method(/* @__PURE__ */ zod.z.object({ state: /* @__PURE__ */ zod.z.string() }), /* @__PURE__ */ zod.z.string()),
269
+ handleCallback: /* @__PURE__ */ require_capability_definition.method(/* @__PURE__ */ zod.z.record(/* @__PURE__ */ zod.z.string(), /* @__PURE__ */ zod.z.string()), AuthResultSchema, { kind: "mutation" }),
270
+ validateToken: /* @__PURE__ */ require_capability_definition.method(/* @__PURE__ */ zod.z.object({ token: /* @__PURE__ */ zod.z.string() }), /* @__PURE__ */ AuthResultSchema.nullable())
271
+ },
272
+ /** BIG PLAN 2: declarative mount hint — read by `@camstack/server/system` `buildCapRouters`. */
273
+ mount: { kind: "skip" },
274
+ vocabulary: { notOperatorFacing: require_system_reasons.NOT_A_DEVICE.IDENTITY }
275
+ };
276
+ //#endregion
277
+ //#region ../types/dist/esm/capabilities/device-credentials.cap.mjs
278
+ var DeviceCaStatusSchema = /* @__PURE__ */ zod.z.discriminatedUnion("state", [
279
+ /* @__PURE__ */ zod.z.object({ state: /* @__PURE__ */ zod.z.literal("absent") }),
280
+ /* @__PURE__ */ zod.z.object({
281
+ state: /* @__PURE__ */ zod.z.literal("ready"),
282
+ subject: /* @__PURE__ */ zod.z.string(),
283
+ fingerprintSha256: /* @__PURE__ */ zod.z.string(),
284
+ validTo: /* @__PURE__ */ zod.z.string()
285
+ }),
286
+ /* @__PURE__ */ zod.z.object({
287
+ state: /* @__PURE__ */ zod.z.literal("unavailable"),
288
+ reason: /* @__PURE__ */ zod.z.string()
289
+ })
290
+ ]);
291
+ var DeviceCertificateSettingsSchema = /* @__PURE__ */ zod.z.object({ selfEnrollment: /* @__PURE__ */ zod.z.enum(["allowed", "disabled"]) });
292
+ /**
293
+ * `device-credentials` — the admin surface of device certificates (D855).
294
+ *
295
+ * Everything a device does ITSELF — completing an enrollment, getting a
296
+ * challenge, signing in, renewing — is a PUBLIC procedure of the hub's `auth`
297
+ * router (`auth.completeEnrollment`, `getDeviceChallenge`,
298
+ * `loginWithDeviceCertificate`, `renewDeviceCertificate`): those legs are
299
+ * proofs of possession, not capability calls, and must not be reachable as
300
+ * cap methods. This cap holds only what an operator does about them.
301
+ *
302
+ * Provider: `local-auth`, which also owns the device CA and the registry.
303
+ * The hub is the only node that persists device credentials.
304
+ */
305
+ var deviceCredentialsCapability = {
306
+ name: "device-credentials",
307
+ scope: "system",
308
+ mode: "singleton",
309
+ methods: {
310
+ /**
311
+ * Every enrolled device, newest first; `userId` narrows to one user.
312
+ * `status` is derived: revoked wins over expired.
313
+ */
314
+ listDeviceCredentials: /* @__PURE__ */ require_capability_definition.method(/* @__PURE__ */ zod.z.object({
315
+ userId: /* @__PURE__ */ zod.z.string().min(1).optional(),
316
+ includeRevoked: /* @__PURE__ */ zod.z.boolean().default(false)
317
+ }), /* @__PURE__ */ zod.z.array(require_device_certificate.DeviceCredentialSchema).readonly(), { auth: "admin" }),
318
+ /**
319
+ * Mint a one-shot enrollment code for `userId` and a device name: 128-bit
320
+ * random, single use, 10 minutes, kept only as a hash. Returns the code
321
+ * once, with the `camstack://enroll?hub=…&code=…` link a QR carries.
322
+ * `caller` (the admin) is recorded in the audit trail.
323
+ */
324
+ startEnrollment: /* @__PURE__ */ require_capability_definition.method(/* @__PURE__ */ zod.z.object({
325
+ userId: /* @__PURE__ */ zod.z.string().min(1),
326
+ deviceName: /* @__PURE__ */ zod.z.string().min(1).max(80)
327
+ }), require_device_certificate.StartEnrollmentOutputSchema, {
328
+ kind: "mutation",
329
+ auth: "admin",
330
+ caller: "required"
331
+ }),
332
+ /**
333
+ * Revoke a credential: its certificate stops logging in at once, and every
334
+ * session it opened ends (an open session also dies at its next refresh
335
+ * even if this call raced it). Idempotent.
336
+ */
337
+ revokeDeviceCredential: /* @__PURE__ */ require_capability_definition.method(/* @__PURE__ */ zod.z.object({ id: /* @__PURE__ */ zod.z.string().min(1) }), /* @__PURE__ */ zod.z.object({
338
+ revoked: /* @__PURE__ */ zod.z.boolean(),
339
+ sessionsEnded: /* @__PURE__ */ zod.z.number().int(),
340
+ status: require_device_certificate.DeviceCredentialStatusSchema
341
+ }), {
342
+ kind: "mutation",
343
+ auth: "admin",
344
+ caller: "required"
345
+ }),
346
+ /**
347
+ * Hub-wide device-certificate settings. `selfEnrollment`: `allowed`
348
+ * (default) lets a signed-in user enroll their own device after a step-up
349
+ * sign-in; `disabled` makes `auth.enrollSelf` refuse. The admin QR path is
350
+ * unaffected. Hub-wide only (no per-role switch).
351
+ */
352
+ getDeviceCertificateSettings: /* @__PURE__ */ require_capability_definition.method(/* @__PURE__ */ zod.z.object({}), DeviceCertificateSettingsSchema, { auth: "admin" }),
353
+ setDeviceCertificateSettings: /* @__PURE__ */ require_capability_definition.method(DeviceCertificateSettingsSchema, DeviceCertificateSettingsSchema, {
354
+ kind: "mutation",
355
+ auth: "admin"
356
+ }),
357
+ /**
358
+ * Delete the registry row of a REVOKED credential (clean-up; the audit trail
359
+ * keeps the revocation). Refuses a live credential: revoke it first. After
360
+ * the row is gone the device's next call answers `unknown-credential`.
361
+ */
362
+ deleteDeviceCredential: /* @__PURE__ */ require_capability_definition.method(/* @__PURE__ */ zod.z.object({ id: /* @__PURE__ */ zod.z.string().min(1) }), /* @__PURE__ */ zod.z.object({ result: /* @__PURE__ */ zod.z.enum([
363
+ "deleted",
364
+ "live",
365
+ "unknown"
366
+ ]) }), {
367
+ kind: "mutation",
368
+ auth: "admin",
369
+ caller: "required"
370
+ }),
371
+ /**
372
+ * The device CA: `absent` until the first enrollment creates it (lazily,
373
+ * never rotated on boot), `unavailable` while the keychain cannot answer.
374
+ */
375
+ getDeviceCaStatus: /* @__PURE__ */ require_capability_definition.method(/* @__PURE__ */ zod.z.object({}), DeviceCaStatusSchema, { auth: "admin" }),
376
+ /** Rename a credential (the label only; the certificate is unchanged). */
377
+ renameDeviceCredential: /* @__PURE__ */ require_capability_definition.method(/* @__PURE__ */ zod.z.object({
378
+ id: /* @__PURE__ */ zod.z.string().min(1),
379
+ deviceName: /* @__PURE__ */ zod.z.string().min(1).max(80)
380
+ }), /* @__PURE__ */ zod.z.object({ renamed: /* @__PURE__ */ zod.z.boolean() }), {
381
+ kind: "mutation",
382
+ auth: "admin"
383
+ })
384
+ },
385
+ vocabulary: { notOperatorFacing: require_system_reasons.NOT_A_DEVICE.IDENTITY }
386
+ };
387
+ //#endregion
388
+ //#region ../types/dist/esm/capabilities/sso-bridge.cap.mjs
389
+ /**
390
+ * `sso-bridge` — internal hub-only cap that lets SSO-style auth
391
+ * providers (OIDC, SAML, …) mint an HMAC-signed token
392
+ * carrying the post-callback claims before redirecting back to
393
+ * `/api/auth/sso/finish`.
394
+ *
395
+ * Without this, any client could craft a `?isAdmin=1` link to
396
+ * `/sso/finish` and become admin. With it, the endpoint accepts ONLY
397
+ * the signed token and rejects everything else.
398
+ *
399
+ * Backed by `AuthManager.{signSsoBridgeToken,verifySsoBridgeToken}` —
400
+ * see `packages/core/src/auth/auth-manager.ts`. The provider is
401
+ * registered at hub boot in `server/backend/src/main.ts`.
402
+ */
403
+ var SsoBridgeClaimsSchema = /* @__PURE__ */ zod.z.object({
404
+ userId: /* @__PURE__ */ zod.z.string(),
405
+ username: /* @__PURE__ */ zod.z.string(),
406
+ isAdmin: /* @__PURE__ */ zod.z.boolean(),
407
+ provider: /* @__PURE__ */ zod.z.string(),
408
+ email: /* @__PURE__ */ zod.z.string().optional(),
409
+ displayName: /* @__PURE__ */ zod.z.string().optional(),
410
+ /**
411
+ * Public HTTPS URL of the hub that issued this token. Used by
412
+ * cloud-mode OAuth proxies (Alexa Smart Home Lambda, future Google
413
+ * Home Lambda) to route a request back to the originating hub
414
+ * without holding routing state of their own. The Lambda decodes the
415
+ * JWT WITHOUT verifying the signature — the hub re-verifies on every
416
+ * inbound call so trust still rests with the signing hub.
417
+ */
418
+ hubUrl: /* @__PURE__ */ zod.z.string().optional(),
419
+ /** Permission scopes baked into the token. Set by the OAuth
420
+ * account-linking grant; absent on ordinary SSO-login tokens. */
421
+ scopes: /* @__PURE__ */ zod.z.array(TokenScopeSchema).optional(),
422
+ /** OAuth authorization-code binding — set only on `oauth-code` tokens. */
423
+ redirectUri: /* @__PURE__ */ zod.z.string().optional(),
424
+ integrationId: /* @__PURE__ */ zod.z.string().optional(),
425
+ /**
426
+ * The integration INSTANCE an OAuth link was made for (planning#415). Set on
427
+ * `oauth-code`, `oauth-access` and `oauth-refresh` tokens of a link made
428
+ * with `instance=`; absent on a link to the default instance. A cloud relay
429
+ * reads it off the access token to route; the hub answers from the session.
430
+ */
431
+ instanceId: /* @__PURE__ */ zod.z.string().optional(),
432
+ /** JWT ID — unique per issued code; consumed-set enforces single-use. */
433
+ jti: /* @__PURE__ */ zod.z.string().optional(),
434
+ /** PKCE S256 challenge — set only on `oauth-code` tokens issued to a public
435
+ * client. Its PRESENCE is what makes the verifier mandatory at exchange,
436
+ * so the requirement travels with the code and not with mutable config. */
437
+ codeChallenge: /* @__PURE__ */ zod.z.string().optional(),
438
+ /** OAuth session registry id — set on `oauth-access`/`oauth-refresh`
439
+ * tokens so the verify path can check the session is not revoked. */
440
+ sessionId: /* @__PURE__ */ zod.z.string().optional(),
441
+ /**
442
+ * The refresh lifetime this LINK was created with, in seconds, or `'never'`.
443
+ * Baked into the code at `/authorize` from the integration's descriptor and
444
+ * carried forward so `oauthRefresh` re-mints with the same lifetime. It rides
445
+ * on the token rather than being re-read from the descriptor on purpose:
446
+ * editing a descriptor must not retroactively extend or shorten a link the
447
+ * operator already consented to.
448
+ */
449
+ refreshTtl: /* @__PURE__ */ zod.z.union([/* @__PURE__ */ zod.z.number().int().positive(), /* @__PURE__ */ zod.z.literal("never")]).optional(),
450
+ /**
451
+ * Opaque handle of a hub-side LINK intent (D782). Set by an OIDC callback
452
+ * that was started from a signed-in user's "Link" button: the finish then
453
+ * links this identity to the intent's user instead of signing anyone in.
454
+ * The handle carries no user id — the hub resolves it, single-use.
455
+ */
456
+ linkIntent: /* @__PURE__ */ zod.z.string().optional(),
457
+ /**
458
+ * Verified `iss` of the id_token behind an OIDC login bridge (D782). A
459
+ * subject is unique only per issuer, so a link is bound to it.
460
+ */
461
+ issuer: /* @__PURE__ */ zod.z.string().optional(),
462
+ /**
463
+ * SHA-256 (hex) of the `camstack_sso_state` cookie the IdP `/start` set in
464
+ * the browser that began this sign-in. `/api/auth/sso/finish` requires the
465
+ * request to present the matching cookie — a login bridge is useless in
466
+ * any other browser.
467
+ */
468
+ browserBinding: /* @__PURE__ */ zod.z.string().optional(),
469
+ /**
470
+ * The native app that started this sign-in (D858): its PKCE challenge,
471
+ * `state`, purpose and allow-listed return URL, copied from the server-side
472
+ * pending OIDC state. A bridge carrying it is finished ONLY at
473
+ * `/api/auth/sso/finish-app` (which mints a handoff code, never a web
474
+ * session); `/api/auth/sso/finish` refuses it.
475
+ */
476
+ app: /* @__PURE__ */ zod.z.object({
477
+ codeChallenge: /* @__PURE__ */ zod.z.string(),
478
+ state: /* @__PURE__ */ zod.z.string(),
479
+ purpose: /* @__PURE__ */ zod.z.enum(["new-session", "step-up"]),
480
+ redirect: /* @__PURE__ */ zod.z.string(),
481
+ /** The page language the app asked for (D858); the confirm page speaks it. */
482
+ lang: /* @__PURE__ */ zod.z.enum(["en", "it"]).optional()
483
+ }).optional()
484
+ });
485
+ var ssoBridgeCapability = {
486
+ name: "sso-bridge",
487
+ scope: "system",
488
+ mode: "singleton",
489
+ internal: true,
490
+ methods: {
491
+ /**
492
+ * `internal: true` did not gate the mount (see the 2026-08-26 note on
493
+ * `data-store-provider`) — `signBridgeToken` was reachable on the
494
+ * AppRouter by ANY authenticated session at the default
495
+ * `auth: 'protected'`. The claims (including `isAdmin`) are CALLER-
496
+ * SUPPLIED: an unprivileged session could have minted its own
497
+ * `isAdmin: true` bridge token and redeemed it at
498
+ * `/api/auth/sso/finish` to become admin — a full privilege escalation
499
+ * through the exact surface this cap exists to close (see the module
500
+ * docblock). Every real caller (`oauth-grants.ts`, `main.ts`
501
+ * registration, the OIDC addon) reaches this through
502
+ * `ctx.api` / the in-process registry — never through tRPC — so
503
+ * `auth: 'admin'` costs those callers nothing.
504
+ */
505
+ signBridgeToken: /* @__PURE__ */ require_capability_definition.method(/* @__PURE__ */ zod.z.object({
506
+ claims: SsoBridgeClaimsSchema,
507
+ /**
508
+ * Seconds, or `'never'` for a token minted with NO `exp` claim.
509
+ *
510
+ * `'never'` is a literal rather than `undefined`/`0` because omitting
511
+ * this field already means "the 5-minute SSO hand-off default", and
512
+ * `jwt.sign` THROWS on `{ expiresIn: undefined }` — a "no expiry" that
513
+ * went through the numeric path would fail at mint time and break
514
+ * linking rather than produce an eternal token.
515
+ */
516
+ ttlSec: /* @__PURE__ */ zod.z.union([/* @__PURE__ */ zod.z.number().int().positive(), /* @__PURE__ */ zod.z.literal("never")]).optional()
517
+ }), /* @__PURE__ */ zod.z.object({ token: /* @__PURE__ */ zod.z.string() }), { auth: "admin" }),
518
+ verifyBridgeToken: /* @__PURE__ */ require_capability_definition.method(/* @__PURE__ */ zod.z.object({ token: /* @__PURE__ */ zod.z.string() }), /* @__PURE__ */ SsoBridgeClaimsSchema.nullable(), { auth: "admin" })
519
+ },
520
+ vocabulary: { notOperatorFacing: require_system_reasons.NOT_A_DEVICE.IDENTITY }
521
+ };
522
+ //#endregion
523
+ //#region ../types/dist/esm/capabilities/user-management.cap.mjs
524
+ var UserSummarySchema = /* @__PURE__ */ zod.z.object({
525
+ id: /* @__PURE__ */ zod.z.string(),
526
+ username: /* @__PURE__ */ zod.z.string(),
527
+ isAdmin: /* @__PURE__ */ zod.z.boolean().default(false),
528
+ allowedProviders: /* @__PURE__ */ zod.z.union([/* @__PURE__ */ zod.z.array(/* @__PURE__ */ zod.z.string()), /* @__PURE__ */ zod.z.literal("*")]),
529
+ allowedDevices: /* @__PURE__ */ zod.z.record(/* @__PURE__ */ zod.z.string(), /* @__PURE__ */ zod.z.union([/* @__PURE__ */ zod.z.array(/* @__PURE__ */ zod.z.string()), /* @__PURE__ */ zod.z.literal("*")])),
530
+ /** Capability rows, or ONE viewer row (D921) — see `UserScopeSchema`. */
531
+ scopes: /* @__PURE__ */ zod.z.array(UserScopeSchema).default([]),
532
+ /**
533
+ * True iff this user has a CONFIRMED TOTP enrollment. Surfaced on
534
+ * `listUsers` so the admin Users page can render the "Remove 2FA"
535
+ * action conditionally without firing one `getTotpStatus` query per
536
+ * row. Self-service enrollment lives on the user's profile page.
537
+ */
538
+ totpEnabled: /* @__PURE__ */ zod.z.boolean().default(false),
539
+ createdAt: /* @__PURE__ */ zod.z.number(),
540
+ updatedAt: /* @__PURE__ */ zod.z.number()
541
+ });
542
+ var CreateUserInputSchema = /* @__PURE__ */ zod.z.object({
543
+ username: /* @__PURE__ */ zod.z.string(),
544
+ password: /* @__PURE__ */ zod.z.string().min(6),
545
+ isAdmin: /* @__PURE__ */ zod.z.boolean().default(false),
546
+ allowedProviders: /* @__PURE__ */ zod.z.union([/* @__PURE__ */ zod.z.array(/* @__PURE__ */ zod.z.string()), /* @__PURE__ */ zod.z.literal("*")]).optional(),
547
+ allowedDevices: /* @__PURE__ */ zod.z.record(/* @__PURE__ */ zod.z.string(), /* @__PURE__ */ zod.z.union([/* @__PURE__ */ zod.z.array(/* @__PURE__ */ zod.z.string()), /* @__PURE__ */ zod.z.literal("*")])).optional(),
548
+ scopes: /* @__PURE__ */ zod.z.array(UserScopeSchema).optional()
549
+ });
550
+ var UpdateUserInputSchema = /* @__PURE__ */ zod.z.object({
551
+ id: /* @__PURE__ */ zod.z.string(),
552
+ isAdmin: /* @__PURE__ */ zod.z.boolean().optional(),
553
+ allowedProviders: /* @__PURE__ */ zod.z.union([/* @__PURE__ */ zod.z.array(/* @__PURE__ */ zod.z.string()), /* @__PURE__ */ zod.z.literal("*")]).optional(),
554
+ allowedDevices: /* @__PURE__ */ zod.z.record(/* @__PURE__ */ zod.z.string(), /* @__PURE__ */ zod.z.union([/* @__PURE__ */ zod.z.array(/* @__PURE__ */ zod.z.string()), /* @__PURE__ */ zod.z.literal("*")])).optional(),
555
+ scopes: /* @__PURE__ */ zod.z.array(UserScopeSchema).optional()
556
+ });
557
+ var OauthSessionSummarySchema = /* @__PURE__ */ zod.z.object({
558
+ id: /* @__PURE__ */ zod.z.string(),
559
+ userId: /* @__PURE__ */ zod.z.string(),
560
+ username: /* @__PURE__ */ zod.z.string(),
561
+ integrationId: /* @__PURE__ */ zod.z.string(),
562
+ /** The instance the link was made for; `null` = the default instance. */
563
+ instanceId: /* @__PURE__ */ zod.z.string().nullable().optional(),
564
+ scopes: /* @__PURE__ */ zod.z.array(TokenScopeSchema),
565
+ createdAt: /* @__PURE__ */ zod.z.number(),
566
+ lastUsedAt: /* @__PURE__ */ zod.z.number(),
567
+ revokedAt: /* @__PURE__ */ zod.z.number().nullable()
568
+ });
569
+ var TotpSetupResultSchema = /* @__PURE__ */ zod.z.object({
570
+ secret: /* @__PURE__ */ zod.z.string(),
571
+ otpauthUrl: /* @__PURE__ */ zod.z.string()
572
+ });
573
+ var TotpStatusSchema = /* @__PURE__ */ zod.z.object({
574
+ /** True iff `confirmedAt != null` — a pending half-enrollment is reported as `enabled: false`. */
575
+ enabled: /* @__PURE__ */ zod.z.boolean(),
576
+ /** Null when no row exists OR the row is still pending confirmation. */
577
+ confirmedAt: /* @__PURE__ */ zod.z.number().nullable()
578
+ });
579
+ /**
580
+ * user-management — singleton capability for user accounts.
581
+ *
582
+ * v2 model: every method gated by `auth: 'admin'`. Admin-only delegation
583
+ * — the subset check on `setUserScopes` is moot
584
+ * because non-admins never reach these. If/when we open non-admin
585
+ * delegation, structural caller-scope subset check goes inside the
586
+ * provider.
587
+ */
588
+ var ExternalIdentitySchema = /* @__PURE__ */ zod.z.object({
589
+ /** Login-method id of the provider instance, e.g. `auth-oidc/authentik`. */
590
+ provider: /* @__PURE__ */ zod.z.string(),
591
+ /** The IdP's stable subject (`sub`) for this account. */
592
+ subject: /* @__PURE__ */ zod.z.string(),
593
+ /** The verified `iss` of the IdP the identity was linked under — `sub` is unique only per issuer. */
594
+ issuer: /* @__PURE__ */ zod.z.string(),
595
+ userId: /* @__PURE__ */ zod.z.string(),
596
+ /** What the IdP called the account at link time (username / email) — display only. */
597
+ label: /* @__PURE__ */ zod.z.string().optional(),
598
+ linkedAt: /* @__PURE__ */ zod.z.number()
599
+ });
600
+ var ExternalIdentityKeySchema = /* @__PURE__ */ zod.z.object({
601
+ provider: /* @__PURE__ */ zod.z.string().min(1),
602
+ subject: /* @__PURE__ */ zod.z.string().min(1)
603
+ });
604
+ var userManagementCapability = {
605
+ name: "user-management",
606
+ scope: "system",
607
+ mode: "singleton",
608
+ methods: {
609
+ listUsers: /* @__PURE__ */ require_capability_definition.method(/* @__PURE__ */ zod.z.void(), /* @__PURE__ */ zod.z.array(UserSummarySchema), { auth: "admin" }),
610
+ /**
611
+ * Read-only: does an admin account still carry the first-boot password
612
+ * (D728, D797)? One typed boolean; the password and its hash never leave
613
+ * the hub. Backs the `setup_wizard` admin step.
614
+ */
615
+ getAdminBootstrapStatus: /* @__PURE__ */ require_capability_definition.method(/* @__PURE__ */ zod.z.void(), /* @__PURE__ */ zod.z.object({ defaultPasswordInUse: /* @__PURE__ */ zod.z.boolean() }), { auth: "admin" }),
616
+ createUser: /* @__PURE__ */ require_capability_definition.method(CreateUserInputSchema, UserSummarySchema, {
617
+ kind: "mutation",
618
+ auth: "admin",
619
+ access: "create"
620
+ }),
621
+ updateUser: /* @__PURE__ */ require_capability_definition.method(UpdateUserInputSchema, /* @__PURE__ */ zod.z.object({ success: /* @__PURE__ */ zod.z.literal(true) }), {
622
+ kind: "mutation",
623
+ auth: "admin",
624
+ access: "create"
625
+ }),
626
+ deleteUser: /* @__PURE__ */ require_capability_definition.method(/* @__PURE__ */ zod.z.object({ id: /* @__PURE__ */ zod.z.string() }), /* @__PURE__ */ zod.z.object({ success: /* @__PURE__ */ zod.z.literal(true) }), {
627
+ kind: "mutation",
628
+ auth: "admin",
629
+ access: "delete"
630
+ }),
631
+ resetPassword: /* @__PURE__ */ require_capability_definition.method(/* @__PURE__ */ zod.z.object({
632
+ id: /* @__PURE__ */ zod.z.string(),
633
+ newPassword: /* @__PURE__ */ zod.z.string().min(6)
634
+ }), /* @__PURE__ */ zod.z.object({ success: /* @__PURE__ */ zod.z.literal(true) }), {
635
+ kind: "mutation",
636
+ auth: "admin",
637
+ access: "create"
638
+ }),
639
+ setUserScopes: /* @__PURE__ */ require_capability_definition.method(/* @__PURE__ */ zod.z.object({
640
+ userId: /* @__PURE__ */ zod.z.string(),
641
+ scopes: /* @__PURE__ */ zod.z.array(UserScopeSchema)
642
+ }), /* @__PURE__ */ zod.z.object({ success: /* @__PURE__ */ zod.z.literal(true) }), {
643
+ kind: "mutation",
644
+ auth: "admin",
645
+ access: "create"
646
+ }),
647
+ validateCredentials: /* @__PURE__ */ require_capability_definition.method(/* @__PURE__ */ zod.z.object({
648
+ username: /* @__PURE__ */ zod.z.string(),
649
+ password: /* @__PURE__ */ zod.z.string()
650
+ }), /* @__PURE__ */ UserSummarySchema.extend({ passwordHash: /* @__PURE__ */ zod.z.string() }).nullable(), {
651
+ kind: "mutation",
652
+ access: "view"
653
+ }),
654
+ setupTotp: /* @__PURE__ */ require_capability_definition.method(/* @__PURE__ */ zod.z.object({ userId: /* @__PURE__ */ zod.z.string() }), TotpSetupResultSchema, {
655
+ kind: "mutation",
656
+ auth: "admin",
657
+ access: "create"
658
+ }),
659
+ confirmTotp: /* @__PURE__ */ require_capability_definition.method(/* @__PURE__ */ zod.z.object({
660
+ userId: /* @__PURE__ */ zod.z.string(),
661
+ code: /* @__PURE__ */ zod.z.string()
662
+ }), /* @__PURE__ */ zod.z.object({ success: /* @__PURE__ */ zod.z.literal(true) }), {
663
+ kind: "mutation",
664
+ auth: "admin",
665
+ access: "create"
666
+ }),
667
+ disableTotp: /* @__PURE__ */ require_capability_definition.method(/* @__PURE__ */ zod.z.object({ userId: /* @__PURE__ */ zod.z.string() }), /* @__PURE__ */ zod.z.object({ success: /* @__PURE__ */ zod.z.literal(true) }), {
668
+ kind: "mutation",
669
+ auth: "admin",
670
+ access: "delete"
671
+ }),
672
+ getTotpStatus: /* @__PURE__ */ require_capability_definition.method(/* @__PURE__ */ zod.z.object({ userId: /* @__PURE__ */ zod.z.string() }), TotpStatusSchema, { auth: "admin" }),
673
+ /**
674
+ * D878: move every TOTP seed stored in plaintext into the keychain (owner
675
+ * `system`), leaving a marker in the row. Dry run unless `apply`;
676
+ * idempotent; counts only.
677
+ */
678
+ migrateRawSecrets: /* @__PURE__ */ require_capability_definition.method(require_raw_secret_migration.RawSecretMigrationInputSchema, require_raw_secret_migration.RawSecretMigrationReportSchema, {
679
+ kind: "mutation",
680
+ auth: "admin",
681
+ access: "create"
682
+ }),
683
+ verifyTotp: /* @__PURE__ */ require_capability_definition.method(/* @__PURE__ */ zod.z.object({
684
+ userId: /* @__PURE__ */ zod.z.string(),
685
+ code: /* @__PURE__ */ zod.z.string()
686
+ }), /* @__PURE__ */ zod.z.object({ valid: /* @__PURE__ */ zod.z.boolean() }), {
687
+ kind: "mutation",
688
+ access: "view"
689
+ }),
690
+ oauthIssueCode: /* @__PURE__ */ require_capability_definition.method(/* @__PURE__ */ zod.z.object({
691
+ integrationId: /* @__PURE__ */ zod.z.string(),
692
+ /** The integration instance the link is for. Omit for the default
693
+ * instance — never pass the addon id to mean it. */
694
+ instanceId: /* @__PURE__ */ zod.z.string().optional(),
695
+ userId: /* @__PURE__ */ zod.z.string(),
696
+ username: /* @__PURE__ */ zod.z.string(),
697
+ scopes: /* @__PURE__ */ zod.z.array(TokenScopeSchema),
698
+ redirectUri: /* @__PURE__ */ zod.z.string(),
699
+ hubUrl: /* @__PURE__ */ zod.z.string(),
700
+ /** PKCE (RFC 7636) S256 challenge. Baked into the signed code; a code
701
+ * that carries one can ONLY be exchanged with the matching verifier. */
702
+ codeChallenge: /* @__PURE__ */ zod.z.string().optional(),
703
+ /** The integration's declared refresh lifetime — seconds, or `'never'`.
704
+ * From `OauthIntegrationDescriptor.refreshTokenTtlSec`. Baked into the
705
+ * code so the link carries its own lifetime; omit for the 30-day
706
+ * default. */
707
+ refreshTtlSec: /* @__PURE__ */ zod.z.union([/* @__PURE__ */ zod.z.number().int().positive(), /* @__PURE__ */ zod.z.literal("never")]).optional()
708
+ }), /* @__PURE__ */ zod.z.object({ code: /* @__PURE__ */ zod.z.string() }), {
709
+ kind: "mutation",
710
+ access: "create"
711
+ }),
712
+ oauthExchangeCode: /* @__PURE__ */ require_capability_definition.method(/* @__PURE__ */ zod.z.object({
713
+ code: /* @__PURE__ */ zod.z.string(),
714
+ redirectUri: /* @__PURE__ */ zod.z.string(),
715
+ /** PKCE verifier. REQUIRED when the code carries a challenge. */
716
+ codeVerifier: /* @__PURE__ */ zod.z.string().optional()
717
+ }), /* @__PURE__ */ zod.z.object({
718
+ accessToken: /* @__PURE__ */ zod.z.string(),
719
+ refreshToken: /* @__PURE__ */ zod.z.string(),
720
+ expiresIn: /* @__PURE__ */ zod.z.number()
721
+ }).nullable(), {
722
+ kind: "mutation",
723
+ access: "view"
724
+ }),
725
+ oauthRefresh: /* @__PURE__ */ require_capability_definition.method(/* @__PURE__ */ zod.z.object({ refreshToken: /* @__PURE__ */ zod.z.string() }), /* @__PURE__ */ zod.z.object({
726
+ accessToken: /* @__PURE__ */ zod.z.string(),
727
+ refreshToken: /* @__PURE__ */ zod.z.string(),
728
+ expiresIn: /* @__PURE__ */ zod.z.number()
729
+ }).nullable(), {
730
+ kind: "mutation",
731
+ access: "view"
732
+ }),
733
+ oauthVerifyAccessToken: /* @__PURE__ */ require_capability_definition.method(/* @__PURE__ */ zod.z.object({ token: /* @__PURE__ */ zod.z.string() }), /* @__PURE__ */ zod.z.object({
734
+ userId: /* @__PURE__ */ zod.z.string(),
735
+ username: /* @__PURE__ */ zod.z.string(),
736
+ scopes: /* @__PURE__ */ zod.z.array(TokenScopeSchema),
737
+ /** The instance the link was made for, read from the SESSION.
738
+ * Absent = the default instance. `oauthLinkServesInstance` is the
739
+ * helper a per-instance route calls to compare it with the instance
740
+ * of its path; no route declares `perInstance` yet (the Alexa
741
+ * per-instance route, T3, is the first consumer). */
742
+ instanceId: /* @__PURE__ */ zod.z.string().optional()
743
+ }).nullable(), { access: "view" }),
744
+ listExternalIdentities: /* @__PURE__ */ require_capability_definition.method(/* @__PURE__ */ zod.z.object({ userId: /* @__PURE__ */ zod.z.string() }), /* @__PURE__ */ zod.z.array(ExternalIdentitySchema), { auth: "admin" }),
745
+ /** The user an identity is linked to, or `null`. */
746
+ findUserByExternalIdentity: /* @__PURE__ */ require_capability_definition.method(ExternalIdentityKeySchema, /* @__PURE__ */ zod.z.object({
747
+ userId: /* @__PURE__ */ zod.z.string(),
748
+ issuer: /* @__PURE__ */ zod.z.string()
749
+ }).nullable(), { auth: "admin" }),
750
+ /** Remove one link of `userId`. `success: false` when it was not linked to that user. */
751
+ unlinkExternalIdentity: /* @__PURE__ */ require_capability_definition.method(/* @__PURE__ */ ExternalIdentityKeySchema.extend({ userId: /* @__PURE__ */ zod.z.string() }), /* @__PURE__ */ zod.z.object({ success: /* @__PURE__ */ zod.z.boolean() }), {
752
+ kind: "mutation",
753
+ auth: "admin",
754
+ access: "delete"
755
+ }),
756
+ listOauthSessions: /* @__PURE__ */ require_capability_definition.method(/* @__PURE__ */ zod.z.void(), /* @__PURE__ */ zod.z.array(OauthSessionSummarySchema), { auth: "admin" }),
757
+ revokeOauthSession: /* @__PURE__ */ require_capability_definition.method(/* @__PURE__ */ zod.z.object({ id: /* @__PURE__ */ zod.z.string() }), /* @__PURE__ */ zod.z.object({ success: /* @__PURE__ */ zod.z.boolean() }), {
758
+ kind: "mutation",
759
+ auth: "admin",
760
+ access: "delete"
761
+ })
762
+ },
763
+ vocabulary: { notOperatorFacing: require_system_reasons.NOT_A_DEVICE.IDENTITY }
764
+ };
765
+ //#endregion
766
+ Object.defineProperty(exports, "MethodAccessSchema", {
767
+ enumerable: true,
768
+ get: function() {
769
+ return MethodAccessSchema;
770
+ }
771
+ });
772
+ Object.defineProperty(exports, "ScopedTokenSchema", {
773
+ enumerable: true,
774
+ get: function() {
775
+ return ScopedTokenSchema;
776
+ }
777
+ });
778
+ Object.defineProperty(exports, "SsoBridgeClaimsSchema", {
779
+ enumerable: true,
780
+ get: function() {
781
+ return SsoBridgeClaimsSchema;
782
+ }
783
+ });
784
+ Object.defineProperty(exports, "TokenScopeSchema", {
785
+ enumerable: true,
786
+ get: function() {
787
+ return TokenScopeSchema;
788
+ }
789
+ });
790
+ Object.defineProperty(exports, "UserRecordSchema", {
791
+ enumerable: true,
792
+ get: function() {
793
+ return UserRecordSchema;
794
+ }
795
+ });
796
+ Object.defineProperty(exports, "ViewerTokenScopeSchema", {
797
+ enumerable: true,
798
+ get: function() {
799
+ return ViewerTokenScopeSchema;
800
+ }
801
+ });
802
+ Object.defineProperty(exports, "authProviderCapability", {
803
+ enumerable: true,
804
+ get: function() {
805
+ return authProviderCapability;
806
+ }
807
+ });
808
+ Object.defineProperty(exports, "deviceCredentialsCapability", {
809
+ enumerable: true,
810
+ get: function() {
811
+ return deviceCredentialsCapability;
812
+ }
813
+ });
814
+ Object.defineProperty(exports, "ssoBridgeCapability", {
815
+ enumerable: true,
816
+ get: function() {
817
+ return ssoBridgeCapability;
818
+ }
819
+ });
820
+ Object.defineProperty(exports, "userManagementCapability", {
821
+ enumerable: true,
822
+ get: function() {
823
+ return userManagementCapability;
824
+ }
825
+ });