@camstack/server 1.2.818 → 1.2.820

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 (100) hide show
  1. package/CHANGELOG.md +28 -0
  2. package/dist/api/core/cap-providers.js +32 -40
  3. package/dist/api/trpc/cap-route-error-formatter.js +19 -1
  4. package/dist/api/trpc/cap-router-runtime.js +23 -0
  5. package/dist/api/trpc/device-config-secret-redaction.js +1 -2
  6. package/dist/api/trpc/generated-cap-routers.js +13 -27
  7. package/dist/api/trpc/localized-schema-paths.js +1 -1
  8. package/dist/api/trpc/trpc.router.js +1 -1
  9. package/dist/core/addon/addon-registry.service.js +2 -2
  10. package/dist/core/addon/addon-settings-provider.js +0 -23
  11. package/dist/core/addon/instance-lifecycle.js +44 -7
  12. package/package.json +27 -14
  13. package/system/dist/addon-runner.js +0 -1
  14. package/system/dist/addon-runner.mjs +0 -1
  15. package/system/dist/{agent-https-ChriyNA8.js → agent-https-CbysxRlV.js} +1 -1
  16. package/system/dist/{agent-https-rhOY61af.mjs → agent-https-XHjvcSEq.mjs} +1 -1
  17. package/system/dist/builtins/addon-pages-aggregator/addon-pages-aggregator.addon.js +1 -1
  18. package/system/dist/builtins/addon-pages-aggregator/addon-pages-aggregator.addon.mjs +1 -1
  19. package/system/dist/builtins/addon-widgets-aggregator/addon-widgets-aggregator.addon.js +1 -1
  20. package/system/dist/builtins/addon-widgets-aggregator/addon-widgets-aggregator.addon.mjs +1 -1
  21. package/system/dist/builtins/alerts/alerts.addon.js +1 -1
  22. package/system/dist/builtins/alerts/alerts.addon.mjs +1 -1
  23. package/system/dist/builtins/autotrack/index.js +1 -1
  24. package/system/dist/builtins/autotrack/index.mjs +1 -1
  25. package/system/dist/builtins/backup-orchestrator/backup-orchestrator.addon.js +2 -2
  26. package/system/dist/builtins/backup-orchestrator/backup-orchestrator.addon.mjs +2 -2
  27. package/system/dist/builtins/calendars/calendars.addon.js +1 -1
  28. package/system/dist/builtins/calendars/calendars.addon.mjs +1 -1
  29. package/system/dist/builtins/camera-grid/index.js +1 -1
  30. package/system/dist/builtins/camera-grid/index.mjs +1 -1
  31. package/system/dist/builtins/composer/composer.addon.js +3 -3
  32. package/system/dist/builtins/composer/composer.addon.mjs +3 -3
  33. package/system/dist/builtins/console-logging/index.js +1 -1
  34. package/system/dist/builtins/console-logging/index.mjs +1 -1
  35. package/system/dist/builtins/core-blocks/blocks-instances.d.ts +2 -2
  36. package/system/dist/builtins/core-blocks/core-blocks.addon.js +5 -5
  37. package/system/dist/builtins/core-blocks/core-blocks.addon.mjs +3 -3
  38. package/system/dist/builtins/device-history/device-history.addon.js +2 -2
  39. package/system/dist/builtins/device-history/device-history.addon.mjs +2 -2
  40. package/system/dist/builtins/device-manager/device-manager.addon.js +1 -1
  41. package/system/dist/builtins/device-manager/device-manager.addon.mjs +1 -1
  42. package/system/dist/builtins/hub-forwarder/index.js +1 -1
  43. package/system/dist/builtins/hub-forwarder/index.mjs +1 -1
  44. package/system/dist/builtins/keychain/index.js +4 -4
  45. package/system/dist/builtins/keychain/index.mjs +4 -4
  46. package/system/dist/builtins/liveness-monitor/liveness-monitor.addon.js +1 -1
  47. package/system/dist/builtins/liveness-monitor/liveness-monitor.addon.mjs +1 -1
  48. package/system/dist/builtins/local-auth/local-auth.addon.js +2 -2
  49. package/system/dist/builtins/local-auth/local-auth.addon.mjs +2 -2
  50. package/system/dist/builtins/local-network/local-network.addon.js +2 -2
  51. package/system/dist/builtins/local-network/local-network.addon.mjs +2 -2
  52. package/system/dist/builtins/loki-logging/index.js +1 -1
  53. package/system/dist/builtins/loki-logging/index.mjs +1 -1
  54. package/system/dist/builtins/native-metrics/native-metrics.addon.js +1 -1
  55. package/system/dist/builtins/native-metrics/native-metrics.addon.mjs +1 -1
  56. package/system/dist/builtins/platform-probe/index.js +1 -1
  57. package/system/dist/builtins/platform-probe/index.mjs +1 -1
  58. package/system/dist/builtins/record-entries/index.js +1 -1
  59. package/system/dist/builtins/record-entries/index.mjs +1 -1
  60. package/system/dist/builtins/remote-access-orchestrator/remote-access-orchestrator.addon.js +1 -1
  61. package/system/dist/builtins/remote-access-orchestrator/remote-access-orchestrator.addon.mjs +1 -1
  62. package/system/dist/builtins/snapshot/index.js +1 -1
  63. package/system/dist/builtins/snapshot/index.mjs +1 -1
  64. package/system/dist/builtins/sqlite-storage/filesystem-storage.addon.js +1 -1
  65. package/system/dist/builtins/sqlite-storage/filesystem-storage.addon.mjs +1 -1
  66. package/system/dist/builtins/sqlite-storage/index.js +1 -1
  67. package/system/dist/builtins/sqlite-storage/index.mjs +1 -1
  68. package/system/dist/builtins/sqlite-storage/sqlite-settings.addon.js +3 -3
  69. package/system/dist/builtins/sqlite-storage/sqlite-settings.addon.mjs +3 -3
  70. package/system/dist/builtins/storage-orchestrator/storage-orchestrator.addon.js +1 -1
  71. package/system/dist/builtins/storage-orchestrator/storage-orchestrator.addon.mjs +1 -1
  72. package/system/dist/builtins/system-config/system-config.addon.js +3 -3
  73. package/system/dist/builtins/system-config/system-config.addon.mjs +3 -3
  74. package/system/dist/builtins/winston-logging/index.js +1 -1
  75. package/system/dist/builtins/winston-logging/index.mjs +1 -1
  76. package/system/dist/{capture-engine-Cgt1r0h5.js → capture-engine-CKtkENOg.js} +1 -1
  77. package/system/dist/{capture-engine-CoK1n1F1.mjs → capture-engine-WSpdP-gE.mjs} +1 -1
  78. package/system/dist/{composition-sources-TkHq8DdF.js → composition-sources-6Qx72gmK.js} +1 -1
  79. package/system/dist/{composition-sources-DSU28FFP.mjs → composition-sources-Dr6uwBGw.mjs} +1 -1
  80. package/system/dist/{constants-D3mNibfv.js → constants-BchSDmTD.js} +1 -1
  81. package/system/dist/{constants-CCezBXPq.mjs → constants-URzk8siY.mjs} +1 -1
  82. package/system/dist/{device-ca-CjX1tQP7.mjs → device-ca-Bu1E5Vgr.mjs} +1 -1
  83. package/system/dist/{device-ca-CEzeY_zI.js → device-ca-kANxsBE5.js} +1 -1
  84. package/system/dist/{dist-BNBgsEk0.mjs → dist-C0Df8iJl.mjs} +91 -126
  85. package/system/dist/{dist-DX1gyM8o.js → dist-R_mOSFtH.js} +91 -126
  86. package/system/dist/file-host-worker.js +1 -1
  87. package/system/dist/file-host-worker.mjs +1 -1
  88. package/system/dist/{hub-mdns-ciao-DBHvpWvv.js → hub-mdns-ciao-2AZ3ucDO.js} +2 -2
  89. package/system/dist/{hub-mdns-ciao-BCfG7mv3.mjs → hub-mdns-ciao-pxgLcmqO.mjs} +2 -2
  90. package/system/dist/index.js +40 -11
  91. package/system/dist/index.mjs +40 -11
  92. package/system/dist/kernel/cap-router-builder.d.ts +9 -0
  93. package/system/dist/kernel/transport/child-cap-protocol.d.ts +1 -1
  94. package/system/dist/{legacy-integration-rows-door-C0X4Ijcr.mjs → legacy-integration-rows-door-Cj58BS60.mjs} +1 -1
  95. package/system/dist/{legacy-integration-rows-door-7K4_MoAP.js → legacy-integration-rows-door-g4CeLJ9g.js} +1 -1
  96. package/system/dist/{restore-archive-WBDJlios.mjs → restore-archive-Bd7fgVo8.mjs} +1 -1
  97. package/system/dist/{restore-archive-DXlN0NYx.js → restore-archive-CAh7u-rY.js} +1 -1
  98. package/system/dist/{wal-maintenance-BPmo2JzY.js → wal-maintenance--0liHBxL.js} +0 -0
  99. package/system/dist/{wal-maintenance-BJ0vDek1.mjs → wal-maintenance-DMf2oEQ-.mjs} +0 -0
  100. package/system/package.json +1 -1
@@ -1211,7 +1211,7 @@ var DeviceRole = /* @__PURE__ */ function(DeviceRole) {
1211
1211
  return DeviceRole;
1212
1212
  }({});
1213
1213
  //#endregion
1214
- //#region ../types/dist/sleep-CS5Xp1iQ.mjs
1214
+ //#region ../types/dist/sleep-CkinsFFb.mjs
1215
1215
  /**
1216
1216
  * The audio chunk plane's byte format, and the ONE expansion from a coded
1217
1217
  * window to float samples (D455).
@@ -4080,16 +4080,6 @@ var BaseAddon = class {
4080
4080
  return null;
4081
4081
  }
4082
4082
  /**
4083
- * The form schema of ONE integration instance, or `null` to use the scoped form.
4084
- *
4085
- * Override it only when an `instanceMode: multiple` addon's instances differ: an NVR integration
4086
- * needs its connection fields, the default integration the addon's own sections. It is the
4087
- * SHAPE of the form only — the values live on the instance record.
4088
- */
4089
- async integrationFormSchema(_instance) {
4090
- return null;
4091
- }
4092
- /**
4093
4083
  * D986 scoped settings: the form shape of the CLUSTER-wide settings one capability this addon
4094
4084
  * provides owns, or `null` when it has none. `cap` is a capability name the addon's manifest
4095
4085
  * declares. Stored as `addon-settings` rows `<addonId>.<field>`. The keys of this schema, of
@@ -4117,8 +4107,7 @@ var BaseAddon = class {
4117
4107
  }
4118
4108
  /**
4119
4109
  * The host's read of the scoped declarations: the schema one capability declares for `scope`,
4120
- * or `null`. Beside {@link getIntegrationFormSchema}, the same shape: the hook is protected, the
4121
- * host asks this method.
4110
+ * or `null`. The hook is protected, the host asks this method.
4122
4111
  */
4123
4112
  async getScopedSettingsSchema(scope, cap) {
4124
4113
  switch (scope) {
@@ -4286,22 +4275,6 @@ var BaseAddon = class {
4286
4275
  return Object.fromEntries([...collectHydratedFieldValues(form)].filter(([, value]) => value !== void 0));
4287
4276
  }
4288
4277
  /**
4289
- * What the create wizard and the integration edit page render for one instance: the addon's
4290
- * per-instance schema when it declares one, else its global schema (what they always showed).
4291
- */
4292
- async getIntegrationFormSchema(instance, nodeId) {
4293
- const scoped = await this.integrationFormSchema(instance);
4294
- if (scoped === null) return this.scopedForm(nodeId);
4295
- return hydrateSchema(scoped, {}, { inlineSecretsAsViews: true });
4296
- }
4297
- /** The form of the scoped schemas this addon declared, hydrated from its store. */
4298
- async scopedForm(nodeId) {
4299
- await this.loadScopedSchemas();
4300
- const schema = this.scopedFormSchema();
4301
- if (!schema) return { sections: [] };
4302
- return hydrateSchema(schema, await this.readRawProjectedStore(nodeId), { inlineSecretsAsViews: true });
4303
- }
4304
- /**
4305
4278
  * The raw addon store PROJECTED onto the target node's bare per-node keys:
4306
4279
  * every `perNode: true` field carries THAT node's scoped value on its bare
4307
4280
  * key (absent scoped key ⇒ key absent, so the schema `default` wins — no
@@ -4488,12 +4461,6 @@ var BaseAddon = class {
4488
4461
  this._nodeKeysByCap = /* @__PURE__ */ new Map();
4489
4462
  this._addonSecretTree = null;
4490
4463
  }
4491
- /** The form of an addon's scoped schemas: their sections, each shown once. */
4492
- scopedFormSchema(cap) {
4493
- const byId = /* @__PURE__ */ new Map();
4494
- for (const entry of this.loadedScopedSchemas(cap)) for (const section of entry.schema.sections) if (!byId.has(section.id)) byId.set(section.id, section);
4495
- return byId.size === 0 ? null : { sections: [...byId.values()] };
4496
- }
4497
4464
  /** Every loaded scoped schema of `cap`, or of every loaded capability. */
4498
4465
  loadedScopedSchemas(cap) {
4499
4466
  if (cap !== void 0) return this._scopedByCap.get(cap) ?? [];
@@ -5083,6 +5050,35 @@ function normalizeAddonInitResult(result) {
5083
5050
  if (Array.isArray(result)) return { providers: result };
5084
5051
  return result;
5085
5052
  }
5053
+ /**
5054
+ * A user-facing error with a STABLE code (D863).
5055
+ *
5056
+ * `message` is always the English text, so every consumer that knows nothing
5057
+ * of codes (old clients, logs, the mesh) behaves exactly as before. The hub's
5058
+ * tRPC error formatter reads `code` + `params` and, when the request language
5059
+ * has a text for `server:<code>`, replaces the response `message`; the code
5060
+ * stays in the payload (`data.i18n`).
5061
+ */
5062
+ /** Dotted lower-case code, e.g. `auth.invalid-credentials`. It is the key in the `server` catalog. */
5063
+ var ErrorCodeSchema = zod.z.string().regex(/^[a-z][a-z0-9-]*(\.[a-z0-9-]+)+$/);
5064
+ zod.z.object({
5065
+ code: ErrorCodeSchema,
5066
+ params: zod.z.record(zod.z.string(), zod.z.union([zod.z.string(), zod.z.number()])).optional()
5067
+ });
5068
+ var CamstackError = class extends Error {
5069
+ i18nCode;
5070
+ i18nParams;
5071
+ constructor(code, params, englishMessage) {
5072
+ super(englishMessage);
5073
+ this.name = "CamstackError";
5074
+ this.i18nCode = code;
5075
+ this.i18nParams = params;
5076
+ }
5077
+ };
5078
+ /** `throw userError('device.not-found', { id }, 'Device 12 not found')` */
5079
+ function userError(code, params, englishFallback) {
5080
+ return new CamstackError(code, params, englishFallback);
5081
+ }
5086
5082
  zod.z.object({
5087
5083
  field: zod.z.string().min(1),
5088
5084
  on: zod.z.literal("advance")
@@ -5236,12 +5232,6 @@ function systemMethod(input, output, options) {
5236
5232
  systemOnly: true
5237
5233
  };
5238
5234
  }
5239
- /**
5240
- * A method a SOURCE of a collection cap may legitimately not serve — OPTIONAL
5241
- * on `InferProvider`. The `providerOptional: true` literal is what
5242
- * `InferProvider` keys on; see {@link CapabilityMethodSchema.providerOptional}
5243
- * for when this is the honest answer and when it is a soft stub.
5244
- */
5245
5235
  function optionalMethod(input, output, options) {
5246
5236
  return {
5247
5237
  ...method(input, output, options),
@@ -13574,35 +13564,6 @@ function auditedFields(cap) {
13574
13564
  return fieldsByCap.get(cap) ?? NO_FIELDS;
13575
13565
  }
13576
13566
  /**
13577
- * A user-facing error with a STABLE code (D863).
13578
- *
13579
- * `message` is always the English text, so every consumer that knows nothing
13580
- * of codes (old clients, logs, the mesh) behaves exactly as before. The hub's
13581
- * tRPC error formatter reads `code` + `params` and, when the request language
13582
- * has a text for `server:<code>`, replaces the response `message`; the code
13583
- * stays in the payload (`data.i18n`).
13584
- */
13585
- /** Dotted lower-case code, e.g. `auth.invalid-credentials`. It is the key in the `server` catalog. */
13586
- var ErrorCodeSchema = zod.z.string().regex(/^[a-z][a-z0-9-]*(\.[a-z0-9-]+)+$/);
13587
- zod.z.object({
13588
- code: ErrorCodeSchema,
13589
- params: zod.z.record(zod.z.string(), zod.z.union([zod.z.string(), zod.z.number()])).optional()
13590
- });
13591
- var CamstackError = class extends Error {
13592
- i18nCode;
13593
- i18nParams;
13594
- constructor(code, params, englishMessage) {
13595
- super(englishMessage);
13596
- this.name = "CamstackError";
13597
- this.i18nCode = code;
13598
- this.i18nParams = params;
13599
- }
13600
- };
13601
- /** `throw userError('device.not-found', { id }, 'Device 12 not found')` */
13602
- function userError(code, params, englishFallback) {
13603
- return new CamstackError(code, params, englishFallback);
13604
- }
13605
- /**
13606
13567
  * Type-safe JSON parsing helpers.
13607
13568
  *
13608
13569
  * `JSON.parse` is typed as `any` in lib.es5.d.ts, which triggers
@@ -17011,25 +16972,6 @@ function describeUnmet(unmet) {
17011
16972
  }
17012
16973
  }
17013
16974
  /**
17014
- * Which integration instance a settings form is for. An addon that serves several instances
17015
- * (`instanceMode: multiple`) can show a different form per instance — an NVR integration
17016
- * needs its connection, the default integration needs the addon's own sections.
17017
- *
17018
- * - `integrationId` is `null` in the create wizard: nothing exists yet, the operator is
17019
- * setting up a NEW instance.
17020
- * - `mode` is the wizard mode of the integration type (`getAvailableTypes`).
17021
- * - `candidateStableId` is the discovery candidate a wizard was seeded from, if any.
17022
- */
17023
- var IntegrationInstanceRefSchema = zod.z.object({
17024
- integrationId: zod.z.string().nullable(),
17025
- mode: zod.z.enum([
17026
- "standalone",
17027
- "account",
17028
- "broker"
17029
- ]),
17030
- candidateStableId: zod.z.string().optional()
17031
- });
17032
- /**
17033
16975
  * notification-output — canonical, capability-gated notification delivery.
17034
16976
  *
17035
16977
  * Apprise-derived model (see
@@ -45919,11 +45861,6 @@ var addonSettingsCapability = {
45919
45861
  scope: ScopedSettingsScopeSchema,
45920
45862
  nodeId: zod.z.string().optional()
45921
45863
  }), zod.z.record(zod.z.string(), zod.z.unknown()).nullable()),
45922
- getIntegrationFormSchema: method(zod.z.object({
45923
- addonId: zod.z.string(),
45924
- nodeId: zod.z.string().optional(),
45925
- instance: IntegrationInstanceRefSchema
45926
- }), SettingsSchemaWithValuesSchema.nullable()),
45927
45864
  getDeclaredSettingsKeys: method(zod.z.object({
45928
45865
  addonId: zod.z.string(),
45929
45866
  nodeId: zod.z.string().optional()
@@ -64092,6 +64029,12 @@ var IntegrationWithStateSchema = zod.z.object({
64092
64029
  name: zod.z.string(),
64093
64030
  /** A projection of the instance body's switch (`setInstanceEnabled` is the only writer). */
64094
64031
  enabled: zod.z.boolean(),
64032
+ /**
64033
+ * True when the addon that holds the switch did not answer (down, failed, or keeps no record for
64034
+ * this row): `enabled` is then the stored registry flag, a stale value, not the state. A reader
64035
+ * must not draw it as on or off (D315).
64036
+ */
64037
+ switchUnknown: zod.z.literal(true).optional(),
64095
64038
  info: zod.z.record(zod.z.string(), zod.z.unknown()).readonly(),
64096
64039
  /** The discovery candidate this integration was set up from (D984). */
64097
64040
  originStableId: zod.z.string().optional(),
@@ -64105,6 +64048,12 @@ var IntegrationLiteSchema = zod.z.object({
64105
64048
  name: zod.z.string(),
64106
64049
  /** A projection of the instance body's switch (`setInstanceEnabled` is the only writer). */
64107
64050
  enabled: zod.z.boolean(),
64051
+ /**
64052
+ * True when the addon that holds the switch did not answer (down, failed, or keeps no record for
64053
+ * this row): `enabled` is then the stored registry flag, a stale value, not the state. A reader
64054
+ * must not draw it as on or off (D315).
64055
+ */
64056
+ switchUnknown: zod.z.literal(true).optional(),
64108
64057
  info: zod.z.record(zod.z.string(), zod.z.unknown()).readonly(),
64109
64058
  /** The discovery candidate this integration was set up from (D984). */
64110
64059
  originStableId: zod.z.string().optional(),
@@ -64203,9 +64152,9 @@ var UpdateIntegrationInputSchema = zod.z.object({
64203
64152
  id: zod.z.string(),
64204
64153
  name: zod.z.string().optional(),
64205
64154
  /**
64206
- * Accepted for a FIXED builtin only (`info.fixed`: alarm panel, camera grid, core blocks,
64207
- * terminal), which keeps no instance record: the registry flag is its one store. Any other
64208
- * integration is switched through `integration-instances.setInstanceEnabled`.
64155
+ * Honoured ONLY for a fixed builtin (`info.fixed`), whose switch is the hub's own registry flag
64156
+ * and works while its addon is down. Any other row is refused (a typed `BAD_REQUEST`): its
64157
+ * switch is `integration-instances.setInstanceEnabled`.
64209
64158
  */
64210
64159
  enabled: zod.z.boolean().optional(),
64211
64160
  info: zod.z.record(zod.z.string(), zod.z.unknown()).optional()
@@ -64226,6 +64175,13 @@ var integrationsCapability = {
64226
64175
  kind: "mutation",
64227
64176
  auth: "admin"
64228
64177
  }),
64178
+ /**
64179
+ * Delete an integration from the hub side: its devices, its registry row and its record, and
64180
+ * announce it. It works while the addon that owns the instance is down (installed but
64181
+ * crashed), where `integration-instances.deleteInstance` has no provider to route to; with the
64182
+ * provider up the record is removed through it as well. A fixed builtin and an instance a link
64183
+ * names are refused first.
64184
+ */
64229
64185
  delete: method(zod.z.object({ id: zod.z.string() }), DeleteIntegrationResultSchema, {
64230
64186
  kind: "mutation",
64231
64187
  auth: "admin"
@@ -64253,6 +64209,12 @@ var integrationsCapability = {
64253
64209
  * the form as a `SecretFieldView`, never text (D789). A patch value omitted, `''`
64254
64210
  * or the redaction token KEEPS the stored secret; `{ $secretClear: true }`
64255
64211
  * clears it.
64212
+ *
64213
+ * Who may call (epic #440): every method but `describe` and `instanceFormSchema` is open to any
64214
+ * session (`caller: 'scoped'`) and default-denies. An admin passes everywhere. A non-admin passes
64215
+ * only on a call pinned to one addon whose `describe().userScoped` is true, and that provider
64216
+ * filters every row on the `caller` the router injected (a notification target is somebody's
64217
+ * phone: a user sees and changes only their own). An addon that says nothing keeps the admin door.
64256
64218
  */
64257
64219
  var ConfigSchemaPassthrough$2 = zod.z.custom();
64258
64220
  var IntegrationInstanceIdSchema = zod.z.string().min(1);
@@ -64366,7 +64328,15 @@ var IntegrationInstanceDescriptionSchema = zod.z.object({
64366
64328
  */
64367
64329
  mintsId: zod.z.boolean().optional(),
64368
64330
  /** The links to other instances the provider's kinds declare; absent means none. */
64369
- links: zod.z.array(IntegrationInstanceLinkSchema).optional()
64331
+ links: zod.z.array(IntegrationInstanceLinkSchema).optional(),
64332
+ /**
64333
+ * The rows belong to individual users (a notification target is somebody's phone). The router
64334
+ * then opens `listInstances`, `getInstance`, `createInstance`, `updateInstance`,
64335
+ * `setInstanceEnabled`, `deleteInstance` and `testInstance` to a NON-admin session on a call
64336
+ * pinned to this addon, and hands the provider the `caller` so it keeps a user to their own rows.
64337
+ * Absent means admin only, as it always was.
64338
+ */
64339
+ userScoped: zod.z.boolean().optional()
64370
64340
  });
64371
64341
  var IntegrationInstanceStatusSchema = zod.z.object({
64372
64342
  state: zod.z.enum([
@@ -64424,8 +64394,14 @@ var integrationInstancesCapability = {
64424
64394
  /** The discovery candidate the wizard was seeded from (`stableId`), if any. */
64425
64395
  candidateStableId: zod.z.string().min(1).optional()
64426
64396
  }), ConfigSchemaPassthrough$2, { auth: "admin" }),
64427
- listInstances: method(zod.z.void(), zod.z.array(IntegrationInstanceSchema).readonly(), { auth: "admin" }),
64428
- getInstance: method(zod.z.object({ id: IntegrationInstanceIdSchema }), IntegrationInstanceSchema.nullable(), { auth: "admin" }),
64397
+ listInstances: method(zod.z.looseObject({}), zod.z.array(IntegrationInstanceSchema).readonly(), {
64398
+ auth: "protected",
64399
+ caller: "scoped"
64400
+ }),
64401
+ getInstance: method(zod.z.object({ id: IntegrationInstanceIdSchema }), IntegrationInstanceSchema.nullable(), {
64402
+ auth: "protected",
64403
+ caller: "scoped"
64404
+ }),
64429
64405
  /**
64430
64406
  * Insert the typed record. With `id` it is stored under that id (a duplicate id is refused);
64431
64407
  * without one the PROVIDER mints it and answers it. `kind` picks one of `describe().kinds`.
@@ -64458,11 +64434,13 @@ var integrationInstancesCapability = {
64458
64434
  seed: zod.z.object({ info: zod.z.record(zod.z.string(), zod.z.unknown()) }).optional()
64459
64435
  }), zod.z.object({ id: zod.z.string() }), {
64460
64436
  kind: "mutation",
64461
- auth: "admin"
64437
+ auth: "protected",
64438
+ caller: "scoped"
64462
64439
  }),
64463
64440
  updateInstance: method(IntegrationInstancePatchSchema, zod.z.object({ ok: zod.z.literal(true) }), {
64464
64441
  kind: "mutation",
64465
- auth: "admin"
64442
+ auth: "protected",
64443
+ caller: "scoped"
64466
64444
  }),
64467
64445
  /**
64468
64446
  * Switch ONE instance on or off, for every role; a missing record is created from the addon's
@@ -64474,7 +64452,8 @@ var integrationInstancesCapability = {
64474
64452
  enabled: zod.z.boolean()
64475
64453
  }), zod.z.object({ ok: zod.z.literal(true) }), {
64476
64454
  kind: "mutation",
64477
- auth: "admin"
64455
+ auth: "protected",
64456
+ caller: "scoped"
64478
64457
  }),
64479
64458
  /**
64480
64459
  * Delete the record and its keychain refs together. For an instance that brings devices the hub
@@ -64483,7 +64462,8 @@ var integrationInstancesCapability = {
64483
64462
  */
64484
64463
  deleteInstance: method(zod.z.object({ id: IntegrationInstanceIdSchema }), zod.z.object({ ok: zod.z.literal(true) }), {
64485
64464
  kind: "mutation",
64486
- auth: "admin"
64465
+ auth: "protected",
64466
+ caller: "scoped"
64487
64467
  }),
64488
64468
  testInstance: optionalMethod(zod.z.object({
64489
64469
  id: IntegrationInstanceIdSchema.nullable(),
@@ -64492,7 +64472,8 @@ var integrationInstancesCapability = {
64492
64472
  kind: zod.z.string().min(1).optional()
64493
64473
  }), TestConnectionResultSchema, {
64494
64474
  kind: "mutation",
64495
- auth: "admin"
64475
+ auth: "protected",
64476
+ caller: "scoped"
64496
64477
  })
64497
64478
  }
64498
64479
  };
@@ -88484,6 +88465,11 @@ var SendEmailResultSchema = zod.z.object({
88484
88465
  var SmtpStatusSchema = zod.z.object({
88485
88466
  /** True iff the addon has successfully verified the relay. */
88486
88467
  ready: zod.z.boolean(),
88468
+ /**
88469
+ * The tri-state behind `ready` (D315): true when the last send worked, false when it failed,
88470
+ * ABSENT when the relay has not sent yet (unknown, never "not verified").
88471
+ */
88472
+ verified: zod.z.boolean().optional(),
88487
88473
  /** Operator-visible host string (no credentials). */
88488
88474
  host: zod.z.string(),
88489
88475
  /** Last error message reported by the relay, when not ready. */
@@ -88503,13 +88489,6 @@ var smtpProviderCapability = {
88503
88489
  auth: "admin",
88504
88490
  access: "create"
88505
88491
  }),
88506
- /** Round-trip ping against the SMTP relay (EHLO + AUTH if configured).
88507
- * Used by the operator's "Test connection" button. */
88508
- verify: method(RelayPinSchema, SmtpStatusSchema, {
88509
- kind: "mutation",
88510
- auth: "admin",
88511
- access: "view"
88512
- }),
88513
88492
  getStatus: method(RelayPinSchema, SmtpStatusSchema, { auth: "admin" })
88514
88493
  }
88515
88494
  };
@@ -101334,13 +101313,6 @@ var METHOD_ACCESS_MAP = Object.freeze({
101334
101313
  access: "view",
101335
101314
  role: "admin"
101336
101315
  },
101337
- "addonSettings.getIntegrationFormSchema": {
101338
- capName: "addon-settings",
101339
- capScope: "system",
101340
- addonId: null,
101341
- access: "view",
101342
- role: "admin"
101343
- },
101344
101316
  "addonSettings.getScopedSettings": {
101345
101317
  capName: "addon-settings",
101346
101318
  capScope: "system",
@@ -109363,13 +109335,6 @@ var METHOD_ACCESS_MAP = Object.freeze({
109363
109335
  access: "create",
109364
109336
  role: "admin"
109365
109337
  },
109366
- "smtpProvider.verify": {
109367
- capName: "smtp-provider",
109368
- capScope: "system",
109369
- addonId: null,
109370
- access: "view",
109371
- role: "admin"
109372
- },
109373
109338
  "snapshot.applyDeviceSettingsPatch": {
109374
109339
  capName: "snapshot",
109375
109340
  capScope: "device",
@@ -1,5 +1,5 @@
1
1
  require("./chunk-Cek0wNdY.js");
2
- const require_wal_maintenance = require("./wal-maintenance-BPmo2JzY.js");
2
+ const require_wal_maintenance = require("./wal-maintenance--0liHBxL.js");
3
3
  let node_worker_threads = require("node:worker_threads");
4
4
  //#region src/builtins/sqlite-storage/file-host-worker.ts
5
5
  /**
@@ -1,4 +1,4 @@
1
- import { A as callRecords, C as isFileHostWorkerData, D as RecordsEngine, M as controlTargetOf, O as callControl, S as isFileHostRequest, a as WalMaintenance, b as collectTransferables, d as callMigrate, f as migrateTargetOf, j as callVector, k as callData, l as SqliteSettingsBackend, o as createVectorIndex, s as vectorProviderOf, u as HUB_MIGRATIONS, v as serializeError, w as trustInput } from "./wal-maintenance-BJ0vDek1.mjs";
1
+ import { A as callRecords, C as isFileHostWorkerData, D as RecordsEngine, M as controlTargetOf, O as callControl, S as isFileHostRequest, a as WalMaintenance, b as collectTransferables, d as callMigrate, f as migrateTargetOf, j as callVector, k as callData, l as SqliteSettingsBackend, o as createVectorIndex, s as vectorProviderOf, u as HUB_MIGRATIONS, v as serializeError, w as trustInput } from "./wal-maintenance-DMf2oEQ-.mjs";
2
2
  import { parentPort, threadId, workerData } from "node:worker_threads";
3
3
  //#region src/builtins/sqlite-storage/file-host-worker.ts
4
4
  /**
@@ -1,7 +1,7 @@
1
1
  const require_chunk = require("./chunk-Cek0wNdY.js");
2
- const require_dist = require("./dist-DX1gyM8o.js");
2
+ const require_dist = require("./dist-R_mOSFtH.js");
3
3
  const require_x509_es = require("./x509.es-WtnRNyYS.js");
4
- const require_agent_https = require("./agent-https-ChriyNA8.js");
4
+ const require_agent_https = require("./agent-https-CbysxRlV.js");
5
5
  let node_crypto = require("node:crypto");
6
6
  let _camstack_types_node = require("@camstack/types/node");
7
7
  let node_fs = require("node:fs");
@@ -1,7 +1,7 @@
1
1
  import { o as __toESM } from "./chunk-CNf5ZN-e.mjs";
2
- import { Uc as userError } from "./dist-BNBgsEk0.mjs";
2
+ import { Uc as userError } from "./dist-C0Df8iJl.mjs";
3
3
  import { f as X509Certificate$1 } from "./x509.es-BRiJgOvu.mjs";
4
- import { D as reasonRequiresNewCa, E as evaluateExistingCert, F as readNameConstraints, N as permitsIdentity, _ as issueLeaf, b as collectCertIdentity, g as generateCa, j as isConstrainedCa, v as loadCa, y as localCaCommonName } from "./agent-https-rhOY61af.mjs";
4
+ import { D as reasonRequiresNewCa, E as evaluateExistingCert, F as readNameConstraints, N as permitsIdentity, _ as issueLeaf, b as collectCertIdentity, g as generateCa, j as isConstrainedCa, v as loadCa, y as localCaCommonName } from "./agent-https-XHjvcSEq.mjs";
5
5
  import { X509Certificate, createPrivateKey } from "node:crypto";
6
6
  import { writeOwnerOnlyFileSync } from "@camstack/types/node";
7
7
  import { copyFileSync, existsSync, mkdirSync, readFileSync, renameSync, rmSync, writeFileSync } from "node:fs";
@@ -1,7 +1,7 @@
1
1
  Object.defineProperty(exports, Symbol.toStringTag, { value: "Module" });
2
2
  const require_chunk = require("./chunk-Cek0wNdY.js");
3
- const require_dist = require("./dist-DX1gyM8o.js");
4
- const require_device_ca = require("./device-ca-CEzeY_zI.js");
3
+ const require_dist = require("./dist-R_mOSFtH.js");
4
+ const require_device_ca = require("./device-ca-kANxsBE5.js");
5
5
  const require_read_all_rows$1 = require("./read-all-rows-CVoO1ONM.js");
6
6
  const require_log_redactor = require("./log-redactor-BhIEMaG9.js");
7
7
  const require_builtins_alerts_alerts_addon = require("./builtins/alerts/alerts.addon.js");
@@ -27,22 +27,22 @@ const require_builtins_loki_logging_index = require("./builtins/loki-logging/ind
27
27
  const require_builtins_native_metrics_native_metrics_addon = require("./builtins/native-metrics/native-metrics.addon.js");
28
28
  const require_builtins_device_history_device_history_addon = require("./builtins/device-history/device-history.addon.js");
29
29
  const require_builtins_sqlite_storage_filesystem_storage_addon = require("./builtins/sqlite-storage/filesystem-storage.addon.js");
30
- const require_wal_maintenance = require("./wal-maintenance-BPmo2JzY.js");
31
- const require_legacy_integration_rows_door = require("./legacy-integration-rows-door-7K4_MoAP.js");
30
+ const require_wal_maintenance = require("./wal-maintenance--0liHBxL.js");
31
+ const require_legacy_integration_rows_door = require("./legacy-integration-rows-door-g4CeLJ9g.js");
32
32
  const require_builtins_sqlite_storage_sqlite_settings_addon = require("./builtins/sqlite-storage/sqlite-settings.addon.js");
33
33
  const require_builtins_sqlite_storage_index = require("./builtins/sqlite-storage/index.js");
34
34
  const require_builtins_storage_orchestrator_storage_orchestrator_addon = require("./builtins/storage-orchestrator/storage-orchestrator.addon.js");
35
35
  require("./builtins/storage-orchestrator/index.js");
36
- const require_agent_https = require("./agent-https-ChriyNA8.js");
37
- const require_constants = require("./constants-D3mNibfv.js");
36
+ const require_agent_https = require("./agent-https-CbysxRlV.js");
37
+ const require_constants = require("./constants-BchSDmTD.js");
38
38
  const require_builtins_system_config_system_config_addon = require("./builtins/system-config/system-config.addon.js");
39
39
  require("./builtins/system-config/index.js");
40
40
  const require_builtins_winston_logging_index = require("./builtins/winston-logging/index.js");
41
41
  const require_custom_action_registry = require("./custom-action-registry-CmWpSeMS.js");
42
- const require_hub_mdns_ciao = require("./hub-mdns-ciao-DBHvpWvv.js");
42
+ const require_hub_mdns_ciao = require("./hub-mdns-ciao-2AZ3ucDO.js");
43
43
  const require_platform_key_source = require("./platform-key-source-Di7HrlGR.js");
44
44
  const require_resource_monitor = require("./resource-monitor-mio9dSCT.js");
45
- const require_restore_archive = require("./restore-archive-DXlN0NYx.js");
45
+ const require_restore_archive = require("./restore-archive-CAh7u-rY.js");
46
46
  const require_coral_accelerators = require("./coral-accelerators-BSVsBVzt.js");
47
47
  let zod = require("zod");
48
48
  let node_crypto = require("node:crypto");
@@ -11500,6 +11500,7 @@ function methodsFor(def) {
11500
11500
  isVoid: require_dist.isVoidInput(m.input),
11501
11501
  isObject: require_dist.isObjectInput(m.input),
11502
11502
  callerRequired: m.caller === "required",
11503
+ callerScoped: m.caller === "scoped",
11503
11504
  isArrayOutput: m.kind !== "subscription" && require_dist.isArrayOutputSchema(m.output)
11504
11505
  };
11505
11506
  });
@@ -11576,6 +11577,30 @@ function injectCaller(rest, ctx, capName, methodName, services) {
11576
11577
  caller
11577
11578
  };
11578
11579
  }
11580
+ /**
11581
+ * `caller: 'scoped'`: the same server-derived identity as {@link injectCaller}, with the
11582
+ * default-deny a method open to every session needs. An ADMIN passes as it always did. A
11583
+ * NON-admin passes only on a call pinned to ONE addon (`addonId`, never the fan-out union) whose
11584
+ * provider says it serves user-scoped rows (`admitsUserCaller`); the provider then filters on
11585
+ * the `caller` it receives. A context with a request but no user fails closed; a context with
11586
+ * neither (an in-process call that holds no session) passes without a caller, as before.
11587
+ */
11588
+ async function injectScopedCaller(rest, ctx, provider, pinnedAddonId, capName, methodName, services) {
11589
+ const caller = extractCallerIdentity(ctx);
11590
+ if (caller === null) {
11591
+ if (!(typeof ctx === "object" && ctx !== null && "req" in ctx && ctx.req !== void 0)) return rest;
11592
+ return (services.unauthorized ?? services.badRequest)(`Capability "${capName}.${methodName}" requires an authenticated caller`);
11593
+ }
11594
+ if (!caller.isAdmin) {
11595
+ const refuse = services.forbidden ?? services.unauthorized ?? services.badRequest;
11596
+ if (pinnedAddonId === void 0) return refuse(`Capability "${capName}.${methodName}" requires admin unless it names one addon`);
11597
+ if (!(await services.admitsUserCaller?.(capName, provider) === true)) return refuse(`Capability "${capName}.${methodName}" requires admin for addon "${pinnedAddonId}"`);
11598
+ }
11599
+ return {
11600
+ ...rest,
11601
+ caller
11602
+ };
11603
+ }
11579
11604
  /** Strip a set of selector keys from an input object, returning a NEW object. */
11580
11605
  function stripKeys(input, keys) {
11581
11606
  const src = input ?? {};
@@ -11633,9 +11658,10 @@ function buildOneCapRouter(def, primitives, services) {
11633
11658
  const nodeIdData = def.nodeIdMode === "data";
11634
11659
  const procedures = {};
11635
11660
  for (const method of methodsFor(def)) {
11636
- if (method.callerRequired && (method.kind === "subscription" || !method.isObject)) throw new Error(`Cap "${capName}" method "${method.name}": caller: 'required' is only supported on query/mutation methods with an object input schema`);
11661
+ if ((method.callerRequired || method.callerScoped) && (method.kind === "subscription" || !method.isObject)) throw new Error(`Cap "${capName}" method "${method.name}": caller: 'required' is only supported on query/mutation methods with an object input schema`);
11637
11662
  const effectiveMountKind = methodMountKindFor(def, mount.kind, method);
11638
11663
  const isCollection = effectiveMountKind === "collection";
11664
+ if (method.callerScoped && (!isCollection || nodeIdData)) throw new Error(`Cap "${capName}" method "${method.name}": caller: 'scoped' needs a collection cap`);
11639
11665
  const getLocal = (ctx, addonId) => services.getLocalProvider(capName, effectiveMountKind, ctx, addonId);
11640
11666
  const base = primitives.procedures[require_dist.procedureAuthKey(method.auth)];
11641
11667
  const inputSchema = method.schema.input;
@@ -11664,7 +11690,8 @@ function buildOneCapRouter(def, primitives, services) {
11664
11690
  }
11665
11691
  if (method.isObject) {
11666
11692
  const stampedCap = require_dist.CALLER_STAMPED_CAPABILITIES.includes(capName);
11667
- const schema = nodeIdData ? inputSchema : require_dist.looseSchema(inputSchema);
11693
+ const routed = nodeIdData ? inputSchema : require_dist.looseSchema(inputSchema);
11694
+ const schema = method.callerScoped && routed instanceof zod.z.ZodType && routed.safeParse({}).success ? routed.optional() : routed;
11668
11695
  procedures[method.name] = base.input(schema)[procKind](({ input: wireInput, ctx }) => {
11669
11696
  const hasHttpReq = typeof ctx === "object" && ctx !== null && "req" in ctx && ctx.req !== void 0;
11670
11697
  const input = stampedCap && hasHttpReq ? require_dist.withoutCallerStamp(wireInput) : wireInput;
@@ -11681,7 +11708,9 @@ function buildOneCapRouter(def, primitives, services) {
11681
11708
  addonId = await Promise.resolve(services.inferCollectionAddonPin(capName, method.name, rest));
11682
11709
  if (addonId !== void 0) refusePin = addonId;
11683
11710
  }
11684
- return invokeObserved(def, ctx, resolveProviderForCall(capName, nodeId, () => getLocal(ctx, addonId), services, refusePin), method, method.callerRequired ? injectCaller(rest, ctx, capName, method.name, services) : rest, isCollection, services);
11711
+ const provider = resolveProviderForCall(capName, nodeId, () => getLocal(ctx, addonId), services, refusePin);
11712
+ if (method.callerScoped) return injectScopedCaller(rest, ctx, provider, topLevelAddonId, capName, method.name, services).then((payload) => invokeObserved(def, ctx, provider, method, payload, isCollection, services));
11713
+ return invokeObserved(def, ctx, provider, method, method.callerRequired ? injectCaller(rest, ctx, capName, method.name, services) : rest, isCollection, services);
11685
11714
  };
11686
11715
  return resolveAndInvoke();
11687
11716
  }