@camstack/addon-mqtt-broker 1.2.128 → 1.2.129

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.
@@ -7976,6 +7976,12 @@ function normalizeAddonInitResult(result) {
7976
7976
  if (Array.isArray(result)) return { providers: result };
7977
7977
  return result;
7978
7978
  }
7979
+ /**
7980
+ * The share-view scope kinds a `csv_*` share token can carry. The hub mints
7981
+ * and validates them (`share-token.service.ts` builds its enum from this
7982
+ * list); a data plane names the kinds it ACCEPTS in `share`.
7983
+ */
7984
+ var SHARE_VIEW_KINDS = ["grid-view", "events-view"];
7979
7985
  /** The wire shape of {@link PeerBytesTicket} — see the type for what it is. */
7980
7986
  var PeerBytesTicketSchema = object({
7981
7987
  /** `http://127.0.0.1:<port>/<token>`. One `GET` takes it. */
@@ -12836,6 +12842,229 @@ var ConvertResultSchema = object({
12836
12842
  files: array(string()).readonly()
12837
12843
  })).readonly()
12838
12844
  });
12845
+ /**
12846
+ * Zod schemas for persisted record types.
12847
+ *
12848
+ * These schemas serve as the single source of truth for types that are
12849
+ * stored in the settings-store backend and retrieved via tRPC. They
12850
+ * replace the manual TypeScript interfaces with schema-derived types,
12851
+ * enabling runtime validation when reading from the backend.
12852
+ *
12853
+ * Convention: each schema is named `<Type>Schema`, the inferred TS type
12854
+ * keeps the original name for backward compatibility.
12855
+ */
12856
+ /**
12857
+ * Auth model (v2 — 2026-05-12 caps-only):
12858
+ *
12859
+ * Two principals:
12860
+ * - `isAdmin: true` — full bypass. Admin scope set is ignored.
12861
+ * - `isAdmin: false` — every call gated by `scopes` (see TokenScope).
12862
+ *
12863
+ * No role enum. There used to be `viewer / agent / scoped` and earlier
12864
+ * `super_admin` — collapsed onto the single boolean because every
12865
+ * non-admin caller is governed by the same scope-check rules; the
12866
+ * distinction was only ever used to route role-specific procedures
12867
+ * which we no longer have. CLI / webhook integrations are `cst_*` tokens
12868
+ * with `isAdmin: false` + an explicit scope list.
12869
+ */
12870
+ /** Per-method access flavour. Materialised on every cap method via codegen. */
12871
+ var MethodAccessSchema = _enum([
12872
+ "view",
12873
+ "create",
12874
+ "delete"
12875
+ ]);
12876
+ /**
12877
+ * A single scope grant. Three forms — checked in matcher with OR
12878
+ * semantics; the first match decides whether the call passes:
12879
+ *
12880
+ * - `category` — broadest. `target: 'device' | 'system'` selects every
12881
+ * cap with the matching `scope` declaration. New caps inherit grants
12882
+ * automatically — adding a device cap to the codebase makes it
12883
+ * reachable to every user with `category:device [...]` without a
12884
+ * re-grant. Use this for "family viewer" / "operator" tiers.
12885
+ *
12886
+ * - `addon` — every cap that ships inside a given addon id. Niche;
12887
+ * useful when an integration needs to interact with one specific
12888
+ * addon's surface regardless of how many caps it exports.
12889
+ *
12890
+ * - `capability` — the most precise form. Single cap name. Use for
12891
+ * integration tokens where you want to grant `addons.installPackage`
12892
+ * and nothing else.
12893
+ *
12894
+ * `access` is REQUIRED with min 1 element. `admin` bypass is the
12895
+ * "give me everything" escape; there is no wildcard scope.
12896
+ */
12897
+ var AllowedProviderSchema = union([literal("*"), array(string())]);
12898
+ var AllowedDevicesSchema = record(string(), union([literal("*"), array(string())]));
12899
+ var CapScopeSchema = _enum(["device", "system"]);
12900
+ /**
12901
+ * DeviceSelector (scope model v3 — 2026-08-12).
12902
+ *
12903
+ * A `device` grant no longer carries a frozen list of deviceIds. It carries
12904
+ * a SELECTOR the matcher resolves against the live fleet, so the grant can be
12905
+ * DYNAMIC: a `types:['camera']` selector automatically covers a camera added
12906
+ * AFTER the grant was minted — no re-grant, no re-login.
12907
+ *
12908
+ * - `all` — every device in the deployment. The broad viewer/operator
12909
+ * lever without a `category` grant (a `category` grant also covers device
12910
+ * caps that carry no deviceId; `all` is specifically the device set).
12911
+ * - `ids` — an explicit deviceId list. This is what a v2 `device:[…]`
12912
+ * grant migrates to (see {@link TokenScopeSchema}); STATIC — a new camera
12913
+ * is NOT covered until the grant is edited.
12914
+ * - `types` — every device of a `DeviceType` (e.g. every `camera`).
12915
+ * DYNAMIC. A device that changes type, or a new device of the type,
12916
+ * re-resolves on the next request.
12917
+ * - `locations` — every device whose operator-assigned `location` label is
12918
+ * in the set (e.g. "Garden", "Front door"). DYNAMIC. A device with a
12919
+ * null/unset location matches NO `locations` selector.
12920
+ */
12921
+ var DeviceSelectorSchema = discriminatedUnion("kind", [
12922
+ object({ kind: literal("all") }),
12923
+ object({
12924
+ kind: literal("ids"),
12925
+ ids: array(number().int()).min(1)
12926
+ }),
12927
+ object({
12928
+ kind: literal("types"),
12929
+ types: array(_enum(DeviceType)).min(1)
12930
+ }),
12931
+ object({
12932
+ kind: literal("locations"),
12933
+ locations: array(string().min(1)).min(1)
12934
+ })
12935
+ ]);
12936
+ var DeviceTokenScopeSchema = object({
12937
+ type: literal("device"),
12938
+ /** The device SET this grant covers — resolved against the live fleet. */
12939
+ selector: DeviceSelectorSchema,
12940
+ access: array(MethodAccessSchema).min(1),
12941
+ /**
12942
+ * Whether a grant on a PARENT device transparently covers its accessory
12943
+ * CHILDREN (siren / floodlight / PIR) via the persisted-parentage walk.
12944
+ * Direction is parent → children ONLY.
12945
+ *
12946
+ * Absent → the matcher DERIVES it from the access flavour: `view`
12947
+ * inherits (a camera viewer sees the camera's accessories), `create` /
12948
+ * `delete` do NOT (actuating/removing a child is an explicit act the
12949
+ * operator must grant on the child, not inherit from the parent). Set it
12950
+ * explicitly to override that default per grant.
12951
+ */
12952
+ includeLinked: boolean().optional()
12953
+ });
12954
+ /**
12955
+ * v2 → v3 lazy migration. A pre-v3 `device` grant carried
12956
+ * `targets: string[]` (stringified deviceIds); it rewrites to the equivalent
12957
+ * `selector: {kind:'ids', ids}`. Applied as a `preprocess` so it runs on
12958
+ * EVERY parse path — stored records AND the JWT-carried scope arrays
12959
+ * normalised at the request boundary ({@link normalizeTokenScopes} in
12960
+ * `device-selector.ts`). Chosen over a one-time DB migration because a
12961
+ * migration cannot reach a JWT already in a client's hands; parse-time
12962
+ * migration covers both without a flag day. No cast — the raw object is read
12963
+ * through `Reflect.get` (its static type is `unknown`).
12964
+ */
12965
+ function migrateLegacyTokenScope(raw) {
12966
+ if (raw === null || typeof raw !== "object" || Array.isArray(raw)) return raw;
12967
+ if (Reflect.get(raw, "type") !== "device") return raw;
12968
+ if (Reflect.get(raw, "selector") !== void 0) return raw;
12969
+ const targets = Reflect.get(raw, "targets");
12970
+ if (!Array.isArray(targets)) return raw;
12971
+ return {
12972
+ type: "device",
12973
+ selector: {
12974
+ kind: "ids",
12975
+ ids: targets.map((t) => typeof t === "string" ? Number(t) : t).filter((n) => typeof n === "number" && Number.isInteger(n))
12976
+ },
12977
+ access: Reflect.get(raw, "access")
12978
+ };
12979
+ }
12980
+ var TokenScopeSchema = preprocess(migrateLegacyTokenScope, discriminatedUnion("type", [
12981
+ object({
12982
+ type: literal("category"),
12983
+ target: CapScopeSchema,
12984
+ access: array(MethodAccessSchema).min(1)
12985
+ }),
12986
+ object({
12987
+ type: literal("capability"),
12988
+ target: string(),
12989
+ access: array(MethodAccessSchema).min(1)
12990
+ }),
12991
+ object({
12992
+ type: literal("addon"),
12993
+ target: string(),
12994
+ access: array(MethodAccessSchema).min(1)
12995
+ }),
12996
+ DeviceTokenScopeSchema
12997
+ ]));
12998
+ object({
12999
+ id: string(),
13000
+ username: string(),
13001
+ passwordHash: string(),
13002
+ /**
13003
+ * Admin bypass. When true, the middleware skips the scope-access
13004
+ * check entirely. There is no other axis of privilege; the legacy
13005
+ * role enum collapsed onto this boolean in v2.
13006
+ */
13007
+ isAdmin: boolean().default(false),
13008
+ allowedProviders: AllowedProviderSchema,
13009
+ allowedDevices: AllowedDevicesSchema,
13010
+ /**
13011
+ * Scopes granted to this user. Admins bypass; their `scopes` is
13012
+ * ignored. Non-admins without scopes are locked out of every
13013
+ * protected call.
13014
+ */
13015
+ scopes: array(TokenScopeSchema).default([]),
13016
+ createdAt: number(),
13017
+ updatedAt: number()
13018
+ });
13019
+ object({
13020
+ id: string(),
13021
+ label: string(),
13022
+ isAdmin: boolean().default(false),
13023
+ allowedProviders: AllowedProviderSchema,
13024
+ allowedDevices: AllowedDevicesSchema,
13025
+ tokenHash: string(),
13026
+ tokenPrefix: string(),
13027
+ createdAt: number(),
13028
+ lastUsedAt: number().optional()
13029
+ });
13030
+ object({
13031
+ id: string(),
13032
+ userId: string(),
13033
+ name: string(),
13034
+ tokenHash: string(),
13035
+ tokenPrefix: string(),
13036
+ scopes: array(TokenScopeSchema),
13037
+ expiresAt: number().nullish(),
13038
+ lastUsedAt: number().nullish(),
13039
+ createdAt: number()
13040
+ });
13041
+ /** What a share-view grant lets its holder see. */
13042
+ var ShareViewGrantSchema = object({
13043
+ kind: _enum(SHARE_VIEW_KINDS),
13044
+ deviceIds: array(number().int().nonnegative()).min(1).max(64),
13045
+ /** Talk-back, opt-in at mint time; absent means off. */
13046
+ talk: boolean().optional()
13047
+ });
13048
+ var ShareViewScopeSchema = object({
13049
+ type: literal("share-view"),
13050
+ grant: ShareViewGrantSchema
13051
+ });
13052
+ var AddonRoutesScopeSchema = object({
13053
+ type: literal("addon-routes"),
13054
+ access: array(MethodAccessSchema).min(1)
13055
+ });
13056
+ var CredentialScopeSchema = union([
13057
+ literal("*"),
13058
+ ShareViewScopeSchema,
13059
+ AddonRoutesScopeSchema,
13060
+ TokenScopeSchema
13061
+ ]);
13062
+ object({
13063
+ kind: literal("credential"),
13064
+ sub: string().min(1),
13065
+ jti: string().min(16),
13066
+ scopes: array(CredentialScopeSchema).min(1)
13067
+ });
12839
13068
  _enum(["new-session", "step-up"]);
12840
13069
  /** The languages the hub's app landing pages are written in (D858). */
12841
13070
  var AppPageLangSchema = _enum(["en", "it"]);
@@ -44041,202 +44270,6 @@ method(object({}), object({ rules: array(NcRuleSchema) }), { auth: "admin" }), m
44041
44270
  auth: "admin"
44042
44271
  }), method(NcAlarmSensorsInputSchema, NcAlarmSensorsSchema, { auth: "admin" });
44043
44272
  /**
44044
- * Zod schemas for persisted record types.
44045
- *
44046
- * These schemas serve as the single source of truth for types that are
44047
- * stored in the settings-store backend and retrieved via tRPC. They
44048
- * replace the manual TypeScript interfaces with schema-derived types,
44049
- * enabling runtime validation when reading from the backend.
44050
- *
44051
- * Convention: each schema is named `<Type>Schema`, the inferred TS type
44052
- * keeps the original name for backward compatibility.
44053
- */
44054
- /**
44055
- * Auth model (v2 — 2026-05-12 caps-only):
44056
- *
44057
- * Two principals:
44058
- * - `isAdmin: true` — full bypass. Admin scope set is ignored.
44059
- * - `isAdmin: false` — every call gated by `scopes` (see TokenScope).
44060
- *
44061
- * No role enum. There used to be `viewer / agent / scoped` and earlier
44062
- * `super_admin` — collapsed onto the single boolean because every
44063
- * non-admin caller is governed by the same scope-check rules; the
44064
- * distinction was only ever used to route role-specific procedures
44065
- * which we no longer have. CLI / webhook integrations are `cst_*` tokens
44066
- * with `isAdmin: false` + an explicit scope list.
44067
- */
44068
- /** Per-method access flavour. Materialised on every cap method via codegen. */
44069
- var MethodAccessSchema = _enum([
44070
- "view",
44071
- "create",
44072
- "delete"
44073
- ]);
44074
- /**
44075
- * A single scope grant. Three forms — checked in matcher with OR
44076
- * semantics; the first match decides whether the call passes:
44077
- *
44078
- * - `category` — broadest. `target: 'device' | 'system'` selects every
44079
- * cap with the matching `scope` declaration. New caps inherit grants
44080
- * automatically — adding a device cap to the codebase makes it
44081
- * reachable to every user with `category:device [...]` without a
44082
- * re-grant. Use this for "family viewer" / "operator" tiers.
44083
- *
44084
- * - `addon` — every cap that ships inside a given addon id. Niche;
44085
- * useful when an integration needs to interact with one specific
44086
- * addon's surface regardless of how many caps it exports.
44087
- *
44088
- * - `capability` — the most precise form. Single cap name. Use for
44089
- * integration tokens where you want to grant `addons.installPackage`
44090
- * and nothing else.
44091
- *
44092
- * `access` is REQUIRED with min 1 element. `admin` bypass is the
44093
- * "give me everything" escape; there is no wildcard scope.
44094
- */
44095
- var AllowedProviderSchema = union([literal("*"), array(string())]);
44096
- var AllowedDevicesSchema = record(string(), union([literal("*"), array(string())]));
44097
- var CapScopeSchema = _enum(["device", "system"]);
44098
- /**
44099
- * DeviceSelector (scope model v3 — 2026-08-12).
44100
- *
44101
- * A `device` grant no longer carries a frozen list of deviceIds. It carries
44102
- * a SELECTOR the matcher resolves against the live fleet, so the grant can be
44103
- * DYNAMIC: a `types:['camera']` selector automatically covers a camera added
44104
- * AFTER the grant was minted — no re-grant, no re-login.
44105
- *
44106
- * - `all` — every device in the deployment. The broad viewer/operator
44107
- * lever without a `category` grant (a `category` grant also covers device
44108
- * caps that carry no deviceId; `all` is specifically the device set).
44109
- * - `ids` — an explicit deviceId list. This is what a v2 `device:[…]`
44110
- * grant migrates to (see {@link TokenScopeSchema}); STATIC — a new camera
44111
- * is NOT covered until the grant is edited.
44112
- * - `types` — every device of a `DeviceType` (e.g. every `camera`).
44113
- * DYNAMIC. A device that changes type, or a new device of the type,
44114
- * re-resolves on the next request.
44115
- * - `locations` — every device whose operator-assigned `location` label is
44116
- * in the set (e.g. "Garden", "Front door"). DYNAMIC. A device with a
44117
- * null/unset location matches NO `locations` selector.
44118
- */
44119
- var DeviceSelectorSchema = discriminatedUnion("kind", [
44120
- object({ kind: literal("all") }),
44121
- object({
44122
- kind: literal("ids"),
44123
- ids: array(number().int()).min(1)
44124
- }),
44125
- object({
44126
- kind: literal("types"),
44127
- types: array(_enum(DeviceType)).min(1)
44128
- }),
44129
- object({
44130
- kind: literal("locations"),
44131
- locations: array(string().min(1)).min(1)
44132
- })
44133
- ]);
44134
- var DeviceTokenScopeSchema = object({
44135
- type: literal("device"),
44136
- /** The device SET this grant covers — resolved against the live fleet. */
44137
- selector: DeviceSelectorSchema,
44138
- access: array(MethodAccessSchema).min(1),
44139
- /**
44140
- * Whether a grant on a PARENT device transparently covers its accessory
44141
- * CHILDREN (siren / floodlight / PIR) via the persisted-parentage walk.
44142
- * Direction is parent → children ONLY.
44143
- *
44144
- * Absent → the matcher DERIVES it from the access flavour: `view`
44145
- * inherits (a camera viewer sees the camera's accessories), `create` /
44146
- * `delete` do NOT (actuating/removing a child is an explicit act the
44147
- * operator must grant on the child, not inherit from the parent). Set it
44148
- * explicitly to override that default per grant.
44149
- */
44150
- includeLinked: boolean().optional()
44151
- });
44152
- /**
44153
- * v2 → v3 lazy migration. A pre-v3 `device` grant carried
44154
- * `targets: string[]` (stringified deviceIds); it rewrites to the equivalent
44155
- * `selector: {kind:'ids', ids}`. Applied as a `preprocess` so it runs on
44156
- * EVERY parse path — stored records AND the JWT-carried scope arrays
44157
- * normalised at the request boundary ({@link normalizeTokenScopes} in
44158
- * `device-selector.ts`). Chosen over a one-time DB migration because a
44159
- * migration cannot reach a JWT already in a client's hands; parse-time
44160
- * migration covers both without a flag day. No cast — the raw object is read
44161
- * through `Reflect.get` (its static type is `unknown`).
44162
- */
44163
- function migrateLegacyTokenScope(raw) {
44164
- if (raw === null || typeof raw !== "object" || Array.isArray(raw)) return raw;
44165
- if (Reflect.get(raw, "type") !== "device") return raw;
44166
- if (Reflect.get(raw, "selector") !== void 0) return raw;
44167
- const targets = Reflect.get(raw, "targets");
44168
- if (!Array.isArray(targets)) return raw;
44169
- return {
44170
- type: "device",
44171
- selector: {
44172
- kind: "ids",
44173
- ids: targets.map((t) => typeof t === "string" ? Number(t) : t).filter((n) => typeof n === "number" && Number.isInteger(n))
44174
- },
44175
- access: Reflect.get(raw, "access")
44176
- };
44177
- }
44178
- var TokenScopeSchema = preprocess(migrateLegacyTokenScope, discriminatedUnion("type", [
44179
- object({
44180
- type: literal("category"),
44181
- target: CapScopeSchema,
44182
- access: array(MethodAccessSchema).min(1)
44183
- }),
44184
- object({
44185
- type: literal("capability"),
44186
- target: string(),
44187
- access: array(MethodAccessSchema).min(1)
44188
- }),
44189
- object({
44190
- type: literal("addon"),
44191
- target: string(),
44192
- access: array(MethodAccessSchema).min(1)
44193
- }),
44194
- DeviceTokenScopeSchema
44195
- ]));
44196
- object({
44197
- id: string(),
44198
- username: string(),
44199
- passwordHash: string(),
44200
- /**
44201
- * Admin bypass. When true, the middleware skips the scope-access
44202
- * check entirely. There is no other axis of privilege; the legacy
44203
- * role enum collapsed onto this boolean in v2.
44204
- */
44205
- isAdmin: boolean().default(false),
44206
- allowedProviders: AllowedProviderSchema,
44207
- allowedDevices: AllowedDevicesSchema,
44208
- /**
44209
- * Scopes granted to this user. Admins bypass; their `scopes` is
44210
- * ignored. Non-admins without scopes are locked out of every
44211
- * protected call.
44212
- */
44213
- scopes: array(TokenScopeSchema).default([]),
44214
- createdAt: number(),
44215
- updatedAt: number()
44216
- });
44217
- object({
44218
- id: string(),
44219
- label: string(),
44220
- isAdmin: boolean().default(false),
44221
- allowedProviders: AllowedProviderSchema,
44222
- allowedDevices: AllowedDevicesSchema,
44223
- tokenHash: string(),
44224
- tokenPrefix: string(),
44225
- createdAt: number(),
44226
- lastUsedAt: number().optional()
44227
- });
44228
- object({
44229
- id: string(),
44230
- userId: string(),
44231
- name: string(),
44232
- tokenHash: string(),
44233
- tokenPrefix: string(),
44234
- scopes: array(TokenScopeSchema),
44235
- expiresAt: number().nullish(),
44236
- lastUsedAt: number().nullish(),
44237
- createdAt: number()
44238
- });
44239
- /**
44240
44273
  * `oauth-integration` — a collection cap by which an addon declares
44241
44274
  * itself a linkable OAuth client of the hub's core `/oauth2/*` server.
44242
44275
  * Each provider returns a static descriptor; the core enumerates them
@@ -7969,6 +7969,12 @@ function normalizeAddonInitResult(result) {
7969
7969
  if (Array.isArray(result)) return { providers: result };
7970
7970
  return result;
7971
7971
  }
7972
+ /**
7973
+ * The share-view scope kinds a `csv_*` share token can carry. The hub mints
7974
+ * and validates them (`share-token.service.ts` builds its enum from this
7975
+ * list); a data plane names the kinds it ACCEPTS in `share`.
7976
+ */
7977
+ var SHARE_VIEW_KINDS = ["grid-view", "events-view"];
7972
7978
  /** The wire shape of {@link PeerBytesTicket} — see the type for what it is. */
7973
7979
  var PeerBytesTicketSchema = object({
7974
7980
  /** `http://127.0.0.1:<port>/<token>`. One `GET` takes it. */
@@ -12829,6 +12835,229 @@ var ConvertResultSchema = object({
12829
12835
  files: array(string()).readonly()
12830
12836
  })).readonly()
12831
12837
  });
12838
+ /**
12839
+ * Zod schemas for persisted record types.
12840
+ *
12841
+ * These schemas serve as the single source of truth for types that are
12842
+ * stored in the settings-store backend and retrieved via tRPC. They
12843
+ * replace the manual TypeScript interfaces with schema-derived types,
12844
+ * enabling runtime validation when reading from the backend.
12845
+ *
12846
+ * Convention: each schema is named `<Type>Schema`, the inferred TS type
12847
+ * keeps the original name for backward compatibility.
12848
+ */
12849
+ /**
12850
+ * Auth model (v2 — 2026-05-12 caps-only):
12851
+ *
12852
+ * Two principals:
12853
+ * - `isAdmin: true` — full bypass. Admin scope set is ignored.
12854
+ * - `isAdmin: false` — every call gated by `scopes` (see TokenScope).
12855
+ *
12856
+ * No role enum. There used to be `viewer / agent / scoped` and earlier
12857
+ * `super_admin` — collapsed onto the single boolean because every
12858
+ * non-admin caller is governed by the same scope-check rules; the
12859
+ * distinction was only ever used to route role-specific procedures
12860
+ * which we no longer have. CLI / webhook integrations are `cst_*` tokens
12861
+ * with `isAdmin: false` + an explicit scope list.
12862
+ */
12863
+ /** Per-method access flavour. Materialised on every cap method via codegen. */
12864
+ var MethodAccessSchema = _enum([
12865
+ "view",
12866
+ "create",
12867
+ "delete"
12868
+ ]);
12869
+ /**
12870
+ * A single scope grant. Three forms — checked in matcher with OR
12871
+ * semantics; the first match decides whether the call passes:
12872
+ *
12873
+ * - `category` — broadest. `target: 'device' | 'system'` selects every
12874
+ * cap with the matching `scope` declaration. New caps inherit grants
12875
+ * automatically — adding a device cap to the codebase makes it
12876
+ * reachable to every user with `category:device [...]` without a
12877
+ * re-grant. Use this for "family viewer" / "operator" tiers.
12878
+ *
12879
+ * - `addon` — every cap that ships inside a given addon id. Niche;
12880
+ * useful when an integration needs to interact with one specific
12881
+ * addon's surface regardless of how many caps it exports.
12882
+ *
12883
+ * - `capability` — the most precise form. Single cap name. Use for
12884
+ * integration tokens where you want to grant `addons.installPackage`
12885
+ * and nothing else.
12886
+ *
12887
+ * `access` is REQUIRED with min 1 element. `admin` bypass is the
12888
+ * "give me everything" escape; there is no wildcard scope.
12889
+ */
12890
+ var AllowedProviderSchema = union([literal("*"), array(string())]);
12891
+ var AllowedDevicesSchema = record(string(), union([literal("*"), array(string())]));
12892
+ var CapScopeSchema = _enum(["device", "system"]);
12893
+ /**
12894
+ * DeviceSelector (scope model v3 — 2026-08-12).
12895
+ *
12896
+ * A `device` grant no longer carries a frozen list of deviceIds. It carries
12897
+ * a SELECTOR the matcher resolves against the live fleet, so the grant can be
12898
+ * DYNAMIC: a `types:['camera']` selector automatically covers a camera added
12899
+ * AFTER the grant was minted — no re-grant, no re-login.
12900
+ *
12901
+ * - `all` — every device in the deployment. The broad viewer/operator
12902
+ * lever without a `category` grant (a `category` grant also covers device
12903
+ * caps that carry no deviceId; `all` is specifically the device set).
12904
+ * - `ids` — an explicit deviceId list. This is what a v2 `device:[…]`
12905
+ * grant migrates to (see {@link TokenScopeSchema}); STATIC — a new camera
12906
+ * is NOT covered until the grant is edited.
12907
+ * - `types` — every device of a `DeviceType` (e.g. every `camera`).
12908
+ * DYNAMIC. A device that changes type, or a new device of the type,
12909
+ * re-resolves on the next request.
12910
+ * - `locations` — every device whose operator-assigned `location` label is
12911
+ * in the set (e.g. "Garden", "Front door"). DYNAMIC. A device with a
12912
+ * null/unset location matches NO `locations` selector.
12913
+ */
12914
+ var DeviceSelectorSchema = discriminatedUnion("kind", [
12915
+ object({ kind: literal("all") }),
12916
+ object({
12917
+ kind: literal("ids"),
12918
+ ids: array(number().int()).min(1)
12919
+ }),
12920
+ object({
12921
+ kind: literal("types"),
12922
+ types: array(_enum(DeviceType)).min(1)
12923
+ }),
12924
+ object({
12925
+ kind: literal("locations"),
12926
+ locations: array(string().min(1)).min(1)
12927
+ })
12928
+ ]);
12929
+ var DeviceTokenScopeSchema = object({
12930
+ type: literal("device"),
12931
+ /** The device SET this grant covers — resolved against the live fleet. */
12932
+ selector: DeviceSelectorSchema,
12933
+ access: array(MethodAccessSchema).min(1),
12934
+ /**
12935
+ * Whether a grant on a PARENT device transparently covers its accessory
12936
+ * CHILDREN (siren / floodlight / PIR) via the persisted-parentage walk.
12937
+ * Direction is parent → children ONLY.
12938
+ *
12939
+ * Absent → the matcher DERIVES it from the access flavour: `view`
12940
+ * inherits (a camera viewer sees the camera's accessories), `create` /
12941
+ * `delete` do NOT (actuating/removing a child is an explicit act the
12942
+ * operator must grant on the child, not inherit from the parent). Set it
12943
+ * explicitly to override that default per grant.
12944
+ */
12945
+ includeLinked: boolean().optional()
12946
+ });
12947
+ /**
12948
+ * v2 → v3 lazy migration. A pre-v3 `device` grant carried
12949
+ * `targets: string[]` (stringified deviceIds); it rewrites to the equivalent
12950
+ * `selector: {kind:'ids', ids}`. Applied as a `preprocess` so it runs on
12951
+ * EVERY parse path — stored records AND the JWT-carried scope arrays
12952
+ * normalised at the request boundary ({@link normalizeTokenScopes} in
12953
+ * `device-selector.ts`). Chosen over a one-time DB migration because a
12954
+ * migration cannot reach a JWT already in a client's hands; parse-time
12955
+ * migration covers both without a flag day. No cast — the raw object is read
12956
+ * through `Reflect.get` (its static type is `unknown`).
12957
+ */
12958
+ function migrateLegacyTokenScope(raw) {
12959
+ if (raw === null || typeof raw !== "object" || Array.isArray(raw)) return raw;
12960
+ if (Reflect.get(raw, "type") !== "device") return raw;
12961
+ if (Reflect.get(raw, "selector") !== void 0) return raw;
12962
+ const targets = Reflect.get(raw, "targets");
12963
+ if (!Array.isArray(targets)) return raw;
12964
+ return {
12965
+ type: "device",
12966
+ selector: {
12967
+ kind: "ids",
12968
+ ids: targets.map((t) => typeof t === "string" ? Number(t) : t).filter((n) => typeof n === "number" && Number.isInteger(n))
12969
+ },
12970
+ access: Reflect.get(raw, "access")
12971
+ };
12972
+ }
12973
+ var TokenScopeSchema = preprocess(migrateLegacyTokenScope, discriminatedUnion("type", [
12974
+ object({
12975
+ type: literal("category"),
12976
+ target: CapScopeSchema,
12977
+ access: array(MethodAccessSchema).min(1)
12978
+ }),
12979
+ object({
12980
+ type: literal("capability"),
12981
+ target: string(),
12982
+ access: array(MethodAccessSchema).min(1)
12983
+ }),
12984
+ object({
12985
+ type: literal("addon"),
12986
+ target: string(),
12987
+ access: array(MethodAccessSchema).min(1)
12988
+ }),
12989
+ DeviceTokenScopeSchema
12990
+ ]));
12991
+ object({
12992
+ id: string(),
12993
+ username: string(),
12994
+ passwordHash: string(),
12995
+ /**
12996
+ * Admin bypass. When true, the middleware skips the scope-access
12997
+ * check entirely. There is no other axis of privilege; the legacy
12998
+ * role enum collapsed onto this boolean in v2.
12999
+ */
13000
+ isAdmin: boolean().default(false),
13001
+ allowedProviders: AllowedProviderSchema,
13002
+ allowedDevices: AllowedDevicesSchema,
13003
+ /**
13004
+ * Scopes granted to this user. Admins bypass; their `scopes` is
13005
+ * ignored. Non-admins without scopes are locked out of every
13006
+ * protected call.
13007
+ */
13008
+ scopes: array(TokenScopeSchema).default([]),
13009
+ createdAt: number(),
13010
+ updatedAt: number()
13011
+ });
13012
+ object({
13013
+ id: string(),
13014
+ label: string(),
13015
+ isAdmin: boolean().default(false),
13016
+ allowedProviders: AllowedProviderSchema,
13017
+ allowedDevices: AllowedDevicesSchema,
13018
+ tokenHash: string(),
13019
+ tokenPrefix: string(),
13020
+ createdAt: number(),
13021
+ lastUsedAt: number().optional()
13022
+ });
13023
+ object({
13024
+ id: string(),
13025
+ userId: string(),
13026
+ name: string(),
13027
+ tokenHash: string(),
13028
+ tokenPrefix: string(),
13029
+ scopes: array(TokenScopeSchema),
13030
+ expiresAt: number().nullish(),
13031
+ lastUsedAt: number().nullish(),
13032
+ createdAt: number()
13033
+ });
13034
+ /** What a share-view grant lets its holder see. */
13035
+ var ShareViewGrantSchema = object({
13036
+ kind: _enum(SHARE_VIEW_KINDS),
13037
+ deviceIds: array(number().int().nonnegative()).min(1).max(64),
13038
+ /** Talk-back, opt-in at mint time; absent means off. */
13039
+ talk: boolean().optional()
13040
+ });
13041
+ var ShareViewScopeSchema = object({
13042
+ type: literal("share-view"),
13043
+ grant: ShareViewGrantSchema
13044
+ });
13045
+ var AddonRoutesScopeSchema = object({
13046
+ type: literal("addon-routes"),
13047
+ access: array(MethodAccessSchema).min(1)
13048
+ });
13049
+ var CredentialScopeSchema = union([
13050
+ literal("*"),
13051
+ ShareViewScopeSchema,
13052
+ AddonRoutesScopeSchema,
13053
+ TokenScopeSchema
13054
+ ]);
13055
+ object({
13056
+ kind: literal("credential"),
13057
+ sub: string().min(1),
13058
+ jti: string().min(16),
13059
+ scopes: array(CredentialScopeSchema).min(1)
13060
+ });
12832
13061
  _enum(["new-session", "step-up"]);
12833
13062
  /** The languages the hub's app landing pages are written in (D858). */
12834
13063
  var AppPageLangSchema = _enum(["en", "it"]);
@@ -44034,202 +44263,6 @@ method(object({}), object({ rules: array(NcRuleSchema) }), { auth: "admin" }), m
44034
44263
  auth: "admin"
44035
44264
  }), method(NcAlarmSensorsInputSchema, NcAlarmSensorsSchema, { auth: "admin" });
44036
44265
  /**
44037
- * Zod schemas for persisted record types.
44038
- *
44039
- * These schemas serve as the single source of truth for types that are
44040
- * stored in the settings-store backend and retrieved via tRPC. They
44041
- * replace the manual TypeScript interfaces with schema-derived types,
44042
- * enabling runtime validation when reading from the backend.
44043
- *
44044
- * Convention: each schema is named `<Type>Schema`, the inferred TS type
44045
- * keeps the original name for backward compatibility.
44046
- */
44047
- /**
44048
- * Auth model (v2 — 2026-05-12 caps-only):
44049
- *
44050
- * Two principals:
44051
- * - `isAdmin: true` — full bypass. Admin scope set is ignored.
44052
- * - `isAdmin: false` — every call gated by `scopes` (see TokenScope).
44053
- *
44054
- * No role enum. There used to be `viewer / agent / scoped` and earlier
44055
- * `super_admin` — collapsed onto the single boolean because every
44056
- * non-admin caller is governed by the same scope-check rules; the
44057
- * distinction was only ever used to route role-specific procedures
44058
- * which we no longer have. CLI / webhook integrations are `cst_*` tokens
44059
- * with `isAdmin: false` + an explicit scope list.
44060
- */
44061
- /** Per-method access flavour. Materialised on every cap method via codegen. */
44062
- var MethodAccessSchema = _enum([
44063
- "view",
44064
- "create",
44065
- "delete"
44066
- ]);
44067
- /**
44068
- * A single scope grant. Three forms — checked in matcher with OR
44069
- * semantics; the first match decides whether the call passes:
44070
- *
44071
- * - `category` — broadest. `target: 'device' | 'system'` selects every
44072
- * cap with the matching `scope` declaration. New caps inherit grants
44073
- * automatically — adding a device cap to the codebase makes it
44074
- * reachable to every user with `category:device [...]` without a
44075
- * re-grant. Use this for "family viewer" / "operator" tiers.
44076
- *
44077
- * - `addon` — every cap that ships inside a given addon id. Niche;
44078
- * useful when an integration needs to interact with one specific
44079
- * addon's surface regardless of how many caps it exports.
44080
- *
44081
- * - `capability` — the most precise form. Single cap name. Use for
44082
- * integration tokens where you want to grant `addons.installPackage`
44083
- * and nothing else.
44084
- *
44085
- * `access` is REQUIRED with min 1 element. `admin` bypass is the
44086
- * "give me everything" escape; there is no wildcard scope.
44087
- */
44088
- var AllowedProviderSchema = union([literal("*"), array(string())]);
44089
- var AllowedDevicesSchema = record(string(), union([literal("*"), array(string())]));
44090
- var CapScopeSchema = _enum(["device", "system"]);
44091
- /**
44092
- * DeviceSelector (scope model v3 — 2026-08-12).
44093
- *
44094
- * A `device` grant no longer carries a frozen list of deviceIds. It carries
44095
- * a SELECTOR the matcher resolves against the live fleet, so the grant can be
44096
- * DYNAMIC: a `types:['camera']` selector automatically covers a camera added
44097
- * AFTER the grant was minted — no re-grant, no re-login.
44098
- *
44099
- * - `all` — every device in the deployment. The broad viewer/operator
44100
- * lever without a `category` grant (a `category` grant also covers device
44101
- * caps that carry no deviceId; `all` is specifically the device set).
44102
- * - `ids` — an explicit deviceId list. This is what a v2 `device:[…]`
44103
- * grant migrates to (see {@link TokenScopeSchema}); STATIC — a new camera
44104
- * is NOT covered until the grant is edited.
44105
- * - `types` — every device of a `DeviceType` (e.g. every `camera`).
44106
- * DYNAMIC. A device that changes type, or a new device of the type,
44107
- * re-resolves on the next request.
44108
- * - `locations` — every device whose operator-assigned `location` label is
44109
- * in the set (e.g. "Garden", "Front door"). DYNAMIC. A device with a
44110
- * null/unset location matches NO `locations` selector.
44111
- */
44112
- var DeviceSelectorSchema = discriminatedUnion("kind", [
44113
- object({ kind: literal("all") }),
44114
- object({
44115
- kind: literal("ids"),
44116
- ids: array(number().int()).min(1)
44117
- }),
44118
- object({
44119
- kind: literal("types"),
44120
- types: array(_enum(DeviceType)).min(1)
44121
- }),
44122
- object({
44123
- kind: literal("locations"),
44124
- locations: array(string().min(1)).min(1)
44125
- })
44126
- ]);
44127
- var DeviceTokenScopeSchema = object({
44128
- type: literal("device"),
44129
- /** The device SET this grant covers — resolved against the live fleet. */
44130
- selector: DeviceSelectorSchema,
44131
- access: array(MethodAccessSchema).min(1),
44132
- /**
44133
- * Whether a grant on a PARENT device transparently covers its accessory
44134
- * CHILDREN (siren / floodlight / PIR) via the persisted-parentage walk.
44135
- * Direction is parent → children ONLY.
44136
- *
44137
- * Absent → the matcher DERIVES it from the access flavour: `view`
44138
- * inherits (a camera viewer sees the camera's accessories), `create` /
44139
- * `delete` do NOT (actuating/removing a child is an explicit act the
44140
- * operator must grant on the child, not inherit from the parent). Set it
44141
- * explicitly to override that default per grant.
44142
- */
44143
- includeLinked: boolean().optional()
44144
- });
44145
- /**
44146
- * v2 → v3 lazy migration. A pre-v3 `device` grant carried
44147
- * `targets: string[]` (stringified deviceIds); it rewrites to the equivalent
44148
- * `selector: {kind:'ids', ids}`. Applied as a `preprocess` so it runs on
44149
- * EVERY parse path — stored records AND the JWT-carried scope arrays
44150
- * normalised at the request boundary ({@link normalizeTokenScopes} in
44151
- * `device-selector.ts`). Chosen over a one-time DB migration because a
44152
- * migration cannot reach a JWT already in a client's hands; parse-time
44153
- * migration covers both without a flag day. No cast — the raw object is read
44154
- * through `Reflect.get` (its static type is `unknown`).
44155
- */
44156
- function migrateLegacyTokenScope(raw) {
44157
- if (raw === null || typeof raw !== "object" || Array.isArray(raw)) return raw;
44158
- if (Reflect.get(raw, "type") !== "device") return raw;
44159
- if (Reflect.get(raw, "selector") !== void 0) return raw;
44160
- const targets = Reflect.get(raw, "targets");
44161
- if (!Array.isArray(targets)) return raw;
44162
- return {
44163
- type: "device",
44164
- selector: {
44165
- kind: "ids",
44166
- ids: targets.map((t) => typeof t === "string" ? Number(t) : t).filter((n) => typeof n === "number" && Number.isInteger(n))
44167
- },
44168
- access: Reflect.get(raw, "access")
44169
- };
44170
- }
44171
- var TokenScopeSchema = preprocess(migrateLegacyTokenScope, discriminatedUnion("type", [
44172
- object({
44173
- type: literal("category"),
44174
- target: CapScopeSchema,
44175
- access: array(MethodAccessSchema).min(1)
44176
- }),
44177
- object({
44178
- type: literal("capability"),
44179
- target: string(),
44180
- access: array(MethodAccessSchema).min(1)
44181
- }),
44182
- object({
44183
- type: literal("addon"),
44184
- target: string(),
44185
- access: array(MethodAccessSchema).min(1)
44186
- }),
44187
- DeviceTokenScopeSchema
44188
- ]));
44189
- object({
44190
- id: string(),
44191
- username: string(),
44192
- passwordHash: string(),
44193
- /**
44194
- * Admin bypass. When true, the middleware skips the scope-access
44195
- * check entirely. There is no other axis of privilege; the legacy
44196
- * role enum collapsed onto this boolean in v2.
44197
- */
44198
- isAdmin: boolean().default(false),
44199
- allowedProviders: AllowedProviderSchema,
44200
- allowedDevices: AllowedDevicesSchema,
44201
- /**
44202
- * Scopes granted to this user. Admins bypass; their `scopes` is
44203
- * ignored. Non-admins without scopes are locked out of every
44204
- * protected call.
44205
- */
44206
- scopes: array(TokenScopeSchema).default([]),
44207
- createdAt: number(),
44208
- updatedAt: number()
44209
- });
44210
- object({
44211
- id: string(),
44212
- label: string(),
44213
- isAdmin: boolean().default(false),
44214
- allowedProviders: AllowedProviderSchema,
44215
- allowedDevices: AllowedDevicesSchema,
44216
- tokenHash: string(),
44217
- tokenPrefix: string(),
44218
- createdAt: number(),
44219
- lastUsedAt: number().optional()
44220
- });
44221
- object({
44222
- id: string(),
44223
- userId: string(),
44224
- name: string(),
44225
- tokenHash: string(),
44226
- tokenPrefix: string(),
44227
- scopes: array(TokenScopeSchema),
44228
- expiresAt: number().nullish(),
44229
- lastUsedAt: number().nullish(),
44230
- createdAt: number()
44231
- });
44232
- /**
44233
44266
  * `oauth-integration` — a collection cap by which an addon declares
44234
44267
  * itself a linkable OAuth client of the hub's core `/oauth2/*` server.
44235
44268
  * Each provider returns a static descriptor; the core enumerates them
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@camstack/addon-mqtt-broker",
3
- "version": "1.2.128",
3
+ "version": "1.2.129",
4
4
  "description": "MQTT broker registry addon for CamStack — manages external broker entries + an optional embedded aedes broker. Consumers spin up their own `mqtt.js` clients via the `mqtt-broker` cap.",
5
5
  "keywords": [
6
6
  "camstack",