@camstack/addon-provider-dreo 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
@@ -7832,6 +7832,12 @@ function normalizeAddonInitResult(result) {
7832
7832
  if (Array.isArray(result)) return { providers: result };
7833
7833
  return result;
7834
7834
  }
7835
+ /**
7836
+ * The share-view scope kinds a `csv_*` share token can carry. The hub mints
7837
+ * and validates them (`share-token.service.ts` builds its enum from this
7838
+ * list); a data plane names the kinds it ACCEPTS in `share`.
7839
+ */
7840
+ var SHARE_VIEW_KINDS = ["grid-view", "events-view"];
7835
7841
  /** The wire shape of {@link PeerBytesTicket} — see the type for what it is. */
7836
7842
  var PeerBytesTicketSchema = object({
7837
7843
  /** `http://127.0.0.1:<port>/<token>`. One `GET` takes it. */
@@ -12497,6 +12503,229 @@ var ConvertResultSchema = object({
12497
12503
  files: array(string()).readonly()
12498
12504
  })).readonly()
12499
12505
  });
12506
+ /**
12507
+ * Zod schemas for persisted record types.
12508
+ *
12509
+ * These schemas serve as the single source of truth for types that are
12510
+ * stored in the settings-store backend and retrieved via tRPC. They
12511
+ * replace the manual TypeScript interfaces with schema-derived types,
12512
+ * enabling runtime validation when reading from the backend.
12513
+ *
12514
+ * Convention: each schema is named `<Type>Schema`, the inferred TS type
12515
+ * keeps the original name for backward compatibility.
12516
+ */
12517
+ /**
12518
+ * Auth model (v2 — 2026-05-12 caps-only):
12519
+ *
12520
+ * Two principals:
12521
+ * - `isAdmin: true` — full bypass. Admin scope set is ignored.
12522
+ * - `isAdmin: false` — every call gated by `scopes` (see TokenScope).
12523
+ *
12524
+ * No role enum. There used to be `viewer / agent / scoped` and earlier
12525
+ * `super_admin` — collapsed onto the single boolean because every
12526
+ * non-admin caller is governed by the same scope-check rules; the
12527
+ * distinction was only ever used to route role-specific procedures
12528
+ * which we no longer have. CLI / webhook integrations are `cst_*` tokens
12529
+ * with `isAdmin: false` + an explicit scope list.
12530
+ */
12531
+ /** Per-method access flavour. Materialised on every cap method via codegen. */
12532
+ var MethodAccessSchema = _enum([
12533
+ "view",
12534
+ "create",
12535
+ "delete"
12536
+ ]);
12537
+ /**
12538
+ * A single scope grant. Three forms — checked in matcher with OR
12539
+ * semantics; the first match decides whether the call passes:
12540
+ *
12541
+ * - `category` — broadest. `target: 'device' | 'system'` selects every
12542
+ * cap with the matching `scope` declaration. New caps inherit grants
12543
+ * automatically — adding a device cap to the codebase makes it
12544
+ * reachable to every user with `category:device [...]` without a
12545
+ * re-grant. Use this for "family viewer" / "operator" tiers.
12546
+ *
12547
+ * - `addon` — every cap that ships inside a given addon id. Niche;
12548
+ * useful when an integration needs to interact with one specific
12549
+ * addon's surface regardless of how many caps it exports.
12550
+ *
12551
+ * - `capability` — the most precise form. Single cap name. Use for
12552
+ * integration tokens where you want to grant `addons.installPackage`
12553
+ * and nothing else.
12554
+ *
12555
+ * `access` is REQUIRED with min 1 element. `admin` bypass is the
12556
+ * "give me everything" escape; there is no wildcard scope.
12557
+ */
12558
+ var AllowedProviderSchema = union([literal("*"), array(string())]);
12559
+ var AllowedDevicesSchema = record(string(), union([literal("*"), array(string())]));
12560
+ var CapScopeSchema = _enum(["device", "system"]);
12561
+ /**
12562
+ * DeviceSelector (scope model v3 — 2026-08-12).
12563
+ *
12564
+ * A `device` grant no longer carries a frozen list of deviceIds. It carries
12565
+ * a SELECTOR the matcher resolves against the live fleet, so the grant can be
12566
+ * DYNAMIC: a `types:['camera']` selector automatically covers a camera added
12567
+ * AFTER the grant was minted — no re-grant, no re-login.
12568
+ *
12569
+ * - `all` — every device in the deployment. The broad viewer/operator
12570
+ * lever without a `category` grant (a `category` grant also covers device
12571
+ * caps that carry no deviceId; `all` is specifically the device set).
12572
+ * - `ids` — an explicit deviceId list. This is what a v2 `device:[…]`
12573
+ * grant migrates to (see {@link TokenScopeSchema}); STATIC — a new camera
12574
+ * is NOT covered until the grant is edited.
12575
+ * - `types` — every device of a `DeviceType` (e.g. every `camera`).
12576
+ * DYNAMIC. A device that changes type, or a new device of the type,
12577
+ * re-resolves on the next request.
12578
+ * - `locations` — every device whose operator-assigned `location` label is
12579
+ * in the set (e.g. "Garden", "Front door"). DYNAMIC. A device with a
12580
+ * null/unset location matches NO `locations` selector.
12581
+ */
12582
+ var DeviceSelectorSchema = discriminatedUnion("kind", [
12583
+ object({ kind: literal("all") }),
12584
+ object({
12585
+ kind: literal("ids"),
12586
+ ids: array(number().int()).min(1)
12587
+ }),
12588
+ object({
12589
+ kind: literal("types"),
12590
+ types: array(_enum(DeviceType)).min(1)
12591
+ }),
12592
+ object({
12593
+ kind: literal("locations"),
12594
+ locations: array(string().min(1)).min(1)
12595
+ })
12596
+ ]);
12597
+ var DeviceTokenScopeSchema = object({
12598
+ type: literal("device"),
12599
+ /** The device SET this grant covers — resolved against the live fleet. */
12600
+ selector: DeviceSelectorSchema,
12601
+ access: array(MethodAccessSchema).min(1),
12602
+ /**
12603
+ * Whether a grant on a PARENT device transparently covers its accessory
12604
+ * CHILDREN (siren / floodlight / PIR) via the persisted-parentage walk.
12605
+ * Direction is parent → children ONLY.
12606
+ *
12607
+ * Absent → the matcher DERIVES it from the access flavour: `view`
12608
+ * inherits (a camera viewer sees the camera's accessories), `create` /
12609
+ * `delete` do NOT (actuating/removing a child is an explicit act the
12610
+ * operator must grant on the child, not inherit from the parent). Set it
12611
+ * explicitly to override that default per grant.
12612
+ */
12613
+ includeLinked: boolean().optional()
12614
+ });
12615
+ /**
12616
+ * v2 → v3 lazy migration. A pre-v3 `device` grant carried
12617
+ * `targets: string[]` (stringified deviceIds); it rewrites to the equivalent
12618
+ * `selector: {kind:'ids', ids}`. Applied as a `preprocess` so it runs on
12619
+ * EVERY parse path — stored records AND the JWT-carried scope arrays
12620
+ * normalised at the request boundary ({@link normalizeTokenScopes} in
12621
+ * `device-selector.ts`). Chosen over a one-time DB migration because a
12622
+ * migration cannot reach a JWT already in a client's hands; parse-time
12623
+ * migration covers both without a flag day. No cast — the raw object is read
12624
+ * through `Reflect.get` (its static type is `unknown`).
12625
+ */
12626
+ function migrateLegacyTokenScope(raw) {
12627
+ if (raw === null || typeof raw !== "object" || Array.isArray(raw)) return raw;
12628
+ if (Reflect.get(raw, "type") !== "device") return raw;
12629
+ if (Reflect.get(raw, "selector") !== void 0) return raw;
12630
+ const targets = Reflect.get(raw, "targets");
12631
+ if (!Array.isArray(targets)) return raw;
12632
+ return {
12633
+ type: "device",
12634
+ selector: {
12635
+ kind: "ids",
12636
+ ids: targets.map((t) => typeof t === "string" ? Number(t) : t).filter((n) => typeof n === "number" && Number.isInteger(n))
12637
+ },
12638
+ access: Reflect.get(raw, "access")
12639
+ };
12640
+ }
12641
+ var TokenScopeSchema = preprocess(migrateLegacyTokenScope, discriminatedUnion("type", [
12642
+ object({
12643
+ type: literal("category"),
12644
+ target: CapScopeSchema,
12645
+ access: array(MethodAccessSchema).min(1)
12646
+ }),
12647
+ object({
12648
+ type: literal("capability"),
12649
+ target: string(),
12650
+ access: array(MethodAccessSchema).min(1)
12651
+ }),
12652
+ object({
12653
+ type: literal("addon"),
12654
+ target: string(),
12655
+ access: array(MethodAccessSchema).min(1)
12656
+ }),
12657
+ DeviceTokenScopeSchema
12658
+ ]));
12659
+ object({
12660
+ id: string(),
12661
+ username: string(),
12662
+ passwordHash: string(),
12663
+ /**
12664
+ * Admin bypass. When true, the middleware skips the scope-access
12665
+ * check entirely. There is no other axis of privilege; the legacy
12666
+ * role enum collapsed onto this boolean in v2.
12667
+ */
12668
+ isAdmin: boolean().default(false),
12669
+ allowedProviders: AllowedProviderSchema,
12670
+ allowedDevices: AllowedDevicesSchema,
12671
+ /**
12672
+ * Scopes granted to this user. Admins bypass; their `scopes` is
12673
+ * ignored. Non-admins without scopes are locked out of every
12674
+ * protected call.
12675
+ */
12676
+ scopes: array(TokenScopeSchema).default([]),
12677
+ createdAt: number(),
12678
+ updatedAt: number()
12679
+ });
12680
+ object({
12681
+ id: string(),
12682
+ label: string(),
12683
+ isAdmin: boolean().default(false),
12684
+ allowedProviders: AllowedProviderSchema,
12685
+ allowedDevices: AllowedDevicesSchema,
12686
+ tokenHash: string(),
12687
+ tokenPrefix: string(),
12688
+ createdAt: number(),
12689
+ lastUsedAt: number().optional()
12690
+ });
12691
+ object({
12692
+ id: string(),
12693
+ userId: string(),
12694
+ name: string(),
12695
+ tokenHash: string(),
12696
+ tokenPrefix: string(),
12697
+ scopes: array(TokenScopeSchema),
12698
+ expiresAt: number().nullish(),
12699
+ lastUsedAt: number().nullish(),
12700
+ createdAt: number()
12701
+ });
12702
+ /** What a share-view grant lets its holder see. */
12703
+ var ShareViewGrantSchema = object({
12704
+ kind: _enum(SHARE_VIEW_KINDS),
12705
+ deviceIds: array(number().int().nonnegative()).min(1).max(64),
12706
+ /** Talk-back, opt-in at mint time; absent means off. */
12707
+ talk: boolean().optional()
12708
+ });
12709
+ var ShareViewScopeSchema = object({
12710
+ type: literal("share-view"),
12711
+ grant: ShareViewGrantSchema
12712
+ });
12713
+ var AddonRoutesScopeSchema = object({
12714
+ type: literal("addon-routes"),
12715
+ access: array(MethodAccessSchema).min(1)
12716
+ });
12717
+ var CredentialScopeSchema = union([
12718
+ literal("*"),
12719
+ ShareViewScopeSchema,
12720
+ AddonRoutesScopeSchema,
12721
+ TokenScopeSchema
12722
+ ]);
12723
+ object({
12724
+ kind: literal("credential"),
12725
+ sub: string().min(1),
12726
+ jti: string().min(16),
12727
+ scopes: array(CredentialScopeSchema).min(1)
12728
+ });
12500
12729
  _enum(["new-session", "step-up"]);
12501
12730
  /** The languages the hub's app landing pages are written in (D858). */
12502
12731
  var AppPageLangSchema = _enum(["en", "it"]);
@@ -43991,202 +44220,6 @@ method(object({}), object({ rules: array(NcRuleSchema) }), { auth: "admin" }), m
43991
44220
  auth: "admin"
43992
44221
  }), method(NcAlarmSensorsInputSchema, NcAlarmSensorsSchema, { auth: "admin" });
43993
44222
  /**
43994
- * Zod schemas for persisted record types.
43995
- *
43996
- * These schemas serve as the single source of truth for types that are
43997
- * stored in the settings-store backend and retrieved via tRPC. They
43998
- * replace the manual TypeScript interfaces with schema-derived types,
43999
- * enabling runtime validation when reading from the backend.
44000
- *
44001
- * Convention: each schema is named `<Type>Schema`, the inferred TS type
44002
- * keeps the original name for backward compatibility.
44003
- */
44004
- /**
44005
- * Auth model (v2 — 2026-05-12 caps-only):
44006
- *
44007
- * Two principals:
44008
- * - `isAdmin: true` — full bypass. Admin scope set is ignored.
44009
- * - `isAdmin: false` — every call gated by `scopes` (see TokenScope).
44010
- *
44011
- * No role enum. There used to be `viewer / agent / scoped` and earlier
44012
- * `super_admin` — collapsed onto the single boolean because every
44013
- * non-admin caller is governed by the same scope-check rules; the
44014
- * distinction was only ever used to route role-specific procedures
44015
- * which we no longer have. CLI / webhook integrations are `cst_*` tokens
44016
- * with `isAdmin: false` + an explicit scope list.
44017
- */
44018
- /** Per-method access flavour. Materialised on every cap method via codegen. */
44019
- var MethodAccessSchema = _enum([
44020
- "view",
44021
- "create",
44022
- "delete"
44023
- ]);
44024
- /**
44025
- * A single scope grant. Three forms — checked in matcher with OR
44026
- * semantics; the first match decides whether the call passes:
44027
- *
44028
- * - `category` — broadest. `target: 'device' | 'system'` selects every
44029
- * cap with the matching `scope` declaration. New caps inherit grants
44030
- * automatically — adding a device cap to the codebase makes it
44031
- * reachable to every user with `category:device [...]` without a
44032
- * re-grant. Use this for "family viewer" / "operator" tiers.
44033
- *
44034
- * - `addon` — every cap that ships inside a given addon id. Niche;
44035
- * useful when an integration needs to interact with one specific
44036
- * addon's surface regardless of how many caps it exports.
44037
- *
44038
- * - `capability` — the most precise form. Single cap name. Use for
44039
- * integration tokens where you want to grant `addons.installPackage`
44040
- * and nothing else.
44041
- *
44042
- * `access` is REQUIRED with min 1 element. `admin` bypass is the
44043
- * "give me everything" escape; there is no wildcard scope.
44044
- */
44045
- var AllowedProviderSchema = union([literal("*"), array(string())]);
44046
- var AllowedDevicesSchema = record(string(), union([literal("*"), array(string())]));
44047
- var CapScopeSchema = _enum(["device", "system"]);
44048
- /**
44049
- * DeviceSelector (scope model v3 — 2026-08-12).
44050
- *
44051
- * A `device` grant no longer carries a frozen list of deviceIds. It carries
44052
- * a SELECTOR the matcher resolves against the live fleet, so the grant can be
44053
- * DYNAMIC: a `types:['camera']` selector automatically covers a camera added
44054
- * AFTER the grant was minted — no re-grant, no re-login.
44055
- *
44056
- * - `all` — every device in the deployment. The broad viewer/operator
44057
- * lever without a `category` grant (a `category` grant also covers device
44058
- * caps that carry no deviceId; `all` is specifically the device set).
44059
- * - `ids` — an explicit deviceId list. This is what a v2 `device:[…]`
44060
- * grant migrates to (see {@link TokenScopeSchema}); STATIC — a new camera
44061
- * is NOT covered until the grant is edited.
44062
- * - `types` — every device of a `DeviceType` (e.g. every `camera`).
44063
- * DYNAMIC. A device that changes type, or a new device of the type,
44064
- * re-resolves on the next request.
44065
- * - `locations` — every device whose operator-assigned `location` label is
44066
- * in the set (e.g. "Garden", "Front door"). DYNAMIC. A device with a
44067
- * null/unset location matches NO `locations` selector.
44068
- */
44069
- var DeviceSelectorSchema = discriminatedUnion("kind", [
44070
- object({ kind: literal("all") }),
44071
- object({
44072
- kind: literal("ids"),
44073
- ids: array(number().int()).min(1)
44074
- }),
44075
- object({
44076
- kind: literal("types"),
44077
- types: array(_enum(DeviceType)).min(1)
44078
- }),
44079
- object({
44080
- kind: literal("locations"),
44081
- locations: array(string().min(1)).min(1)
44082
- })
44083
- ]);
44084
- var DeviceTokenScopeSchema = object({
44085
- type: literal("device"),
44086
- /** The device SET this grant covers — resolved against the live fleet. */
44087
- selector: DeviceSelectorSchema,
44088
- access: array(MethodAccessSchema).min(1),
44089
- /**
44090
- * Whether a grant on a PARENT device transparently covers its accessory
44091
- * CHILDREN (siren / floodlight / PIR) via the persisted-parentage walk.
44092
- * Direction is parent → children ONLY.
44093
- *
44094
- * Absent → the matcher DERIVES it from the access flavour: `view`
44095
- * inherits (a camera viewer sees the camera's accessories), `create` /
44096
- * `delete` do NOT (actuating/removing a child is an explicit act the
44097
- * operator must grant on the child, not inherit from the parent). Set it
44098
- * explicitly to override that default per grant.
44099
- */
44100
- includeLinked: boolean().optional()
44101
- });
44102
- /**
44103
- * v2 → v3 lazy migration. A pre-v3 `device` grant carried
44104
- * `targets: string[]` (stringified deviceIds); it rewrites to the equivalent
44105
- * `selector: {kind:'ids', ids}`. Applied as a `preprocess` so it runs on
44106
- * EVERY parse path — stored records AND the JWT-carried scope arrays
44107
- * normalised at the request boundary ({@link normalizeTokenScopes} in
44108
- * `device-selector.ts`). Chosen over a one-time DB migration because a
44109
- * migration cannot reach a JWT already in a client's hands; parse-time
44110
- * migration covers both without a flag day. No cast — the raw object is read
44111
- * through `Reflect.get` (its static type is `unknown`).
44112
- */
44113
- function migrateLegacyTokenScope(raw) {
44114
- if (raw === null || typeof raw !== "object" || Array.isArray(raw)) return raw;
44115
- if (Reflect.get(raw, "type") !== "device") return raw;
44116
- if (Reflect.get(raw, "selector") !== void 0) return raw;
44117
- const targets = Reflect.get(raw, "targets");
44118
- if (!Array.isArray(targets)) return raw;
44119
- return {
44120
- type: "device",
44121
- selector: {
44122
- kind: "ids",
44123
- ids: targets.map((t) => typeof t === "string" ? Number(t) : t).filter((n) => typeof n === "number" && Number.isInteger(n))
44124
- },
44125
- access: Reflect.get(raw, "access")
44126
- };
44127
- }
44128
- var TokenScopeSchema = preprocess(migrateLegacyTokenScope, discriminatedUnion("type", [
44129
- object({
44130
- type: literal("category"),
44131
- target: CapScopeSchema,
44132
- access: array(MethodAccessSchema).min(1)
44133
- }),
44134
- object({
44135
- type: literal("capability"),
44136
- target: string(),
44137
- access: array(MethodAccessSchema).min(1)
44138
- }),
44139
- object({
44140
- type: literal("addon"),
44141
- target: string(),
44142
- access: array(MethodAccessSchema).min(1)
44143
- }),
44144
- DeviceTokenScopeSchema
44145
- ]));
44146
- object({
44147
- id: string(),
44148
- username: string(),
44149
- passwordHash: string(),
44150
- /**
44151
- * Admin bypass. When true, the middleware skips the scope-access
44152
- * check entirely. There is no other axis of privilege; the legacy
44153
- * role enum collapsed onto this boolean in v2.
44154
- */
44155
- isAdmin: boolean().default(false),
44156
- allowedProviders: AllowedProviderSchema,
44157
- allowedDevices: AllowedDevicesSchema,
44158
- /**
44159
- * Scopes granted to this user. Admins bypass; their `scopes` is
44160
- * ignored. Non-admins without scopes are locked out of every
44161
- * protected call.
44162
- */
44163
- scopes: array(TokenScopeSchema).default([]),
44164
- createdAt: number(),
44165
- updatedAt: number()
44166
- });
44167
- object({
44168
- id: string(),
44169
- label: string(),
44170
- isAdmin: boolean().default(false),
44171
- allowedProviders: AllowedProviderSchema,
44172
- allowedDevices: AllowedDevicesSchema,
44173
- tokenHash: string(),
44174
- tokenPrefix: string(),
44175
- createdAt: number(),
44176
- lastUsedAt: number().optional()
44177
- });
44178
- object({
44179
- id: string(),
44180
- userId: string(),
44181
- name: string(),
44182
- tokenHash: string(),
44183
- tokenPrefix: string(),
44184
- scopes: array(TokenScopeSchema),
44185
- expiresAt: number().nullish(),
44186
- lastUsedAt: number().nullish(),
44187
- createdAt: number()
44188
- });
44189
- /**
44190
44223
  * `oauth-integration` — a collection cap by which an addon declares
44191
44224
  * itself a linkable OAuth client of the hub's core `/oauth2/*` server.
44192
44225
  * Each provider returns a static descriptor; the core enumerates them
package/dist/addon.mjs CHANGED
@@ -7833,6 +7833,12 @@ function normalizeAddonInitResult(result) {
7833
7833
  if (Array.isArray(result)) return { providers: result };
7834
7834
  return result;
7835
7835
  }
7836
+ /**
7837
+ * The share-view scope kinds a `csv_*` share token can carry. The hub mints
7838
+ * and validates them (`share-token.service.ts` builds its enum from this
7839
+ * list); a data plane names the kinds it ACCEPTS in `share`.
7840
+ */
7841
+ var SHARE_VIEW_KINDS = ["grid-view", "events-view"];
7836
7842
  /** The wire shape of {@link PeerBytesTicket} — see the type for what it is. */
7837
7843
  var PeerBytesTicketSchema = object({
7838
7844
  /** `http://127.0.0.1:<port>/<token>`. One `GET` takes it. */
@@ -12498,6 +12504,229 @@ var ConvertResultSchema = object({
12498
12504
  files: array(string()).readonly()
12499
12505
  })).readonly()
12500
12506
  });
12507
+ /**
12508
+ * Zod schemas for persisted record types.
12509
+ *
12510
+ * These schemas serve as the single source of truth for types that are
12511
+ * stored in the settings-store backend and retrieved via tRPC. They
12512
+ * replace the manual TypeScript interfaces with schema-derived types,
12513
+ * enabling runtime validation when reading from the backend.
12514
+ *
12515
+ * Convention: each schema is named `<Type>Schema`, the inferred TS type
12516
+ * keeps the original name for backward compatibility.
12517
+ */
12518
+ /**
12519
+ * Auth model (v2 — 2026-05-12 caps-only):
12520
+ *
12521
+ * Two principals:
12522
+ * - `isAdmin: true` — full bypass. Admin scope set is ignored.
12523
+ * - `isAdmin: false` — every call gated by `scopes` (see TokenScope).
12524
+ *
12525
+ * No role enum. There used to be `viewer / agent / scoped` and earlier
12526
+ * `super_admin` — collapsed onto the single boolean because every
12527
+ * non-admin caller is governed by the same scope-check rules; the
12528
+ * distinction was only ever used to route role-specific procedures
12529
+ * which we no longer have. CLI / webhook integrations are `cst_*` tokens
12530
+ * with `isAdmin: false` + an explicit scope list.
12531
+ */
12532
+ /** Per-method access flavour. Materialised on every cap method via codegen. */
12533
+ var MethodAccessSchema = _enum([
12534
+ "view",
12535
+ "create",
12536
+ "delete"
12537
+ ]);
12538
+ /**
12539
+ * A single scope grant. Three forms — checked in matcher with OR
12540
+ * semantics; the first match decides whether the call passes:
12541
+ *
12542
+ * - `category` — broadest. `target: 'device' | 'system'` selects every
12543
+ * cap with the matching `scope` declaration. New caps inherit grants
12544
+ * automatically — adding a device cap to the codebase makes it
12545
+ * reachable to every user with `category:device [...]` without a
12546
+ * re-grant. Use this for "family viewer" / "operator" tiers.
12547
+ *
12548
+ * - `addon` — every cap that ships inside a given addon id. Niche;
12549
+ * useful when an integration needs to interact with one specific
12550
+ * addon's surface regardless of how many caps it exports.
12551
+ *
12552
+ * - `capability` — the most precise form. Single cap name. Use for
12553
+ * integration tokens where you want to grant `addons.installPackage`
12554
+ * and nothing else.
12555
+ *
12556
+ * `access` is REQUIRED with min 1 element. `admin` bypass is the
12557
+ * "give me everything" escape; there is no wildcard scope.
12558
+ */
12559
+ var AllowedProviderSchema = union([literal("*"), array(string())]);
12560
+ var AllowedDevicesSchema = record(string(), union([literal("*"), array(string())]));
12561
+ var CapScopeSchema = _enum(["device", "system"]);
12562
+ /**
12563
+ * DeviceSelector (scope model v3 — 2026-08-12).
12564
+ *
12565
+ * A `device` grant no longer carries a frozen list of deviceIds. It carries
12566
+ * a SELECTOR the matcher resolves against the live fleet, so the grant can be
12567
+ * DYNAMIC: a `types:['camera']` selector automatically covers a camera added
12568
+ * AFTER the grant was minted — no re-grant, no re-login.
12569
+ *
12570
+ * - `all` — every device in the deployment. The broad viewer/operator
12571
+ * lever without a `category` grant (a `category` grant also covers device
12572
+ * caps that carry no deviceId; `all` is specifically the device set).
12573
+ * - `ids` — an explicit deviceId list. This is what a v2 `device:[…]`
12574
+ * grant migrates to (see {@link TokenScopeSchema}); STATIC — a new camera
12575
+ * is NOT covered until the grant is edited.
12576
+ * - `types` — every device of a `DeviceType` (e.g. every `camera`).
12577
+ * DYNAMIC. A device that changes type, or a new device of the type,
12578
+ * re-resolves on the next request.
12579
+ * - `locations` — every device whose operator-assigned `location` label is
12580
+ * in the set (e.g. "Garden", "Front door"). DYNAMIC. A device with a
12581
+ * null/unset location matches NO `locations` selector.
12582
+ */
12583
+ var DeviceSelectorSchema = discriminatedUnion("kind", [
12584
+ object({ kind: literal("all") }),
12585
+ object({
12586
+ kind: literal("ids"),
12587
+ ids: array(number().int()).min(1)
12588
+ }),
12589
+ object({
12590
+ kind: literal("types"),
12591
+ types: array(_enum(DeviceType)).min(1)
12592
+ }),
12593
+ object({
12594
+ kind: literal("locations"),
12595
+ locations: array(string().min(1)).min(1)
12596
+ })
12597
+ ]);
12598
+ var DeviceTokenScopeSchema = object({
12599
+ type: literal("device"),
12600
+ /** The device SET this grant covers — resolved against the live fleet. */
12601
+ selector: DeviceSelectorSchema,
12602
+ access: array(MethodAccessSchema).min(1),
12603
+ /**
12604
+ * Whether a grant on a PARENT device transparently covers its accessory
12605
+ * CHILDREN (siren / floodlight / PIR) via the persisted-parentage walk.
12606
+ * Direction is parent → children ONLY.
12607
+ *
12608
+ * Absent → the matcher DERIVES it from the access flavour: `view`
12609
+ * inherits (a camera viewer sees the camera's accessories), `create` /
12610
+ * `delete` do NOT (actuating/removing a child is an explicit act the
12611
+ * operator must grant on the child, not inherit from the parent). Set it
12612
+ * explicitly to override that default per grant.
12613
+ */
12614
+ includeLinked: boolean().optional()
12615
+ });
12616
+ /**
12617
+ * v2 → v3 lazy migration. A pre-v3 `device` grant carried
12618
+ * `targets: string[]` (stringified deviceIds); it rewrites to the equivalent
12619
+ * `selector: {kind:'ids', ids}`. Applied as a `preprocess` so it runs on
12620
+ * EVERY parse path — stored records AND the JWT-carried scope arrays
12621
+ * normalised at the request boundary ({@link normalizeTokenScopes} in
12622
+ * `device-selector.ts`). Chosen over a one-time DB migration because a
12623
+ * migration cannot reach a JWT already in a client's hands; parse-time
12624
+ * migration covers both without a flag day. No cast — the raw object is read
12625
+ * through `Reflect.get` (its static type is `unknown`).
12626
+ */
12627
+ function migrateLegacyTokenScope(raw) {
12628
+ if (raw === null || typeof raw !== "object" || Array.isArray(raw)) return raw;
12629
+ if (Reflect.get(raw, "type") !== "device") return raw;
12630
+ if (Reflect.get(raw, "selector") !== void 0) return raw;
12631
+ const targets = Reflect.get(raw, "targets");
12632
+ if (!Array.isArray(targets)) return raw;
12633
+ return {
12634
+ type: "device",
12635
+ selector: {
12636
+ kind: "ids",
12637
+ ids: targets.map((t) => typeof t === "string" ? Number(t) : t).filter((n) => typeof n === "number" && Number.isInteger(n))
12638
+ },
12639
+ access: Reflect.get(raw, "access")
12640
+ };
12641
+ }
12642
+ var TokenScopeSchema = preprocess(migrateLegacyTokenScope, discriminatedUnion("type", [
12643
+ object({
12644
+ type: literal("category"),
12645
+ target: CapScopeSchema,
12646
+ access: array(MethodAccessSchema).min(1)
12647
+ }),
12648
+ object({
12649
+ type: literal("capability"),
12650
+ target: string(),
12651
+ access: array(MethodAccessSchema).min(1)
12652
+ }),
12653
+ object({
12654
+ type: literal("addon"),
12655
+ target: string(),
12656
+ access: array(MethodAccessSchema).min(1)
12657
+ }),
12658
+ DeviceTokenScopeSchema
12659
+ ]));
12660
+ object({
12661
+ id: string(),
12662
+ username: string(),
12663
+ passwordHash: string(),
12664
+ /**
12665
+ * Admin bypass. When true, the middleware skips the scope-access
12666
+ * check entirely. There is no other axis of privilege; the legacy
12667
+ * role enum collapsed onto this boolean in v2.
12668
+ */
12669
+ isAdmin: boolean().default(false),
12670
+ allowedProviders: AllowedProviderSchema,
12671
+ allowedDevices: AllowedDevicesSchema,
12672
+ /**
12673
+ * Scopes granted to this user. Admins bypass; their `scopes` is
12674
+ * ignored. Non-admins without scopes are locked out of every
12675
+ * protected call.
12676
+ */
12677
+ scopes: array(TokenScopeSchema).default([]),
12678
+ createdAt: number(),
12679
+ updatedAt: number()
12680
+ });
12681
+ object({
12682
+ id: string(),
12683
+ label: string(),
12684
+ isAdmin: boolean().default(false),
12685
+ allowedProviders: AllowedProviderSchema,
12686
+ allowedDevices: AllowedDevicesSchema,
12687
+ tokenHash: string(),
12688
+ tokenPrefix: string(),
12689
+ createdAt: number(),
12690
+ lastUsedAt: number().optional()
12691
+ });
12692
+ object({
12693
+ id: string(),
12694
+ userId: string(),
12695
+ name: string(),
12696
+ tokenHash: string(),
12697
+ tokenPrefix: string(),
12698
+ scopes: array(TokenScopeSchema),
12699
+ expiresAt: number().nullish(),
12700
+ lastUsedAt: number().nullish(),
12701
+ createdAt: number()
12702
+ });
12703
+ /** What a share-view grant lets its holder see. */
12704
+ var ShareViewGrantSchema = object({
12705
+ kind: _enum(SHARE_VIEW_KINDS),
12706
+ deviceIds: array(number().int().nonnegative()).min(1).max(64),
12707
+ /** Talk-back, opt-in at mint time; absent means off. */
12708
+ talk: boolean().optional()
12709
+ });
12710
+ var ShareViewScopeSchema = object({
12711
+ type: literal("share-view"),
12712
+ grant: ShareViewGrantSchema
12713
+ });
12714
+ var AddonRoutesScopeSchema = object({
12715
+ type: literal("addon-routes"),
12716
+ access: array(MethodAccessSchema).min(1)
12717
+ });
12718
+ var CredentialScopeSchema = union([
12719
+ literal("*"),
12720
+ ShareViewScopeSchema,
12721
+ AddonRoutesScopeSchema,
12722
+ TokenScopeSchema
12723
+ ]);
12724
+ object({
12725
+ kind: literal("credential"),
12726
+ sub: string().min(1),
12727
+ jti: string().min(16),
12728
+ scopes: array(CredentialScopeSchema).min(1)
12729
+ });
12501
12730
  _enum(["new-session", "step-up"]);
12502
12731
  /** The languages the hub's app landing pages are written in (D858). */
12503
12732
  var AppPageLangSchema = _enum(["en", "it"]);
@@ -43992,202 +44221,6 @@ method(object({}), object({ rules: array(NcRuleSchema) }), { auth: "admin" }), m
43992
44221
  auth: "admin"
43993
44222
  }), method(NcAlarmSensorsInputSchema, NcAlarmSensorsSchema, { auth: "admin" });
43994
44223
  /**
43995
- * Zod schemas for persisted record types.
43996
- *
43997
- * These schemas serve as the single source of truth for types that are
43998
- * stored in the settings-store backend and retrieved via tRPC. They
43999
- * replace the manual TypeScript interfaces with schema-derived types,
44000
- * enabling runtime validation when reading from the backend.
44001
- *
44002
- * Convention: each schema is named `<Type>Schema`, the inferred TS type
44003
- * keeps the original name for backward compatibility.
44004
- */
44005
- /**
44006
- * Auth model (v2 — 2026-05-12 caps-only):
44007
- *
44008
- * Two principals:
44009
- * - `isAdmin: true` — full bypass. Admin scope set is ignored.
44010
- * - `isAdmin: false` — every call gated by `scopes` (see TokenScope).
44011
- *
44012
- * No role enum. There used to be `viewer / agent / scoped` and earlier
44013
- * `super_admin` — collapsed onto the single boolean because every
44014
- * non-admin caller is governed by the same scope-check rules; the
44015
- * distinction was only ever used to route role-specific procedures
44016
- * which we no longer have. CLI / webhook integrations are `cst_*` tokens
44017
- * with `isAdmin: false` + an explicit scope list.
44018
- */
44019
- /** Per-method access flavour. Materialised on every cap method via codegen. */
44020
- var MethodAccessSchema = _enum([
44021
- "view",
44022
- "create",
44023
- "delete"
44024
- ]);
44025
- /**
44026
- * A single scope grant. Three forms — checked in matcher with OR
44027
- * semantics; the first match decides whether the call passes:
44028
- *
44029
- * - `category` — broadest. `target: 'device' | 'system'` selects every
44030
- * cap with the matching `scope` declaration. New caps inherit grants
44031
- * automatically — adding a device cap to the codebase makes it
44032
- * reachable to every user with `category:device [...]` without a
44033
- * re-grant. Use this for "family viewer" / "operator" tiers.
44034
- *
44035
- * - `addon` — every cap that ships inside a given addon id. Niche;
44036
- * useful when an integration needs to interact with one specific
44037
- * addon's surface regardless of how many caps it exports.
44038
- *
44039
- * - `capability` — the most precise form. Single cap name. Use for
44040
- * integration tokens where you want to grant `addons.installPackage`
44041
- * and nothing else.
44042
- *
44043
- * `access` is REQUIRED with min 1 element. `admin` bypass is the
44044
- * "give me everything" escape; there is no wildcard scope.
44045
- */
44046
- var AllowedProviderSchema = union([literal("*"), array(string())]);
44047
- var AllowedDevicesSchema = record(string(), union([literal("*"), array(string())]));
44048
- var CapScopeSchema = _enum(["device", "system"]);
44049
- /**
44050
- * DeviceSelector (scope model v3 — 2026-08-12).
44051
- *
44052
- * A `device` grant no longer carries a frozen list of deviceIds. It carries
44053
- * a SELECTOR the matcher resolves against the live fleet, so the grant can be
44054
- * DYNAMIC: a `types:['camera']` selector automatically covers a camera added
44055
- * AFTER the grant was minted — no re-grant, no re-login.
44056
- *
44057
- * - `all` — every device in the deployment. The broad viewer/operator
44058
- * lever without a `category` grant (a `category` grant also covers device
44059
- * caps that carry no deviceId; `all` is specifically the device set).
44060
- * - `ids` — an explicit deviceId list. This is what a v2 `device:[…]`
44061
- * grant migrates to (see {@link TokenScopeSchema}); STATIC — a new camera
44062
- * is NOT covered until the grant is edited.
44063
- * - `types` — every device of a `DeviceType` (e.g. every `camera`).
44064
- * DYNAMIC. A device that changes type, or a new device of the type,
44065
- * re-resolves on the next request.
44066
- * - `locations` — every device whose operator-assigned `location` label is
44067
- * in the set (e.g. "Garden", "Front door"). DYNAMIC. A device with a
44068
- * null/unset location matches NO `locations` selector.
44069
- */
44070
- var DeviceSelectorSchema = discriminatedUnion("kind", [
44071
- object({ kind: literal("all") }),
44072
- object({
44073
- kind: literal("ids"),
44074
- ids: array(number().int()).min(1)
44075
- }),
44076
- object({
44077
- kind: literal("types"),
44078
- types: array(_enum(DeviceType)).min(1)
44079
- }),
44080
- object({
44081
- kind: literal("locations"),
44082
- locations: array(string().min(1)).min(1)
44083
- })
44084
- ]);
44085
- var DeviceTokenScopeSchema = object({
44086
- type: literal("device"),
44087
- /** The device SET this grant covers — resolved against the live fleet. */
44088
- selector: DeviceSelectorSchema,
44089
- access: array(MethodAccessSchema).min(1),
44090
- /**
44091
- * Whether a grant on a PARENT device transparently covers its accessory
44092
- * CHILDREN (siren / floodlight / PIR) via the persisted-parentage walk.
44093
- * Direction is parent → children ONLY.
44094
- *
44095
- * Absent → the matcher DERIVES it from the access flavour: `view`
44096
- * inherits (a camera viewer sees the camera's accessories), `create` /
44097
- * `delete` do NOT (actuating/removing a child is an explicit act the
44098
- * operator must grant on the child, not inherit from the parent). Set it
44099
- * explicitly to override that default per grant.
44100
- */
44101
- includeLinked: boolean().optional()
44102
- });
44103
- /**
44104
- * v2 → v3 lazy migration. A pre-v3 `device` grant carried
44105
- * `targets: string[]` (stringified deviceIds); it rewrites to the equivalent
44106
- * `selector: {kind:'ids', ids}`. Applied as a `preprocess` so it runs on
44107
- * EVERY parse path — stored records AND the JWT-carried scope arrays
44108
- * normalised at the request boundary ({@link normalizeTokenScopes} in
44109
- * `device-selector.ts`). Chosen over a one-time DB migration because a
44110
- * migration cannot reach a JWT already in a client's hands; parse-time
44111
- * migration covers both without a flag day. No cast — the raw object is read
44112
- * through `Reflect.get` (its static type is `unknown`).
44113
- */
44114
- function migrateLegacyTokenScope(raw) {
44115
- if (raw === null || typeof raw !== "object" || Array.isArray(raw)) return raw;
44116
- if (Reflect.get(raw, "type") !== "device") return raw;
44117
- if (Reflect.get(raw, "selector") !== void 0) return raw;
44118
- const targets = Reflect.get(raw, "targets");
44119
- if (!Array.isArray(targets)) return raw;
44120
- return {
44121
- type: "device",
44122
- selector: {
44123
- kind: "ids",
44124
- ids: targets.map((t) => typeof t === "string" ? Number(t) : t).filter((n) => typeof n === "number" && Number.isInteger(n))
44125
- },
44126
- access: Reflect.get(raw, "access")
44127
- };
44128
- }
44129
- var TokenScopeSchema = preprocess(migrateLegacyTokenScope, discriminatedUnion("type", [
44130
- object({
44131
- type: literal("category"),
44132
- target: CapScopeSchema,
44133
- access: array(MethodAccessSchema).min(1)
44134
- }),
44135
- object({
44136
- type: literal("capability"),
44137
- target: string(),
44138
- access: array(MethodAccessSchema).min(1)
44139
- }),
44140
- object({
44141
- type: literal("addon"),
44142
- target: string(),
44143
- access: array(MethodAccessSchema).min(1)
44144
- }),
44145
- DeviceTokenScopeSchema
44146
- ]));
44147
- object({
44148
- id: string(),
44149
- username: string(),
44150
- passwordHash: string(),
44151
- /**
44152
- * Admin bypass. When true, the middleware skips the scope-access
44153
- * check entirely. There is no other axis of privilege; the legacy
44154
- * role enum collapsed onto this boolean in v2.
44155
- */
44156
- isAdmin: boolean().default(false),
44157
- allowedProviders: AllowedProviderSchema,
44158
- allowedDevices: AllowedDevicesSchema,
44159
- /**
44160
- * Scopes granted to this user. Admins bypass; their `scopes` is
44161
- * ignored. Non-admins without scopes are locked out of every
44162
- * protected call.
44163
- */
44164
- scopes: array(TokenScopeSchema).default([]),
44165
- createdAt: number(),
44166
- updatedAt: number()
44167
- });
44168
- object({
44169
- id: string(),
44170
- label: string(),
44171
- isAdmin: boolean().default(false),
44172
- allowedProviders: AllowedProviderSchema,
44173
- allowedDevices: AllowedDevicesSchema,
44174
- tokenHash: string(),
44175
- tokenPrefix: string(),
44176
- createdAt: number(),
44177
- lastUsedAt: number().optional()
44178
- });
44179
- object({
44180
- id: string(),
44181
- userId: string(),
44182
- name: string(),
44183
- tokenHash: string(),
44184
- tokenPrefix: string(),
44185
- scopes: array(TokenScopeSchema),
44186
- expiresAt: number().nullish(),
44187
- lastUsedAt: number().nullish(),
44188
- createdAt: number()
44189
- });
44190
- /**
44191
44224
  * `oauth-integration` — a collection cap by which an addon declares
44192
44225
  * itself a linkable OAuth client of the hub's core `/oauth2/*` server.
44193
44226
  * 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-dreo",
3
- "version": "0.2.129",
3
+ "version": "0.2.130",
4
4
  "description": "Dreo smart-device (fan / air-circulator / purifier / heater / humidifier) device-provider addon for CamStack — wraps the @apocaliss92/nodedreo Dreo cloud client (REST + WebSocket)",
5
5
  "keywords": [
6
6
  "camstack",