@camstack/addon-provider-rtsp 1.2.129 → 1.2.130

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 (3) hide show
  1. package/dist/addon.js +229 -196
  2. package/dist/addon.mjs +229 -196
  3. package/package.json +1 -1
package/dist/addon.js CHANGED
@@ -7820,6 +7820,12 @@ function normalizeAddonInitResult(result) {
7820
7820
  if (Array.isArray(result)) return { providers: result };
7821
7821
  return result;
7822
7822
  }
7823
+ /**
7824
+ * The share-view scope kinds a `csv_*` share token can carry. The hub mints
7825
+ * and validates them (`share-token.service.ts` builds its enum from this
7826
+ * list); a data plane names the kinds it ACCEPTS in `share`.
7827
+ */
7828
+ var SHARE_VIEW_KINDS = ["grid-view", "events-view"];
7823
7829
  /** The wire shape of {@link PeerBytesTicket} — see the type for what it is. */
7824
7830
  var PeerBytesTicketSchema = object({
7825
7831
  /** `http://127.0.0.1:<port>/<token>`. One `GET` takes it. */
@@ -12606,6 +12612,229 @@ var ConvertResultSchema = object({
12606
12612
  files: array(string()).readonly()
12607
12613
  })).readonly()
12608
12614
  });
12615
+ /**
12616
+ * Zod schemas for persisted record types.
12617
+ *
12618
+ * These schemas serve as the single source of truth for types that are
12619
+ * stored in the settings-store backend and retrieved via tRPC. They
12620
+ * replace the manual TypeScript interfaces with schema-derived types,
12621
+ * enabling runtime validation when reading from the backend.
12622
+ *
12623
+ * Convention: each schema is named `<Type>Schema`, the inferred TS type
12624
+ * keeps the original name for backward compatibility.
12625
+ */
12626
+ /**
12627
+ * Auth model (v2 — 2026-05-12 caps-only):
12628
+ *
12629
+ * Two principals:
12630
+ * - `isAdmin: true` — full bypass. Admin scope set is ignored.
12631
+ * - `isAdmin: false` — every call gated by `scopes` (see TokenScope).
12632
+ *
12633
+ * No role enum. There used to be `viewer / agent / scoped` and earlier
12634
+ * `super_admin` — collapsed onto the single boolean because every
12635
+ * non-admin caller is governed by the same scope-check rules; the
12636
+ * distinction was only ever used to route role-specific procedures
12637
+ * which we no longer have. CLI / webhook integrations are `cst_*` tokens
12638
+ * with `isAdmin: false` + an explicit scope list.
12639
+ */
12640
+ /** Per-method access flavour. Materialised on every cap method via codegen. */
12641
+ var MethodAccessSchema = _enum([
12642
+ "view",
12643
+ "create",
12644
+ "delete"
12645
+ ]);
12646
+ /**
12647
+ * A single scope grant. Three forms — checked in matcher with OR
12648
+ * semantics; the first match decides whether the call passes:
12649
+ *
12650
+ * - `category` — broadest. `target: 'device' | 'system'` selects every
12651
+ * cap with the matching `scope` declaration. New caps inherit grants
12652
+ * automatically — adding a device cap to the codebase makes it
12653
+ * reachable to every user with `category:device [...]` without a
12654
+ * re-grant. Use this for "family viewer" / "operator" tiers.
12655
+ *
12656
+ * - `addon` — every cap that ships inside a given addon id. Niche;
12657
+ * useful when an integration needs to interact with one specific
12658
+ * addon's surface regardless of how many caps it exports.
12659
+ *
12660
+ * - `capability` — the most precise form. Single cap name. Use for
12661
+ * integration tokens where you want to grant `addons.installPackage`
12662
+ * and nothing else.
12663
+ *
12664
+ * `access` is REQUIRED with min 1 element. `admin` bypass is the
12665
+ * "give me everything" escape; there is no wildcard scope.
12666
+ */
12667
+ var AllowedProviderSchema = union([literal("*"), array(string())]);
12668
+ var AllowedDevicesSchema = record(string(), union([literal("*"), array(string())]));
12669
+ var CapScopeSchema = _enum(["device", "system"]);
12670
+ /**
12671
+ * DeviceSelector (scope model v3 — 2026-08-12).
12672
+ *
12673
+ * A `device` grant no longer carries a frozen list of deviceIds. It carries
12674
+ * a SELECTOR the matcher resolves against the live fleet, so the grant can be
12675
+ * DYNAMIC: a `types:['camera']` selector automatically covers a camera added
12676
+ * AFTER the grant was minted — no re-grant, no re-login.
12677
+ *
12678
+ * - `all` — every device in the deployment. The broad viewer/operator
12679
+ * lever without a `category` grant (a `category` grant also covers device
12680
+ * caps that carry no deviceId; `all` is specifically the device set).
12681
+ * - `ids` — an explicit deviceId list. This is what a v2 `device:[…]`
12682
+ * grant migrates to (see {@link TokenScopeSchema}); STATIC — a new camera
12683
+ * is NOT covered until the grant is edited.
12684
+ * - `types` — every device of a `DeviceType` (e.g. every `camera`).
12685
+ * DYNAMIC. A device that changes type, or a new device of the type,
12686
+ * re-resolves on the next request.
12687
+ * - `locations` — every device whose operator-assigned `location` label is
12688
+ * in the set (e.g. "Garden", "Front door"). DYNAMIC. A device with a
12689
+ * null/unset location matches NO `locations` selector.
12690
+ */
12691
+ var DeviceSelectorSchema = discriminatedUnion("kind", [
12692
+ object({ kind: literal("all") }),
12693
+ object({
12694
+ kind: literal("ids"),
12695
+ ids: array(number().int()).min(1)
12696
+ }),
12697
+ object({
12698
+ kind: literal("types"),
12699
+ types: array(_enum(DeviceType)).min(1)
12700
+ }),
12701
+ object({
12702
+ kind: literal("locations"),
12703
+ locations: array(string().min(1)).min(1)
12704
+ })
12705
+ ]);
12706
+ var DeviceTokenScopeSchema = object({
12707
+ type: literal("device"),
12708
+ /** The device SET this grant covers — resolved against the live fleet. */
12709
+ selector: DeviceSelectorSchema,
12710
+ access: array(MethodAccessSchema).min(1),
12711
+ /**
12712
+ * Whether a grant on a PARENT device transparently covers its accessory
12713
+ * CHILDREN (siren / floodlight / PIR) via the persisted-parentage walk.
12714
+ * Direction is parent → children ONLY.
12715
+ *
12716
+ * Absent → the matcher DERIVES it from the access flavour: `view`
12717
+ * inherits (a camera viewer sees the camera's accessories), `create` /
12718
+ * `delete` do NOT (actuating/removing a child is an explicit act the
12719
+ * operator must grant on the child, not inherit from the parent). Set it
12720
+ * explicitly to override that default per grant.
12721
+ */
12722
+ includeLinked: boolean().optional()
12723
+ });
12724
+ /**
12725
+ * v2 → v3 lazy migration. A pre-v3 `device` grant carried
12726
+ * `targets: string[]` (stringified deviceIds); it rewrites to the equivalent
12727
+ * `selector: {kind:'ids', ids}`. Applied as a `preprocess` so it runs on
12728
+ * EVERY parse path — stored records AND the JWT-carried scope arrays
12729
+ * normalised at the request boundary ({@link normalizeTokenScopes} in
12730
+ * `device-selector.ts`). Chosen over a one-time DB migration because a
12731
+ * migration cannot reach a JWT already in a client's hands; parse-time
12732
+ * migration covers both without a flag day. No cast — the raw object is read
12733
+ * through `Reflect.get` (its static type is `unknown`).
12734
+ */
12735
+ function migrateLegacyTokenScope(raw) {
12736
+ if (raw === null || typeof raw !== "object" || Array.isArray(raw)) return raw;
12737
+ if (Reflect.get(raw, "type") !== "device") return raw;
12738
+ if (Reflect.get(raw, "selector") !== void 0) return raw;
12739
+ const targets = Reflect.get(raw, "targets");
12740
+ if (!Array.isArray(targets)) return raw;
12741
+ return {
12742
+ type: "device",
12743
+ selector: {
12744
+ kind: "ids",
12745
+ ids: targets.map((t) => typeof t === "string" ? Number(t) : t).filter((n) => typeof n === "number" && Number.isInteger(n))
12746
+ },
12747
+ access: Reflect.get(raw, "access")
12748
+ };
12749
+ }
12750
+ var TokenScopeSchema = preprocess(migrateLegacyTokenScope, discriminatedUnion("type", [
12751
+ object({
12752
+ type: literal("category"),
12753
+ target: CapScopeSchema,
12754
+ access: array(MethodAccessSchema).min(1)
12755
+ }),
12756
+ object({
12757
+ type: literal("capability"),
12758
+ target: string(),
12759
+ access: array(MethodAccessSchema).min(1)
12760
+ }),
12761
+ object({
12762
+ type: literal("addon"),
12763
+ target: string(),
12764
+ access: array(MethodAccessSchema).min(1)
12765
+ }),
12766
+ DeviceTokenScopeSchema
12767
+ ]));
12768
+ object({
12769
+ id: string(),
12770
+ username: string(),
12771
+ passwordHash: string(),
12772
+ /**
12773
+ * Admin bypass. When true, the middleware skips the scope-access
12774
+ * check entirely. There is no other axis of privilege; the legacy
12775
+ * role enum collapsed onto this boolean in v2.
12776
+ */
12777
+ isAdmin: boolean().default(false),
12778
+ allowedProviders: AllowedProviderSchema,
12779
+ allowedDevices: AllowedDevicesSchema,
12780
+ /**
12781
+ * Scopes granted to this user. Admins bypass; their `scopes` is
12782
+ * ignored. Non-admins without scopes are locked out of every
12783
+ * protected call.
12784
+ */
12785
+ scopes: array(TokenScopeSchema).default([]),
12786
+ createdAt: number(),
12787
+ updatedAt: number()
12788
+ });
12789
+ object({
12790
+ id: string(),
12791
+ label: string(),
12792
+ isAdmin: boolean().default(false),
12793
+ allowedProviders: AllowedProviderSchema,
12794
+ allowedDevices: AllowedDevicesSchema,
12795
+ tokenHash: string(),
12796
+ tokenPrefix: string(),
12797
+ createdAt: number(),
12798
+ lastUsedAt: number().optional()
12799
+ });
12800
+ object({
12801
+ id: string(),
12802
+ userId: string(),
12803
+ name: string(),
12804
+ tokenHash: string(),
12805
+ tokenPrefix: string(),
12806
+ scopes: array(TokenScopeSchema),
12807
+ expiresAt: number().nullish(),
12808
+ lastUsedAt: number().nullish(),
12809
+ createdAt: number()
12810
+ });
12811
+ /** What a share-view grant lets its holder see. */
12812
+ var ShareViewGrantSchema = object({
12813
+ kind: _enum(SHARE_VIEW_KINDS),
12814
+ deviceIds: array(number().int().nonnegative()).min(1).max(64),
12815
+ /** Talk-back, opt-in at mint time; absent means off. */
12816
+ talk: boolean().optional()
12817
+ });
12818
+ var ShareViewScopeSchema = object({
12819
+ type: literal("share-view"),
12820
+ grant: ShareViewGrantSchema
12821
+ });
12822
+ var AddonRoutesScopeSchema = object({
12823
+ type: literal("addon-routes"),
12824
+ access: array(MethodAccessSchema).min(1)
12825
+ });
12826
+ var CredentialScopeSchema = union([
12827
+ literal("*"),
12828
+ ShareViewScopeSchema,
12829
+ AddonRoutesScopeSchema,
12830
+ TokenScopeSchema
12831
+ ]);
12832
+ object({
12833
+ kind: literal("credential"),
12834
+ sub: string().min(1),
12835
+ jti: string().min(16),
12836
+ scopes: array(CredentialScopeSchema).min(1)
12837
+ });
12609
12838
  _enum(["new-session", "step-up"]);
12610
12839
  /** The languages the hub's app landing pages are written in (D858). */
12611
12840
  var AppPageLangSchema = _enum(["en", "it"]);
@@ -44083,202 +44312,6 @@ method(object({}), object({ rules: array(NcRuleSchema) }), { auth: "admin" }), m
44083
44312
  auth: "admin"
44084
44313
  }), method(NcAlarmSensorsInputSchema, NcAlarmSensorsSchema, { auth: "admin" });
44085
44314
  /**
44086
- * Zod schemas for persisted record types.
44087
- *
44088
- * These schemas serve as the single source of truth for types that are
44089
- * stored in the settings-store backend and retrieved via tRPC. They
44090
- * replace the manual TypeScript interfaces with schema-derived types,
44091
- * enabling runtime validation when reading from the backend.
44092
- *
44093
- * Convention: each schema is named `<Type>Schema`, the inferred TS type
44094
- * keeps the original name for backward compatibility.
44095
- */
44096
- /**
44097
- * Auth model (v2 — 2026-05-12 caps-only):
44098
- *
44099
- * Two principals:
44100
- * - `isAdmin: true` — full bypass. Admin scope set is ignored.
44101
- * - `isAdmin: false` — every call gated by `scopes` (see TokenScope).
44102
- *
44103
- * No role enum. There used to be `viewer / agent / scoped` and earlier
44104
- * `super_admin` — collapsed onto the single boolean because every
44105
- * non-admin caller is governed by the same scope-check rules; the
44106
- * distinction was only ever used to route role-specific procedures
44107
- * which we no longer have. CLI / webhook integrations are `cst_*` tokens
44108
- * with `isAdmin: false` + an explicit scope list.
44109
- */
44110
- /** Per-method access flavour. Materialised on every cap method via codegen. */
44111
- var MethodAccessSchema = _enum([
44112
- "view",
44113
- "create",
44114
- "delete"
44115
- ]);
44116
- /**
44117
- * A single scope grant. Three forms — checked in matcher with OR
44118
- * semantics; the first match decides whether the call passes:
44119
- *
44120
- * - `category` — broadest. `target: 'device' | 'system'` selects every
44121
- * cap with the matching `scope` declaration. New caps inherit grants
44122
- * automatically — adding a device cap to the codebase makes it
44123
- * reachable to every user with `category:device [...]` without a
44124
- * re-grant. Use this for "family viewer" / "operator" tiers.
44125
- *
44126
- * - `addon` — every cap that ships inside a given addon id. Niche;
44127
- * useful when an integration needs to interact with one specific
44128
- * addon's surface regardless of how many caps it exports.
44129
- *
44130
- * - `capability` — the most precise form. Single cap name. Use for
44131
- * integration tokens where you want to grant `addons.installPackage`
44132
- * and nothing else.
44133
- *
44134
- * `access` is REQUIRED with min 1 element. `admin` bypass is the
44135
- * "give me everything" escape; there is no wildcard scope.
44136
- */
44137
- var AllowedProviderSchema = union([literal("*"), array(string())]);
44138
- var AllowedDevicesSchema = record(string(), union([literal("*"), array(string())]));
44139
- var CapScopeSchema = _enum(["device", "system"]);
44140
- /**
44141
- * DeviceSelector (scope model v3 — 2026-08-12).
44142
- *
44143
- * A `device` grant no longer carries a frozen list of deviceIds. It carries
44144
- * a SELECTOR the matcher resolves against the live fleet, so the grant can be
44145
- * DYNAMIC: a `types:['camera']` selector automatically covers a camera added
44146
- * AFTER the grant was minted — no re-grant, no re-login.
44147
- *
44148
- * - `all` — every device in the deployment. The broad viewer/operator
44149
- * lever without a `category` grant (a `category` grant also covers device
44150
- * caps that carry no deviceId; `all` is specifically the device set).
44151
- * - `ids` — an explicit deviceId list. This is what a v2 `device:[…]`
44152
- * grant migrates to (see {@link TokenScopeSchema}); STATIC — a new camera
44153
- * is NOT covered until the grant is edited.
44154
- * - `types` — every device of a `DeviceType` (e.g. every `camera`).
44155
- * DYNAMIC. A device that changes type, or a new device of the type,
44156
- * re-resolves on the next request.
44157
- * - `locations` — every device whose operator-assigned `location` label is
44158
- * in the set (e.g. "Garden", "Front door"). DYNAMIC. A device with a
44159
- * null/unset location matches NO `locations` selector.
44160
- */
44161
- var DeviceSelectorSchema = discriminatedUnion("kind", [
44162
- object({ kind: literal("all") }),
44163
- object({
44164
- kind: literal("ids"),
44165
- ids: array(number().int()).min(1)
44166
- }),
44167
- object({
44168
- kind: literal("types"),
44169
- types: array(_enum(DeviceType)).min(1)
44170
- }),
44171
- object({
44172
- kind: literal("locations"),
44173
- locations: array(string().min(1)).min(1)
44174
- })
44175
- ]);
44176
- var DeviceTokenScopeSchema = object({
44177
- type: literal("device"),
44178
- /** The device SET this grant covers — resolved against the live fleet. */
44179
- selector: DeviceSelectorSchema,
44180
- access: array(MethodAccessSchema).min(1),
44181
- /**
44182
- * Whether a grant on a PARENT device transparently covers its accessory
44183
- * CHILDREN (siren / floodlight / PIR) via the persisted-parentage walk.
44184
- * Direction is parent → children ONLY.
44185
- *
44186
- * Absent → the matcher DERIVES it from the access flavour: `view`
44187
- * inherits (a camera viewer sees the camera's accessories), `create` /
44188
- * `delete` do NOT (actuating/removing a child is an explicit act the
44189
- * operator must grant on the child, not inherit from the parent). Set it
44190
- * explicitly to override that default per grant.
44191
- */
44192
- includeLinked: boolean().optional()
44193
- });
44194
- /**
44195
- * v2 → v3 lazy migration. A pre-v3 `device` grant carried
44196
- * `targets: string[]` (stringified deviceIds); it rewrites to the equivalent
44197
- * `selector: {kind:'ids', ids}`. Applied as a `preprocess` so it runs on
44198
- * EVERY parse path — stored records AND the JWT-carried scope arrays
44199
- * normalised at the request boundary ({@link normalizeTokenScopes} in
44200
- * `device-selector.ts`). Chosen over a one-time DB migration because a
44201
- * migration cannot reach a JWT already in a client's hands; parse-time
44202
- * migration covers both without a flag day. No cast — the raw object is read
44203
- * through `Reflect.get` (its static type is `unknown`).
44204
- */
44205
- function migrateLegacyTokenScope(raw) {
44206
- if (raw === null || typeof raw !== "object" || Array.isArray(raw)) return raw;
44207
- if (Reflect.get(raw, "type") !== "device") return raw;
44208
- if (Reflect.get(raw, "selector") !== void 0) return raw;
44209
- const targets = Reflect.get(raw, "targets");
44210
- if (!Array.isArray(targets)) return raw;
44211
- return {
44212
- type: "device",
44213
- selector: {
44214
- kind: "ids",
44215
- ids: targets.map((t) => typeof t === "string" ? Number(t) : t).filter((n) => typeof n === "number" && Number.isInteger(n))
44216
- },
44217
- access: Reflect.get(raw, "access")
44218
- };
44219
- }
44220
- var TokenScopeSchema = preprocess(migrateLegacyTokenScope, discriminatedUnion("type", [
44221
- object({
44222
- type: literal("category"),
44223
- target: CapScopeSchema,
44224
- access: array(MethodAccessSchema).min(1)
44225
- }),
44226
- object({
44227
- type: literal("capability"),
44228
- target: string(),
44229
- access: array(MethodAccessSchema).min(1)
44230
- }),
44231
- object({
44232
- type: literal("addon"),
44233
- target: string(),
44234
- access: array(MethodAccessSchema).min(1)
44235
- }),
44236
- DeviceTokenScopeSchema
44237
- ]));
44238
- object({
44239
- id: string(),
44240
- username: string(),
44241
- passwordHash: string(),
44242
- /**
44243
- * Admin bypass. When true, the middleware skips the scope-access
44244
- * check entirely. There is no other axis of privilege; the legacy
44245
- * role enum collapsed onto this boolean in v2.
44246
- */
44247
- isAdmin: boolean().default(false),
44248
- allowedProviders: AllowedProviderSchema,
44249
- allowedDevices: AllowedDevicesSchema,
44250
- /**
44251
- * Scopes granted to this user. Admins bypass; their `scopes` is
44252
- * ignored. Non-admins without scopes are locked out of every
44253
- * protected call.
44254
- */
44255
- scopes: array(TokenScopeSchema).default([]),
44256
- createdAt: number(),
44257
- updatedAt: number()
44258
- });
44259
- object({
44260
- id: string(),
44261
- label: string(),
44262
- isAdmin: boolean().default(false),
44263
- allowedProviders: AllowedProviderSchema,
44264
- allowedDevices: AllowedDevicesSchema,
44265
- tokenHash: string(),
44266
- tokenPrefix: string(),
44267
- createdAt: number(),
44268
- lastUsedAt: number().optional()
44269
- });
44270
- object({
44271
- id: string(),
44272
- userId: string(),
44273
- name: string(),
44274
- tokenHash: string(),
44275
- tokenPrefix: string(),
44276
- scopes: array(TokenScopeSchema),
44277
- expiresAt: number().nullish(),
44278
- lastUsedAt: number().nullish(),
44279
- createdAt: number()
44280
- });
44281
- /**
44282
44315
  * `oauth-integration` — a collection cap by which an addon declares
44283
44316
  * itself a linkable OAuth client of the hub's core `/oauth2/*` server.
44284
44317
  * Each provider returns a static descriptor; the core enumerates them
package/dist/addon.mjs CHANGED
@@ -7796,6 +7796,12 @@ function normalizeAddonInitResult(result) {
7796
7796
  if (Array.isArray(result)) return { providers: result };
7797
7797
  return result;
7798
7798
  }
7799
+ /**
7800
+ * The share-view scope kinds a `csv_*` share token can carry. The hub mints
7801
+ * and validates them (`share-token.service.ts` builds its enum from this
7802
+ * list); a data plane names the kinds it ACCEPTS in `share`.
7803
+ */
7804
+ var SHARE_VIEW_KINDS = ["grid-view", "events-view"];
7799
7805
  /** The wire shape of {@link PeerBytesTicket} — see the type for what it is. */
7800
7806
  var PeerBytesTicketSchema = object({
7801
7807
  /** `http://127.0.0.1:<port>/<token>`. One `GET` takes it. */
@@ -12582,6 +12588,229 @@ var ConvertResultSchema = object({
12582
12588
  files: array(string()).readonly()
12583
12589
  })).readonly()
12584
12590
  });
12591
+ /**
12592
+ * Zod schemas for persisted record types.
12593
+ *
12594
+ * These schemas serve as the single source of truth for types that are
12595
+ * stored in the settings-store backend and retrieved via tRPC. They
12596
+ * replace the manual TypeScript interfaces with schema-derived types,
12597
+ * enabling runtime validation when reading from the backend.
12598
+ *
12599
+ * Convention: each schema is named `<Type>Schema`, the inferred TS type
12600
+ * keeps the original name for backward compatibility.
12601
+ */
12602
+ /**
12603
+ * Auth model (v2 — 2026-05-12 caps-only):
12604
+ *
12605
+ * Two principals:
12606
+ * - `isAdmin: true` — full bypass. Admin scope set is ignored.
12607
+ * - `isAdmin: false` — every call gated by `scopes` (see TokenScope).
12608
+ *
12609
+ * No role enum. There used to be `viewer / agent / scoped` and earlier
12610
+ * `super_admin` — collapsed onto the single boolean because every
12611
+ * non-admin caller is governed by the same scope-check rules; the
12612
+ * distinction was only ever used to route role-specific procedures
12613
+ * which we no longer have. CLI / webhook integrations are `cst_*` tokens
12614
+ * with `isAdmin: false` + an explicit scope list.
12615
+ */
12616
+ /** Per-method access flavour. Materialised on every cap method via codegen. */
12617
+ var MethodAccessSchema = _enum([
12618
+ "view",
12619
+ "create",
12620
+ "delete"
12621
+ ]);
12622
+ /**
12623
+ * A single scope grant. Three forms — checked in matcher with OR
12624
+ * semantics; the first match decides whether the call passes:
12625
+ *
12626
+ * - `category` — broadest. `target: 'device' | 'system'` selects every
12627
+ * cap with the matching `scope` declaration. New caps inherit grants
12628
+ * automatically — adding a device cap to the codebase makes it
12629
+ * reachable to every user with `category:device [...]` without a
12630
+ * re-grant. Use this for "family viewer" / "operator" tiers.
12631
+ *
12632
+ * - `addon` — every cap that ships inside a given addon id. Niche;
12633
+ * useful when an integration needs to interact with one specific
12634
+ * addon's surface regardless of how many caps it exports.
12635
+ *
12636
+ * - `capability` — the most precise form. Single cap name. Use for
12637
+ * integration tokens where you want to grant `addons.installPackage`
12638
+ * and nothing else.
12639
+ *
12640
+ * `access` is REQUIRED with min 1 element. `admin` bypass is the
12641
+ * "give me everything" escape; there is no wildcard scope.
12642
+ */
12643
+ var AllowedProviderSchema = union([literal("*"), array(string())]);
12644
+ var AllowedDevicesSchema = record(string(), union([literal("*"), array(string())]));
12645
+ var CapScopeSchema = _enum(["device", "system"]);
12646
+ /**
12647
+ * DeviceSelector (scope model v3 — 2026-08-12).
12648
+ *
12649
+ * A `device` grant no longer carries a frozen list of deviceIds. It carries
12650
+ * a SELECTOR the matcher resolves against the live fleet, so the grant can be
12651
+ * DYNAMIC: a `types:['camera']` selector automatically covers a camera added
12652
+ * AFTER the grant was minted — no re-grant, no re-login.
12653
+ *
12654
+ * - `all` — every device in the deployment. The broad viewer/operator
12655
+ * lever without a `category` grant (a `category` grant also covers device
12656
+ * caps that carry no deviceId; `all` is specifically the device set).
12657
+ * - `ids` — an explicit deviceId list. This is what a v2 `device:[…]`
12658
+ * grant migrates to (see {@link TokenScopeSchema}); STATIC — a new camera
12659
+ * is NOT covered until the grant is edited.
12660
+ * - `types` — every device of a `DeviceType` (e.g. every `camera`).
12661
+ * DYNAMIC. A device that changes type, or a new device of the type,
12662
+ * re-resolves on the next request.
12663
+ * - `locations` — every device whose operator-assigned `location` label is
12664
+ * in the set (e.g. "Garden", "Front door"). DYNAMIC. A device with a
12665
+ * null/unset location matches NO `locations` selector.
12666
+ */
12667
+ var DeviceSelectorSchema = discriminatedUnion("kind", [
12668
+ object({ kind: literal("all") }),
12669
+ object({
12670
+ kind: literal("ids"),
12671
+ ids: array(number().int()).min(1)
12672
+ }),
12673
+ object({
12674
+ kind: literal("types"),
12675
+ types: array(_enum(DeviceType)).min(1)
12676
+ }),
12677
+ object({
12678
+ kind: literal("locations"),
12679
+ locations: array(string().min(1)).min(1)
12680
+ })
12681
+ ]);
12682
+ var DeviceTokenScopeSchema = object({
12683
+ type: literal("device"),
12684
+ /** The device SET this grant covers — resolved against the live fleet. */
12685
+ selector: DeviceSelectorSchema,
12686
+ access: array(MethodAccessSchema).min(1),
12687
+ /**
12688
+ * Whether a grant on a PARENT device transparently covers its accessory
12689
+ * CHILDREN (siren / floodlight / PIR) via the persisted-parentage walk.
12690
+ * Direction is parent → children ONLY.
12691
+ *
12692
+ * Absent → the matcher DERIVES it from the access flavour: `view`
12693
+ * inherits (a camera viewer sees the camera's accessories), `create` /
12694
+ * `delete` do NOT (actuating/removing a child is an explicit act the
12695
+ * operator must grant on the child, not inherit from the parent). Set it
12696
+ * explicitly to override that default per grant.
12697
+ */
12698
+ includeLinked: boolean().optional()
12699
+ });
12700
+ /**
12701
+ * v2 → v3 lazy migration. A pre-v3 `device` grant carried
12702
+ * `targets: string[]` (stringified deviceIds); it rewrites to the equivalent
12703
+ * `selector: {kind:'ids', ids}`. Applied as a `preprocess` so it runs on
12704
+ * EVERY parse path — stored records AND the JWT-carried scope arrays
12705
+ * normalised at the request boundary ({@link normalizeTokenScopes} in
12706
+ * `device-selector.ts`). Chosen over a one-time DB migration because a
12707
+ * migration cannot reach a JWT already in a client's hands; parse-time
12708
+ * migration covers both without a flag day. No cast — the raw object is read
12709
+ * through `Reflect.get` (its static type is `unknown`).
12710
+ */
12711
+ function migrateLegacyTokenScope(raw) {
12712
+ if (raw === null || typeof raw !== "object" || Array.isArray(raw)) return raw;
12713
+ if (Reflect.get(raw, "type") !== "device") return raw;
12714
+ if (Reflect.get(raw, "selector") !== void 0) return raw;
12715
+ const targets = Reflect.get(raw, "targets");
12716
+ if (!Array.isArray(targets)) return raw;
12717
+ return {
12718
+ type: "device",
12719
+ selector: {
12720
+ kind: "ids",
12721
+ ids: targets.map((t) => typeof t === "string" ? Number(t) : t).filter((n) => typeof n === "number" && Number.isInteger(n))
12722
+ },
12723
+ access: Reflect.get(raw, "access")
12724
+ };
12725
+ }
12726
+ var TokenScopeSchema = preprocess(migrateLegacyTokenScope, discriminatedUnion("type", [
12727
+ object({
12728
+ type: literal("category"),
12729
+ target: CapScopeSchema,
12730
+ access: array(MethodAccessSchema).min(1)
12731
+ }),
12732
+ object({
12733
+ type: literal("capability"),
12734
+ target: string(),
12735
+ access: array(MethodAccessSchema).min(1)
12736
+ }),
12737
+ object({
12738
+ type: literal("addon"),
12739
+ target: string(),
12740
+ access: array(MethodAccessSchema).min(1)
12741
+ }),
12742
+ DeviceTokenScopeSchema
12743
+ ]));
12744
+ object({
12745
+ id: string(),
12746
+ username: string(),
12747
+ passwordHash: string(),
12748
+ /**
12749
+ * Admin bypass. When true, the middleware skips the scope-access
12750
+ * check entirely. There is no other axis of privilege; the legacy
12751
+ * role enum collapsed onto this boolean in v2.
12752
+ */
12753
+ isAdmin: boolean().default(false),
12754
+ allowedProviders: AllowedProviderSchema,
12755
+ allowedDevices: AllowedDevicesSchema,
12756
+ /**
12757
+ * Scopes granted to this user. Admins bypass; their `scopes` is
12758
+ * ignored. Non-admins without scopes are locked out of every
12759
+ * protected call.
12760
+ */
12761
+ scopes: array(TokenScopeSchema).default([]),
12762
+ createdAt: number(),
12763
+ updatedAt: number()
12764
+ });
12765
+ object({
12766
+ id: string(),
12767
+ label: string(),
12768
+ isAdmin: boolean().default(false),
12769
+ allowedProviders: AllowedProviderSchema,
12770
+ allowedDevices: AllowedDevicesSchema,
12771
+ tokenHash: string(),
12772
+ tokenPrefix: string(),
12773
+ createdAt: number(),
12774
+ lastUsedAt: number().optional()
12775
+ });
12776
+ object({
12777
+ id: string(),
12778
+ userId: string(),
12779
+ name: string(),
12780
+ tokenHash: string(),
12781
+ tokenPrefix: string(),
12782
+ scopes: array(TokenScopeSchema),
12783
+ expiresAt: number().nullish(),
12784
+ lastUsedAt: number().nullish(),
12785
+ createdAt: number()
12786
+ });
12787
+ /** What a share-view grant lets its holder see. */
12788
+ var ShareViewGrantSchema = object({
12789
+ kind: _enum(SHARE_VIEW_KINDS),
12790
+ deviceIds: array(number().int().nonnegative()).min(1).max(64),
12791
+ /** Talk-back, opt-in at mint time; absent means off. */
12792
+ talk: boolean().optional()
12793
+ });
12794
+ var ShareViewScopeSchema = object({
12795
+ type: literal("share-view"),
12796
+ grant: ShareViewGrantSchema
12797
+ });
12798
+ var AddonRoutesScopeSchema = object({
12799
+ type: literal("addon-routes"),
12800
+ access: array(MethodAccessSchema).min(1)
12801
+ });
12802
+ var CredentialScopeSchema = union([
12803
+ literal("*"),
12804
+ ShareViewScopeSchema,
12805
+ AddonRoutesScopeSchema,
12806
+ TokenScopeSchema
12807
+ ]);
12808
+ object({
12809
+ kind: literal("credential"),
12810
+ sub: string().min(1),
12811
+ jti: string().min(16),
12812
+ scopes: array(CredentialScopeSchema).min(1)
12813
+ });
12585
12814
  _enum(["new-session", "step-up"]);
12586
12815
  /** The languages the hub's app landing pages are written in (D858). */
12587
12816
  var AppPageLangSchema = _enum(["en", "it"]);
@@ -44059,202 +44288,6 @@ method(object({}), object({ rules: array(NcRuleSchema) }), { auth: "admin" }), m
44059
44288
  auth: "admin"
44060
44289
  }), method(NcAlarmSensorsInputSchema, NcAlarmSensorsSchema, { auth: "admin" });
44061
44290
  /**
44062
- * Zod schemas for persisted record types.
44063
- *
44064
- * These schemas serve as the single source of truth for types that are
44065
- * stored in the settings-store backend and retrieved via tRPC. They
44066
- * replace the manual TypeScript interfaces with schema-derived types,
44067
- * enabling runtime validation when reading from the backend.
44068
- *
44069
- * Convention: each schema is named `<Type>Schema`, the inferred TS type
44070
- * keeps the original name for backward compatibility.
44071
- */
44072
- /**
44073
- * Auth model (v2 — 2026-05-12 caps-only):
44074
- *
44075
- * Two principals:
44076
- * - `isAdmin: true` — full bypass. Admin scope set is ignored.
44077
- * - `isAdmin: false` — every call gated by `scopes` (see TokenScope).
44078
- *
44079
- * No role enum. There used to be `viewer / agent / scoped` and earlier
44080
- * `super_admin` — collapsed onto the single boolean because every
44081
- * non-admin caller is governed by the same scope-check rules; the
44082
- * distinction was only ever used to route role-specific procedures
44083
- * which we no longer have. CLI / webhook integrations are `cst_*` tokens
44084
- * with `isAdmin: false` + an explicit scope list.
44085
- */
44086
- /** Per-method access flavour. Materialised on every cap method via codegen. */
44087
- var MethodAccessSchema = _enum([
44088
- "view",
44089
- "create",
44090
- "delete"
44091
- ]);
44092
- /**
44093
- * A single scope grant. Three forms — checked in matcher with OR
44094
- * semantics; the first match decides whether the call passes:
44095
- *
44096
- * - `category` — broadest. `target: 'device' | 'system'` selects every
44097
- * cap with the matching `scope` declaration. New caps inherit grants
44098
- * automatically — adding a device cap to the codebase makes it
44099
- * reachable to every user with `category:device [...]` without a
44100
- * re-grant. Use this for "family viewer" / "operator" tiers.
44101
- *
44102
- * - `addon` — every cap that ships inside a given addon id. Niche;
44103
- * useful when an integration needs to interact with one specific
44104
- * addon's surface regardless of how many caps it exports.
44105
- *
44106
- * - `capability` — the most precise form. Single cap name. Use for
44107
- * integration tokens where you want to grant `addons.installPackage`
44108
- * and nothing else.
44109
- *
44110
- * `access` is REQUIRED with min 1 element. `admin` bypass is the
44111
- * "give me everything" escape; there is no wildcard scope.
44112
- */
44113
- var AllowedProviderSchema = union([literal("*"), array(string())]);
44114
- var AllowedDevicesSchema = record(string(), union([literal("*"), array(string())]));
44115
- var CapScopeSchema = _enum(["device", "system"]);
44116
- /**
44117
- * DeviceSelector (scope model v3 — 2026-08-12).
44118
- *
44119
- * A `device` grant no longer carries a frozen list of deviceIds. It carries
44120
- * a SELECTOR the matcher resolves against the live fleet, so the grant can be
44121
- * DYNAMIC: a `types:['camera']` selector automatically covers a camera added
44122
- * AFTER the grant was minted — no re-grant, no re-login.
44123
- *
44124
- * - `all` — every device in the deployment. The broad viewer/operator
44125
- * lever without a `category` grant (a `category` grant also covers device
44126
- * caps that carry no deviceId; `all` is specifically the device set).
44127
- * - `ids` — an explicit deviceId list. This is what a v2 `device:[…]`
44128
- * grant migrates to (see {@link TokenScopeSchema}); STATIC — a new camera
44129
- * is NOT covered until the grant is edited.
44130
- * - `types` — every device of a `DeviceType` (e.g. every `camera`).
44131
- * DYNAMIC. A device that changes type, or a new device of the type,
44132
- * re-resolves on the next request.
44133
- * - `locations` — every device whose operator-assigned `location` label is
44134
- * in the set (e.g. "Garden", "Front door"). DYNAMIC. A device with a
44135
- * null/unset location matches NO `locations` selector.
44136
- */
44137
- var DeviceSelectorSchema = discriminatedUnion("kind", [
44138
- object({ kind: literal("all") }),
44139
- object({
44140
- kind: literal("ids"),
44141
- ids: array(number().int()).min(1)
44142
- }),
44143
- object({
44144
- kind: literal("types"),
44145
- types: array(_enum(DeviceType)).min(1)
44146
- }),
44147
- object({
44148
- kind: literal("locations"),
44149
- locations: array(string().min(1)).min(1)
44150
- })
44151
- ]);
44152
- var DeviceTokenScopeSchema = object({
44153
- type: literal("device"),
44154
- /** The device SET this grant covers — resolved against the live fleet. */
44155
- selector: DeviceSelectorSchema,
44156
- access: array(MethodAccessSchema).min(1),
44157
- /**
44158
- * Whether a grant on a PARENT device transparently covers its accessory
44159
- * CHILDREN (siren / floodlight / PIR) via the persisted-parentage walk.
44160
- * Direction is parent → children ONLY.
44161
- *
44162
- * Absent → the matcher DERIVES it from the access flavour: `view`
44163
- * inherits (a camera viewer sees the camera's accessories), `create` /
44164
- * `delete` do NOT (actuating/removing a child is an explicit act the
44165
- * operator must grant on the child, not inherit from the parent). Set it
44166
- * explicitly to override that default per grant.
44167
- */
44168
- includeLinked: boolean().optional()
44169
- });
44170
- /**
44171
- * v2 → v3 lazy migration. A pre-v3 `device` grant carried
44172
- * `targets: string[]` (stringified deviceIds); it rewrites to the equivalent
44173
- * `selector: {kind:'ids', ids}`. Applied as a `preprocess` so it runs on
44174
- * EVERY parse path — stored records AND the JWT-carried scope arrays
44175
- * normalised at the request boundary ({@link normalizeTokenScopes} in
44176
- * `device-selector.ts`). Chosen over a one-time DB migration because a
44177
- * migration cannot reach a JWT already in a client's hands; parse-time
44178
- * migration covers both without a flag day. No cast — the raw object is read
44179
- * through `Reflect.get` (its static type is `unknown`).
44180
- */
44181
- function migrateLegacyTokenScope(raw) {
44182
- if (raw === null || typeof raw !== "object" || Array.isArray(raw)) return raw;
44183
- if (Reflect.get(raw, "type") !== "device") return raw;
44184
- if (Reflect.get(raw, "selector") !== void 0) return raw;
44185
- const targets = Reflect.get(raw, "targets");
44186
- if (!Array.isArray(targets)) return raw;
44187
- return {
44188
- type: "device",
44189
- selector: {
44190
- kind: "ids",
44191
- ids: targets.map((t) => typeof t === "string" ? Number(t) : t).filter((n) => typeof n === "number" && Number.isInteger(n))
44192
- },
44193
- access: Reflect.get(raw, "access")
44194
- };
44195
- }
44196
- var TokenScopeSchema = preprocess(migrateLegacyTokenScope, discriminatedUnion("type", [
44197
- object({
44198
- type: literal("category"),
44199
- target: CapScopeSchema,
44200
- access: array(MethodAccessSchema).min(1)
44201
- }),
44202
- object({
44203
- type: literal("capability"),
44204
- target: string(),
44205
- access: array(MethodAccessSchema).min(1)
44206
- }),
44207
- object({
44208
- type: literal("addon"),
44209
- target: string(),
44210
- access: array(MethodAccessSchema).min(1)
44211
- }),
44212
- DeviceTokenScopeSchema
44213
- ]));
44214
- object({
44215
- id: string(),
44216
- username: string(),
44217
- passwordHash: string(),
44218
- /**
44219
- * Admin bypass. When true, the middleware skips the scope-access
44220
- * check entirely. There is no other axis of privilege; the legacy
44221
- * role enum collapsed onto this boolean in v2.
44222
- */
44223
- isAdmin: boolean().default(false),
44224
- allowedProviders: AllowedProviderSchema,
44225
- allowedDevices: AllowedDevicesSchema,
44226
- /**
44227
- * Scopes granted to this user. Admins bypass; their `scopes` is
44228
- * ignored. Non-admins without scopes are locked out of every
44229
- * protected call.
44230
- */
44231
- scopes: array(TokenScopeSchema).default([]),
44232
- createdAt: number(),
44233
- updatedAt: number()
44234
- });
44235
- object({
44236
- id: string(),
44237
- label: string(),
44238
- isAdmin: boolean().default(false),
44239
- allowedProviders: AllowedProviderSchema,
44240
- allowedDevices: AllowedDevicesSchema,
44241
- tokenHash: string(),
44242
- tokenPrefix: string(),
44243
- createdAt: number(),
44244
- lastUsedAt: number().optional()
44245
- });
44246
- object({
44247
- id: string(),
44248
- userId: string(),
44249
- name: string(),
44250
- tokenHash: string(),
44251
- tokenPrefix: string(),
44252
- scopes: array(TokenScopeSchema),
44253
- expiresAt: number().nullish(),
44254
- lastUsedAt: number().nullish(),
44255
- createdAt: number()
44256
- });
44257
- /**
44258
44291
  * `oauth-integration` — a collection cap by which an addon declares
44259
44292
  * itself a linkable OAuth client of the hub's core `/oauth2/*` server.
44260
44293
  * 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-provider-rtsp",
3
- "version": "1.2.129",
3
+ "version": "1.2.130",
4
4
  "description": "Generic RTSP camera device provider addon for CamStack",
5
5
  "keywords": [
6
6
  "camstack",