@camstack/addon-provider-wyze 0.2.141 → 0.2.142

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