@camstack/addon-export-hap 1.2.161 → 1.2.162

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.
@@ -7846,6 +7846,12 @@ function normalizeAddonInitResult(result) {
7846
7846
  if (Array.isArray(result)) return { providers: result };
7847
7847
  return result;
7848
7848
  }
7849
+ /**
7850
+ * The share-view scope kinds a `csv_*` share token can carry. The hub mints
7851
+ * and validates them (`share-token.service.ts` builds its enum from this
7852
+ * list); a data plane names the kinds it ACCEPTS in `share`.
7853
+ */
7854
+ var SHARE_VIEW_KINDS = ["grid-view", "events-view"];
7849
7855
  /** The wire shape of {@link PeerBytesTicket} — see the type for what it is. */
7850
7856
  var PeerBytesTicketSchema = object({
7851
7857
  /** `http://127.0.0.1:<port>/<token>`. One `GET` takes it. */
@@ -13318,6 +13324,229 @@ var ConvertResultSchema = object({
13318
13324
  files: array(string()).readonly()
13319
13325
  })).readonly()
13320
13326
  });
13327
+ /**
13328
+ * Zod schemas for persisted record types.
13329
+ *
13330
+ * These schemas serve as the single source of truth for types that are
13331
+ * stored in the settings-store backend and retrieved via tRPC. They
13332
+ * replace the manual TypeScript interfaces with schema-derived types,
13333
+ * enabling runtime validation when reading from the backend.
13334
+ *
13335
+ * Convention: each schema is named `<Type>Schema`, the inferred TS type
13336
+ * keeps the original name for backward compatibility.
13337
+ */
13338
+ /**
13339
+ * Auth model (v2 — 2026-05-12 caps-only):
13340
+ *
13341
+ * Two principals:
13342
+ * - `isAdmin: true` — full bypass. Admin scope set is ignored.
13343
+ * - `isAdmin: false` — every call gated by `scopes` (see TokenScope).
13344
+ *
13345
+ * No role enum. There used to be `viewer / agent / scoped` and earlier
13346
+ * `super_admin` — collapsed onto the single boolean because every
13347
+ * non-admin caller is governed by the same scope-check rules; the
13348
+ * distinction was only ever used to route role-specific procedures
13349
+ * which we no longer have. CLI / webhook integrations are `cst_*` tokens
13350
+ * with `isAdmin: false` + an explicit scope list.
13351
+ */
13352
+ /** Per-method access flavour. Materialised on every cap method via codegen. */
13353
+ var MethodAccessSchema = _enum([
13354
+ "view",
13355
+ "create",
13356
+ "delete"
13357
+ ]);
13358
+ /**
13359
+ * A single scope grant. Three forms — checked in matcher with OR
13360
+ * semantics; the first match decides whether the call passes:
13361
+ *
13362
+ * - `category` — broadest. `target: 'device' | 'system'` selects every
13363
+ * cap with the matching `scope` declaration. New caps inherit grants
13364
+ * automatically — adding a device cap to the codebase makes it
13365
+ * reachable to every user with `category:device [...]` without a
13366
+ * re-grant. Use this for "family viewer" / "operator" tiers.
13367
+ *
13368
+ * - `addon` — every cap that ships inside a given addon id. Niche;
13369
+ * useful when an integration needs to interact with one specific
13370
+ * addon's surface regardless of how many caps it exports.
13371
+ *
13372
+ * - `capability` — the most precise form. Single cap name. Use for
13373
+ * integration tokens where you want to grant `addons.installPackage`
13374
+ * and nothing else.
13375
+ *
13376
+ * `access` is REQUIRED with min 1 element. `admin` bypass is the
13377
+ * "give me everything" escape; there is no wildcard scope.
13378
+ */
13379
+ var AllowedProviderSchema = union([literal("*"), array(string())]);
13380
+ var AllowedDevicesSchema = record(string(), union([literal("*"), array(string())]));
13381
+ var CapScopeSchema = _enum(["device", "system"]);
13382
+ /**
13383
+ * DeviceSelector (scope model v3 — 2026-08-12).
13384
+ *
13385
+ * A `device` grant no longer carries a frozen list of deviceIds. It carries
13386
+ * a SELECTOR the matcher resolves against the live fleet, so the grant can be
13387
+ * DYNAMIC: a `types:['camera']` selector automatically covers a camera added
13388
+ * AFTER the grant was minted — no re-grant, no re-login.
13389
+ *
13390
+ * - `all` — every device in the deployment. The broad viewer/operator
13391
+ * lever without a `category` grant (a `category` grant also covers device
13392
+ * caps that carry no deviceId; `all` is specifically the device set).
13393
+ * - `ids` — an explicit deviceId list. This is what a v2 `device:[…]`
13394
+ * grant migrates to (see {@link TokenScopeSchema}); STATIC — a new camera
13395
+ * is NOT covered until the grant is edited.
13396
+ * - `types` — every device of a `DeviceType` (e.g. every `camera`).
13397
+ * DYNAMIC. A device that changes type, or a new device of the type,
13398
+ * re-resolves on the next request.
13399
+ * - `locations` — every device whose operator-assigned `location` label is
13400
+ * in the set (e.g. "Garden", "Front door"). DYNAMIC. A device with a
13401
+ * null/unset location matches NO `locations` selector.
13402
+ */
13403
+ var DeviceSelectorSchema = discriminatedUnion("kind", [
13404
+ object({ kind: literal("all") }),
13405
+ object({
13406
+ kind: literal("ids"),
13407
+ ids: array(number().int()).min(1)
13408
+ }),
13409
+ object({
13410
+ kind: literal("types"),
13411
+ types: array(_enum(DeviceType)).min(1)
13412
+ }),
13413
+ object({
13414
+ kind: literal("locations"),
13415
+ locations: array(string().min(1)).min(1)
13416
+ })
13417
+ ]);
13418
+ var DeviceTokenScopeSchema = object({
13419
+ type: literal("device"),
13420
+ /** The device SET this grant covers — resolved against the live fleet. */
13421
+ selector: DeviceSelectorSchema,
13422
+ access: array(MethodAccessSchema).min(1),
13423
+ /**
13424
+ * Whether a grant on a PARENT device transparently covers its accessory
13425
+ * CHILDREN (siren / floodlight / PIR) via the persisted-parentage walk.
13426
+ * Direction is parent → children ONLY.
13427
+ *
13428
+ * Absent → the matcher DERIVES it from the access flavour: `view`
13429
+ * inherits (a camera viewer sees the camera's accessories), `create` /
13430
+ * `delete` do NOT (actuating/removing a child is an explicit act the
13431
+ * operator must grant on the child, not inherit from the parent). Set it
13432
+ * explicitly to override that default per grant.
13433
+ */
13434
+ includeLinked: boolean().optional()
13435
+ });
13436
+ /**
13437
+ * v2 → v3 lazy migration. A pre-v3 `device` grant carried
13438
+ * `targets: string[]` (stringified deviceIds); it rewrites to the equivalent
13439
+ * `selector: {kind:'ids', ids}`. Applied as a `preprocess` so it runs on
13440
+ * EVERY parse path — stored records AND the JWT-carried scope arrays
13441
+ * normalised at the request boundary ({@link normalizeTokenScopes} in
13442
+ * `device-selector.ts`). Chosen over a one-time DB migration because a
13443
+ * migration cannot reach a JWT already in a client's hands; parse-time
13444
+ * migration covers both without a flag day. No cast — the raw object is read
13445
+ * through `Reflect.get` (its static type is `unknown`).
13446
+ */
13447
+ function migrateLegacyTokenScope(raw) {
13448
+ if (raw === null || typeof raw !== "object" || Array.isArray(raw)) return raw;
13449
+ if (Reflect.get(raw, "type") !== "device") return raw;
13450
+ if (Reflect.get(raw, "selector") !== void 0) return raw;
13451
+ const targets = Reflect.get(raw, "targets");
13452
+ if (!Array.isArray(targets)) return raw;
13453
+ return {
13454
+ type: "device",
13455
+ selector: {
13456
+ kind: "ids",
13457
+ ids: targets.map((t) => typeof t === "string" ? Number(t) : t).filter((n) => typeof n === "number" && Number.isInteger(n))
13458
+ },
13459
+ access: Reflect.get(raw, "access")
13460
+ };
13461
+ }
13462
+ var TokenScopeSchema = preprocess(migrateLegacyTokenScope, discriminatedUnion("type", [
13463
+ object({
13464
+ type: literal("category"),
13465
+ target: CapScopeSchema,
13466
+ access: array(MethodAccessSchema).min(1)
13467
+ }),
13468
+ object({
13469
+ type: literal("capability"),
13470
+ target: string(),
13471
+ access: array(MethodAccessSchema).min(1)
13472
+ }),
13473
+ object({
13474
+ type: literal("addon"),
13475
+ target: string(),
13476
+ access: array(MethodAccessSchema).min(1)
13477
+ }),
13478
+ DeviceTokenScopeSchema
13479
+ ]));
13480
+ object({
13481
+ id: string(),
13482
+ username: string(),
13483
+ passwordHash: string(),
13484
+ /**
13485
+ * Admin bypass. When true, the middleware skips the scope-access
13486
+ * check entirely. There is no other axis of privilege; the legacy
13487
+ * role enum collapsed onto this boolean in v2.
13488
+ */
13489
+ isAdmin: boolean().default(false),
13490
+ allowedProviders: AllowedProviderSchema,
13491
+ allowedDevices: AllowedDevicesSchema,
13492
+ /**
13493
+ * Scopes granted to this user. Admins bypass; their `scopes` is
13494
+ * ignored. Non-admins without scopes are locked out of every
13495
+ * protected call.
13496
+ */
13497
+ scopes: array(TokenScopeSchema).default([]),
13498
+ createdAt: number(),
13499
+ updatedAt: number()
13500
+ });
13501
+ object({
13502
+ id: string(),
13503
+ label: string(),
13504
+ isAdmin: boolean().default(false),
13505
+ allowedProviders: AllowedProviderSchema,
13506
+ allowedDevices: AllowedDevicesSchema,
13507
+ tokenHash: string(),
13508
+ tokenPrefix: string(),
13509
+ createdAt: number(),
13510
+ lastUsedAt: number().optional()
13511
+ });
13512
+ object({
13513
+ id: string(),
13514
+ userId: string(),
13515
+ name: string(),
13516
+ tokenHash: string(),
13517
+ tokenPrefix: string(),
13518
+ scopes: array(TokenScopeSchema),
13519
+ expiresAt: number().nullish(),
13520
+ lastUsedAt: number().nullish(),
13521
+ createdAt: number()
13522
+ });
13523
+ /** What a share-view grant lets its holder see. */
13524
+ var ShareViewGrantSchema = object({
13525
+ kind: _enum(SHARE_VIEW_KINDS),
13526
+ deviceIds: array(number().int().nonnegative()).min(1).max(64),
13527
+ /** Talk-back, opt-in at mint time; absent means off. */
13528
+ talk: boolean().optional()
13529
+ });
13530
+ var ShareViewScopeSchema = object({
13531
+ type: literal("share-view"),
13532
+ grant: ShareViewGrantSchema
13533
+ });
13534
+ var AddonRoutesScopeSchema = object({
13535
+ type: literal("addon-routes"),
13536
+ access: array(MethodAccessSchema).min(1)
13537
+ });
13538
+ var CredentialScopeSchema = union([
13539
+ literal("*"),
13540
+ ShareViewScopeSchema,
13541
+ AddonRoutesScopeSchema,
13542
+ TokenScopeSchema
13543
+ ]);
13544
+ object({
13545
+ kind: literal("credential"),
13546
+ sub: string().min(1),
13547
+ jti: string().min(16),
13548
+ scopes: array(CredentialScopeSchema).min(1)
13549
+ });
13321
13550
  _enum(["new-session", "step-up"]);
13322
13551
  /** The languages the hub's app landing pages are written in (D858). */
13323
13552
  var AppPageLangSchema = _enum(["en", "it"]);
@@ -44536,202 +44765,6 @@ method(object({}), object({ rules: array(NcRuleSchema) }), { auth: "admin" }), m
44536
44765
  auth: "admin"
44537
44766
  }), method(NcAlarmSensorsInputSchema, NcAlarmSensorsSchema, { auth: "admin" });
44538
44767
  /**
44539
- * Zod schemas for persisted record types.
44540
- *
44541
- * These schemas serve as the single source of truth for types that are
44542
- * stored in the settings-store backend and retrieved via tRPC. They
44543
- * replace the manual TypeScript interfaces with schema-derived types,
44544
- * enabling runtime validation when reading from the backend.
44545
- *
44546
- * Convention: each schema is named `<Type>Schema`, the inferred TS type
44547
- * keeps the original name for backward compatibility.
44548
- */
44549
- /**
44550
- * Auth model (v2 — 2026-05-12 caps-only):
44551
- *
44552
- * Two principals:
44553
- * - `isAdmin: true` — full bypass. Admin scope set is ignored.
44554
- * - `isAdmin: false` — every call gated by `scopes` (see TokenScope).
44555
- *
44556
- * No role enum. There used to be `viewer / agent / scoped` and earlier
44557
- * `super_admin` — collapsed onto the single boolean because every
44558
- * non-admin caller is governed by the same scope-check rules; the
44559
- * distinction was only ever used to route role-specific procedures
44560
- * which we no longer have. CLI / webhook integrations are `cst_*` tokens
44561
- * with `isAdmin: false` + an explicit scope list.
44562
- */
44563
- /** Per-method access flavour. Materialised on every cap method via codegen. */
44564
- var MethodAccessSchema = _enum([
44565
- "view",
44566
- "create",
44567
- "delete"
44568
- ]);
44569
- /**
44570
- * A single scope grant. Three forms — checked in matcher with OR
44571
- * semantics; the first match decides whether the call passes:
44572
- *
44573
- * - `category` — broadest. `target: 'device' | 'system'` selects every
44574
- * cap with the matching `scope` declaration. New caps inherit grants
44575
- * automatically — adding a device cap to the codebase makes it
44576
- * reachable to every user with `category:device [...]` without a
44577
- * re-grant. Use this for "family viewer" / "operator" tiers.
44578
- *
44579
- * - `addon` — every cap that ships inside a given addon id. Niche;
44580
- * useful when an integration needs to interact with one specific
44581
- * addon's surface regardless of how many caps it exports.
44582
- *
44583
- * - `capability` — the most precise form. Single cap name. Use for
44584
- * integration tokens where you want to grant `addons.installPackage`
44585
- * and nothing else.
44586
- *
44587
- * `access` is REQUIRED with min 1 element. `admin` bypass is the
44588
- * "give me everything" escape; there is no wildcard scope.
44589
- */
44590
- var AllowedProviderSchema = union([literal("*"), array(string())]);
44591
- var AllowedDevicesSchema = record(string(), union([literal("*"), array(string())]));
44592
- var CapScopeSchema = _enum(["device", "system"]);
44593
- /**
44594
- * DeviceSelector (scope model v3 — 2026-08-12).
44595
- *
44596
- * A `device` grant no longer carries a frozen list of deviceIds. It carries
44597
- * a SELECTOR the matcher resolves against the live fleet, so the grant can be
44598
- * DYNAMIC: a `types:['camera']` selector automatically covers a camera added
44599
- * AFTER the grant was minted — no re-grant, no re-login.
44600
- *
44601
- * - `all` — every device in the deployment. The broad viewer/operator
44602
- * lever without a `category` grant (a `category` grant also covers device
44603
- * caps that carry no deviceId; `all` is specifically the device set).
44604
- * - `ids` — an explicit deviceId list. This is what a v2 `device:[…]`
44605
- * grant migrates to (see {@link TokenScopeSchema}); STATIC — a new camera
44606
- * is NOT covered until the grant is edited.
44607
- * - `types` — every device of a `DeviceType` (e.g. every `camera`).
44608
- * DYNAMIC. A device that changes type, or a new device of the type,
44609
- * re-resolves on the next request.
44610
- * - `locations` — every device whose operator-assigned `location` label is
44611
- * in the set (e.g. "Garden", "Front door"). DYNAMIC. A device with a
44612
- * null/unset location matches NO `locations` selector.
44613
- */
44614
- var DeviceSelectorSchema = discriminatedUnion("kind", [
44615
- object({ kind: literal("all") }),
44616
- object({
44617
- kind: literal("ids"),
44618
- ids: array(number().int()).min(1)
44619
- }),
44620
- object({
44621
- kind: literal("types"),
44622
- types: array(_enum(DeviceType)).min(1)
44623
- }),
44624
- object({
44625
- kind: literal("locations"),
44626
- locations: array(string().min(1)).min(1)
44627
- })
44628
- ]);
44629
- var DeviceTokenScopeSchema = object({
44630
- type: literal("device"),
44631
- /** The device SET this grant covers — resolved against the live fleet. */
44632
- selector: DeviceSelectorSchema,
44633
- access: array(MethodAccessSchema).min(1),
44634
- /**
44635
- * Whether a grant on a PARENT device transparently covers its accessory
44636
- * CHILDREN (siren / floodlight / PIR) via the persisted-parentage walk.
44637
- * Direction is parent → children ONLY.
44638
- *
44639
- * Absent → the matcher DERIVES it from the access flavour: `view`
44640
- * inherits (a camera viewer sees the camera's accessories), `create` /
44641
- * `delete` do NOT (actuating/removing a child is an explicit act the
44642
- * operator must grant on the child, not inherit from the parent). Set it
44643
- * explicitly to override that default per grant.
44644
- */
44645
- includeLinked: boolean().optional()
44646
- });
44647
- /**
44648
- * v2 → v3 lazy migration. A pre-v3 `device` grant carried
44649
- * `targets: string[]` (stringified deviceIds); it rewrites to the equivalent
44650
- * `selector: {kind:'ids', ids}`. Applied as a `preprocess` so it runs on
44651
- * EVERY parse path — stored records AND the JWT-carried scope arrays
44652
- * normalised at the request boundary ({@link normalizeTokenScopes} in
44653
- * `device-selector.ts`). Chosen over a one-time DB migration because a
44654
- * migration cannot reach a JWT already in a client's hands; parse-time
44655
- * migration covers both without a flag day. No cast — the raw object is read
44656
- * through `Reflect.get` (its static type is `unknown`).
44657
- */
44658
- function migrateLegacyTokenScope(raw) {
44659
- if (raw === null || typeof raw !== "object" || Array.isArray(raw)) return raw;
44660
- if (Reflect.get(raw, "type") !== "device") return raw;
44661
- if (Reflect.get(raw, "selector") !== void 0) return raw;
44662
- const targets = Reflect.get(raw, "targets");
44663
- if (!Array.isArray(targets)) return raw;
44664
- return {
44665
- type: "device",
44666
- selector: {
44667
- kind: "ids",
44668
- ids: targets.map((t) => typeof t === "string" ? Number(t) : t).filter((n) => typeof n === "number" && Number.isInteger(n))
44669
- },
44670
- access: Reflect.get(raw, "access")
44671
- };
44672
- }
44673
- var TokenScopeSchema = preprocess(migrateLegacyTokenScope, discriminatedUnion("type", [
44674
- object({
44675
- type: literal("category"),
44676
- target: CapScopeSchema,
44677
- access: array(MethodAccessSchema).min(1)
44678
- }),
44679
- object({
44680
- type: literal("capability"),
44681
- target: string(),
44682
- access: array(MethodAccessSchema).min(1)
44683
- }),
44684
- object({
44685
- type: literal("addon"),
44686
- target: string(),
44687
- access: array(MethodAccessSchema).min(1)
44688
- }),
44689
- DeviceTokenScopeSchema
44690
- ]));
44691
- object({
44692
- id: string(),
44693
- username: string(),
44694
- passwordHash: string(),
44695
- /**
44696
- * Admin bypass. When true, the middleware skips the scope-access
44697
- * check entirely. There is no other axis of privilege; the legacy
44698
- * role enum collapsed onto this boolean in v2.
44699
- */
44700
- isAdmin: boolean().default(false),
44701
- allowedProviders: AllowedProviderSchema,
44702
- allowedDevices: AllowedDevicesSchema,
44703
- /**
44704
- * Scopes granted to this user. Admins bypass; their `scopes` is
44705
- * ignored. Non-admins without scopes are locked out of every
44706
- * protected call.
44707
- */
44708
- scopes: array(TokenScopeSchema).default([]),
44709
- createdAt: number(),
44710
- updatedAt: number()
44711
- });
44712
- object({
44713
- id: string(),
44714
- label: string(),
44715
- isAdmin: boolean().default(false),
44716
- allowedProviders: AllowedProviderSchema,
44717
- allowedDevices: AllowedDevicesSchema,
44718
- tokenHash: string(),
44719
- tokenPrefix: string(),
44720
- createdAt: number(),
44721
- lastUsedAt: number().optional()
44722
- });
44723
- object({
44724
- id: string(),
44725
- userId: string(),
44726
- name: string(),
44727
- tokenHash: string(),
44728
- tokenPrefix: string(),
44729
- scopes: array(TokenScopeSchema),
44730
- expiresAt: number().nullish(),
44731
- lastUsedAt: number().nullish(),
44732
- createdAt: number()
44733
- });
44734
- /**
44735
44768
  * `oauth-integration` — a collection cap by which an addon declares
44736
44769
  * itself a linkable OAuth client of the hub's core `/oauth2/*` server.
44737
44770
  * Each provider returns a static descriptor; the core enumerates them
@@ -7836,6 +7836,12 @@ function normalizeAddonInitResult(result) {
7836
7836
  if (Array.isArray(result)) return { providers: result };
7837
7837
  return result;
7838
7838
  }
7839
+ /**
7840
+ * The share-view scope kinds a `csv_*` share token can carry. The hub mints
7841
+ * and validates them (`share-token.service.ts` builds its enum from this
7842
+ * list); a data plane names the kinds it ACCEPTS in `share`.
7843
+ */
7844
+ var SHARE_VIEW_KINDS = ["grid-view", "events-view"];
7839
7845
  /** The wire shape of {@link PeerBytesTicket} — see the type for what it is. */
7840
7846
  var PeerBytesTicketSchema = object({
7841
7847
  /** `http://127.0.0.1:<port>/<token>`. One `GET` takes it. */
@@ -13308,6 +13314,229 @@ var ConvertResultSchema = object({
13308
13314
  files: array(string()).readonly()
13309
13315
  })).readonly()
13310
13316
  });
13317
+ /**
13318
+ * Zod schemas for persisted record types.
13319
+ *
13320
+ * These schemas serve as the single source of truth for types that are
13321
+ * stored in the settings-store backend and retrieved via tRPC. They
13322
+ * replace the manual TypeScript interfaces with schema-derived types,
13323
+ * enabling runtime validation when reading from the backend.
13324
+ *
13325
+ * Convention: each schema is named `<Type>Schema`, the inferred TS type
13326
+ * keeps the original name for backward compatibility.
13327
+ */
13328
+ /**
13329
+ * Auth model (v2 — 2026-05-12 caps-only):
13330
+ *
13331
+ * Two principals:
13332
+ * - `isAdmin: true` — full bypass. Admin scope set is ignored.
13333
+ * - `isAdmin: false` — every call gated by `scopes` (see TokenScope).
13334
+ *
13335
+ * No role enum. There used to be `viewer / agent / scoped` and earlier
13336
+ * `super_admin` — collapsed onto the single boolean because every
13337
+ * non-admin caller is governed by the same scope-check rules; the
13338
+ * distinction was only ever used to route role-specific procedures
13339
+ * which we no longer have. CLI / webhook integrations are `cst_*` tokens
13340
+ * with `isAdmin: false` + an explicit scope list.
13341
+ */
13342
+ /** Per-method access flavour. Materialised on every cap method via codegen. */
13343
+ var MethodAccessSchema = _enum([
13344
+ "view",
13345
+ "create",
13346
+ "delete"
13347
+ ]);
13348
+ /**
13349
+ * A single scope grant. Three forms — checked in matcher with OR
13350
+ * semantics; the first match decides whether the call passes:
13351
+ *
13352
+ * - `category` — broadest. `target: 'device' | 'system'` selects every
13353
+ * cap with the matching `scope` declaration. New caps inherit grants
13354
+ * automatically — adding a device cap to the codebase makes it
13355
+ * reachable to every user with `category:device [...]` without a
13356
+ * re-grant. Use this for "family viewer" / "operator" tiers.
13357
+ *
13358
+ * - `addon` — every cap that ships inside a given addon id. Niche;
13359
+ * useful when an integration needs to interact with one specific
13360
+ * addon's surface regardless of how many caps it exports.
13361
+ *
13362
+ * - `capability` — the most precise form. Single cap name. Use for
13363
+ * integration tokens where you want to grant `addons.installPackage`
13364
+ * and nothing else.
13365
+ *
13366
+ * `access` is REQUIRED with min 1 element. `admin` bypass is the
13367
+ * "give me everything" escape; there is no wildcard scope.
13368
+ */
13369
+ var AllowedProviderSchema = union([literal("*"), array(string())]);
13370
+ var AllowedDevicesSchema = record(string(), union([literal("*"), array(string())]));
13371
+ var CapScopeSchema = _enum(["device", "system"]);
13372
+ /**
13373
+ * DeviceSelector (scope model v3 — 2026-08-12).
13374
+ *
13375
+ * A `device` grant no longer carries a frozen list of deviceIds. It carries
13376
+ * a SELECTOR the matcher resolves against the live fleet, so the grant can be
13377
+ * DYNAMIC: a `types:['camera']` selector automatically covers a camera added
13378
+ * AFTER the grant was minted — no re-grant, no re-login.
13379
+ *
13380
+ * - `all` — every device in the deployment. The broad viewer/operator
13381
+ * lever without a `category` grant (a `category` grant also covers device
13382
+ * caps that carry no deviceId; `all` is specifically the device set).
13383
+ * - `ids` — an explicit deviceId list. This is what a v2 `device:[…]`
13384
+ * grant migrates to (see {@link TokenScopeSchema}); STATIC — a new camera
13385
+ * is NOT covered until the grant is edited.
13386
+ * - `types` — every device of a `DeviceType` (e.g. every `camera`).
13387
+ * DYNAMIC. A device that changes type, or a new device of the type,
13388
+ * re-resolves on the next request.
13389
+ * - `locations` — every device whose operator-assigned `location` label is
13390
+ * in the set (e.g. "Garden", "Front door"). DYNAMIC. A device with a
13391
+ * null/unset location matches NO `locations` selector.
13392
+ */
13393
+ var DeviceSelectorSchema = discriminatedUnion("kind", [
13394
+ object({ kind: literal("all") }),
13395
+ object({
13396
+ kind: literal("ids"),
13397
+ ids: array(number().int()).min(1)
13398
+ }),
13399
+ object({
13400
+ kind: literal("types"),
13401
+ types: array(_enum(DeviceType)).min(1)
13402
+ }),
13403
+ object({
13404
+ kind: literal("locations"),
13405
+ locations: array(string().min(1)).min(1)
13406
+ })
13407
+ ]);
13408
+ var DeviceTokenScopeSchema = object({
13409
+ type: literal("device"),
13410
+ /** The device SET this grant covers — resolved against the live fleet. */
13411
+ selector: DeviceSelectorSchema,
13412
+ access: array(MethodAccessSchema).min(1),
13413
+ /**
13414
+ * Whether a grant on a PARENT device transparently covers its accessory
13415
+ * CHILDREN (siren / floodlight / PIR) via the persisted-parentage walk.
13416
+ * Direction is parent → children ONLY.
13417
+ *
13418
+ * Absent → the matcher DERIVES it from the access flavour: `view`
13419
+ * inherits (a camera viewer sees the camera's accessories), `create` /
13420
+ * `delete` do NOT (actuating/removing a child is an explicit act the
13421
+ * operator must grant on the child, not inherit from the parent). Set it
13422
+ * explicitly to override that default per grant.
13423
+ */
13424
+ includeLinked: boolean().optional()
13425
+ });
13426
+ /**
13427
+ * v2 → v3 lazy migration. A pre-v3 `device` grant carried
13428
+ * `targets: string[]` (stringified deviceIds); it rewrites to the equivalent
13429
+ * `selector: {kind:'ids', ids}`. Applied as a `preprocess` so it runs on
13430
+ * EVERY parse path — stored records AND the JWT-carried scope arrays
13431
+ * normalised at the request boundary ({@link normalizeTokenScopes} in
13432
+ * `device-selector.ts`). Chosen over a one-time DB migration because a
13433
+ * migration cannot reach a JWT already in a client's hands; parse-time
13434
+ * migration covers both without a flag day. No cast — the raw object is read
13435
+ * through `Reflect.get` (its static type is `unknown`).
13436
+ */
13437
+ function migrateLegacyTokenScope(raw) {
13438
+ if (raw === null || typeof raw !== "object" || Array.isArray(raw)) return raw;
13439
+ if (Reflect.get(raw, "type") !== "device") return raw;
13440
+ if (Reflect.get(raw, "selector") !== void 0) return raw;
13441
+ const targets = Reflect.get(raw, "targets");
13442
+ if (!Array.isArray(targets)) return raw;
13443
+ return {
13444
+ type: "device",
13445
+ selector: {
13446
+ kind: "ids",
13447
+ ids: targets.map((t) => typeof t === "string" ? Number(t) : t).filter((n) => typeof n === "number" && Number.isInteger(n))
13448
+ },
13449
+ access: Reflect.get(raw, "access")
13450
+ };
13451
+ }
13452
+ var TokenScopeSchema = preprocess(migrateLegacyTokenScope, discriminatedUnion("type", [
13453
+ object({
13454
+ type: literal("category"),
13455
+ target: CapScopeSchema,
13456
+ access: array(MethodAccessSchema).min(1)
13457
+ }),
13458
+ object({
13459
+ type: literal("capability"),
13460
+ target: string(),
13461
+ access: array(MethodAccessSchema).min(1)
13462
+ }),
13463
+ object({
13464
+ type: literal("addon"),
13465
+ target: string(),
13466
+ access: array(MethodAccessSchema).min(1)
13467
+ }),
13468
+ DeviceTokenScopeSchema
13469
+ ]));
13470
+ object({
13471
+ id: string(),
13472
+ username: string(),
13473
+ passwordHash: string(),
13474
+ /**
13475
+ * Admin bypass. When true, the middleware skips the scope-access
13476
+ * check entirely. There is no other axis of privilege; the legacy
13477
+ * role enum collapsed onto this boolean in v2.
13478
+ */
13479
+ isAdmin: boolean().default(false),
13480
+ allowedProviders: AllowedProviderSchema,
13481
+ allowedDevices: AllowedDevicesSchema,
13482
+ /**
13483
+ * Scopes granted to this user. Admins bypass; their `scopes` is
13484
+ * ignored. Non-admins without scopes are locked out of every
13485
+ * protected call.
13486
+ */
13487
+ scopes: array(TokenScopeSchema).default([]),
13488
+ createdAt: number(),
13489
+ updatedAt: number()
13490
+ });
13491
+ object({
13492
+ id: string(),
13493
+ label: string(),
13494
+ isAdmin: boolean().default(false),
13495
+ allowedProviders: AllowedProviderSchema,
13496
+ allowedDevices: AllowedDevicesSchema,
13497
+ tokenHash: string(),
13498
+ tokenPrefix: string(),
13499
+ createdAt: number(),
13500
+ lastUsedAt: number().optional()
13501
+ });
13502
+ object({
13503
+ id: string(),
13504
+ userId: string(),
13505
+ name: string(),
13506
+ tokenHash: string(),
13507
+ tokenPrefix: string(),
13508
+ scopes: array(TokenScopeSchema),
13509
+ expiresAt: number().nullish(),
13510
+ lastUsedAt: number().nullish(),
13511
+ createdAt: number()
13512
+ });
13513
+ /** What a share-view grant lets its holder see. */
13514
+ var ShareViewGrantSchema = object({
13515
+ kind: _enum(SHARE_VIEW_KINDS),
13516
+ deviceIds: array(number().int().nonnegative()).min(1).max(64),
13517
+ /** Talk-back, opt-in at mint time; absent means off. */
13518
+ talk: boolean().optional()
13519
+ });
13520
+ var ShareViewScopeSchema = object({
13521
+ type: literal("share-view"),
13522
+ grant: ShareViewGrantSchema
13523
+ });
13524
+ var AddonRoutesScopeSchema = object({
13525
+ type: literal("addon-routes"),
13526
+ access: array(MethodAccessSchema).min(1)
13527
+ });
13528
+ var CredentialScopeSchema = union([
13529
+ literal("*"),
13530
+ ShareViewScopeSchema,
13531
+ AddonRoutesScopeSchema,
13532
+ TokenScopeSchema
13533
+ ]);
13534
+ object({
13535
+ kind: literal("credential"),
13536
+ sub: string().min(1),
13537
+ jti: string().min(16),
13538
+ scopes: array(CredentialScopeSchema).min(1)
13539
+ });
13311
13540
  _enum(["new-session", "step-up"]);
13312
13541
  /** The languages the hub's app landing pages are written in (D858). */
13313
13542
  var AppPageLangSchema = _enum(["en", "it"]);
@@ -44526,202 +44755,6 @@ method(object({}), object({ rules: array(NcRuleSchema) }), { auth: "admin" }), m
44526
44755
  auth: "admin"
44527
44756
  }), method(NcAlarmSensorsInputSchema, NcAlarmSensorsSchema, { auth: "admin" });
44528
44757
  /**
44529
- * Zod schemas for persisted record types.
44530
- *
44531
- * These schemas serve as the single source of truth for types that are
44532
- * stored in the settings-store backend and retrieved via tRPC. They
44533
- * replace the manual TypeScript interfaces with schema-derived types,
44534
- * enabling runtime validation when reading from the backend.
44535
- *
44536
- * Convention: each schema is named `<Type>Schema`, the inferred TS type
44537
- * keeps the original name for backward compatibility.
44538
- */
44539
- /**
44540
- * Auth model (v2 — 2026-05-12 caps-only):
44541
- *
44542
- * Two principals:
44543
- * - `isAdmin: true` — full bypass. Admin scope set is ignored.
44544
- * - `isAdmin: false` — every call gated by `scopes` (see TokenScope).
44545
- *
44546
- * No role enum. There used to be `viewer / agent / scoped` and earlier
44547
- * `super_admin` — collapsed onto the single boolean because every
44548
- * non-admin caller is governed by the same scope-check rules; the
44549
- * distinction was only ever used to route role-specific procedures
44550
- * which we no longer have. CLI / webhook integrations are `cst_*` tokens
44551
- * with `isAdmin: false` + an explicit scope list.
44552
- */
44553
- /** Per-method access flavour. Materialised on every cap method via codegen. */
44554
- var MethodAccessSchema = _enum([
44555
- "view",
44556
- "create",
44557
- "delete"
44558
- ]);
44559
- /**
44560
- * A single scope grant. Three forms — checked in matcher with OR
44561
- * semantics; the first match decides whether the call passes:
44562
- *
44563
- * - `category` — broadest. `target: 'device' | 'system'` selects every
44564
- * cap with the matching `scope` declaration. New caps inherit grants
44565
- * automatically — adding a device cap to the codebase makes it
44566
- * reachable to every user with `category:device [...]` without a
44567
- * re-grant. Use this for "family viewer" / "operator" tiers.
44568
- *
44569
- * - `addon` — every cap that ships inside a given addon id. Niche;
44570
- * useful when an integration needs to interact with one specific
44571
- * addon's surface regardless of how many caps it exports.
44572
- *
44573
- * - `capability` — the most precise form. Single cap name. Use for
44574
- * integration tokens where you want to grant `addons.installPackage`
44575
- * and nothing else.
44576
- *
44577
- * `access` is REQUIRED with min 1 element. `admin` bypass is the
44578
- * "give me everything" escape; there is no wildcard scope.
44579
- */
44580
- var AllowedProviderSchema = union([literal("*"), array(string())]);
44581
- var AllowedDevicesSchema = record(string(), union([literal("*"), array(string())]));
44582
- var CapScopeSchema = _enum(["device", "system"]);
44583
- /**
44584
- * DeviceSelector (scope model v3 — 2026-08-12).
44585
- *
44586
- * A `device` grant no longer carries a frozen list of deviceIds. It carries
44587
- * a SELECTOR the matcher resolves against the live fleet, so the grant can be
44588
- * DYNAMIC: a `types:['camera']` selector automatically covers a camera added
44589
- * AFTER the grant was minted — no re-grant, no re-login.
44590
- *
44591
- * - `all` — every device in the deployment. The broad viewer/operator
44592
- * lever without a `category` grant (a `category` grant also covers device
44593
- * caps that carry no deviceId; `all` is specifically the device set).
44594
- * - `ids` — an explicit deviceId list. This is what a v2 `device:[…]`
44595
- * grant migrates to (see {@link TokenScopeSchema}); STATIC — a new camera
44596
- * is NOT covered until the grant is edited.
44597
- * - `types` — every device of a `DeviceType` (e.g. every `camera`).
44598
- * DYNAMIC. A device that changes type, or a new device of the type,
44599
- * re-resolves on the next request.
44600
- * - `locations` — every device whose operator-assigned `location` label is
44601
- * in the set (e.g. "Garden", "Front door"). DYNAMIC. A device with a
44602
- * null/unset location matches NO `locations` selector.
44603
- */
44604
- var DeviceSelectorSchema = discriminatedUnion("kind", [
44605
- object({ kind: literal("all") }),
44606
- object({
44607
- kind: literal("ids"),
44608
- ids: array(number().int()).min(1)
44609
- }),
44610
- object({
44611
- kind: literal("types"),
44612
- types: array(_enum(DeviceType)).min(1)
44613
- }),
44614
- object({
44615
- kind: literal("locations"),
44616
- locations: array(string().min(1)).min(1)
44617
- })
44618
- ]);
44619
- var DeviceTokenScopeSchema = object({
44620
- type: literal("device"),
44621
- /** The device SET this grant covers — resolved against the live fleet. */
44622
- selector: DeviceSelectorSchema,
44623
- access: array(MethodAccessSchema).min(1),
44624
- /**
44625
- * Whether a grant on a PARENT device transparently covers its accessory
44626
- * CHILDREN (siren / floodlight / PIR) via the persisted-parentage walk.
44627
- * Direction is parent → children ONLY.
44628
- *
44629
- * Absent → the matcher DERIVES it from the access flavour: `view`
44630
- * inherits (a camera viewer sees the camera's accessories), `create` /
44631
- * `delete` do NOT (actuating/removing a child is an explicit act the
44632
- * operator must grant on the child, not inherit from the parent). Set it
44633
- * explicitly to override that default per grant.
44634
- */
44635
- includeLinked: boolean().optional()
44636
- });
44637
- /**
44638
- * v2 → v3 lazy migration. A pre-v3 `device` grant carried
44639
- * `targets: string[]` (stringified deviceIds); it rewrites to the equivalent
44640
- * `selector: {kind:'ids', ids}`. Applied as a `preprocess` so it runs on
44641
- * EVERY parse path — stored records AND the JWT-carried scope arrays
44642
- * normalised at the request boundary ({@link normalizeTokenScopes} in
44643
- * `device-selector.ts`). Chosen over a one-time DB migration because a
44644
- * migration cannot reach a JWT already in a client's hands; parse-time
44645
- * migration covers both without a flag day. No cast — the raw object is read
44646
- * through `Reflect.get` (its static type is `unknown`).
44647
- */
44648
- function migrateLegacyTokenScope(raw) {
44649
- if (raw === null || typeof raw !== "object" || Array.isArray(raw)) return raw;
44650
- if (Reflect.get(raw, "type") !== "device") return raw;
44651
- if (Reflect.get(raw, "selector") !== void 0) return raw;
44652
- const targets = Reflect.get(raw, "targets");
44653
- if (!Array.isArray(targets)) return raw;
44654
- return {
44655
- type: "device",
44656
- selector: {
44657
- kind: "ids",
44658
- ids: targets.map((t) => typeof t === "string" ? Number(t) : t).filter((n) => typeof n === "number" && Number.isInteger(n))
44659
- },
44660
- access: Reflect.get(raw, "access")
44661
- };
44662
- }
44663
- var TokenScopeSchema = preprocess(migrateLegacyTokenScope, discriminatedUnion("type", [
44664
- object({
44665
- type: literal("category"),
44666
- target: CapScopeSchema,
44667
- access: array(MethodAccessSchema).min(1)
44668
- }),
44669
- object({
44670
- type: literal("capability"),
44671
- target: string(),
44672
- access: array(MethodAccessSchema).min(1)
44673
- }),
44674
- object({
44675
- type: literal("addon"),
44676
- target: string(),
44677
- access: array(MethodAccessSchema).min(1)
44678
- }),
44679
- DeviceTokenScopeSchema
44680
- ]));
44681
- object({
44682
- id: string(),
44683
- username: string(),
44684
- passwordHash: string(),
44685
- /**
44686
- * Admin bypass. When true, the middleware skips the scope-access
44687
- * check entirely. There is no other axis of privilege; the legacy
44688
- * role enum collapsed onto this boolean in v2.
44689
- */
44690
- isAdmin: boolean().default(false),
44691
- allowedProviders: AllowedProviderSchema,
44692
- allowedDevices: AllowedDevicesSchema,
44693
- /**
44694
- * Scopes granted to this user. Admins bypass; their `scopes` is
44695
- * ignored. Non-admins without scopes are locked out of every
44696
- * protected call.
44697
- */
44698
- scopes: array(TokenScopeSchema).default([]),
44699
- createdAt: number(),
44700
- updatedAt: number()
44701
- });
44702
- object({
44703
- id: string(),
44704
- label: string(),
44705
- isAdmin: boolean().default(false),
44706
- allowedProviders: AllowedProviderSchema,
44707
- allowedDevices: AllowedDevicesSchema,
44708
- tokenHash: string(),
44709
- tokenPrefix: string(),
44710
- createdAt: number(),
44711
- lastUsedAt: number().optional()
44712
- });
44713
- object({
44714
- id: string(),
44715
- userId: string(),
44716
- name: string(),
44717
- tokenHash: string(),
44718
- tokenPrefix: string(),
44719
- scopes: array(TokenScopeSchema),
44720
- expiresAt: number().nullish(),
44721
- lastUsedAt: number().nullish(),
44722
- createdAt: number()
44723
- });
44724
- /**
44725
44758
  * `oauth-integration` — a collection cap by which an addon declares
44726
44759
  * itself a linkable OAuth client of the hub's core `/oauth2/*` server.
44727
44760
  * 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-export-hap",
3
- "version": "1.2.161",
3
+ "version": "1.2.162",
4
4
  "description": "HomeKit (HAP) exporter for CamStack devices. Publishes each exposed device as its own HomeKit accessory: cameras and doorbells with SRTP streaming, HomeKit Secure Video, motion, two-way audio, PTZ and battery; switches, lights, locks and sensors through a capability→service table.",
5
5
  "keywords": [
6
6
  "camstack",