@camstack/addon-provider-rademacher 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
@@ -8781,6 +8781,12 @@ function normalizeAddonInitResult(result) {
8781
8781
  if (Array.isArray(result)) return { providers: result };
8782
8782
  return result;
8783
8783
  }
8784
+ /**
8785
+ * The share-view scope kinds a `csv_*` share token can carry. The hub mints
8786
+ * and validates them (`share-token.service.ts` builds its enum from this
8787
+ * list); a data plane names the kinds it ACCEPTS in `share`.
8788
+ */
8789
+ var SHARE_VIEW_KINDS = ["grid-view", "events-view"];
8784
8790
  /** The wire shape of {@link PeerBytesTicket} — see the type for what it is. */
8785
8791
  var PeerBytesTicketSchema = object({
8786
8792
  /** `http://127.0.0.1:<port>/<token>`. One `GET` takes it. */
@@ -13446,6 +13452,229 @@ var ConvertResultSchema = object({
13446
13452
  files: array(string()).readonly()
13447
13453
  })).readonly()
13448
13454
  });
13455
+ /**
13456
+ * Zod schemas for persisted record types.
13457
+ *
13458
+ * These schemas serve as the single source of truth for types that are
13459
+ * stored in the settings-store backend and retrieved via tRPC. They
13460
+ * replace the manual TypeScript interfaces with schema-derived types,
13461
+ * enabling runtime validation when reading from the backend.
13462
+ *
13463
+ * Convention: each schema is named `<Type>Schema`, the inferred TS type
13464
+ * keeps the original name for backward compatibility.
13465
+ */
13466
+ /**
13467
+ * Auth model (v2 — 2026-05-12 caps-only):
13468
+ *
13469
+ * Two principals:
13470
+ * - `isAdmin: true` — full bypass. Admin scope set is ignored.
13471
+ * - `isAdmin: false` — every call gated by `scopes` (see TokenScope).
13472
+ *
13473
+ * No role enum. There used to be `viewer / agent / scoped` and earlier
13474
+ * `super_admin` — collapsed onto the single boolean because every
13475
+ * non-admin caller is governed by the same scope-check rules; the
13476
+ * distinction was only ever used to route role-specific procedures
13477
+ * which we no longer have. CLI / webhook integrations are `cst_*` tokens
13478
+ * with `isAdmin: false` + an explicit scope list.
13479
+ */
13480
+ /** Per-method access flavour. Materialised on every cap method via codegen. */
13481
+ var MethodAccessSchema = _enum([
13482
+ "view",
13483
+ "create",
13484
+ "delete"
13485
+ ]);
13486
+ /**
13487
+ * A single scope grant. Three forms — checked in matcher with OR
13488
+ * semantics; the first match decides whether the call passes:
13489
+ *
13490
+ * - `category` — broadest. `target: 'device' | 'system'` selects every
13491
+ * cap with the matching `scope` declaration. New caps inherit grants
13492
+ * automatically — adding a device cap to the codebase makes it
13493
+ * reachable to every user with `category:device [...]` without a
13494
+ * re-grant. Use this for "family viewer" / "operator" tiers.
13495
+ *
13496
+ * - `addon` — every cap that ships inside a given addon id. Niche;
13497
+ * useful when an integration needs to interact with one specific
13498
+ * addon's surface regardless of how many caps it exports.
13499
+ *
13500
+ * - `capability` — the most precise form. Single cap name. Use for
13501
+ * integration tokens where you want to grant `addons.installPackage`
13502
+ * and nothing else.
13503
+ *
13504
+ * `access` is REQUIRED with min 1 element. `admin` bypass is the
13505
+ * "give me everything" escape; there is no wildcard scope.
13506
+ */
13507
+ var AllowedProviderSchema = union([literal("*"), array(string())]);
13508
+ var AllowedDevicesSchema = record(string(), union([literal("*"), array(string())]));
13509
+ var CapScopeSchema = _enum(["device", "system"]);
13510
+ /**
13511
+ * DeviceSelector (scope model v3 — 2026-08-12).
13512
+ *
13513
+ * A `device` grant no longer carries a frozen list of deviceIds. It carries
13514
+ * a SELECTOR the matcher resolves against the live fleet, so the grant can be
13515
+ * DYNAMIC: a `types:['camera']` selector automatically covers a camera added
13516
+ * AFTER the grant was minted — no re-grant, no re-login.
13517
+ *
13518
+ * - `all` — every device in the deployment. The broad viewer/operator
13519
+ * lever without a `category` grant (a `category` grant also covers device
13520
+ * caps that carry no deviceId; `all` is specifically the device set).
13521
+ * - `ids` — an explicit deviceId list. This is what a v2 `device:[…]`
13522
+ * grant migrates to (see {@link TokenScopeSchema}); STATIC — a new camera
13523
+ * is NOT covered until the grant is edited.
13524
+ * - `types` — every device of a `DeviceType` (e.g. every `camera`).
13525
+ * DYNAMIC. A device that changes type, or a new device of the type,
13526
+ * re-resolves on the next request.
13527
+ * - `locations` — every device whose operator-assigned `location` label is
13528
+ * in the set (e.g. "Garden", "Front door"). DYNAMIC. A device with a
13529
+ * null/unset location matches NO `locations` selector.
13530
+ */
13531
+ var DeviceSelectorSchema = discriminatedUnion("kind", [
13532
+ object({ kind: literal("all") }),
13533
+ object({
13534
+ kind: literal("ids"),
13535
+ ids: array(number().int()).min(1)
13536
+ }),
13537
+ object({
13538
+ kind: literal("types"),
13539
+ types: array(_enum(DeviceType)).min(1)
13540
+ }),
13541
+ object({
13542
+ kind: literal("locations"),
13543
+ locations: array(string().min(1)).min(1)
13544
+ })
13545
+ ]);
13546
+ var DeviceTokenScopeSchema = object({
13547
+ type: literal("device"),
13548
+ /** The device SET this grant covers — resolved against the live fleet. */
13549
+ selector: DeviceSelectorSchema,
13550
+ access: array(MethodAccessSchema).min(1),
13551
+ /**
13552
+ * Whether a grant on a PARENT device transparently covers its accessory
13553
+ * CHILDREN (siren / floodlight / PIR) via the persisted-parentage walk.
13554
+ * Direction is parent → children ONLY.
13555
+ *
13556
+ * Absent → the matcher DERIVES it from the access flavour: `view`
13557
+ * inherits (a camera viewer sees the camera's accessories), `create` /
13558
+ * `delete` do NOT (actuating/removing a child is an explicit act the
13559
+ * operator must grant on the child, not inherit from the parent). Set it
13560
+ * explicitly to override that default per grant.
13561
+ */
13562
+ includeLinked: boolean().optional()
13563
+ });
13564
+ /**
13565
+ * v2 → v3 lazy migration. A pre-v3 `device` grant carried
13566
+ * `targets: string[]` (stringified deviceIds); it rewrites to the equivalent
13567
+ * `selector: {kind:'ids', ids}`. Applied as a `preprocess` so it runs on
13568
+ * EVERY parse path — stored records AND the JWT-carried scope arrays
13569
+ * normalised at the request boundary ({@link normalizeTokenScopes} in
13570
+ * `device-selector.ts`). Chosen over a one-time DB migration because a
13571
+ * migration cannot reach a JWT already in a client's hands; parse-time
13572
+ * migration covers both without a flag day. No cast — the raw object is read
13573
+ * through `Reflect.get` (its static type is `unknown`).
13574
+ */
13575
+ function migrateLegacyTokenScope(raw) {
13576
+ if (raw === null || typeof raw !== "object" || Array.isArray(raw)) return raw;
13577
+ if (Reflect.get(raw, "type") !== "device") return raw;
13578
+ if (Reflect.get(raw, "selector") !== void 0) return raw;
13579
+ const targets = Reflect.get(raw, "targets");
13580
+ if (!Array.isArray(targets)) return raw;
13581
+ return {
13582
+ type: "device",
13583
+ selector: {
13584
+ kind: "ids",
13585
+ ids: targets.map((t) => typeof t === "string" ? Number(t) : t).filter((n) => typeof n === "number" && Number.isInteger(n))
13586
+ },
13587
+ access: Reflect.get(raw, "access")
13588
+ };
13589
+ }
13590
+ var TokenScopeSchema = preprocess(migrateLegacyTokenScope, discriminatedUnion("type", [
13591
+ object({
13592
+ type: literal("category"),
13593
+ target: CapScopeSchema,
13594
+ access: array(MethodAccessSchema).min(1)
13595
+ }),
13596
+ object({
13597
+ type: literal("capability"),
13598
+ target: string(),
13599
+ access: array(MethodAccessSchema).min(1)
13600
+ }),
13601
+ object({
13602
+ type: literal("addon"),
13603
+ target: string(),
13604
+ access: array(MethodAccessSchema).min(1)
13605
+ }),
13606
+ DeviceTokenScopeSchema
13607
+ ]));
13608
+ object({
13609
+ id: string(),
13610
+ username: string(),
13611
+ passwordHash: string(),
13612
+ /**
13613
+ * Admin bypass. When true, the middleware skips the scope-access
13614
+ * check entirely. There is no other axis of privilege; the legacy
13615
+ * role enum collapsed onto this boolean in v2.
13616
+ */
13617
+ isAdmin: boolean().default(false),
13618
+ allowedProviders: AllowedProviderSchema,
13619
+ allowedDevices: AllowedDevicesSchema,
13620
+ /**
13621
+ * Scopes granted to this user. Admins bypass; their `scopes` is
13622
+ * ignored. Non-admins without scopes are locked out of every
13623
+ * protected call.
13624
+ */
13625
+ scopes: array(TokenScopeSchema).default([]),
13626
+ createdAt: number(),
13627
+ updatedAt: number()
13628
+ });
13629
+ object({
13630
+ id: string(),
13631
+ label: string(),
13632
+ isAdmin: boolean().default(false),
13633
+ allowedProviders: AllowedProviderSchema,
13634
+ allowedDevices: AllowedDevicesSchema,
13635
+ tokenHash: string(),
13636
+ tokenPrefix: string(),
13637
+ createdAt: number(),
13638
+ lastUsedAt: number().optional()
13639
+ });
13640
+ object({
13641
+ id: string(),
13642
+ userId: string(),
13643
+ name: string(),
13644
+ tokenHash: string(),
13645
+ tokenPrefix: string(),
13646
+ scopes: array(TokenScopeSchema),
13647
+ expiresAt: number().nullish(),
13648
+ lastUsedAt: number().nullish(),
13649
+ createdAt: number()
13650
+ });
13651
+ /** What a share-view grant lets its holder see. */
13652
+ var ShareViewGrantSchema = object({
13653
+ kind: _enum(SHARE_VIEW_KINDS),
13654
+ deviceIds: array(number().int().nonnegative()).min(1).max(64),
13655
+ /** Talk-back, opt-in at mint time; absent means off. */
13656
+ talk: boolean().optional()
13657
+ });
13658
+ var ShareViewScopeSchema = object({
13659
+ type: literal("share-view"),
13660
+ grant: ShareViewGrantSchema
13661
+ });
13662
+ var AddonRoutesScopeSchema = object({
13663
+ type: literal("addon-routes"),
13664
+ access: array(MethodAccessSchema).min(1)
13665
+ });
13666
+ var CredentialScopeSchema = union([
13667
+ literal("*"),
13668
+ ShareViewScopeSchema,
13669
+ AddonRoutesScopeSchema,
13670
+ TokenScopeSchema
13671
+ ]);
13672
+ object({
13673
+ kind: literal("credential"),
13674
+ sub: string().min(1),
13675
+ jti: string().min(16),
13676
+ scopes: array(CredentialScopeSchema).min(1)
13677
+ });
13449
13678
  _enum(["new-session", "step-up"]);
13450
13679
  /** The languages the hub's app landing pages are written in (D858). */
13451
13680
  var AppPageLangSchema = _enum(["en", "it"]);
@@ -45036,202 +45265,6 @@ method(object({}), object({ rules: array(NcRuleSchema) }), { auth: "admin" }), m
45036
45265
  auth: "admin"
45037
45266
  }), method(NcAlarmSensorsInputSchema, NcAlarmSensorsSchema, { auth: "admin" });
45038
45267
  /**
45039
- * Zod schemas for persisted record types.
45040
- *
45041
- * These schemas serve as the single source of truth for types that are
45042
- * stored in the settings-store backend and retrieved via tRPC. They
45043
- * replace the manual TypeScript interfaces with schema-derived types,
45044
- * enabling runtime validation when reading from the backend.
45045
- *
45046
- * Convention: each schema is named `<Type>Schema`, the inferred TS type
45047
- * keeps the original name for backward compatibility.
45048
- */
45049
- /**
45050
- * Auth model (v2 — 2026-05-12 caps-only):
45051
- *
45052
- * Two principals:
45053
- * - `isAdmin: true` — full bypass. Admin scope set is ignored.
45054
- * - `isAdmin: false` — every call gated by `scopes` (see TokenScope).
45055
- *
45056
- * No role enum. There used to be `viewer / agent / scoped` and earlier
45057
- * `super_admin` — collapsed onto the single boolean because every
45058
- * non-admin caller is governed by the same scope-check rules; the
45059
- * distinction was only ever used to route role-specific procedures
45060
- * which we no longer have. CLI / webhook integrations are `cst_*` tokens
45061
- * with `isAdmin: false` + an explicit scope list.
45062
- */
45063
- /** Per-method access flavour. Materialised on every cap method via codegen. */
45064
- var MethodAccessSchema = _enum([
45065
- "view",
45066
- "create",
45067
- "delete"
45068
- ]);
45069
- /**
45070
- * A single scope grant. Three forms — checked in matcher with OR
45071
- * semantics; the first match decides whether the call passes:
45072
- *
45073
- * - `category` — broadest. `target: 'device' | 'system'` selects every
45074
- * cap with the matching `scope` declaration. New caps inherit grants
45075
- * automatically — adding a device cap to the codebase makes it
45076
- * reachable to every user with `category:device [...]` without a
45077
- * re-grant. Use this for "family viewer" / "operator" tiers.
45078
- *
45079
- * - `addon` — every cap that ships inside a given addon id. Niche;
45080
- * useful when an integration needs to interact with one specific
45081
- * addon's surface regardless of how many caps it exports.
45082
- *
45083
- * - `capability` — the most precise form. Single cap name. Use for
45084
- * integration tokens where you want to grant `addons.installPackage`
45085
- * and nothing else.
45086
- *
45087
- * `access` is REQUIRED with min 1 element. `admin` bypass is the
45088
- * "give me everything" escape; there is no wildcard scope.
45089
- */
45090
- var AllowedProviderSchema = union([literal("*"), array(string())]);
45091
- var AllowedDevicesSchema = record(string(), union([literal("*"), array(string())]));
45092
- var CapScopeSchema = _enum(["device", "system"]);
45093
- /**
45094
- * DeviceSelector (scope model v3 — 2026-08-12).
45095
- *
45096
- * A `device` grant no longer carries a frozen list of deviceIds. It carries
45097
- * a SELECTOR the matcher resolves against the live fleet, so the grant can be
45098
- * DYNAMIC: a `types:['camera']` selector automatically covers a camera added
45099
- * AFTER the grant was minted — no re-grant, no re-login.
45100
- *
45101
- * - `all` — every device in the deployment. The broad viewer/operator
45102
- * lever without a `category` grant (a `category` grant also covers device
45103
- * caps that carry no deviceId; `all` is specifically the device set).
45104
- * - `ids` — an explicit deviceId list. This is what a v2 `device:[…]`
45105
- * grant migrates to (see {@link TokenScopeSchema}); STATIC — a new camera
45106
- * is NOT covered until the grant is edited.
45107
- * - `types` — every device of a `DeviceType` (e.g. every `camera`).
45108
- * DYNAMIC. A device that changes type, or a new device of the type,
45109
- * re-resolves on the next request.
45110
- * - `locations` — every device whose operator-assigned `location` label is
45111
- * in the set (e.g. "Garden", "Front door"). DYNAMIC. A device with a
45112
- * null/unset location matches NO `locations` selector.
45113
- */
45114
- var DeviceSelectorSchema = discriminatedUnion("kind", [
45115
- object({ kind: literal("all") }),
45116
- object({
45117
- kind: literal("ids"),
45118
- ids: array(number().int()).min(1)
45119
- }),
45120
- object({
45121
- kind: literal("types"),
45122
- types: array(_enum(DeviceType)).min(1)
45123
- }),
45124
- object({
45125
- kind: literal("locations"),
45126
- locations: array(string().min(1)).min(1)
45127
- })
45128
- ]);
45129
- var DeviceTokenScopeSchema = object({
45130
- type: literal("device"),
45131
- /** The device SET this grant covers — resolved against the live fleet. */
45132
- selector: DeviceSelectorSchema,
45133
- access: array(MethodAccessSchema).min(1),
45134
- /**
45135
- * Whether a grant on a PARENT device transparently covers its accessory
45136
- * CHILDREN (siren / floodlight / PIR) via the persisted-parentage walk.
45137
- * Direction is parent → children ONLY.
45138
- *
45139
- * Absent → the matcher DERIVES it from the access flavour: `view`
45140
- * inherits (a camera viewer sees the camera's accessories), `create` /
45141
- * `delete` do NOT (actuating/removing a child is an explicit act the
45142
- * operator must grant on the child, not inherit from the parent). Set it
45143
- * explicitly to override that default per grant.
45144
- */
45145
- includeLinked: boolean().optional()
45146
- });
45147
- /**
45148
- * v2 → v3 lazy migration. A pre-v3 `device` grant carried
45149
- * `targets: string[]` (stringified deviceIds); it rewrites to the equivalent
45150
- * `selector: {kind:'ids', ids}`. Applied as a `preprocess` so it runs on
45151
- * EVERY parse path — stored records AND the JWT-carried scope arrays
45152
- * normalised at the request boundary ({@link normalizeTokenScopes} in
45153
- * `device-selector.ts`). Chosen over a one-time DB migration because a
45154
- * migration cannot reach a JWT already in a client's hands; parse-time
45155
- * migration covers both without a flag day. No cast — the raw object is read
45156
- * through `Reflect.get` (its static type is `unknown`).
45157
- */
45158
- function migrateLegacyTokenScope(raw) {
45159
- if (raw === null || typeof raw !== "object" || Array.isArray(raw)) return raw;
45160
- if (Reflect.get(raw, "type") !== "device") return raw;
45161
- if (Reflect.get(raw, "selector") !== void 0) return raw;
45162
- const targets = Reflect.get(raw, "targets");
45163
- if (!Array.isArray(targets)) return raw;
45164
- return {
45165
- type: "device",
45166
- selector: {
45167
- kind: "ids",
45168
- ids: targets.map((t) => typeof t === "string" ? Number(t) : t).filter((n) => typeof n === "number" && Number.isInteger(n))
45169
- },
45170
- access: Reflect.get(raw, "access")
45171
- };
45172
- }
45173
- var TokenScopeSchema = preprocess(migrateLegacyTokenScope, discriminatedUnion("type", [
45174
- object({
45175
- type: literal("category"),
45176
- target: CapScopeSchema,
45177
- access: array(MethodAccessSchema).min(1)
45178
- }),
45179
- object({
45180
- type: literal("capability"),
45181
- target: string(),
45182
- access: array(MethodAccessSchema).min(1)
45183
- }),
45184
- object({
45185
- type: literal("addon"),
45186
- target: string(),
45187
- access: array(MethodAccessSchema).min(1)
45188
- }),
45189
- DeviceTokenScopeSchema
45190
- ]));
45191
- object({
45192
- id: string(),
45193
- username: string(),
45194
- passwordHash: string(),
45195
- /**
45196
- * Admin bypass. When true, the middleware skips the scope-access
45197
- * check entirely. There is no other axis of privilege; the legacy
45198
- * role enum collapsed onto this boolean in v2.
45199
- */
45200
- isAdmin: boolean().default(false),
45201
- allowedProviders: AllowedProviderSchema,
45202
- allowedDevices: AllowedDevicesSchema,
45203
- /**
45204
- * Scopes granted to this user. Admins bypass; their `scopes` is
45205
- * ignored. Non-admins without scopes are locked out of every
45206
- * protected call.
45207
- */
45208
- scopes: array(TokenScopeSchema).default([]),
45209
- createdAt: number(),
45210
- updatedAt: number()
45211
- });
45212
- object({
45213
- id: string(),
45214
- label: string(),
45215
- isAdmin: boolean().default(false),
45216
- allowedProviders: AllowedProviderSchema,
45217
- allowedDevices: AllowedDevicesSchema,
45218
- tokenHash: string(),
45219
- tokenPrefix: string(),
45220
- createdAt: number(),
45221
- lastUsedAt: number().optional()
45222
- });
45223
- object({
45224
- id: string(),
45225
- userId: string(),
45226
- name: string(),
45227
- tokenHash: string(),
45228
- tokenPrefix: string(),
45229
- scopes: array(TokenScopeSchema),
45230
- expiresAt: number().nullish(),
45231
- lastUsedAt: number().nullish(),
45232
- createdAt: number()
45233
- });
45234
- /**
45235
45268
  * `oauth-integration` — a collection cap by which an addon declares
45236
45269
  * itself a linkable OAuth client of the hub's core `/oauth2/*` server.
45237
45270
  * Each provider returns a static descriptor; the core enumerates them
package/dist/addon.mjs CHANGED
@@ -8780,6 +8780,12 @@ function normalizeAddonInitResult(result) {
8780
8780
  if (Array.isArray(result)) return { providers: result };
8781
8781
  return result;
8782
8782
  }
8783
+ /**
8784
+ * The share-view scope kinds a `csv_*` share token can carry. The hub mints
8785
+ * and validates them (`share-token.service.ts` builds its enum from this
8786
+ * list); a data plane names the kinds it ACCEPTS in `share`.
8787
+ */
8788
+ var SHARE_VIEW_KINDS = ["grid-view", "events-view"];
8783
8789
  /** The wire shape of {@link PeerBytesTicket} — see the type for what it is. */
8784
8790
  var PeerBytesTicketSchema = object({
8785
8791
  /** `http://127.0.0.1:<port>/<token>`. One `GET` takes it. */
@@ -13445,6 +13451,229 @@ var ConvertResultSchema = object({
13445
13451
  files: array(string()).readonly()
13446
13452
  })).readonly()
13447
13453
  });
13454
+ /**
13455
+ * Zod schemas for persisted record types.
13456
+ *
13457
+ * These schemas serve as the single source of truth for types that are
13458
+ * stored in the settings-store backend and retrieved via tRPC. They
13459
+ * replace the manual TypeScript interfaces with schema-derived types,
13460
+ * enabling runtime validation when reading from the backend.
13461
+ *
13462
+ * Convention: each schema is named `<Type>Schema`, the inferred TS type
13463
+ * keeps the original name for backward compatibility.
13464
+ */
13465
+ /**
13466
+ * Auth model (v2 — 2026-05-12 caps-only):
13467
+ *
13468
+ * Two principals:
13469
+ * - `isAdmin: true` — full bypass. Admin scope set is ignored.
13470
+ * - `isAdmin: false` — every call gated by `scopes` (see TokenScope).
13471
+ *
13472
+ * No role enum. There used to be `viewer / agent / scoped` and earlier
13473
+ * `super_admin` — collapsed onto the single boolean because every
13474
+ * non-admin caller is governed by the same scope-check rules; the
13475
+ * distinction was only ever used to route role-specific procedures
13476
+ * which we no longer have. CLI / webhook integrations are `cst_*` tokens
13477
+ * with `isAdmin: false` + an explicit scope list.
13478
+ */
13479
+ /** Per-method access flavour. Materialised on every cap method via codegen. */
13480
+ var MethodAccessSchema = _enum([
13481
+ "view",
13482
+ "create",
13483
+ "delete"
13484
+ ]);
13485
+ /**
13486
+ * A single scope grant. Three forms — checked in matcher with OR
13487
+ * semantics; the first match decides whether the call passes:
13488
+ *
13489
+ * - `category` — broadest. `target: 'device' | 'system'` selects every
13490
+ * cap with the matching `scope` declaration. New caps inherit grants
13491
+ * automatically — adding a device cap to the codebase makes it
13492
+ * reachable to every user with `category:device [...]` without a
13493
+ * re-grant. Use this for "family viewer" / "operator" tiers.
13494
+ *
13495
+ * - `addon` — every cap that ships inside a given addon id. Niche;
13496
+ * useful when an integration needs to interact with one specific
13497
+ * addon's surface regardless of how many caps it exports.
13498
+ *
13499
+ * - `capability` — the most precise form. Single cap name. Use for
13500
+ * integration tokens where you want to grant `addons.installPackage`
13501
+ * and nothing else.
13502
+ *
13503
+ * `access` is REQUIRED with min 1 element. `admin` bypass is the
13504
+ * "give me everything" escape; there is no wildcard scope.
13505
+ */
13506
+ var AllowedProviderSchema = union([literal("*"), array(string())]);
13507
+ var AllowedDevicesSchema = record(string(), union([literal("*"), array(string())]));
13508
+ var CapScopeSchema = _enum(["device", "system"]);
13509
+ /**
13510
+ * DeviceSelector (scope model v3 — 2026-08-12).
13511
+ *
13512
+ * A `device` grant no longer carries a frozen list of deviceIds. It carries
13513
+ * a SELECTOR the matcher resolves against the live fleet, so the grant can be
13514
+ * DYNAMIC: a `types:['camera']` selector automatically covers a camera added
13515
+ * AFTER the grant was minted — no re-grant, no re-login.
13516
+ *
13517
+ * - `all` — every device in the deployment. The broad viewer/operator
13518
+ * lever without a `category` grant (a `category` grant also covers device
13519
+ * caps that carry no deviceId; `all` is specifically the device set).
13520
+ * - `ids` — an explicit deviceId list. This is what a v2 `device:[…]`
13521
+ * grant migrates to (see {@link TokenScopeSchema}); STATIC — a new camera
13522
+ * is NOT covered until the grant is edited.
13523
+ * - `types` — every device of a `DeviceType` (e.g. every `camera`).
13524
+ * DYNAMIC. A device that changes type, or a new device of the type,
13525
+ * re-resolves on the next request.
13526
+ * - `locations` — every device whose operator-assigned `location` label is
13527
+ * in the set (e.g. "Garden", "Front door"). DYNAMIC. A device with a
13528
+ * null/unset location matches NO `locations` selector.
13529
+ */
13530
+ var DeviceSelectorSchema = discriminatedUnion("kind", [
13531
+ object({ kind: literal("all") }),
13532
+ object({
13533
+ kind: literal("ids"),
13534
+ ids: array(number().int()).min(1)
13535
+ }),
13536
+ object({
13537
+ kind: literal("types"),
13538
+ types: array(_enum(DeviceType)).min(1)
13539
+ }),
13540
+ object({
13541
+ kind: literal("locations"),
13542
+ locations: array(string().min(1)).min(1)
13543
+ })
13544
+ ]);
13545
+ var DeviceTokenScopeSchema = object({
13546
+ type: literal("device"),
13547
+ /** The device SET this grant covers — resolved against the live fleet. */
13548
+ selector: DeviceSelectorSchema,
13549
+ access: array(MethodAccessSchema).min(1),
13550
+ /**
13551
+ * Whether a grant on a PARENT device transparently covers its accessory
13552
+ * CHILDREN (siren / floodlight / PIR) via the persisted-parentage walk.
13553
+ * Direction is parent → children ONLY.
13554
+ *
13555
+ * Absent → the matcher DERIVES it from the access flavour: `view`
13556
+ * inherits (a camera viewer sees the camera's accessories), `create` /
13557
+ * `delete` do NOT (actuating/removing a child is an explicit act the
13558
+ * operator must grant on the child, not inherit from the parent). Set it
13559
+ * explicitly to override that default per grant.
13560
+ */
13561
+ includeLinked: boolean().optional()
13562
+ });
13563
+ /**
13564
+ * v2 → v3 lazy migration. A pre-v3 `device` grant carried
13565
+ * `targets: string[]` (stringified deviceIds); it rewrites to the equivalent
13566
+ * `selector: {kind:'ids', ids}`. Applied as a `preprocess` so it runs on
13567
+ * EVERY parse path — stored records AND the JWT-carried scope arrays
13568
+ * normalised at the request boundary ({@link normalizeTokenScopes} in
13569
+ * `device-selector.ts`). Chosen over a one-time DB migration because a
13570
+ * migration cannot reach a JWT already in a client's hands; parse-time
13571
+ * migration covers both without a flag day. No cast — the raw object is read
13572
+ * through `Reflect.get` (its static type is `unknown`).
13573
+ */
13574
+ function migrateLegacyTokenScope(raw) {
13575
+ if (raw === null || typeof raw !== "object" || Array.isArray(raw)) return raw;
13576
+ if (Reflect.get(raw, "type") !== "device") return raw;
13577
+ if (Reflect.get(raw, "selector") !== void 0) return raw;
13578
+ const targets = Reflect.get(raw, "targets");
13579
+ if (!Array.isArray(targets)) return raw;
13580
+ return {
13581
+ type: "device",
13582
+ selector: {
13583
+ kind: "ids",
13584
+ ids: targets.map((t) => typeof t === "string" ? Number(t) : t).filter((n) => typeof n === "number" && Number.isInteger(n))
13585
+ },
13586
+ access: Reflect.get(raw, "access")
13587
+ };
13588
+ }
13589
+ var TokenScopeSchema = preprocess(migrateLegacyTokenScope, discriminatedUnion("type", [
13590
+ object({
13591
+ type: literal("category"),
13592
+ target: CapScopeSchema,
13593
+ access: array(MethodAccessSchema).min(1)
13594
+ }),
13595
+ object({
13596
+ type: literal("capability"),
13597
+ target: string(),
13598
+ access: array(MethodAccessSchema).min(1)
13599
+ }),
13600
+ object({
13601
+ type: literal("addon"),
13602
+ target: string(),
13603
+ access: array(MethodAccessSchema).min(1)
13604
+ }),
13605
+ DeviceTokenScopeSchema
13606
+ ]));
13607
+ object({
13608
+ id: string(),
13609
+ username: string(),
13610
+ passwordHash: string(),
13611
+ /**
13612
+ * Admin bypass. When true, the middleware skips the scope-access
13613
+ * check entirely. There is no other axis of privilege; the legacy
13614
+ * role enum collapsed onto this boolean in v2.
13615
+ */
13616
+ isAdmin: boolean().default(false),
13617
+ allowedProviders: AllowedProviderSchema,
13618
+ allowedDevices: AllowedDevicesSchema,
13619
+ /**
13620
+ * Scopes granted to this user. Admins bypass; their `scopes` is
13621
+ * ignored. Non-admins without scopes are locked out of every
13622
+ * protected call.
13623
+ */
13624
+ scopes: array(TokenScopeSchema).default([]),
13625
+ createdAt: number(),
13626
+ updatedAt: number()
13627
+ });
13628
+ object({
13629
+ id: string(),
13630
+ label: string(),
13631
+ isAdmin: boolean().default(false),
13632
+ allowedProviders: AllowedProviderSchema,
13633
+ allowedDevices: AllowedDevicesSchema,
13634
+ tokenHash: string(),
13635
+ tokenPrefix: string(),
13636
+ createdAt: number(),
13637
+ lastUsedAt: number().optional()
13638
+ });
13639
+ object({
13640
+ id: string(),
13641
+ userId: string(),
13642
+ name: string(),
13643
+ tokenHash: string(),
13644
+ tokenPrefix: string(),
13645
+ scopes: array(TokenScopeSchema),
13646
+ expiresAt: number().nullish(),
13647
+ lastUsedAt: number().nullish(),
13648
+ createdAt: number()
13649
+ });
13650
+ /** What a share-view grant lets its holder see. */
13651
+ var ShareViewGrantSchema = object({
13652
+ kind: _enum(SHARE_VIEW_KINDS),
13653
+ deviceIds: array(number().int().nonnegative()).min(1).max(64),
13654
+ /** Talk-back, opt-in at mint time; absent means off. */
13655
+ talk: boolean().optional()
13656
+ });
13657
+ var ShareViewScopeSchema = object({
13658
+ type: literal("share-view"),
13659
+ grant: ShareViewGrantSchema
13660
+ });
13661
+ var AddonRoutesScopeSchema = object({
13662
+ type: literal("addon-routes"),
13663
+ access: array(MethodAccessSchema).min(1)
13664
+ });
13665
+ var CredentialScopeSchema = union([
13666
+ literal("*"),
13667
+ ShareViewScopeSchema,
13668
+ AddonRoutesScopeSchema,
13669
+ TokenScopeSchema
13670
+ ]);
13671
+ object({
13672
+ kind: literal("credential"),
13673
+ sub: string().min(1),
13674
+ jti: string().min(16),
13675
+ scopes: array(CredentialScopeSchema).min(1)
13676
+ });
13448
13677
  _enum(["new-session", "step-up"]);
13449
13678
  /** The languages the hub's app landing pages are written in (D858). */
13450
13679
  var AppPageLangSchema = _enum(["en", "it"]);
@@ -45035,202 +45264,6 @@ method(object({}), object({ rules: array(NcRuleSchema) }), { auth: "admin" }), m
45035
45264
  auth: "admin"
45036
45265
  }), method(NcAlarmSensorsInputSchema, NcAlarmSensorsSchema, { auth: "admin" });
45037
45266
  /**
45038
- * Zod schemas for persisted record types.
45039
- *
45040
- * These schemas serve as the single source of truth for types that are
45041
- * stored in the settings-store backend and retrieved via tRPC. They
45042
- * replace the manual TypeScript interfaces with schema-derived types,
45043
- * enabling runtime validation when reading from the backend.
45044
- *
45045
- * Convention: each schema is named `<Type>Schema`, the inferred TS type
45046
- * keeps the original name for backward compatibility.
45047
- */
45048
- /**
45049
- * Auth model (v2 — 2026-05-12 caps-only):
45050
- *
45051
- * Two principals:
45052
- * - `isAdmin: true` — full bypass. Admin scope set is ignored.
45053
- * - `isAdmin: false` — every call gated by `scopes` (see TokenScope).
45054
- *
45055
- * No role enum. There used to be `viewer / agent / scoped` and earlier
45056
- * `super_admin` — collapsed onto the single boolean because every
45057
- * non-admin caller is governed by the same scope-check rules; the
45058
- * distinction was only ever used to route role-specific procedures
45059
- * which we no longer have. CLI / webhook integrations are `cst_*` tokens
45060
- * with `isAdmin: false` + an explicit scope list.
45061
- */
45062
- /** Per-method access flavour. Materialised on every cap method via codegen. */
45063
- var MethodAccessSchema = _enum([
45064
- "view",
45065
- "create",
45066
- "delete"
45067
- ]);
45068
- /**
45069
- * A single scope grant. Three forms — checked in matcher with OR
45070
- * semantics; the first match decides whether the call passes:
45071
- *
45072
- * - `category` — broadest. `target: 'device' | 'system'` selects every
45073
- * cap with the matching `scope` declaration. New caps inherit grants
45074
- * automatically — adding a device cap to the codebase makes it
45075
- * reachable to every user with `category:device [...]` without a
45076
- * re-grant. Use this for "family viewer" / "operator" tiers.
45077
- *
45078
- * - `addon` — every cap that ships inside a given addon id. Niche;
45079
- * useful when an integration needs to interact with one specific
45080
- * addon's surface regardless of how many caps it exports.
45081
- *
45082
- * - `capability` — the most precise form. Single cap name. Use for
45083
- * integration tokens where you want to grant `addons.installPackage`
45084
- * and nothing else.
45085
- *
45086
- * `access` is REQUIRED with min 1 element. `admin` bypass is the
45087
- * "give me everything" escape; there is no wildcard scope.
45088
- */
45089
- var AllowedProviderSchema = union([literal("*"), array(string())]);
45090
- var AllowedDevicesSchema = record(string(), union([literal("*"), array(string())]));
45091
- var CapScopeSchema = _enum(["device", "system"]);
45092
- /**
45093
- * DeviceSelector (scope model v3 — 2026-08-12).
45094
- *
45095
- * A `device` grant no longer carries a frozen list of deviceIds. It carries
45096
- * a SELECTOR the matcher resolves against the live fleet, so the grant can be
45097
- * DYNAMIC: a `types:['camera']` selector automatically covers a camera added
45098
- * AFTER the grant was minted — no re-grant, no re-login.
45099
- *
45100
- * - `all` — every device in the deployment. The broad viewer/operator
45101
- * lever without a `category` grant (a `category` grant also covers device
45102
- * caps that carry no deviceId; `all` is specifically the device set).
45103
- * - `ids` — an explicit deviceId list. This is what a v2 `device:[…]`
45104
- * grant migrates to (see {@link TokenScopeSchema}); STATIC — a new camera
45105
- * is NOT covered until the grant is edited.
45106
- * - `types` — every device of a `DeviceType` (e.g. every `camera`).
45107
- * DYNAMIC. A device that changes type, or a new device of the type,
45108
- * re-resolves on the next request.
45109
- * - `locations` — every device whose operator-assigned `location` label is
45110
- * in the set (e.g. "Garden", "Front door"). DYNAMIC. A device with a
45111
- * null/unset location matches NO `locations` selector.
45112
- */
45113
- var DeviceSelectorSchema = discriminatedUnion("kind", [
45114
- object({ kind: literal("all") }),
45115
- object({
45116
- kind: literal("ids"),
45117
- ids: array(number().int()).min(1)
45118
- }),
45119
- object({
45120
- kind: literal("types"),
45121
- types: array(_enum(DeviceType)).min(1)
45122
- }),
45123
- object({
45124
- kind: literal("locations"),
45125
- locations: array(string().min(1)).min(1)
45126
- })
45127
- ]);
45128
- var DeviceTokenScopeSchema = object({
45129
- type: literal("device"),
45130
- /** The device SET this grant covers — resolved against the live fleet. */
45131
- selector: DeviceSelectorSchema,
45132
- access: array(MethodAccessSchema).min(1),
45133
- /**
45134
- * Whether a grant on a PARENT device transparently covers its accessory
45135
- * CHILDREN (siren / floodlight / PIR) via the persisted-parentage walk.
45136
- * Direction is parent → children ONLY.
45137
- *
45138
- * Absent → the matcher DERIVES it from the access flavour: `view`
45139
- * inherits (a camera viewer sees the camera's accessories), `create` /
45140
- * `delete` do NOT (actuating/removing a child is an explicit act the
45141
- * operator must grant on the child, not inherit from the parent). Set it
45142
- * explicitly to override that default per grant.
45143
- */
45144
- includeLinked: boolean().optional()
45145
- });
45146
- /**
45147
- * v2 → v3 lazy migration. A pre-v3 `device` grant carried
45148
- * `targets: string[]` (stringified deviceIds); it rewrites to the equivalent
45149
- * `selector: {kind:'ids', ids}`. Applied as a `preprocess` so it runs on
45150
- * EVERY parse path — stored records AND the JWT-carried scope arrays
45151
- * normalised at the request boundary ({@link normalizeTokenScopes} in
45152
- * `device-selector.ts`). Chosen over a one-time DB migration because a
45153
- * migration cannot reach a JWT already in a client's hands; parse-time
45154
- * migration covers both without a flag day. No cast — the raw object is read
45155
- * through `Reflect.get` (its static type is `unknown`).
45156
- */
45157
- function migrateLegacyTokenScope(raw) {
45158
- if (raw === null || typeof raw !== "object" || Array.isArray(raw)) return raw;
45159
- if (Reflect.get(raw, "type") !== "device") return raw;
45160
- if (Reflect.get(raw, "selector") !== void 0) return raw;
45161
- const targets = Reflect.get(raw, "targets");
45162
- if (!Array.isArray(targets)) return raw;
45163
- return {
45164
- type: "device",
45165
- selector: {
45166
- kind: "ids",
45167
- ids: targets.map((t) => typeof t === "string" ? Number(t) : t).filter((n) => typeof n === "number" && Number.isInteger(n))
45168
- },
45169
- access: Reflect.get(raw, "access")
45170
- };
45171
- }
45172
- var TokenScopeSchema = preprocess(migrateLegacyTokenScope, discriminatedUnion("type", [
45173
- object({
45174
- type: literal("category"),
45175
- target: CapScopeSchema,
45176
- access: array(MethodAccessSchema).min(1)
45177
- }),
45178
- object({
45179
- type: literal("capability"),
45180
- target: string(),
45181
- access: array(MethodAccessSchema).min(1)
45182
- }),
45183
- object({
45184
- type: literal("addon"),
45185
- target: string(),
45186
- access: array(MethodAccessSchema).min(1)
45187
- }),
45188
- DeviceTokenScopeSchema
45189
- ]));
45190
- object({
45191
- id: string(),
45192
- username: string(),
45193
- passwordHash: string(),
45194
- /**
45195
- * Admin bypass. When true, the middleware skips the scope-access
45196
- * check entirely. There is no other axis of privilege; the legacy
45197
- * role enum collapsed onto this boolean in v2.
45198
- */
45199
- isAdmin: boolean().default(false),
45200
- allowedProviders: AllowedProviderSchema,
45201
- allowedDevices: AllowedDevicesSchema,
45202
- /**
45203
- * Scopes granted to this user. Admins bypass; their `scopes` is
45204
- * ignored. Non-admins without scopes are locked out of every
45205
- * protected call.
45206
- */
45207
- scopes: array(TokenScopeSchema).default([]),
45208
- createdAt: number(),
45209
- updatedAt: number()
45210
- });
45211
- object({
45212
- id: string(),
45213
- label: string(),
45214
- isAdmin: boolean().default(false),
45215
- allowedProviders: AllowedProviderSchema,
45216
- allowedDevices: AllowedDevicesSchema,
45217
- tokenHash: string(),
45218
- tokenPrefix: string(),
45219
- createdAt: number(),
45220
- lastUsedAt: number().optional()
45221
- });
45222
- object({
45223
- id: string(),
45224
- userId: string(),
45225
- name: string(),
45226
- tokenHash: string(),
45227
- tokenPrefix: string(),
45228
- scopes: array(TokenScopeSchema),
45229
- expiresAt: number().nullish(),
45230
- lastUsedAt: number().nullish(),
45231
- createdAt: number()
45232
- });
45233
- /**
45234
45267
  * `oauth-integration` — a collection cap by which an addon declares
45235
45268
  * itself a linkable OAuth client of the hub's core `/oauth2/*` server.
45236
45269
  * 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-rademacher",
3
- "version": "0.2.129",
3
+ "version": "0.2.130",
4
4
  "description": "Rademacher HomePilot device-provider addon for CamStack — wraps the @apocaliss92/noderademacher local-hub client (roller shutters over the cover cap)",
5
5
  "keywords": [
6
6
  "camstack",