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