@camstack/addon-provider-velux 0.2.129 → 0.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
@@ -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. */
@@ -12475,6 +12481,229 @@ var ConvertResultSchema = object({
12475
12481
  files: array(string()).readonly()
12476
12482
  })).readonly()
12477
12483
  });
12484
+ /**
12485
+ * Zod schemas for persisted record types.
12486
+ *
12487
+ * These schemas serve as the single source of truth for types that are
12488
+ * stored in the settings-store backend and retrieved via tRPC. They
12489
+ * replace the manual TypeScript interfaces with schema-derived types,
12490
+ * enabling runtime validation when reading from the backend.
12491
+ *
12492
+ * Convention: each schema is named `<Type>Schema`, the inferred TS type
12493
+ * keeps the original name for backward compatibility.
12494
+ */
12495
+ /**
12496
+ * Auth model (v2 — 2026-05-12 caps-only):
12497
+ *
12498
+ * Two principals:
12499
+ * - `isAdmin: true` — full bypass. Admin scope set is ignored.
12500
+ * - `isAdmin: false` — every call gated by `scopes` (see TokenScope).
12501
+ *
12502
+ * No role enum. There used to be `viewer / agent / scoped` and earlier
12503
+ * `super_admin` — collapsed onto the single boolean because every
12504
+ * non-admin caller is governed by the same scope-check rules; the
12505
+ * distinction was only ever used to route role-specific procedures
12506
+ * which we no longer have. CLI / webhook integrations are `cst_*` tokens
12507
+ * with `isAdmin: false` + an explicit scope list.
12508
+ */
12509
+ /** Per-method access flavour. Materialised on every cap method via codegen. */
12510
+ var MethodAccessSchema = _enum([
12511
+ "view",
12512
+ "create",
12513
+ "delete"
12514
+ ]);
12515
+ /**
12516
+ * A single scope grant. Three forms — checked in matcher with OR
12517
+ * semantics; the first match decides whether the call passes:
12518
+ *
12519
+ * - `category` — broadest. `target: 'device' | 'system'` selects every
12520
+ * cap with the matching `scope` declaration. New caps inherit grants
12521
+ * automatically — adding a device cap to the codebase makes it
12522
+ * reachable to every user with `category:device [...]` without a
12523
+ * re-grant. Use this for "family viewer" / "operator" tiers.
12524
+ *
12525
+ * - `addon` — every cap that ships inside a given addon id. Niche;
12526
+ * useful when an integration needs to interact with one specific
12527
+ * addon's surface regardless of how many caps it exports.
12528
+ *
12529
+ * - `capability` — the most precise form. Single cap name. Use for
12530
+ * integration tokens where you want to grant `addons.installPackage`
12531
+ * and nothing else.
12532
+ *
12533
+ * `access` is REQUIRED with min 1 element. `admin` bypass is the
12534
+ * "give me everything" escape; there is no wildcard scope.
12535
+ */
12536
+ var AllowedProviderSchema = union([literal("*"), array(string())]);
12537
+ var AllowedDevicesSchema = record(string(), union([literal("*"), array(string())]));
12538
+ var CapScopeSchema = _enum(["device", "system"]);
12539
+ /**
12540
+ * DeviceSelector (scope model v3 — 2026-08-12).
12541
+ *
12542
+ * A `device` grant no longer carries a frozen list of deviceIds. It carries
12543
+ * a SELECTOR the matcher resolves against the live fleet, so the grant can be
12544
+ * DYNAMIC: a `types:['camera']` selector automatically covers a camera added
12545
+ * AFTER the grant was minted — no re-grant, no re-login.
12546
+ *
12547
+ * - `all` — every device in the deployment. The broad viewer/operator
12548
+ * lever without a `category` grant (a `category` grant also covers device
12549
+ * caps that carry no deviceId; `all` is specifically the device set).
12550
+ * - `ids` — an explicit deviceId list. This is what a v2 `device:[…]`
12551
+ * grant migrates to (see {@link TokenScopeSchema}); STATIC — a new camera
12552
+ * is NOT covered until the grant is edited.
12553
+ * - `types` — every device of a `DeviceType` (e.g. every `camera`).
12554
+ * DYNAMIC. A device that changes type, or a new device of the type,
12555
+ * re-resolves on the next request.
12556
+ * - `locations` — every device whose operator-assigned `location` label is
12557
+ * in the set (e.g. "Garden", "Front door"). DYNAMIC. A device with a
12558
+ * null/unset location matches NO `locations` selector.
12559
+ */
12560
+ var DeviceSelectorSchema = discriminatedUnion("kind", [
12561
+ object({ kind: literal("all") }),
12562
+ object({
12563
+ kind: literal("ids"),
12564
+ ids: array(number().int()).min(1)
12565
+ }),
12566
+ object({
12567
+ kind: literal("types"),
12568
+ types: array(_enum(DeviceType)).min(1)
12569
+ }),
12570
+ object({
12571
+ kind: literal("locations"),
12572
+ locations: array(string().min(1)).min(1)
12573
+ })
12574
+ ]);
12575
+ var DeviceTokenScopeSchema = object({
12576
+ type: literal("device"),
12577
+ /** The device SET this grant covers — resolved against the live fleet. */
12578
+ selector: DeviceSelectorSchema,
12579
+ access: array(MethodAccessSchema).min(1),
12580
+ /**
12581
+ * Whether a grant on a PARENT device transparently covers its accessory
12582
+ * CHILDREN (siren / floodlight / PIR) via the persisted-parentage walk.
12583
+ * Direction is parent → children ONLY.
12584
+ *
12585
+ * Absent → the matcher DERIVES it from the access flavour: `view`
12586
+ * inherits (a camera viewer sees the camera's accessories), `create` /
12587
+ * `delete` do NOT (actuating/removing a child is an explicit act the
12588
+ * operator must grant on the child, not inherit from the parent). Set it
12589
+ * explicitly to override that default per grant.
12590
+ */
12591
+ includeLinked: boolean().optional()
12592
+ });
12593
+ /**
12594
+ * v2 → v3 lazy migration. A pre-v3 `device` grant carried
12595
+ * `targets: string[]` (stringified deviceIds); it rewrites to the equivalent
12596
+ * `selector: {kind:'ids', ids}`. Applied as a `preprocess` so it runs on
12597
+ * EVERY parse path — stored records AND the JWT-carried scope arrays
12598
+ * normalised at the request boundary ({@link normalizeTokenScopes} in
12599
+ * `device-selector.ts`). Chosen over a one-time DB migration because a
12600
+ * migration cannot reach a JWT already in a client's hands; parse-time
12601
+ * migration covers both without a flag day. No cast — the raw object is read
12602
+ * through `Reflect.get` (its static type is `unknown`).
12603
+ */
12604
+ function migrateLegacyTokenScope(raw) {
12605
+ if (raw === null || typeof raw !== "object" || Array.isArray(raw)) return raw;
12606
+ if (Reflect.get(raw, "type") !== "device") return raw;
12607
+ if (Reflect.get(raw, "selector") !== void 0) return raw;
12608
+ const targets = Reflect.get(raw, "targets");
12609
+ if (!Array.isArray(targets)) return raw;
12610
+ return {
12611
+ type: "device",
12612
+ selector: {
12613
+ kind: "ids",
12614
+ ids: targets.map((t) => typeof t === "string" ? Number(t) : t).filter((n) => typeof n === "number" && Number.isInteger(n))
12615
+ },
12616
+ access: Reflect.get(raw, "access")
12617
+ };
12618
+ }
12619
+ var TokenScopeSchema = preprocess(migrateLegacyTokenScope, discriminatedUnion("type", [
12620
+ object({
12621
+ type: literal("category"),
12622
+ target: CapScopeSchema,
12623
+ access: array(MethodAccessSchema).min(1)
12624
+ }),
12625
+ object({
12626
+ type: literal("capability"),
12627
+ target: string(),
12628
+ access: array(MethodAccessSchema).min(1)
12629
+ }),
12630
+ object({
12631
+ type: literal("addon"),
12632
+ target: string(),
12633
+ access: array(MethodAccessSchema).min(1)
12634
+ }),
12635
+ DeviceTokenScopeSchema
12636
+ ]));
12637
+ object({
12638
+ id: string(),
12639
+ username: string(),
12640
+ passwordHash: string(),
12641
+ /**
12642
+ * Admin bypass. When true, the middleware skips the scope-access
12643
+ * check entirely. There is no other axis of privilege; the legacy
12644
+ * role enum collapsed onto this boolean in v2.
12645
+ */
12646
+ isAdmin: boolean().default(false),
12647
+ allowedProviders: AllowedProviderSchema,
12648
+ allowedDevices: AllowedDevicesSchema,
12649
+ /**
12650
+ * Scopes granted to this user. Admins bypass; their `scopes` is
12651
+ * ignored. Non-admins without scopes are locked out of every
12652
+ * protected call.
12653
+ */
12654
+ scopes: array(TokenScopeSchema).default([]),
12655
+ createdAt: number(),
12656
+ updatedAt: number()
12657
+ });
12658
+ object({
12659
+ id: string(),
12660
+ label: string(),
12661
+ isAdmin: boolean().default(false),
12662
+ allowedProviders: AllowedProviderSchema,
12663
+ allowedDevices: AllowedDevicesSchema,
12664
+ tokenHash: string(),
12665
+ tokenPrefix: string(),
12666
+ createdAt: number(),
12667
+ lastUsedAt: number().optional()
12668
+ });
12669
+ object({
12670
+ id: string(),
12671
+ userId: string(),
12672
+ name: string(),
12673
+ tokenHash: string(),
12674
+ tokenPrefix: string(),
12675
+ scopes: array(TokenScopeSchema),
12676
+ expiresAt: number().nullish(),
12677
+ lastUsedAt: number().nullish(),
12678
+ createdAt: number()
12679
+ });
12680
+ /** What a share-view grant lets its holder see. */
12681
+ var ShareViewGrantSchema = object({
12682
+ kind: _enum(SHARE_VIEW_KINDS),
12683
+ deviceIds: array(number().int().nonnegative()).min(1).max(64),
12684
+ /** Talk-back, opt-in at mint time; absent means off. */
12685
+ talk: boolean().optional()
12686
+ });
12687
+ var ShareViewScopeSchema = object({
12688
+ type: literal("share-view"),
12689
+ grant: ShareViewGrantSchema
12690
+ });
12691
+ var AddonRoutesScopeSchema = object({
12692
+ type: literal("addon-routes"),
12693
+ access: array(MethodAccessSchema).min(1)
12694
+ });
12695
+ var CredentialScopeSchema = union([
12696
+ literal("*"),
12697
+ ShareViewScopeSchema,
12698
+ AddonRoutesScopeSchema,
12699
+ TokenScopeSchema
12700
+ ]);
12701
+ object({
12702
+ kind: literal("credential"),
12703
+ sub: string().min(1),
12704
+ jti: string().min(16),
12705
+ scopes: array(CredentialScopeSchema).min(1)
12706
+ });
12478
12707
  _enum(["new-session", "step-up"]);
12479
12708
  /** The languages the hub's app landing pages are written in (D858). */
12480
12709
  var AppPageLangSchema = _enum(["en", "it"]);
@@ -44065,202 +44294,6 @@ method(object({}), object({ rules: array(NcRuleSchema) }), { auth: "admin" }), m
44065
44294
  auth: "admin"
44066
44295
  }), method(NcAlarmSensorsInputSchema, NcAlarmSensorsSchema, { auth: "admin" });
44067
44296
  /**
44068
- * Zod schemas for persisted record types.
44069
- *
44070
- * These schemas serve as the single source of truth for types that are
44071
- * stored in the settings-store backend and retrieved via tRPC. They
44072
- * replace the manual TypeScript interfaces with schema-derived types,
44073
- * enabling runtime validation when reading from the backend.
44074
- *
44075
- * Convention: each schema is named `<Type>Schema`, the inferred TS type
44076
- * keeps the original name for backward compatibility.
44077
- */
44078
- /**
44079
- * Auth model (v2 — 2026-05-12 caps-only):
44080
- *
44081
- * Two principals:
44082
- * - `isAdmin: true` — full bypass. Admin scope set is ignored.
44083
- * - `isAdmin: false` — every call gated by `scopes` (see TokenScope).
44084
- *
44085
- * No role enum. There used to be `viewer / agent / scoped` and earlier
44086
- * `super_admin` — collapsed onto the single boolean because every
44087
- * non-admin caller is governed by the same scope-check rules; the
44088
- * distinction was only ever used to route role-specific procedures
44089
- * which we no longer have. CLI / webhook integrations are `cst_*` tokens
44090
- * with `isAdmin: false` + an explicit scope list.
44091
- */
44092
- /** Per-method access flavour. Materialised on every cap method via codegen. */
44093
- var MethodAccessSchema = _enum([
44094
- "view",
44095
- "create",
44096
- "delete"
44097
- ]);
44098
- /**
44099
- * A single scope grant. Three forms — checked in matcher with OR
44100
- * semantics; the first match decides whether the call passes:
44101
- *
44102
- * - `category` — broadest. `target: 'device' | 'system'` selects every
44103
- * cap with the matching `scope` declaration. New caps inherit grants
44104
- * automatically — adding a device cap to the codebase makes it
44105
- * reachable to every user with `category:device [...]` without a
44106
- * re-grant. Use this for "family viewer" / "operator" tiers.
44107
- *
44108
- * - `addon` — every cap that ships inside a given addon id. Niche;
44109
- * useful when an integration needs to interact with one specific
44110
- * addon's surface regardless of how many caps it exports.
44111
- *
44112
- * - `capability` — the most precise form. Single cap name. Use for
44113
- * integration tokens where you want to grant `addons.installPackage`
44114
- * and nothing else.
44115
- *
44116
- * `access` is REQUIRED with min 1 element. `admin` bypass is the
44117
- * "give me everything" escape; there is no wildcard scope.
44118
- */
44119
- var AllowedProviderSchema = union([literal("*"), array(string())]);
44120
- var AllowedDevicesSchema = record(string(), union([literal("*"), array(string())]));
44121
- var CapScopeSchema = _enum(["device", "system"]);
44122
- /**
44123
- * DeviceSelector (scope model v3 — 2026-08-12).
44124
- *
44125
- * A `device` grant no longer carries a frozen list of deviceIds. It carries
44126
- * a SELECTOR the matcher resolves against the live fleet, so the grant can be
44127
- * DYNAMIC: a `types:['camera']` selector automatically covers a camera added
44128
- * AFTER the grant was minted — no re-grant, no re-login.
44129
- *
44130
- * - `all` — every device in the deployment. The broad viewer/operator
44131
- * lever without a `category` grant (a `category` grant also covers device
44132
- * caps that carry no deviceId; `all` is specifically the device set).
44133
- * - `ids` — an explicit deviceId list. This is what a v2 `device:[…]`
44134
- * grant migrates to (see {@link TokenScopeSchema}); STATIC — a new camera
44135
- * is NOT covered until the grant is edited.
44136
- * - `types` — every device of a `DeviceType` (e.g. every `camera`).
44137
- * DYNAMIC. A device that changes type, or a new device of the type,
44138
- * re-resolves on the next request.
44139
- * - `locations` — every device whose operator-assigned `location` label is
44140
- * in the set (e.g. "Garden", "Front door"). DYNAMIC. A device with a
44141
- * null/unset location matches NO `locations` selector.
44142
- */
44143
- var DeviceSelectorSchema = discriminatedUnion("kind", [
44144
- object({ kind: literal("all") }),
44145
- object({
44146
- kind: literal("ids"),
44147
- ids: array(number().int()).min(1)
44148
- }),
44149
- object({
44150
- kind: literal("types"),
44151
- types: array(_enum(DeviceType)).min(1)
44152
- }),
44153
- object({
44154
- kind: literal("locations"),
44155
- locations: array(string().min(1)).min(1)
44156
- })
44157
- ]);
44158
- var DeviceTokenScopeSchema = object({
44159
- type: literal("device"),
44160
- /** The device SET this grant covers — resolved against the live fleet. */
44161
- selector: DeviceSelectorSchema,
44162
- access: array(MethodAccessSchema).min(1),
44163
- /**
44164
- * Whether a grant on a PARENT device transparently covers its accessory
44165
- * CHILDREN (siren / floodlight / PIR) via the persisted-parentage walk.
44166
- * Direction is parent → children ONLY.
44167
- *
44168
- * Absent → the matcher DERIVES it from the access flavour: `view`
44169
- * inherits (a camera viewer sees the camera's accessories), `create` /
44170
- * `delete` do NOT (actuating/removing a child is an explicit act the
44171
- * operator must grant on the child, not inherit from the parent). Set it
44172
- * explicitly to override that default per grant.
44173
- */
44174
- includeLinked: boolean().optional()
44175
- });
44176
- /**
44177
- * v2 → v3 lazy migration. A pre-v3 `device` grant carried
44178
- * `targets: string[]` (stringified deviceIds); it rewrites to the equivalent
44179
- * `selector: {kind:'ids', ids}`. Applied as a `preprocess` so it runs on
44180
- * EVERY parse path — stored records AND the JWT-carried scope arrays
44181
- * normalised at the request boundary ({@link normalizeTokenScopes} in
44182
- * `device-selector.ts`). Chosen over a one-time DB migration because a
44183
- * migration cannot reach a JWT already in a client's hands; parse-time
44184
- * migration covers both without a flag day. No cast — the raw object is read
44185
- * through `Reflect.get` (its static type is `unknown`).
44186
- */
44187
- function migrateLegacyTokenScope(raw) {
44188
- if (raw === null || typeof raw !== "object" || Array.isArray(raw)) return raw;
44189
- if (Reflect.get(raw, "type") !== "device") return raw;
44190
- if (Reflect.get(raw, "selector") !== void 0) return raw;
44191
- const targets = Reflect.get(raw, "targets");
44192
- if (!Array.isArray(targets)) return raw;
44193
- return {
44194
- type: "device",
44195
- selector: {
44196
- kind: "ids",
44197
- ids: targets.map((t) => typeof t === "string" ? Number(t) : t).filter((n) => typeof n === "number" && Number.isInteger(n))
44198
- },
44199
- access: Reflect.get(raw, "access")
44200
- };
44201
- }
44202
- var TokenScopeSchema = preprocess(migrateLegacyTokenScope, discriminatedUnion("type", [
44203
- object({
44204
- type: literal("category"),
44205
- target: CapScopeSchema,
44206
- access: array(MethodAccessSchema).min(1)
44207
- }),
44208
- object({
44209
- type: literal("capability"),
44210
- target: string(),
44211
- access: array(MethodAccessSchema).min(1)
44212
- }),
44213
- object({
44214
- type: literal("addon"),
44215
- target: string(),
44216
- access: array(MethodAccessSchema).min(1)
44217
- }),
44218
- DeviceTokenScopeSchema
44219
- ]));
44220
- object({
44221
- id: string(),
44222
- username: string(),
44223
- passwordHash: string(),
44224
- /**
44225
- * Admin bypass. When true, the middleware skips the scope-access
44226
- * check entirely. There is no other axis of privilege; the legacy
44227
- * role enum collapsed onto this boolean in v2.
44228
- */
44229
- isAdmin: boolean().default(false),
44230
- allowedProviders: AllowedProviderSchema,
44231
- allowedDevices: AllowedDevicesSchema,
44232
- /**
44233
- * Scopes granted to this user. Admins bypass; their `scopes` is
44234
- * ignored. Non-admins without scopes are locked out of every
44235
- * protected call.
44236
- */
44237
- scopes: array(TokenScopeSchema).default([]),
44238
- createdAt: number(),
44239
- updatedAt: number()
44240
- });
44241
- object({
44242
- id: string(),
44243
- label: string(),
44244
- isAdmin: boolean().default(false),
44245
- allowedProviders: AllowedProviderSchema,
44246
- allowedDevices: AllowedDevicesSchema,
44247
- tokenHash: string(),
44248
- tokenPrefix: string(),
44249
- createdAt: number(),
44250
- lastUsedAt: number().optional()
44251
- });
44252
- object({
44253
- id: string(),
44254
- userId: string(),
44255
- name: string(),
44256
- tokenHash: string(),
44257
- tokenPrefix: string(),
44258
- scopes: array(TokenScopeSchema),
44259
- expiresAt: number().nullish(),
44260
- lastUsedAt: number().nullish(),
44261
- createdAt: number()
44262
- });
44263
- /**
44264
44297
  * `oauth-integration` — a collection cap by which an addon declares
44265
44298
  * itself a linkable OAuth client of the hub's core `/oauth2/*` server.
44266
44299
  * Each provider returns a static descriptor; the core enumerates them
package/dist/addon.mjs CHANGED
@@ -7795,6 +7795,12 @@ function normalizeAddonInitResult(result) {
7795
7795
  if (Array.isArray(result)) return { providers: result };
7796
7796
  return result;
7797
7797
  }
7798
+ /**
7799
+ * The share-view scope kinds a `csv_*` share token can carry. The hub mints
7800
+ * and validates them (`share-token.service.ts` builds its enum from this
7801
+ * list); a data plane names the kinds it ACCEPTS in `share`.
7802
+ */
7803
+ var SHARE_VIEW_KINDS = ["grid-view", "events-view"];
7798
7804
  /** The wire shape of {@link PeerBytesTicket} — see the type for what it is. */
7799
7805
  var PeerBytesTicketSchema = object({
7800
7806
  /** `http://127.0.0.1:<port>/<token>`. One `GET` takes it. */
@@ -12474,6 +12480,229 @@ var ConvertResultSchema = object({
12474
12480
  files: array(string()).readonly()
12475
12481
  })).readonly()
12476
12482
  });
12483
+ /**
12484
+ * Zod schemas for persisted record types.
12485
+ *
12486
+ * These schemas serve as the single source of truth for types that are
12487
+ * stored in the settings-store backend and retrieved via tRPC. They
12488
+ * replace the manual TypeScript interfaces with schema-derived types,
12489
+ * enabling runtime validation when reading from the backend.
12490
+ *
12491
+ * Convention: each schema is named `<Type>Schema`, the inferred TS type
12492
+ * keeps the original name for backward compatibility.
12493
+ */
12494
+ /**
12495
+ * Auth model (v2 — 2026-05-12 caps-only):
12496
+ *
12497
+ * Two principals:
12498
+ * - `isAdmin: true` — full bypass. Admin scope set is ignored.
12499
+ * - `isAdmin: false` — every call gated by `scopes` (see TokenScope).
12500
+ *
12501
+ * No role enum. There used to be `viewer / agent / scoped` and earlier
12502
+ * `super_admin` — collapsed onto the single boolean because every
12503
+ * non-admin caller is governed by the same scope-check rules; the
12504
+ * distinction was only ever used to route role-specific procedures
12505
+ * which we no longer have. CLI / webhook integrations are `cst_*` tokens
12506
+ * with `isAdmin: false` + an explicit scope list.
12507
+ */
12508
+ /** Per-method access flavour. Materialised on every cap method via codegen. */
12509
+ var MethodAccessSchema = _enum([
12510
+ "view",
12511
+ "create",
12512
+ "delete"
12513
+ ]);
12514
+ /**
12515
+ * A single scope grant. Three forms — checked in matcher with OR
12516
+ * semantics; the first match decides whether the call passes:
12517
+ *
12518
+ * - `category` — broadest. `target: 'device' | 'system'` selects every
12519
+ * cap with the matching `scope` declaration. New caps inherit grants
12520
+ * automatically — adding a device cap to the codebase makes it
12521
+ * reachable to every user with `category:device [...]` without a
12522
+ * re-grant. Use this for "family viewer" / "operator" tiers.
12523
+ *
12524
+ * - `addon` — every cap that ships inside a given addon id. Niche;
12525
+ * useful when an integration needs to interact with one specific
12526
+ * addon's surface regardless of how many caps it exports.
12527
+ *
12528
+ * - `capability` — the most precise form. Single cap name. Use for
12529
+ * integration tokens where you want to grant `addons.installPackage`
12530
+ * and nothing else.
12531
+ *
12532
+ * `access` is REQUIRED with min 1 element. `admin` bypass is the
12533
+ * "give me everything" escape; there is no wildcard scope.
12534
+ */
12535
+ var AllowedProviderSchema = union([literal("*"), array(string())]);
12536
+ var AllowedDevicesSchema = record(string(), union([literal("*"), array(string())]));
12537
+ var CapScopeSchema = _enum(["device", "system"]);
12538
+ /**
12539
+ * DeviceSelector (scope model v3 — 2026-08-12).
12540
+ *
12541
+ * A `device` grant no longer carries a frozen list of deviceIds. It carries
12542
+ * a SELECTOR the matcher resolves against the live fleet, so the grant can be
12543
+ * DYNAMIC: a `types:['camera']` selector automatically covers a camera added
12544
+ * AFTER the grant was minted — no re-grant, no re-login.
12545
+ *
12546
+ * - `all` — every device in the deployment. The broad viewer/operator
12547
+ * lever without a `category` grant (a `category` grant also covers device
12548
+ * caps that carry no deviceId; `all` is specifically the device set).
12549
+ * - `ids` — an explicit deviceId list. This is what a v2 `device:[…]`
12550
+ * grant migrates to (see {@link TokenScopeSchema}); STATIC — a new camera
12551
+ * is NOT covered until the grant is edited.
12552
+ * - `types` — every device of a `DeviceType` (e.g. every `camera`).
12553
+ * DYNAMIC. A device that changes type, or a new device of the type,
12554
+ * re-resolves on the next request.
12555
+ * - `locations` — every device whose operator-assigned `location` label is
12556
+ * in the set (e.g. "Garden", "Front door"). DYNAMIC. A device with a
12557
+ * null/unset location matches NO `locations` selector.
12558
+ */
12559
+ var DeviceSelectorSchema = discriminatedUnion("kind", [
12560
+ object({ kind: literal("all") }),
12561
+ object({
12562
+ kind: literal("ids"),
12563
+ ids: array(number().int()).min(1)
12564
+ }),
12565
+ object({
12566
+ kind: literal("types"),
12567
+ types: array(_enum(DeviceType)).min(1)
12568
+ }),
12569
+ object({
12570
+ kind: literal("locations"),
12571
+ locations: array(string().min(1)).min(1)
12572
+ })
12573
+ ]);
12574
+ var DeviceTokenScopeSchema = object({
12575
+ type: literal("device"),
12576
+ /** The device SET this grant covers — resolved against the live fleet. */
12577
+ selector: DeviceSelectorSchema,
12578
+ access: array(MethodAccessSchema).min(1),
12579
+ /**
12580
+ * Whether a grant on a PARENT device transparently covers its accessory
12581
+ * CHILDREN (siren / floodlight / PIR) via the persisted-parentage walk.
12582
+ * Direction is parent → children ONLY.
12583
+ *
12584
+ * Absent → the matcher DERIVES it from the access flavour: `view`
12585
+ * inherits (a camera viewer sees the camera's accessories), `create` /
12586
+ * `delete` do NOT (actuating/removing a child is an explicit act the
12587
+ * operator must grant on the child, not inherit from the parent). Set it
12588
+ * explicitly to override that default per grant.
12589
+ */
12590
+ includeLinked: boolean().optional()
12591
+ });
12592
+ /**
12593
+ * v2 → v3 lazy migration. A pre-v3 `device` grant carried
12594
+ * `targets: string[]` (stringified deviceIds); it rewrites to the equivalent
12595
+ * `selector: {kind:'ids', ids}`. Applied as a `preprocess` so it runs on
12596
+ * EVERY parse path — stored records AND the JWT-carried scope arrays
12597
+ * normalised at the request boundary ({@link normalizeTokenScopes} in
12598
+ * `device-selector.ts`). Chosen over a one-time DB migration because a
12599
+ * migration cannot reach a JWT already in a client's hands; parse-time
12600
+ * migration covers both without a flag day. No cast — the raw object is read
12601
+ * through `Reflect.get` (its static type is `unknown`).
12602
+ */
12603
+ function migrateLegacyTokenScope(raw) {
12604
+ if (raw === null || typeof raw !== "object" || Array.isArray(raw)) return raw;
12605
+ if (Reflect.get(raw, "type") !== "device") return raw;
12606
+ if (Reflect.get(raw, "selector") !== void 0) return raw;
12607
+ const targets = Reflect.get(raw, "targets");
12608
+ if (!Array.isArray(targets)) return raw;
12609
+ return {
12610
+ type: "device",
12611
+ selector: {
12612
+ kind: "ids",
12613
+ ids: targets.map((t) => typeof t === "string" ? Number(t) : t).filter((n) => typeof n === "number" && Number.isInteger(n))
12614
+ },
12615
+ access: Reflect.get(raw, "access")
12616
+ };
12617
+ }
12618
+ var TokenScopeSchema = preprocess(migrateLegacyTokenScope, discriminatedUnion("type", [
12619
+ object({
12620
+ type: literal("category"),
12621
+ target: CapScopeSchema,
12622
+ access: array(MethodAccessSchema).min(1)
12623
+ }),
12624
+ object({
12625
+ type: literal("capability"),
12626
+ target: string(),
12627
+ access: array(MethodAccessSchema).min(1)
12628
+ }),
12629
+ object({
12630
+ type: literal("addon"),
12631
+ target: string(),
12632
+ access: array(MethodAccessSchema).min(1)
12633
+ }),
12634
+ DeviceTokenScopeSchema
12635
+ ]));
12636
+ object({
12637
+ id: string(),
12638
+ username: string(),
12639
+ passwordHash: string(),
12640
+ /**
12641
+ * Admin bypass. When true, the middleware skips the scope-access
12642
+ * check entirely. There is no other axis of privilege; the legacy
12643
+ * role enum collapsed onto this boolean in v2.
12644
+ */
12645
+ isAdmin: boolean().default(false),
12646
+ allowedProviders: AllowedProviderSchema,
12647
+ allowedDevices: AllowedDevicesSchema,
12648
+ /**
12649
+ * Scopes granted to this user. Admins bypass; their `scopes` is
12650
+ * ignored. Non-admins without scopes are locked out of every
12651
+ * protected call.
12652
+ */
12653
+ scopes: array(TokenScopeSchema).default([]),
12654
+ createdAt: number(),
12655
+ updatedAt: number()
12656
+ });
12657
+ object({
12658
+ id: string(),
12659
+ label: string(),
12660
+ isAdmin: boolean().default(false),
12661
+ allowedProviders: AllowedProviderSchema,
12662
+ allowedDevices: AllowedDevicesSchema,
12663
+ tokenHash: string(),
12664
+ tokenPrefix: string(),
12665
+ createdAt: number(),
12666
+ lastUsedAt: number().optional()
12667
+ });
12668
+ object({
12669
+ id: string(),
12670
+ userId: string(),
12671
+ name: string(),
12672
+ tokenHash: string(),
12673
+ tokenPrefix: string(),
12674
+ scopes: array(TokenScopeSchema),
12675
+ expiresAt: number().nullish(),
12676
+ lastUsedAt: number().nullish(),
12677
+ createdAt: number()
12678
+ });
12679
+ /** What a share-view grant lets its holder see. */
12680
+ var ShareViewGrantSchema = object({
12681
+ kind: _enum(SHARE_VIEW_KINDS),
12682
+ deviceIds: array(number().int().nonnegative()).min(1).max(64),
12683
+ /** Talk-back, opt-in at mint time; absent means off. */
12684
+ talk: boolean().optional()
12685
+ });
12686
+ var ShareViewScopeSchema = object({
12687
+ type: literal("share-view"),
12688
+ grant: ShareViewGrantSchema
12689
+ });
12690
+ var AddonRoutesScopeSchema = object({
12691
+ type: literal("addon-routes"),
12692
+ access: array(MethodAccessSchema).min(1)
12693
+ });
12694
+ var CredentialScopeSchema = union([
12695
+ literal("*"),
12696
+ ShareViewScopeSchema,
12697
+ AddonRoutesScopeSchema,
12698
+ TokenScopeSchema
12699
+ ]);
12700
+ object({
12701
+ kind: literal("credential"),
12702
+ sub: string().min(1),
12703
+ jti: string().min(16),
12704
+ scopes: array(CredentialScopeSchema).min(1)
12705
+ });
12477
12706
  _enum(["new-session", "step-up"]);
12478
12707
  /** The languages the hub's app landing pages are written in (D858). */
12479
12708
  var AppPageLangSchema = _enum(["en", "it"]);
@@ -44064,202 +44293,6 @@ method(object({}), object({ rules: array(NcRuleSchema) }), { auth: "admin" }), m
44064
44293
  auth: "admin"
44065
44294
  }), method(NcAlarmSensorsInputSchema, NcAlarmSensorsSchema, { auth: "admin" });
44066
44295
  /**
44067
- * Zod schemas for persisted record types.
44068
- *
44069
- * These schemas serve as the single source of truth for types that are
44070
- * stored in the settings-store backend and retrieved via tRPC. They
44071
- * replace the manual TypeScript interfaces with schema-derived types,
44072
- * enabling runtime validation when reading from the backend.
44073
- *
44074
- * Convention: each schema is named `<Type>Schema`, the inferred TS type
44075
- * keeps the original name for backward compatibility.
44076
- */
44077
- /**
44078
- * Auth model (v2 — 2026-05-12 caps-only):
44079
- *
44080
- * Two principals:
44081
- * - `isAdmin: true` — full bypass. Admin scope set is ignored.
44082
- * - `isAdmin: false` — every call gated by `scopes` (see TokenScope).
44083
- *
44084
- * No role enum. There used to be `viewer / agent / scoped` and earlier
44085
- * `super_admin` — collapsed onto the single boolean because every
44086
- * non-admin caller is governed by the same scope-check rules; the
44087
- * distinction was only ever used to route role-specific procedures
44088
- * which we no longer have. CLI / webhook integrations are `cst_*` tokens
44089
- * with `isAdmin: false` + an explicit scope list.
44090
- */
44091
- /** Per-method access flavour. Materialised on every cap method via codegen. */
44092
- var MethodAccessSchema = _enum([
44093
- "view",
44094
- "create",
44095
- "delete"
44096
- ]);
44097
- /**
44098
- * A single scope grant. Three forms — checked in matcher with OR
44099
- * semantics; the first match decides whether the call passes:
44100
- *
44101
- * - `category` — broadest. `target: 'device' | 'system'` selects every
44102
- * cap with the matching `scope` declaration. New caps inherit grants
44103
- * automatically — adding a device cap to the codebase makes it
44104
- * reachable to every user with `category:device [...]` without a
44105
- * re-grant. Use this for "family viewer" / "operator" tiers.
44106
- *
44107
- * - `addon` — every cap that ships inside a given addon id. Niche;
44108
- * useful when an integration needs to interact with one specific
44109
- * addon's surface regardless of how many caps it exports.
44110
- *
44111
- * - `capability` — the most precise form. Single cap name. Use for
44112
- * integration tokens where you want to grant `addons.installPackage`
44113
- * and nothing else.
44114
- *
44115
- * `access` is REQUIRED with min 1 element. `admin` bypass is the
44116
- * "give me everything" escape; there is no wildcard scope.
44117
- */
44118
- var AllowedProviderSchema = union([literal("*"), array(string())]);
44119
- var AllowedDevicesSchema = record(string(), union([literal("*"), array(string())]));
44120
- var CapScopeSchema = _enum(["device", "system"]);
44121
- /**
44122
- * DeviceSelector (scope model v3 — 2026-08-12).
44123
- *
44124
- * A `device` grant no longer carries a frozen list of deviceIds. It carries
44125
- * a SELECTOR the matcher resolves against the live fleet, so the grant can be
44126
- * DYNAMIC: a `types:['camera']` selector automatically covers a camera added
44127
- * AFTER the grant was minted — no re-grant, no re-login.
44128
- *
44129
- * - `all` — every device in the deployment. The broad viewer/operator
44130
- * lever without a `category` grant (a `category` grant also covers device
44131
- * caps that carry no deviceId; `all` is specifically the device set).
44132
- * - `ids` — an explicit deviceId list. This is what a v2 `device:[…]`
44133
- * grant migrates to (see {@link TokenScopeSchema}); STATIC — a new camera
44134
- * is NOT covered until the grant is edited.
44135
- * - `types` — every device of a `DeviceType` (e.g. every `camera`).
44136
- * DYNAMIC. A device that changes type, or a new device of the type,
44137
- * re-resolves on the next request.
44138
- * - `locations` — every device whose operator-assigned `location` label is
44139
- * in the set (e.g. "Garden", "Front door"). DYNAMIC. A device with a
44140
- * null/unset location matches NO `locations` selector.
44141
- */
44142
- var DeviceSelectorSchema = discriminatedUnion("kind", [
44143
- object({ kind: literal("all") }),
44144
- object({
44145
- kind: literal("ids"),
44146
- ids: array(number().int()).min(1)
44147
- }),
44148
- object({
44149
- kind: literal("types"),
44150
- types: array(_enum(DeviceType)).min(1)
44151
- }),
44152
- object({
44153
- kind: literal("locations"),
44154
- locations: array(string().min(1)).min(1)
44155
- })
44156
- ]);
44157
- var DeviceTokenScopeSchema = object({
44158
- type: literal("device"),
44159
- /** The device SET this grant covers — resolved against the live fleet. */
44160
- selector: DeviceSelectorSchema,
44161
- access: array(MethodAccessSchema).min(1),
44162
- /**
44163
- * Whether a grant on a PARENT device transparently covers its accessory
44164
- * CHILDREN (siren / floodlight / PIR) via the persisted-parentage walk.
44165
- * Direction is parent → children ONLY.
44166
- *
44167
- * Absent → the matcher DERIVES it from the access flavour: `view`
44168
- * inherits (a camera viewer sees the camera's accessories), `create` /
44169
- * `delete` do NOT (actuating/removing a child is an explicit act the
44170
- * operator must grant on the child, not inherit from the parent). Set it
44171
- * explicitly to override that default per grant.
44172
- */
44173
- includeLinked: boolean().optional()
44174
- });
44175
- /**
44176
- * v2 → v3 lazy migration. A pre-v3 `device` grant carried
44177
- * `targets: string[]` (stringified deviceIds); it rewrites to the equivalent
44178
- * `selector: {kind:'ids', ids}`. Applied as a `preprocess` so it runs on
44179
- * EVERY parse path — stored records AND the JWT-carried scope arrays
44180
- * normalised at the request boundary ({@link normalizeTokenScopes} in
44181
- * `device-selector.ts`). Chosen over a one-time DB migration because a
44182
- * migration cannot reach a JWT already in a client's hands; parse-time
44183
- * migration covers both without a flag day. No cast — the raw object is read
44184
- * through `Reflect.get` (its static type is `unknown`).
44185
- */
44186
- function migrateLegacyTokenScope(raw) {
44187
- if (raw === null || typeof raw !== "object" || Array.isArray(raw)) return raw;
44188
- if (Reflect.get(raw, "type") !== "device") return raw;
44189
- if (Reflect.get(raw, "selector") !== void 0) return raw;
44190
- const targets = Reflect.get(raw, "targets");
44191
- if (!Array.isArray(targets)) return raw;
44192
- return {
44193
- type: "device",
44194
- selector: {
44195
- kind: "ids",
44196
- ids: targets.map((t) => typeof t === "string" ? Number(t) : t).filter((n) => typeof n === "number" && Number.isInteger(n))
44197
- },
44198
- access: Reflect.get(raw, "access")
44199
- };
44200
- }
44201
- var TokenScopeSchema = preprocess(migrateLegacyTokenScope, discriminatedUnion("type", [
44202
- object({
44203
- type: literal("category"),
44204
- target: CapScopeSchema,
44205
- access: array(MethodAccessSchema).min(1)
44206
- }),
44207
- object({
44208
- type: literal("capability"),
44209
- target: string(),
44210
- access: array(MethodAccessSchema).min(1)
44211
- }),
44212
- object({
44213
- type: literal("addon"),
44214
- target: string(),
44215
- access: array(MethodAccessSchema).min(1)
44216
- }),
44217
- DeviceTokenScopeSchema
44218
- ]));
44219
- object({
44220
- id: string(),
44221
- username: string(),
44222
- passwordHash: string(),
44223
- /**
44224
- * Admin bypass. When true, the middleware skips the scope-access
44225
- * check entirely. There is no other axis of privilege; the legacy
44226
- * role enum collapsed onto this boolean in v2.
44227
- */
44228
- isAdmin: boolean().default(false),
44229
- allowedProviders: AllowedProviderSchema,
44230
- allowedDevices: AllowedDevicesSchema,
44231
- /**
44232
- * Scopes granted to this user. Admins bypass; their `scopes` is
44233
- * ignored. Non-admins without scopes are locked out of every
44234
- * protected call.
44235
- */
44236
- scopes: array(TokenScopeSchema).default([]),
44237
- createdAt: number(),
44238
- updatedAt: number()
44239
- });
44240
- object({
44241
- id: string(),
44242
- label: string(),
44243
- isAdmin: boolean().default(false),
44244
- allowedProviders: AllowedProviderSchema,
44245
- allowedDevices: AllowedDevicesSchema,
44246
- tokenHash: string(),
44247
- tokenPrefix: string(),
44248
- createdAt: number(),
44249
- lastUsedAt: number().optional()
44250
- });
44251
- object({
44252
- id: string(),
44253
- userId: string(),
44254
- name: string(),
44255
- tokenHash: string(),
44256
- tokenPrefix: string(),
44257
- scopes: array(TokenScopeSchema),
44258
- expiresAt: number().nullish(),
44259
- lastUsedAt: number().nullish(),
44260
- createdAt: number()
44261
- });
44262
- /**
44263
44296
  * `oauth-integration` — a collection cap by which an addon declares
44264
44297
  * itself a linkable OAuth client of the hub's core `/oauth2/*` server.
44265
44298
  * 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-velux",
3
- "version": "0.2.129",
3
+ "version": "0.2.130",
4
4
  "description": "Velux KLF-200 device-provider addon for CamStack — local-gateway window + shutter covers (positional, no tilt)",
5
5
  "keywords": [
6
6
  "camstack",