@camstack/addon-provider-petkit 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
@@ -8898,6 +8898,12 @@ function normalizeAddonInitResult(result) {
8898
8898
  if (Array.isArray(result)) return { providers: result };
8899
8899
  return result;
8900
8900
  }
8901
+ /**
8902
+ * The share-view scope kinds a `csv_*` share token can carry. The hub mints
8903
+ * and validates them (`share-token.service.ts` builds its enum from this
8904
+ * list); a data plane names the kinds it ACCEPTS in `share`.
8905
+ */
8906
+ var SHARE_VIEW_KINDS = ["grid-view", "events-view"];
8901
8907
  /** The wire shape of {@link PeerBytesTicket} — see the type for what it is. */
8902
8908
  var PeerBytesTicketSchema = object({
8903
8909
  /** `http://127.0.0.1:<port>/<token>`. One `GET` takes it. */
@@ -13563,6 +13569,229 @@ var ConvertResultSchema = object({
13563
13569
  files: array(string()).readonly()
13564
13570
  })).readonly()
13565
13571
  });
13572
+ /**
13573
+ * Zod schemas for persisted record types.
13574
+ *
13575
+ * These schemas serve as the single source of truth for types that are
13576
+ * stored in the settings-store backend and retrieved via tRPC. They
13577
+ * replace the manual TypeScript interfaces with schema-derived types,
13578
+ * enabling runtime validation when reading from the backend.
13579
+ *
13580
+ * Convention: each schema is named `<Type>Schema`, the inferred TS type
13581
+ * keeps the original name for backward compatibility.
13582
+ */
13583
+ /**
13584
+ * Auth model (v2 — 2026-05-12 caps-only):
13585
+ *
13586
+ * Two principals:
13587
+ * - `isAdmin: true` — full bypass. Admin scope set is ignored.
13588
+ * - `isAdmin: false` — every call gated by `scopes` (see TokenScope).
13589
+ *
13590
+ * No role enum. There used to be `viewer / agent / scoped` and earlier
13591
+ * `super_admin` — collapsed onto the single boolean because every
13592
+ * non-admin caller is governed by the same scope-check rules; the
13593
+ * distinction was only ever used to route role-specific procedures
13594
+ * which we no longer have. CLI / webhook integrations are `cst_*` tokens
13595
+ * with `isAdmin: false` + an explicit scope list.
13596
+ */
13597
+ /** Per-method access flavour. Materialised on every cap method via codegen. */
13598
+ var MethodAccessSchema = _enum([
13599
+ "view",
13600
+ "create",
13601
+ "delete"
13602
+ ]);
13603
+ /**
13604
+ * A single scope grant. Three forms — checked in matcher with OR
13605
+ * semantics; the first match decides whether the call passes:
13606
+ *
13607
+ * - `category` — broadest. `target: 'device' | 'system'` selects every
13608
+ * cap with the matching `scope` declaration. New caps inherit grants
13609
+ * automatically — adding a device cap to the codebase makes it
13610
+ * reachable to every user with `category:device [...]` without a
13611
+ * re-grant. Use this for "family viewer" / "operator" tiers.
13612
+ *
13613
+ * - `addon` — every cap that ships inside a given addon id. Niche;
13614
+ * useful when an integration needs to interact with one specific
13615
+ * addon's surface regardless of how many caps it exports.
13616
+ *
13617
+ * - `capability` — the most precise form. Single cap name. Use for
13618
+ * integration tokens where you want to grant `addons.installPackage`
13619
+ * and nothing else.
13620
+ *
13621
+ * `access` is REQUIRED with min 1 element. `admin` bypass is the
13622
+ * "give me everything" escape; there is no wildcard scope.
13623
+ */
13624
+ var AllowedProviderSchema = union([literal("*"), array(string())]);
13625
+ var AllowedDevicesSchema = record(string(), union([literal("*"), array(string())]));
13626
+ var CapScopeSchema = _enum(["device", "system"]);
13627
+ /**
13628
+ * DeviceSelector (scope model v3 — 2026-08-12).
13629
+ *
13630
+ * A `device` grant no longer carries a frozen list of deviceIds. It carries
13631
+ * a SELECTOR the matcher resolves against the live fleet, so the grant can be
13632
+ * DYNAMIC: a `types:['camera']` selector automatically covers a camera added
13633
+ * AFTER the grant was minted — no re-grant, no re-login.
13634
+ *
13635
+ * - `all` — every device in the deployment. The broad viewer/operator
13636
+ * lever without a `category` grant (a `category` grant also covers device
13637
+ * caps that carry no deviceId; `all` is specifically the device set).
13638
+ * - `ids` — an explicit deviceId list. This is what a v2 `device:[…]`
13639
+ * grant migrates to (see {@link TokenScopeSchema}); STATIC — a new camera
13640
+ * is NOT covered until the grant is edited.
13641
+ * - `types` — every device of a `DeviceType` (e.g. every `camera`).
13642
+ * DYNAMIC. A device that changes type, or a new device of the type,
13643
+ * re-resolves on the next request.
13644
+ * - `locations` — every device whose operator-assigned `location` label is
13645
+ * in the set (e.g. "Garden", "Front door"). DYNAMIC. A device with a
13646
+ * null/unset location matches NO `locations` selector.
13647
+ */
13648
+ var DeviceSelectorSchema = discriminatedUnion("kind", [
13649
+ object({ kind: literal("all") }),
13650
+ object({
13651
+ kind: literal("ids"),
13652
+ ids: array(number().int()).min(1)
13653
+ }),
13654
+ object({
13655
+ kind: literal("types"),
13656
+ types: array(_enum(DeviceType)).min(1)
13657
+ }),
13658
+ object({
13659
+ kind: literal("locations"),
13660
+ locations: array(string().min(1)).min(1)
13661
+ })
13662
+ ]);
13663
+ var DeviceTokenScopeSchema = object({
13664
+ type: literal("device"),
13665
+ /** The device SET this grant covers — resolved against the live fleet. */
13666
+ selector: DeviceSelectorSchema,
13667
+ access: array(MethodAccessSchema).min(1),
13668
+ /**
13669
+ * Whether a grant on a PARENT device transparently covers its accessory
13670
+ * CHILDREN (siren / floodlight / PIR) via the persisted-parentage walk.
13671
+ * Direction is parent → children ONLY.
13672
+ *
13673
+ * Absent → the matcher DERIVES it from the access flavour: `view`
13674
+ * inherits (a camera viewer sees the camera's accessories), `create` /
13675
+ * `delete` do NOT (actuating/removing a child is an explicit act the
13676
+ * operator must grant on the child, not inherit from the parent). Set it
13677
+ * explicitly to override that default per grant.
13678
+ */
13679
+ includeLinked: boolean().optional()
13680
+ });
13681
+ /**
13682
+ * v2 → v3 lazy migration. A pre-v3 `device` grant carried
13683
+ * `targets: string[]` (stringified deviceIds); it rewrites to the equivalent
13684
+ * `selector: {kind:'ids', ids}`. Applied as a `preprocess` so it runs on
13685
+ * EVERY parse path — stored records AND the JWT-carried scope arrays
13686
+ * normalised at the request boundary ({@link normalizeTokenScopes} in
13687
+ * `device-selector.ts`). Chosen over a one-time DB migration because a
13688
+ * migration cannot reach a JWT already in a client's hands; parse-time
13689
+ * migration covers both without a flag day. No cast — the raw object is read
13690
+ * through `Reflect.get` (its static type is `unknown`).
13691
+ */
13692
+ function migrateLegacyTokenScope(raw) {
13693
+ if (raw === null || typeof raw !== "object" || Array.isArray(raw)) return raw;
13694
+ if (Reflect.get(raw, "type") !== "device") return raw;
13695
+ if (Reflect.get(raw, "selector") !== void 0) return raw;
13696
+ const targets = Reflect.get(raw, "targets");
13697
+ if (!Array.isArray(targets)) return raw;
13698
+ return {
13699
+ type: "device",
13700
+ selector: {
13701
+ kind: "ids",
13702
+ ids: targets.map((t) => typeof t === "string" ? Number(t) : t).filter((n) => typeof n === "number" && Number.isInteger(n))
13703
+ },
13704
+ access: Reflect.get(raw, "access")
13705
+ };
13706
+ }
13707
+ var TokenScopeSchema = preprocess(migrateLegacyTokenScope, discriminatedUnion("type", [
13708
+ object({
13709
+ type: literal("category"),
13710
+ target: CapScopeSchema,
13711
+ access: array(MethodAccessSchema).min(1)
13712
+ }),
13713
+ object({
13714
+ type: literal("capability"),
13715
+ target: string(),
13716
+ access: array(MethodAccessSchema).min(1)
13717
+ }),
13718
+ object({
13719
+ type: literal("addon"),
13720
+ target: string(),
13721
+ access: array(MethodAccessSchema).min(1)
13722
+ }),
13723
+ DeviceTokenScopeSchema
13724
+ ]));
13725
+ object({
13726
+ id: string(),
13727
+ username: string(),
13728
+ passwordHash: string(),
13729
+ /**
13730
+ * Admin bypass. When true, the middleware skips the scope-access
13731
+ * check entirely. There is no other axis of privilege; the legacy
13732
+ * role enum collapsed onto this boolean in v2.
13733
+ */
13734
+ isAdmin: boolean().default(false),
13735
+ allowedProviders: AllowedProviderSchema,
13736
+ allowedDevices: AllowedDevicesSchema,
13737
+ /**
13738
+ * Scopes granted to this user. Admins bypass; their `scopes` is
13739
+ * ignored. Non-admins without scopes are locked out of every
13740
+ * protected call.
13741
+ */
13742
+ scopes: array(TokenScopeSchema).default([]),
13743
+ createdAt: number(),
13744
+ updatedAt: number()
13745
+ });
13746
+ object({
13747
+ id: string(),
13748
+ label: string(),
13749
+ isAdmin: boolean().default(false),
13750
+ allowedProviders: AllowedProviderSchema,
13751
+ allowedDevices: AllowedDevicesSchema,
13752
+ tokenHash: string(),
13753
+ tokenPrefix: string(),
13754
+ createdAt: number(),
13755
+ lastUsedAt: number().optional()
13756
+ });
13757
+ object({
13758
+ id: string(),
13759
+ userId: string(),
13760
+ name: string(),
13761
+ tokenHash: string(),
13762
+ tokenPrefix: string(),
13763
+ scopes: array(TokenScopeSchema),
13764
+ expiresAt: number().nullish(),
13765
+ lastUsedAt: number().nullish(),
13766
+ createdAt: number()
13767
+ });
13768
+ /** What a share-view grant lets its holder see. */
13769
+ var ShareViewGrantSchema = object({
13770
+ kind: _enum(SHARE_VIEW_KINDS),
13771
+ deviceIds: array(number().int().nonnegative()).min(1).max(64),
13772
+ /** Talk-back, opt-in at mint time; absent means off. */
13773
+ talk: boolean().optional()
13774
+ });
13775
+ var ShareViewScopeSchema = object({
13776
+ type: literal("share-view"),
13777
+ grant: ShareViewGrantSchema
13778
+ });
13779
+ var AddonRoutesScopeSchema = object({
13780
+ type: literal("addon-routes"),
13781
+ access: array(MethodAccessSchema).min(1)
13782
+ });
13783
+ var CredentialScopeSchema = union([
13784
+ literal("*"),
13785
+ ShareViewScopeSchema,
13786
+ AddonRoutesScopeSchema,
13787
+ TokenScopeSchema
13788
+ ]);
13789
+ object({
13790
+ kind: literal("credential"),
13791
+ sub: string().min(1),
13792
+ jti: string().min(16),
13793
+ scopes: array(CredentialScopeSchema).min(1)
13794
+ });
13566
13795
  _enum(["new-session", "step-up"]);
13567
13796
  /** The languages the hub's app landing pages are written in (D858). */
13568
13797
  var AppPageLangSchema = _enum(["en", "it"]);
@@ -45057,202 +45286,6 @@ method(object({}), object({ rules: array(NcRuleSchema) }), { auth: "admin" }), m
45057
45286
  auth: "admin"
45058
45287
  }), method(NcAlarmSensorsInputSchema, NcAlarmSensorsSchema, { auth: "admin" });
45059
45288
  /**
45060
- * Zod schemas for persisted record types.
45061
- *
45062
- * These schemas serve as the single source of truth for types that are
45063
- * stored in the settings-store backend and retrieved via tRPC. They
45064
- * replace the manual TypeScript interfaces with schema-derived types,
45065
- * enabling runtime validation when reading from the backend.
45066
- *
45067
- * Convention: each schema is named `<Type>Schema`, the inferred TS type
45068
- * keeps the original name for backward compatibility.
45069
- */
45070
- /**
45071
- * Auth model (v2 — 2026-05-12 caps-only):
45072
- *
45073
- * Two principals:
45074
- * - `isAdmin: true` — full bypass. Admin scope set is ignored.
45075
- * - `isAdmin: false` — every call gated by `scopes` (see TokenScope).
45076
- *
45077
- * No role enum. There used to be `viewer / agent / scoped` and earlier
45078
- * `super_admin` — collapsed onto the single boolean because every
45079
- * non-admin caller is governed by the same scope-check rules; the
45080
- * distinction was only ever used to route role-specific procedures
45081
- * which we no longer have. CLI / webhook integrations are `cst_*` tokens
45082
- * with `isAdmin: false` + an explicit scope list.
45083
- */
45084
- /** Per-method access flavour. Materialised on every cap method via codegen. */
45085
- var MethodAccessSchema = _enum([
45086
- "view",
45087
- "create",
45088
- "delete"
45089
- ]);
45090
- /**
45091
- * A single scope grant. Three forms — checked in matcher with OR
45092
- * semantics; the first match decides whether the call passes:
45093
- *
45094
- * - `category` — broadest. `target: 'device' | 'system'` selects every
45095
- * cap with the matching `scope` declaration. New caps inherit grants
45096
- * automatically — adding a device cap to the codebase makes it
45097
- * reachable to every user with `category:device [...]` without a
45098
- * re-grant. Use this for "family viewer" / "operator" tiers.
45099
- *
45100
- * - `addon` — every cap that ships inside a given addon id. Niche;
45101
- * useful when an integration needs to interact with one specific
45102
- * addon's surface regardless of how many caps it exports.
45103
- *
45104
- * - `capability` — the most precise form. Single cap name. Use for
45105
- * integration tokens where you want to grant `addons.installPackage`
45106
- * and nothing else.
45107
- *
45108
- * `access` is REQUIRED with min 1 element. `admin` bypass is the
45109
- * "give me everything" escape; there is no wildcard scope.
45110
- */
45111
- var AllowedProviderSchema = union([literal("*"), array(string())]);
45112
- var AllowedDevicesSchema = record(string(), union([literal("*"), array(string())]));
45113
- var CapScopeSchema = _enum(["device", "system"]);
45114
- /**
45115
- * DeviceSelector (scope model v3 — 2026-08-12).
45116
- *
45117
- * A `device` grant no longer carries a frozen list of deviceIds. It carries
45118
- * a SELECTOR the matcher resolves against the live fleet, so the grant can be
45119
- * DYNAMIC: a `types:['camera']` selector automatically covers a camera added
45120
- * AFTER the grant was minted — no re-grant, no re-login.
45121
- *
45122
- * - `all` — every device in the deployment. The broad viewer/operator
45123
- * lever without a `category` grant (a `category` grant also covers device
45124
- * caps that carry no deviceId; `all` is specifically the device set).
45125
- * - `ids` — an explicit deviceId list. This is what a v2 `device:[…]`
45126
- * grant migrates to (see {@link TokenScopeSchema}); STATIC — a new camera
45127
- * is NOT covered until the grant is edited.
45128
- * - `types` — every device of a `DeviceType` (e.g. every `camera`).
45129
- * DYNAMIC. A device that changes type, or a new device of the type,
45130
- * re-resolves on the next request.
45131
- * - `locations` — every device whose operator-assigned `location` label is
45132
- * in the set (e.g. "Garden", "Front door"). DYNAMIC. A device with a
45133
- * null/unset location matches NO `locations` selector.
45134
- */
45135
- var DeviceSelectorSchema = discriminatedUnion("kind", [
45136
- object({ kind: literal("all") }),
45137
- object({
45138
- kind: literal("ids"),
45139
- ids: array(number().int()).min(1)
45140
- }),
45141
- object({
45142
- kind: literal("types"),
45143
- types: array(_enum(DeviceType)).min(1)
45144
- }),
45145
- object({
45146
- kind: literal("locations"),
45147
- locations: array(string().min(1)).min(1)
45148
- })
45149
- ]);
45150
- var DeviceTokenScopeSchema = object({
45151
- type: literal("device"),
45152
- /** The device SET this grant covers — resolved against the live fleet. */
45153
- selector: DeviceSelectorSchema,
45154
- access: array(MethodAccessSchema).min(1),
45155
- /**
45156
- * Whether a grant on a PARENT device transparently covers its accessory
45157
- * CHILDREN (siren / floodlight / PIR) via the persisted-parentage walk.
45158
- * Direction is parent → children ONLY.
45159
- *
45160
- * Absent → the matcher DERIVES it from the access flavour: `view`
45161
- * inherits (a camera viewer sees the camera's accessories), `create` /
45162
- * `delete` do NOT (actuating/removing a child is an explicit act the
45163
- * operator must grant on the child, not inherit from the parent). Set it
45164
- * explicitly to override that default per grant.
45165
- */
45166
- includeLinked: boolean().optional()
45167
- });
45168
- /**
45169
- * v2 → v3 lazy migration. A pre-v3 `device` grant carried
45170
- * `targets: string[]` (stringified deviceIds); it rewrites to the equivalent
45171
- * `selector: {kind:'ids', ids}`. Applied as a `preprocess` so it runs on
45172
- * EVERY parse path — stored records AND the JWT-carried scope arrays
45173
- * normalised at the request boundary ({@link normalizeTokenScopes} in
45174
- * `device-selector.ts`). Chosen over a one-time DB migration because a
45175
- * migration cannot reach a JWT already in a client's hands; parse-time
45176
- * migration covers both without a flag day. No cast — the raw object is read
45177
- * through `Reflect.get` (its static type is `unknown`).
45178
- */
45179
- function migrateLegacyTokenScope(raw) {
45180
- if (raw === null || typeof raw !== "object" || Array.isArray(raw)) return raw;
45181
- if (Reflect.get(raw, "type") !== "device") return raw;
45182
- if (Reflect.get(raw, "selector") !== void 0) return raw;
45183
- const targets = Reflect.get(raw, "targets");
45184
- if (!Array.isArray(targets)) return raw;
45185
- return {
45186
- type: "device",
45187
- selector: {
45188
- kind: "ids",
45189
- ids: targets.map((t) => typeof t === "string" ? Number(t) : t).filter((n) => typeof n === "number" && Number.isInteger(n))
45190
- },
45191
- access: Reflect.get(raw, "access")
45192
- };
45193
- }
45194
- var TokenScopeSchema = preprocess(migrateLegacyTokenScope, discriminatedUnion("type", [
45195
- object({
45196
- type: literal("category"),
45197
- target: CapScopeSchema,
45198
- access: array(MethodAccessSchema).min(1)
45199
- }),
45200
- object({
45201
- type: literal("capability"),
45202
- target: string(),
45203
- access: array(MethodAccessSchema).min(1)
45204
- }),
45205
- object({
45206
- type: literal("addon"),
45207
- target: string(),
45208
- access: array(MethodAccessSchema).min(1)
45209
- }),
45210
- DeviceTokenScopeSchema
45211
- ]));
45212
- object({
45213
- id: string(),
45214
- username: string(),
45215
- passwordHash: string(),
45216
- /**
45217
- * Admin bypass. When true, the middleware skips the scope-access
45218
- * check entirely. There is no other axis of privilege; the legacy
45219
- * role enum collapsed onto this boolean in v2.
45220
- */
45221
- isAdmin: boolean().default(false),
45222
- allowedProviders: AllowedProviderSchema,
45223
- allowedDevices: AllowedDevicesSchema,
45224
- /**
45225
- * Scopes granted to this user. Admins bypass; their `scopes` is
45226
- * ignored. Non-admins without scopes are locked out of every
45227
- * protected call.
45228
- */
45229
- scopes: array(TokenScopeSchema).default([]),
45230
- createdAt: number(),
45231
- updatedAt: number()
45232
- });
45233
- object({
45234
- id: string(),
45235
- label: string(),
45236
- isAdmin: boolean().default(false),
45237
- allowedProviders: AllowedProviderSchema,
45238
- allowedDevices: AllowedDevicesSchema,
45239
- tokenHash: string(),
45240
- tokenPrefix: string(),
45241
- createdAt: number(),
45242
- lastUsedAt: number().optional()
45243
- });
45244
- object({
45245
- id: string(),
45246
- userId: string(),
45247
- name: string(),
45248
- tokenHash: string(),
45249
- tokenPrefix: string(),
45250
- scopes: array(TokenScopeSchema),
45251
- expiresAt: number().nullish(),
45252
- lastUsedAt: number().nullish(),
45253
- createdAt: number()
45254
- });
45255
- /**
45256
45289
  * `oauth-integration` — a collection cap by which an addon declares
45257
45290
  * itself a linkable OAuth client of the hub's core `/oauth2/*` server.
45258
45291
  * Each provider returns a static descriptor; the core enumerates them
package/dist/addon.mjs CHANGED
@@ -8897,6 +8897,12 @@ function normalizeAddonInitResult(result) {
8897
8897
  if (Array.isArray(result)) return { providers: result };
8898
8898
  return result;
8899
8899
  }
8900
+ /**
8901
+ * The share-view scope kinds a `csv_*` share token can carry. The hub mints
8902
+ * and validates them (`share-token.service.ts` builds its enum from this
8903
+ * list); a data plane names the kinds it ACCEPTS in `share`.
8904
+ */
8905
+ var SHARE_VIEW_KINDS = ["grid-view", "events-view"];
8900
8906
  /** The wire shape of {@link PeerBytesTicket} — see the type for what it is. */
8901
8907
  var PeerBytesTicketSchema = object({
8902
8908
  /** `http://127.0.0.1:<port>/<token>`. One `GET` takes it. */
@@ -13562,6 +13568,229 @@ var ConvertResultSchema = object({
13562
13568
  files: array(string()).readonly()
13563
13569
  })).readonly()
13564
13570
  });
13571
+ /**
13572
+ * Zod schemas for persisted record types.
13573
+ *
13574
+ * These schemas serve as the single source of truth for types that are
13575
+ * stored in the settings-store backend and retrieved via tRPC. They
13576
+ * replace the manual TypeScript interfaces with schema-derived types,
13577
+ * enabling runtime validation when reading from the backend.
13578
+ *
13579
+ * Convention: each schema is named `<Type>Schema`, the inferred TS type
13580
+ * keeps the original name for backward compatibility.
13581
+ */
13582
+ /**
13583
+ * Auth model (v2 — 2026-05-12 caps-only):
13584
+ *
13585
+ * Two principals:
13586
+ * - `isAdmin: true` — full bypass. Admin scope set is ignored.
13587
+ * - `isAdmin: false` — every call gated by `scopes` (see TokenScope).
13588
+ *
13589
+ * No role enum. There used to be `viewer / agent / scoped` and earlier
13590
+ * `super_admin` — collapsed onto the single boolean because every
13591
+ * non-admin caller is governed by the same scope-check rules; the
13592
+ * distinction was only ever used to route role-specific procedures
13593
+ * which we no longer have. CLI / webhook integrations are `cst_*` tokens
13594
+ * with `isAdmin: false` + an explicit scope list.
13595
+ */
13596
+ /** Per-method access flavour. Materialised on every cap method via codegen. */
13597
+ var MethodAccessSchema = _enum([
13598
+ "view",
13599
+ "create",
13600
+ "delete"
13601
+ ]);
13602
+ /**
13603
+ * A single scope grant. Three forms — checked in matcher with OR
13604
+ * semantics; the first match decides whether the call passes:
13605
+ *
13606
+ * - `category` — broadest. `target: 'device' | 'system'` selects every
13607
+ * cap with the matching `scope` declaration. New caps inherit grants
13608
+ * automatically — adding a device cap to the codebase makes it
13609
+ * reachable to every user with `category:device [...]` without a
13610
+ * re-grant. Use this for "family viewer" / "operator" tiers.
13611
+ *
13612
+ * - `addon` — every cap that ships inside a given addon id. Niche;
13613
+ * useful when an integration needs to interact with one specific
13614
+ * addon's surface regardless of how many caps it exports.
13615
+ *
13616
+ * - `capability` — the most precise form. Single cap name. Use for
13617
+ * integration tokens where you want to grant `addons.installPackage`
13618
+ * and nothing else.
13619
+ *
13620
+ * `access` is REQUIRED with min 1 element. `admin` bypass is the
13621
+ * "give me everything" escape; there is no wildcard scope.
13622
+ */
13623
+ var AllowedProviderSchema = union([literal("*"), array(string())]);
13624
+ var AllowedDevicesSchema = record(string(), union([literal("*"), array(string())]));
13625
+ var CapScopeSchema = _enum(["device", "system"]);
13626
+ /**
13627
+ * DeviceSelector (scope model v3 — 2026-08-12).
13628
+ *
13629
+ * A `device` grant no longer carries a frozen list of deviceIds. It carries
13630
+ * a SELECTOR the matcher resolves against the live fleet, so the grant can be
13631
+ * DYNAMIC: a `types:['camera']` selector automatically covers a camera added
13632
+ * AFTER the grant was minted — no re-grant, no re-login.
13633
+ *
13634
+ * - `all` — every device in the deployment. The broad viewer/operator
13635
+ * lever without a `category` grant (a `category` grant also covers device
13636
+ * caps that carry no deviceId; `all` is specifically the device set).
13637
+ * - `ids` — an explicit deviceId list. This is what a v2 `device:[…]`
13638
+ * grant migrates to (see {@link TokenScopeSchema}); STATIC — a new camera
13639
+ * is NOT covered until the grant is edited.
13640
+ * - `types` — every device of a `DeviceType` (e.g. every `camera`).
13641
+ * DYNAMIC. A device that changes type, or a new device of the type,
13642
+ * re-resolves on the next request.
13643
+ * - `locations` — every device whose operator-assigned `location` label is
13644
+ * in the set (e.g. "Garden", "Front door"). DYNAMIC. A device with a
13645
+ * null/unset location matches NO `locations` selector.
13646
+ */
13647
+ var DeviceSelectorSchema = discriminatedUnion("kind", [
13648
+ object({ kind: literal("all") }),
13649
+ object({
13650
+ kind: literal("ids"),
13651
+ ids: array(number().int()).min(1)
13652
+ }),
13653
+ object({
13654
+ kind: literal("types"),
13655
+ types: array(_enum(DeviceType)).min(1)
13656
+ }),
13657
+ object({
13658
+ kind: literal("locations"),
13659
+ locations: array(string().min(1)).min(1)
13660
+ })
13661
+ ]);
13662
+ var DeviceTokenScopeSchema = object({
13663
+ type: literal("device"),
13664
+ /** The device SET this grant covers — resolved against the live fleet. */
13665
+ selector: DeviceSelectorSchema,
13666
+ access: array(MethodAccessSchema).min(1),
13667
+ /**
13668
+ * Whether a grant on a PARENT device transparently covers its accessory
13669
+ * CHILDREN (siren / floodlight / PIR) via the persisted-parentage walk.
13670
+ * Direction is parent → children ONLY.
13671
+ *
13672
+ * Absent → the matcher DERIVES it from the access flavour: `view`
13673
+ * inherits (a camera viewer sees the camera's accessories), `create` /
13674
+ * `delete` do NOT (actuating/removing a child is an explicit act the
13675
+ * operator must grant on the child, not inherit from the parent). Set it
13676
+ * explicitly to override that default per grant.
13677
+ */
13678
+ includeLinked: boolean().optional()
13679
+ });
13680
+ /**
13681
+ * v2 → v3 lazy migration. A pre-v3 `device` grant carried
13682
+ * `targets: string[]` (stringified deviceIds); it rewrites to the equivalent
13683
+ * `selector: {kind:'ids', ids}`. Applied as a `preprocess` so it runs on
13684
+ * EVERY parse path — stored records AND the JWT-carried scope arrays
13685
+ * normalised at the request boundary ({@link normalizeTokenScopes} in
13686
+ * `device-selector.ts`). Chosen over a one-time DB migration because a
13687
+ * migration cannot reach a JWT already in a client's hands; parse-time
13688
+ * migration covers both without a flag day. No cast — the raw object is read
13689
+ * through `Reflect.get` (its static type is `unknown`).
13690
+ */
13691
+ function migrateLegacyTokenScope(raw) {
13692
+ if (raw === null || typeof raw !== "object" || Array.isArray(raw)) return raw;
13693
+ if (Reflect.get(raw, "type") !== "device") return raw;
13694
+ if (Reflect.get(raw, "selector") !== void 0) return raw;
13695
+ const targets = Reflect.get(raw, "targets");
13696
+ if (!Array.isArray(targets)) return raw;
13697
+ return {
13698
+ type: "device",
13699
+ selector: {
13700
+ kind: "ids",
13701
+ ids: targets.map((t) => typeof t === "string" ? Number(t) : t).filter((n) => typeof n === "number" && Number.isInteger(n))
13702
+ },
13703
+ access: Reflect.get(raw, "access")
13704
+ };
13705
+ }
13706
+ var TokenScopeSchema = preprocess(migrateLegacyTokenScope, discriminatedUnion("type", [
13707
+ object({
13708
+ type: literal("category"),
13709
+ target: CapScopeSchema,
13710
+ access: array(MethodAccessSchema).min(1)
13711
+ }),
13712
+ object({
13713
+ type: literal("capability"),
13714
+ target: string(),
13715
+ access: array(MethodAccessSchema).min(1)
13716
+ }),
13717
+ object({
13718
+ type: literal("addon"),
13719
+ target: string(),
13720
+ access: array(MethodAccessSchema).min(1)
13721
+ }),
13722
+ DeviceTokenScopeSchema
13723
+ ]));
13724
+ object({
13725
+ id: string(),
13726
+ username: string(),
13727
+ passwordHash: string(),
13728
+ /**
13729
+ * Admin bypass. When true, the middleware skips the scope-access
13730
+ * check entirely. There is no other axis of privilege; the legacy
13731
+ * role enum collapsed onto this boolean in v2.
13732
+ */
13733
+ isAdmin: boolean().default(false),
13734
+ allowedProviders: AllowedProviderSchema,
13735
+ allowedDevices: AllowedDevicesSchema,
13736
+ /**
13737
+ * Scopes granted to this user. Admins bypass; their `scopes` is
13738
+ * ignored. Non-admins without scopes are locked out of every
13739
+ * protected call.
13740
+ */
13741
+ scopes: array(TokenScopeSchema).default([]),
13742
+ createdAt: number(),
13743
+ updatedAt: number()
13744
+ });
13745
+ object({
13746
+ id: string(),
13747
+ label: string(),
13748
+ isAdmin: boolean().default(false),
13749
+ allowedProviders: AllowedProviderSchema,
13750
+ allowedDevices: AllowedDevicesSchema,
13751
+ tokenHash: string(),
13752
+ tokenPrefix: string(),
13753
+ createdAt: number(),
13754
+ lastUsedAt: number().optional()
13755
+ });
13756
+ object({
13757
+ id: string(),
13758
+ userId: string(),
13759
+ name: string(),
13760
+ tokenHash: string(),
13761
+ tokenPrefix: string(),
13762
+ scopes: array(TokenScopeSchema),
13763
+ expiresAt: number().nullish(),
13764
+ lastUsedAt: number().nullish(),
13765
+ createdAt: number()
13766
+ });
13767
+ /** What a share-view grant lets its holder see. */
13768
+ var ShareViewGrantSchema = object({
13769
+ kind: _enum(SHARE_VIEW_KINDS),
13770
+ deviceIds: array(number().int().nonnegative()).min(1).max(64),
13771
+ /** Talk-back, opt-in at mint time; absent means off. */
13772
+ talk: boolean().optional()
13773
+ });
13774
+ var ShareViewScopeSchema = object({
13775
+ type: literal("share-view"),
13776
+ grant: ShareViewGrantSchema
13777
+ });
13778
+ var AddonRoutesScopeSchema = object({
13779
+ type: literal("addon-routes"),
13780
+ access: array(MethodAccessSchema).min(1)
13781
+ });
13782
+ var CredentialScopeSchema = union([
13783
+ literal("*"),
13784
+ ShareViewScopeSchema,
13785
+ AddonRoutesScopeSchema,
13786
+ TokenScopeSchema
13787
+ ]);
13788
+ object({
13789
+ kind: literal("credential"),
13790
+ sub: string().min(1),
13791
+ jti: string().min(16),
13792
+ scopes: array(CredentialScopeSchema).min(1)
13793
+ });
13565
13794
  _enum(["new-session", "step-up"]);
13566
13795
  /** The languages the hub's app landing pages are written in (D858). */
13567
13796
  var AppPageLangSchema = _enum(["en", "it"]);
@@ -45056,202 +45285,6 @@ method(object({}), object({ rules: array(NcRuleSchema) }), { auth: "admin" }), m
45056
45285
  auth: "admin"
45057
45286
  }), method(NcAlarmSensorsInputSchema, NcAlarmSensorsSchema, { auth: "admin" });
45058
45287
  /**
45059
- * Zod schemas for persisted record types.
45060
- *
45061
- * These schemas serve as the single source of truth for types that are
45062
- * stored in the settings-store backend and retrieved via tRPC. They
45063
- * replace the manual TypeScript interfaces with schema-derived types,
45064
- * enabling runtime validation when reading from the backend.
45065
- *
45066
- * Convention: each schema is named `<Type>Schema`, the inferred TS type
45067
- * keeps the original name for backward compatibility.
45068
- */
45069
- /**
45070
- * Auth model (v2 — 2026-05-12 caps-only):
45071
- *
45072
- * Two principals:
45073
- * - `isAdmin: true` — full bypass. Admin scope set is ignored.
45074
- * - `isAdmin: false` — every call gated by `scopes` (see TokenScope).
45075
- *
45076
- * No role enum. There used to be `viewer / agent / scoped` and earlier
45077
- * `super_admin` — collapsed onto the single boolean because every
45078
- * non-admin caller is governed by the same scope-check rules; the
45079
- * distinction was only ever used to route role-specific procedures
45080
- * which we no longer have. CLI / webhook integrations are `cst_*` tokens
45081
- * with `isAdmin: false` + an explicit scope list.
45082
- */
45083
- /** Per-method access flavour. Materialised on every cap method via codegen. */
45084
- var MethodAccessSchema = _enum([
45085
- "view",
45086
- "create",
45087
- "delete"
45088
- ]);
45089
- /**
45090
- * A single scope grant. Three forms — checked in matcher with OR
45091
- * semantics; the first match decides whether the call passes:
45092
- *
45093
- * - `category` — broadest. `target: 'device' | 'system'` selects every
45094
- * cap with the matching `scope` declaration. New caps inherit grants
45095
- * automatically — adding a device cap to the codebase makes it
45096
- * reachable to every user with `category:device [...]` without a
45097
- * re-grant. Use this for "family viewer" / "operator" tiers.
45098
- *
45099
- * - `addon` — every cap that ships inside a given addon id. Niche;
45100
- * useful when an integration needs to interact with one specific
45101
- * addon's surface regardless of how many caps it exports.
45102
- *
45103
- * - `capability` — the most precise form. Single cap name. Use for
45104
- * integration tokens where you want to grant `addons.installPackage`
45105
- * and nothing else.
45106
- *
45107
- * `access` is REQUIRED with min 1 element. `admin` bypass is the
45108
- * "give me everything" escape; there is no wildcard scope.
45109
- */
45110
- var AllowedProviderSchema = union([literal("*"), array(string())]);
45111
- var AllowedDevicesSchema = record(string(), union([literal("*"), array(string())]));
45112
- var CapScopeSchema = _enum(["device", "system"]);
45113
- /**
45114
- * DeviceSelector (scope model v3 — 2026-08-12).
45115
- *
45116
- * A `device` grant no longer carries a frozen list of deviceIds. It carries
45117
- * a SELECTOR the matcher resolves against the live fleet, so the grant can be
45118
- * DYNAMIC: a `types:['camera']` selector automatically covers a camera added
45119
- * AFTER the grant was minted — no re-grant, no re-login.
45120
- *
45121
- * - `all` — every device in the deployment. The broad viewer/operator
45122
- * lever without a `category` grant (a `category` grant also covers device
45123
- * caps that carry no deviceId; `all` is specifically the device set).
45124
- * - `ids` — an explicit deviceId list. This is what a v2 `device:[…]`
45125
- * grant migrates to (see {@link TokenScopeSchema}); STATIC — a new camera
45126
- * is NOT covered until the grant is edited.
45127
- * - `types` — every device of a `DeviceType` (e.g. every `camera`).
45128
- * DYNAMIC. A device that changes type, or a new device of the type,
45129
- * re-resolves on the next request.
45130
- * - `locations` — every device whose operator-assigned `location` label is
45131
- * in the set (e.g. "Garden", "Front door"). DYNAMIC. A device with a
45132
- * null/unset location matches NO `locations` selector.
45133
- */
45134
- var DeviceSelectorSchema = discriminatedUnion("kind", [
45135
- object({ kind: literal("all") }),
45136
- object({
45137
- kind: literal("ids"),
45138
- ids: array(number().int()).min(1)
45139
- }),
45140
- object({
45141
- kind: literal("types"),
45142
- types: array(_enum(DeviceType)).min(1)
45143
- }),
45144
- object({
45145
- kind: literal("locations"),
45146
- locations: array(string().min(1)).min(1)
45147
- })
45148
- ]);
45149
- var DeviceTokenScopeSchema = object({
45150
- type: literal("device"),
45151
- /** The device SET this grant covers — resolved against the live fleet. */
45152
- selector: DeviceSelectorSchema,
45153
- access: array(MethodAccessSchema).min(1),
45154
- /**
45155
- * Whether a grant on a PARENT device transparently covers its accessory
45156
- * CHILDREN (siren / floodlight / PIR) via the persisted-parentage walk.
45157
- * Direction is parent → children ONLY.
45158
- *
45159
- * Absent → the matcher DERIVES it from the access flavour: `view`
45160
- * inherits (a camera viewer sees the camera's accessories), `create` /
45161
- * `delete` do NOT (actuating/removing a child is an explicit act the
45162
- * operator must grant on the child, not inherit from the parent). Set it
45163
- * explicitly to override that default per grant.
45164
- */
45165
- includeLinked: boolean().optional()
45166
- });
45167
- /**
45168
- * v2 → v3 lazy migration. A pre-v3 `device` grant carried
45169
- * `targets: string[]` (stringified deviceIds); it rewrites to the equivalent
45170
- * `selector: {kind:'ids', ids}`. Applied as a `preprocess` so it runs on
45171
- * EVERY parse path — stored records AND the JWT-carried scope arrays
45172
- * normalised at the request boundary ({@link normalizeTokenScopes} in
45173
- * `device-selector.ts`). Chosen over a one-time DB migration because a
45174
- * migration cannot reach a JWT already in a client's hands; parse-time
45175
- * migration covers both without a flag day. No cast — the raw object is read
45176
- * through `Reflect.get` (its static type is `unknown`).
45177
- */
45178
- function migrateLegacyTokenScope(raw) {
45179
- if (raw === null || typeof raw !== "object" || Array.isArray(raw)) return raw;
45180
- if (Reflect.get(raw, "type") !== "device") return raw;
45181
- if (Reflect.get(raw, "selector") !== void 0) return raw;
45182
- const targets = Reflect.get(raw, "targets");
45183
- if (!Array.isArray(targets)) return raw;
45184
- return {
45185
- type: "device",
45186
- selector: {
45187
- kind: "ids",
45188
- ids: targets.map((t) => typeof t === "string" ? Number(t) : t).filter((n) => typeof n === "number" && Number.isInteger(n))
45189
- },
45190
- access: Reflect.get(raw, "access")
45191
- };
45192
- }
45193
- var TokenScopeSchema = preprocess(migrateLegacyTokenScope, discriminatedUnion("type", [
45194
- object({
45195
- type: literal("category"),
45196
- target: CapScopeSchema,
45197
- access: array(MethodAccessSchema).min(1)
45198
- }),
45199
- object({
45200
- type: literal("capability"),
45201
- target: string(),
45202
- access: array(MethodAccessSchema).min(1)
45203
- }),
45204
- object({
45205
- type: literal("addon"),
45206
- target: string(),
45207
- access: array(MethodAccessSchema).min(1)
45208
- }),
45209
- DeviceTokenScopeSchema
45210
- ]));
45211
- object({
45212
- id: string(),
45213
- username: string(),
45214
- passwordHash: string(),
45215
- /**
45216
- * Admin bypass. When true, the middleware skips the scope-access
45217
- * check entirely. There is no other axis of privilege; the legacy
45218
- * role enum collapsed onto this boolean in v2.
45219
- */
45220
- isAdmin: boolean().default(false),
45221
- allowedProviders: AllowedProviderSchema,
45222
- allowedDevices: AllowedDevicesSchema,
45223
- /**
45224
- * Scopes granted to this user. Admins bypass; their `scopes` is
45225
- * ignored. Non-admins without scopes are locked out of every
45226
- * protected call.
45227
- */
45228
- scopes: array(TokenScopeSchema).default([]),
45229
- createdAt: number(),
45230
- updatedAt: number()
45231
- });
45232
- object({
45233
- id: string(),
45234
- label: string(),
45235
- isAdmin: boolean().default(false),
45236
- allowedProviders: AllowedProviderSchema,
45237
- allowedDevices: AllowedDevicesSchema,
45238
- tokenHash: string(),
45239
- tokenPrefix: string(),
45240
- createdAt: number(),
45241
- lastUsedAt: number().optional()
45242
- });
45243
- object({
45244
- id: string(),
45245
- userId: string(),
45246
- name: string(),
45247
- tokenHash: string(),
45248
- tokenPrefix: string(),
45249
- scopes: array(TokenScopeSchema),
45250
- expiresAt: number().nullish(),
45251
- lastUsedAt: number().nullish(),
45252
- createdAt: number()
45253
- });
45254
- /**
45255
45288
  * `oauth-integration` — a collection cap by which an addon declares
45256
45289
  * itself a linkable OAuth client of the hub's core `/oauth2/*` server.
45257
45290
  * 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-petkit",
3
- "version": "0.2.129",
3
+ "version": "0.2.130",
4
4
  "description": "PetKit smart-feeder device-provider addon for CamStack — wraps the @apocaliss92/nodepetkit PetKit cloud client",
5
5
  "keywords": [
6
6
  "camstack",