@camstack/addon-decoder-nodeav 1.2.125 → 1.2.126

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/index.js +229 -196
  2. package/dist/index.mjs +229 -196
  3. package/package.json +1 -1
package/dist/index.js CHANGED
@@ -7800,6 +7800,12 @@ function normalizeAddonInitResult(result) {
7800
7800
  if (Array.isArray(result)) return { providers: result };
7801
7801
  return result;
7802
7802
  }
7803
+ /**
7804
+ * The share-view scope kinds a `csv_*` share token can carry. The hub mints
7805
+ * and validates them (`share-token.service.ts` builds its enum from this
7806
+ * list); a data plane names the kinds it ACCEPTS in `share`.
7807
+ */
7808
+ var SHARE_VIEW_KINDS = ["grid-view", "events-view"];
7803
7809
  /** The wire shape of {@link PeerBytesTicket} — see the type for what it is. */
7804
7810
  var PeerBytesTicketSchema = object({
7805
7811
  /** `http://127.0.0.1:<port>/<token>`. One `GET` takes it. */
@@ -12394,6 +12400,229 @@ var ConvertResultSchema = object({
12394
12400
  files: array(string()).readonly()
12395
12401
  })).readonly()
12396
12402
  });
12403
+ /**
12404
+ * Zod schemas for persisted record types.
12405
+ *
12406
+ * These schemas serve as the single source of truth for types that are
12407
+ * stored in the settings-store backend and retrieved via tRPC. They
12408
+ * replace the manual TypeScript interfaces with schema-derived types,
12409
+ * enabling runtime validation when reading from the backend.
12410
+ *
12411
+ * Convention: each schema is named `<Type>Schema`, the inferred TS type
12412
+ * keeps the original name for backward compatibility.
12413
+ */
12414
+ /**
12415
+ * Auth model (v2 — 2026-05-12 caps-only):
12416
+ *
12417
+ * Two principals:
12418
+ * - `isAdmin: true` — full bypass. Admin scope set is ignored.
12419
+ * - `isAdmin: false` — every call gated by `scopes` (see TokenScope).
12420
+ *
12421
+ * No role enum. There used to be `viewer / agent / scoped` and earlier
12422
+ * `super_admin` — collapsed onto the single boolean because every
12423
+ * non-admin caller is governed by the same scope-check rules; the
12424
+ * distinction was only ever used to route role-specific procedures
12425
+ * which we no longer have. CLI / webhook integrations are `cst_*` tokens
12426
+ * with `isAdmin: false` + an explicit scope list.
12427
+ */
12428
+ /** Per-method access flavour. Materialised on every cap method via codegen. */
12429
+ var MethodAccessSchema = _enum([
12430
+ "view",
12431
+ "create",
12432
+ "delete"
12433
+ ]);
12434
+ /**
12435
+ * A single scope grant. Three forms — checked in matcher with OR
12436
+ * semantics; the first match decides whether the call passes:
12437
+ *
12438
+ * - `category` — broadest. `target: 'device' | 'system'` selects every
12439
+ * cap with the matching `scope` declaration. New caps inherit grants
12440
+ * automatically — adding a device cap to the codebase makes it
12441
+ * reachable to every user with `category:device [...]` without a
12442
+ * re-grant. Use this for "family viewer" / "operator" tiers.
12443
+ *
12444
+ * - `addon` — every cap that ships inside a given addon id. Niche;
12445
+ * useful when an integration needs to interact with one specific
12446
+ * addon's surface regardless of how many caps it exports.
12447
+ *
12448
+ * - `capability` — the most precise form. Single cap name. Use for
12449
+ * integration tokens where you want to grant `addons.installPackage`
12450
+ * and nothing else.
12451
+ *
12452
+ * `access` is REQUIRED with min 1 element. `admin` bypass is the
12453
+ * "give me everything" escape; there is no wildcard scope.
12454
+ */
12455
+ var AllowedProviderSchema = union([literal("*"), array(string())]);
12456
+ var AllowedDevicesSchema = record(string(), union([literal("*"), array(string())]));
12457
+ var CapScopeSchema = _enum(["device", "system"]);
12458
+ /**
12459
+ * DeviceSelector (scope model v3 — 2026-08-12).
12460
+ *
12461
+ * A `device` grant no longer carries a frozen list of deviceIds. It carries
12462
+ * a SELECTOR the matcher resolves against the live fleet, so the grant can be
12463
+ * DYNAMIC: a `types:['camera']` selector automatically covers a camera added
12464
+ * AFTER the grant was minted — no re-grant, no re-login.
12465
+ *
12466
+ * - `all` — every device in the deployment. The broad viewer/operator
12467
+ * lever without a `category` grant (a `category` grant also covers device
12468
+ * caps that carry no deviceId; `all` is specifically the device set).
12469
+ * - `ids` — an explicit deviceId list. This is what a v2 `device:[…]`
12470
+ * grant migrates to (see {@link TokenScopeSchema}); STATIC — a new camera
12471
+ * is NOT covered until the grant is edited.
12472
+ * - `types` — every device of a `DeviceType` (e.g. every `camera`).
12473
+ * DYNAMIC. A device that changes type, or a new device of the type,
12474
+ * re-resolves on the next request.
12475
+ * - `locations` — every device whose operator-assigned `location` label is
12476
+ * in the set (e.g. "Garden", "Front door"). DYNAMIC. A device with a
12477
+ * null/unset location matches NO `locations` selector.
12478
+ */
12479
+ var DeviceSelectorSchema = discriminatedUnion("kind", [
12480
+ object({ kind: literal("all") }),
12481
+ object({
12482
+ kind: literal("ids"),
12483
+ ids: array(number().int()).min(1)
12484
+ }),
12485
+ object({
12486
+ kind: literal("types"),
12487
+ types: array(_enum(DeviceType)).min(1)
12488
+ }),
12489
+ object({
12490
+ kind: literal("locations"),
12491
+ locations: array(string().min(1)).min(1)
12492
+ })
12493
+ ]);
12494
+ var DeviceTokenScopeSchema = object({
12495
+ type: literal("device"),
12496
+ /** The device SET this grant covers — resolved against the live fleet. */
12497
+ selector: DeviceSelectorSchema,
12498
+ access: array(MethodAccessSchema).min(1),
12499
+ /**
12500
+ * Whether a grant on a PARENT device transparently covers its accessory
12501
+ * CHILDREN (siren / floodlight / PIR) via the persisted-parentage walk.
12502
+ * Direction is parent → children ONLY.
12503
+ *
12504
+ * Absent → the matcher DERIVES it from the access flavour: `view`
12505
+ * inherits (a camera viewer sees the camera's accessories), `create` /
12506
+ * `delete` do NOT (actuating/removing a child is an explicit act the
12507
+ * operator must grant on the child, not inherit from the parent). Set it
12508
+ * explicitly to override that default per grant.
12509
+ */
12510
+ includeLinked: boolean().optional()
12511
+ });
12512
+ /**
12513
+ * v2 → v3 lazy migration. A pre-v3 `device` grant carried
12514
+ * `targets: string[]` (stringified deviceIds); it rewrites to the equivalent
12515
+ * `selector: {kind:'ids', ids}`. Applied as a `preprocess` so it runs on
12516
+ * EVERY parse path — stored records AND the JWT-carried scope arrays
12517
+ * normalised at the request boundary ({@link normalizeTokenScopes} in
12518
+ * `device-selector.ts`). Chosen over a one-time DB migration because a
12519
+ * migration cannot reach a JWT already in a client's hands; parse-time
12520
+ * migration covers both without a flag day. No cast — the raw object is read
12521
+ * through `Reflect.get` (its static type is `unknown`).
12522
+ */
12523
+ function migrateLegacyTokenScope(raw) {
12524
+ if (raw === null || typeof raw !== "object" || Array.isArray(raw)) return raw;
12525
+ if (Reflect.get(raw, "type") !== "device") return raw;
12526
+ if (Reflect.get(raw, "selector") !== void 0) return raw;
12527
+ const targets = Reflect.get(raw, "targets");
12528
+ if (!Array.isArray(targets)) return raw;
12529
+ return {
12530
+ type: "device",
12531
+ selector: {
12532
+ kind: "ids",
12533
+ ids: targets.map((t) => typeof t === "string" ? Number(t) : t).filter((n) => typeof n === "number" && Number.isInteger(n))
12534
+ },
12535
+ access: Reflect.get(raw, "access")
12536
+ };
12537
+ }
12538
+ var TokenScopeSchema = preprocess(migrateLegacyTokenScope, discriminatedUnion("type", [
12539
+ object({
12540
+ type: literal("category"),
12541
+ target: CapScopeSchema,
12542
+ access: array(MethodAccessSchema).min(1)
12543
+ }),
12544
+ object({
12545
+ type: literal("capability"),
12546
+ target: string(),
12547
+ access: array(MethodAccessSchema).min(1)
12548
+ }),
12549
+ object({
12550
+ type: literal("addon"),
12551
+ target: string(),
12552
+ access: array(MethodAccessSchema).min(1)
12553
+ }),
12554
+ DeviceTokenScopeSchema
12555
+ ]));
12556
+ object({
12557
+ id: string(),
12558
+ username: string(),
12559
+ passwordHash: string(),
12560
+ /**
12561
+ * Admin bypass. When true, the middleware skips the scope-access
12562
+ * check entirely. There is no other axis of privilege; the legacy
12563
+ * role enum collapsed onto this boolean in v2.
12564
+ */
12565
+ isAdmin: boolean().default(false),
12566
+ allowedProviders: AllowedProviderSchema,
12567
+ allowedDevices: AllowedDevicesSchema,
12568
+ /**
12569
+ * Scopes granted to this user. Admins bypass; their `scopes` is
12570
+ * ignored. Non-admins without scopes are locked out of every
12571
+ * protected call.
12572
+ */
12573
+ scopes: array(TokenScopeSchema).default([]),
12574
+ createdAt: number(),
12575
+ updatedAt: number()
12576
+ });
12577
+ object({
12578
+ id: string(),
12579
+ label: string(),
12580
+ isAdmin: boolean().default(false),
12581
+ allowedProviders: AllowedProviderSchema,
12582
+ allowedDevices: AllowedDevicesSchema,
12583
+ tokenHash: string(),
12584
+ tokenPrefix: string(),
12585
+ createdAt: number(),
12586
+ lastUsedAt: number().optional()
12587
+ });
12588
+ object({
12589
+ id: string(),
12590
+ userId: string(),
12591
+ name: string(),
12592
+ tokenHash: string(),
12593
+ tokenPrefix: string(),
12594
+ scopes: array(TokenScopeSchema),
12595
+ expiresAt: number().nullish(),
12596
+ lastUsedAt: number().nullish(),
12597
+ createdAt: number()
12598
+ });
12599
+ /** What a share-view grant lets its holder see. */
12600
+ var ShareViewGrantSchema = object({
12601
+ kind: _enum(SHARE_VIEW_KINDS),
12602
+ deviceIds: array(number().int().nonnegative()).min(1).max(64),
12603
+ /** Talk-back, opt-in at mint time; absent means off. */
12604
+ talk: boolean().optional()
12605
+ });
12606
+ var ShareViewScopeSchema = object({
12607
+ type: literal("share-view"),
12608
+ grant: ShareViewGrantSchema
12609
+ });
12610
+ var AddonRoutesScopeSchema = object({
12611
+ type: literal("addon-routes"),
12612
+ access: array(MethodAccessSchema).min(1)
12613
+ });
12614
+ var CredentialScopeSchema = union([
12615
+ literal("*"),
12616
+ ShareViewScopeSchema,
12617
+ AddonRoutesScopeSchema,
12618
+ TokenScopeSchema
12619
+ ]);
12620
+ object({
12621
+ kind: literal("credential"),
12622
+ sub: string().min(1),
12623
+ jti: string().min(16),
12624
+ scopes: array(CredentialScopeSchema).min(1)
12625
+ });
12397
12626
  _enum(["new-session", "step-up"]);
12398
12627
  /** The languages the hub's app landing pages are written in (D858). */
12399
12628
  var AppPageLangSchema = _enum(["en", "it"]);
@@ -43649,202 +43878,6 @@ method(object({}), object({ rules: array(NcRuleSchema) }), { auth: "admin" }), m
43649
43878
  auth: "admin"
43650
43879
  }), method(NcAlarmSensorsInputSchema, NcAlarmSensorsSchema, { auth: "admin" });
43651
43880
  /**
43652
- * Zod schemas for persisted record types.
43653
- *
43654
- * These schemas serve as the single source of truth for types that are
43655
- * stored in the settings-store backend and retrieved via tRPC. They
43656
- * replace the manual TypeScript interfaces with schema-derived types,
43657
- * enabling runtime validation when reading from the backend.
43658
- *
43659
- * Convention: each schema is named `<Type>Schema`, the inferred TS type
43660
- * keeps the original name for backward compatibility.
43661
- */
43662
- /**
43663
- * Auth model (v2 — 2026-05-12 caps-only):
43664
- *
43665
- * Two principals:
43666
- * - `isAdmin: true` — full bypass. Admin scope set is ignored.
43667
- * - `isAdmin: false` — every call gated by `scopes` (see TokenScope).
43668
- *
43669
- * No role enum. There used to be `viewer / agent / scoped` and earlier
43670
- * `super_admin` — collapsed onto the single boolean because every
43671
- * non-admin caller is governed by the same scope-check rules; the
43672
- * distinction was only ever used to route role-specific procedures
43673
- * which we no longer have. CLI / webhook integrations are `cst_*` tokens
43674
- * with `isAdmin: false` + an explicit scope list.
43675
- */
43676
- /** Per-method access flavour. Materialised on every cap method via codegen. */
43677
- var MethodAccessSchema = _enum([
43678
- "view",
43679
- "create",
43680
- "delete"
43681
- ]);
43682
- /**
43683
- * A single scope grant. Three forms — checked in matcher with OR
43684
- * semantics; the first match decides whether the call passes:
43685
- *
43686
- * - `category` — broadest. `target: 'device' | 'system'` selects every
43687
- * cap with the matching `scope` declaration. New caps inherit grants
43688
- * automatically — adding a device cap to the codebase makes it
43689
- * reachable to every user with `category:device [...]` without a
43690
- * re-grant. Use this for "family viewer" / "operator" tiers.
43691
- *
43692
- * - `addon` — every cap that ships inside a given addon id. Niche;
43693
- * useful when an integration needs to interact with one specific
43694
- * addon's surface regardless of how many caps it exports.
43695
- *
43696
- * - `capability` — the most precise form. Single cap name. Use for
43697
- * integration tokens where you want to grant `addons.installPackage`
43698
- * and nothing else.
43699
- *
43700
- * `access` is REQUIRED with min 1 element. `admin` bypass is the
43701
- * "give me everything" escape; there is no wildcard scope.
43702
- */
43703
- var AllowedProviderSchema = union([literal("*"), array(string())]);
43704
- var AllowedDevicesSchema = record(string(), union([literal("*"), array(string())]));
43705
- var CapScopeSchema = _enum(["device", "system"]);
43706
- /**
43707
- * DeviceSelector (scope model v3 — 2026-08-12).
43708
- *
43709
- * A `device` grant no longer carries a frozen list of deviceIds. It carries
43710
- * a SELECTOR the matcher resolves against the live fleet, so the grant can be
43711
- * DYNAMIC: a `types:['camera']` selector automatically covers a camera added
43712
- * AFTER the grant was minted — no re-grant, no re-login.
43713
- *
43714
- * - `all` — every device in the deployment. The broad viewer/operator
43715
- * lever without a `category` grant (a `category` grant also covers device
43716
- * caps that carry no deviceId; `all` is specifically the device set).
43717
- * - `ids` — an explicit deviceId list. This is what a v2 `device:[…]`
43718
- * grant migrates to (see {@link TokenScopeSchema}); STATIC — a new camera
43719
- * is NOT covered until the grant is edited.
43720
- * - `types` — every device of a `DeviceType` (e.g. every `camera`).
43721
- * DYNAMIC. A device that changes type, or a new device of the type,
43722
- * re-resolves on the next request.
43723
- * - `locations` — every device whose operator-assigned `location` label is
43724
- * in the set (e.g. "Garden", "Front door"). DYNAMIC. A device with a
43725
- * null/unset location matches NO `locations` selector.
43726
- */
43727
- var DeviceSelectorSchema = discriminatedUnion("kind", [
43728
- object({ kind: literal("all") }),
43729
- object({
43730
- kind: literal("ids"),
43731
- ids: array(number().int()).min(1)
43732
- }),
43733
- object({
43734
- kind: literal("types"),
43735
- types: array(_enum(DeviceType)).min(1)
43736
- }),
43737
- object({
43738
- kind: literal("locations"),
43739
- locations: array(string().min(1)).min(1)
43740
- })
43741
- ]);
43742
- var DeviceTokenScopeSchema = object({
43743
- type: literal("device"),
43744
- /** The device SET this grant covers — resolved against the live fleet. */
43745
- selector: DeviceSelectorSchema,
43746
- access: array(MethodAccessSchema).min(1),
43747
- /**
43748
- * Whether a grant on a PARENT device transparently covers its accessory
43749
- * CHILDREN (siren / floodlight / PIR) via the persisted-parentage walk.
43750
- * Direction is parent → children ONLY.
43751
- *
43752
- * Absent → the matcher DERIVES it from the access flavour: `view`
43753
- * inherits (a camera viewer sees the camera's accessories), `create` /
43754
- * `delete` do NOT (actuating/removing a child is an explicit act the
43755
- * operator must grant on the child, not inherit from the parent). Set it
43756
- * explicitly to override that default per grant.
43757
- */
43758
- includeLinked: boolean().optional()
43759
- });
43760
- /**
43761
- * v2 → v3 lazy migration. A pre-v3 `device` grant carried
43762
- * `targets: string[]` (stringified deviceIds); it rewrites to the equivalent
43763
- * `selector: {kind:'ids', ids}`. Applied as a `preprocess` so it runs on
43764
- * EVERY parse path — stored records AND the JWT-carried scope arrays
43765
- * normalised at the request boundary ({@link normalizeTokenScopes} in
43766
- * `device-selector.ts`). Chosen over a one-time DB migration because a
43767
- * migration cannot reach a JWT already in a client's hands; parse-time
43768
- * migration covers both without a flag day. No cast — the raw object is read
43769
- * through `Reflect.get` (its static type is `unknown`).
43770
- */
43771
- function migrateLegacyTokenScope(raw) {
43772
- if (raw === null || typeof raw !== "object" || Array.isArray(raw)) return raw;
43773
- if (Reflect.get(raw, "type") !== "device") return raw;
43774
- if (Reflect.get(raw, "selector") !== void 0) return raw;
43775
- const targets = Reflect.get(raw, "targets");
43776
- if (!Array.isArray(targets)) return raw;
43777
- return {
43778
- type: "device",
43779
- selector: {
43780
- kind: "ids",
43781
- ids: targets.map((t) => typeof t === "string" ? Number(t) : t).filter((n) => typeof n === "number" && Number.isInteger(n))
43782
- },
43783
- access: Reflect.get(raw, "access")
43784
- };
43785
- }
43786
- var TokenScopeSchema = preprocess(migrateLegacyTokenScope, discriminatedUnion("type", [
43787
- object({
43788
- type: literal("category"),
43789
- target: CapScopeSchema,
43790
- access: array(MethodAccessSchema).min(1)
43791
- }),
43792
- object({
43793
- type: literal("capability"),
43794
- target: string(),
43795
- access: array(MethodAccessSchema).min(1)
43796
- }),
43797
- object({
43798
- type: literal("addon"),
43799
- target: string(),
43800
- access: array(MethodAccessSchema).min(1)
43801
- }),
43802
- DeviceTokenScopeSchema
43803
- ]));
43804
- object({
43805
- id: string(),
43806
- username: string(),
43807
- passwordHash: string(),
43808
- /**
43809
- * Admin bypass. When true, the middleware skips the scope-access
43810
- * check entirely. There is no other axis of privilege; the legacy
43811
- * role enum collapsed onto this boolean in v2.
43812
- */
43813
- isAdmin: boolean().default(false),
43814
- allowedProviders: AllowedProviderSchema,
43815
- allowedDevices: AllowedDevicesSchema,
43816
- /**
43817
- * Scopes granted to this user. Admins bypass; their `scopes` is
43818
- * ignored. Non-admins without scopes are locked out of every
43819
- * protected call.
43820
- */
43821
- scopes: array(TokenScopeSchema).default([]),
43822
- createdAt: number(),
43823
- updatedAt: number()
43824
- });
43825
- object({
43826
- id: string(),
43827
- label: string(),
43828
- isAdmin: boolean().default(false),
43829
- allowedProviders: AllowedProviderSchema,
43830
- allowedDevices: AllowedDevicesSchema,
43831
- tokenHash: string(),
43832
- tokenPrefix: string(),
43833
- createdAt: number(),
43834
- lastUsedAt: number().optional()
43835
- });
43836
- object({
43837
- id: string(),
43838
- userId: string(),
43839
- name: string(),
43840
- tokenHash: string(),
43841
- tokenPrefix: string(),
43842
- scopes: array(TokenScopeSchema),
43843
- expiresAt: number().nullish(),
43844
- lastUsedAt: number().nullish(),
43845
- createdAt: number()
43846
- });
43847
- /**
43848
43881
  * `oauth-integration` — a collection cap by which an addon declares
43849
43882
  * itself a linkable OAuth client of the hub's core `/oauth2/*` server.
43850
43883
  * Each provider returns a static descriptor; the core enumerates them
package/dist/index.mjs CHANGED
@@ -7796,6 +7796,12 @@ function normalizeAddonInitResult(result) {
7796
7796
  if (Array.isArray(result)) return { providers: result };
7797
7797
  return result;
7798
7798
  }
7799
+ /**
7800
+ * The share-view scope kinds a `csv_*` share token can carry. The hub mints
7801
+ * and validates them (`share-token.service.ts` builds its enum from this
7802
+ * list); a data plane names the kinds it ACCEPTS in `share`.
7803
+ */
7804
+ var SHARE_VIEW_KINDS = ["grid-view", "events-view"];
7799
7805
  /** The wire shape of {@link PeerBytesTicket} — see the type for what it is. */
7800
7806
  var PeerBytesTicketSchema = object({
7801
7807
  /** `http://127.0.0.1:<port>/<token>`. One `GET` takes it. */
@@ -12390,6 +12396,229 @@ var ConvertResultSchema = object({
12390
12396
  files: array(string()).readonly()
12391
12397
  })).readonly()
12392
12398
  });
12399
+ /**
12400
+ * Zod schemas for persisted record types.
12401
+ *
12402
+ * These schemas serve as the single source of truth for types that are
12403
+ * stored in the settings-store backend and retrieved via tRPC. They
12404
+ * replace the manual TypeScript interfaces with schema-derived types,
12405
+ * enabling runtime validation when reading from the backend.
12406
+ *
12407
+ * Convention: each schema is named `<Type>Schema`, the inferred TS type
12408
+ * keeps the original name for backward compatibility.
12409
+ */
12410
+ /**
12411
+ * Auth model (v2 — 2026-05-12 caps-only):
12412
+ *
12413
+ * Two principals:
12414
+ * - `isAdmin: true` — full bypass. Admin scope set is ignored.
12415
+ * - `isAdmin: false` — every call gated by `scopes` (see TokenScope).
12416
+ *
12417
+ * No role enum. There used to be `viewer / agent / scoped` and earlier
12418
+ * `super_admin` — collapsed onto the single boolean because every
12419
+ * non-admin caller is governed by the same scope-check rules; the
12420
+ * distinction was only ever used to route role-specific procedures
12421
+ * which we no longer have. CLI / webhook integrations are `cst_*` tokens
12422
+ * with `isAdmin: false` + an explicit scope list.
12423
+ */
12424
+ /** Per-method access flavour. Materialised on every cap method via codegen. */
12425
+ var MethodAccessSchema = _enum([
12426
+ "view",
12427
+ "create",
12428
+ "delete"
12429
+ ]);
12430
+ /**
12431
+ * A single scope grant. Three forms — checked in matcher with OR
12432
+ * semantics; the first match decides whether the call passes:
12433
+ *
12434
+ * - `category` — broadest. `target: 'device' | 'system'` selects every
12435
+ * cap with the matching `scope` declaration. New caps inherit grants
12436
+ * automatically — adding a device cap to the codebase makes it
12437
+ * reachable to every user with `category:device [...]` without a
12438
+ * re-grant. Use this for "family viewer" / "operator" tiers.
12439
+ *
12440
+ * - `addon` — every cap that ships inside a given addon id. Niche;
12441
+ * useful when an integration needs to interact with one specific
12442
+ * addon's surface regardless of how many caps it exports.
12443
+ *
12444
+ * - `capability` — the most precise form. Single cap name. Use for
12445
+ * integration tokens where you want to grant `addons.installPackage`
12446
+ * and nothing else.
12447
+ *
12448
+ * `access` is REQUIRED with min 1 element. `admin` bypass is the
12449
+ * "give me everything" escape; there is no wildcard scope.
12450
+ */
12451
+ var AllowedProviderSchema = union([literal("*"), array(string())]);
12452
+ var AllowedDevicesSchema = record(string(), union([literal("*"), array(string())]));
12453
+ var CapScopeSchema = _enum(["device", "system"]);
12454
+ /**
12455
+ * DeviceSelector (scope model v3 — 2026-08-12).
12456
+ *
12457
+ * A `device` grant no longer carries a frozen list of deviceIds. It carries
12458
+ * a SELECTOR the matcher resolves against the live fleet, so the grant can be
12459
+ * DYNAMIC: a `types:['camera']` selector automatically covers a camera added
12460
+ * AFTER the grant was minted — no re-grant, no re-login.
12461
+ *
12462
+ * - `all` — every device in the deployment. The broad viewer/operator
12463
+ * lever without a `category` grant (a `category` grant also covers device
12464
+ * caps that carry no deviceId; `all` is specifically the device set).
12465
+ * - `ids` — an explicit deviceId list. This is what a v2 `device:[…]`
12466
+ * grant migrates to (see {@link TokenScopeSchema}); STATIC — a new camera
12467
+ * is NOT covered until the grant is edited.
12468
+ * - `types` — every device of a `DeviceType` (e.g. every `camera`).
12469
+ * DYNAMIC. A device that changes type, or a new device of the type,
12470
+ * re-resolves on the next request.
12471
+ * - `locations` — every device whose operator-assigned `location` label is
12472
+ * in the set (e.g. "Garden", "Front door"). DYNAMIC. A device with a
12473
+ * null/unset location matches NO `locations` selector.
12474
+ */
12475
+ var DeviceSelectorSchema = discriminatedUnion("kind", [
12476
+ object({ kind: literal("all") }),
12477
+ object({
12478
+ kind: literal("ids"),
12479
+ ids: array(number().int()).min(1)
12480
+ }),
12481
+ object({
12482
+ kind: literal("types"),
12483
+ types: array(_enum(DeviceType)).min(1)
12484
+ }),
12485
+ object({
12486
+ kind: literal("locations"),
12487
+ locations: array(string().min(1)).min(1)
12488
+ })
12489
+ ]);
12490
+ var DeviceTokenScopeSchema = object({
12491
+ type: literal("device"),
12492
+ /** The device SET this grant covers — resolved against the live fleet. */
12493
+ selector: DeviceSelectorSchema,
12494
+ access: array(MethodAccessSchema).min(1),
12495
+ /**
12496
+ * Whether a grant on a PARENT device transparently covers its accessory
12497
+ * CHILDREN (siren / floodlight / PIR) via the persisted-parentage walk.
12498
+ * Direction is parent → children ONLY.
12499
+ *
12500
+ * Absent → the matcher DERIVES it from the access flavour: `view`
12501
+ * inherits (a camera viewer sees the camera's accessories), `create` /
12502
+ * `delete` do NOT (actuating/removing a child is an explicit act the
12503
+ * operator must grant on the child, not inherit from the parent). Set it
12504
+ * explicitly to override that default per grant.
12505
+ */
12506
+ includeLinked: boolean().optional()
12507
+ });
12508
+ /**
12509
+ * v2 → v3 lazy migration. A pre-v3 `device` grant carried
12510
+ * `targets: string[]` (stringified deviceIds); it rewrites to the equivalent
12511
+ * `selector: {kind:'ids', ids}`. Applied as a `preprocess` so it runs on
12512
+ * EVERY parse path — stored records AND the JWT-carried scope arrays
12513
+ * normalised at the request boundary ({@link normalizeTokenScopes} in
12514
+ * `device-selector.ts`). Chosen over a one-time DB migration because a
12515
+ * migration cannot reach a JWT already in a client's hands; parse-time
12516
+ * migration covers both without a flag day. No cast — the raw object is read
12517
+ * through `Reflect.get` (its static type is `unknown`).
12518
+ */
12519
+ function migrateLegacyTokenScope(raw) {
12520
+ if (raw === null || typeof raw !== "object" || Array.isArray(raw)) return raw;
12521
+ if (Reflect.get(raw, "type") !== "device") return raw;
12522
+ if (Reflect.get(raw, "selector") !== void 0) return raw;
12523
+ const targets = Reflect.get(raw, "targets");
12524
+ if (!Array.isArray(targets)) return raw;
12525
+ return {
12526
+ type: "device",
12527
+ selector: {
12528
+ kind: "ids",
12529
+ ids: targets.map((t) => typeof t === "string" ? Number(t) : t).filter((n) => typeof n === "number" && Number.isInteger(n))
12530
+ },
12531
+ access: Reflect.get(raw, "access")
12532
+ };
12533
+ }
12534
+ var TokenScopeSchema = preprocess(migrateLegacyTokenScope, discriminatedUnion("type", [
12535
+ object({
12536
+ type: literal("category"),
12537
+ target: CapScopeSchema,
12538
+ access: array(MethodAccessSchema).min(1)
12539
+ }),
12540
+ object({
12541
+ type: literal("capability"),
12542
+ target: string(),
12543
+ access: array(MethodAccessSchema).min(1)
12544
+ }),
12545
+ object({
12546
+ type: literal("addon"),
12547
+ target: string(),
12548
+ access: array(MethodAccessSchema).min(1)
12549
+ }),
12550
+ DeviceTokenScopeSchema
12551
+ ]));
12552
+ object({
12553
+ id: string(),
12554
+ username: string(),
12555
+ passwordHash: string(),
12556
+ /**
12557
+ * Admin bypass. When true, the middleware skips the scope-access
12558
+ * check entirely. There is no other axis of privilege; the legacy
12559
+ * role enum collapsed onto this boolean in v2.
12560
+ */
12561
+ isAdmin: boolean().default(false),
12562
+ allowedProviders: AllowedProviderSchema,
12563
+ allowedDevices: AllowedDevicesSchema,
12564
+ /**
12565
+ * Scopes granted to this user. Admins bypass; their `scopes` is
12566
+ * ignored. Non-admins without scopes are locked out of every
12567
+ * protected call.
12568
+ */
12569
+ scopes: array(TokenScopeSchema).default([]),
12570
+ createdAt: number(),
12571
+ updatedAt: number()
12572
+ });
12573
+ object({
12574
+ id: string(),
12575
+ label: string(),
12576
+ isAdmin: boolean().default(false),
12577
+ allowedProviders: AllowedProviderSchema,
12578
+ allowedDevices: AllowedDevicesSchema,
12579
+ tokenHash: string(),
12580
+ tokenPrefix: string(),
12581
+ createdAt: number(),
12582
+ lastUsedAt: number().optional()
12583
+ });
12584
+ object({
12585
+ id: string(),
12586
+ userId: string(),
12587
+ name: string(),
12588
+ tokenHash: string(),
12589
+ tokenPrefix: string(),
12590
+ scopes: array(TokenScopeSchema),
12591
+ expiresAt: number().nullish(),
12592
+ lastUsedAt: number().nullish(),
12593
+ createdAt: number()
12594
+ });
12595
+ /** What a share-view grant lets its holder see. */
12596
+ var ShareViewGrantSchema = object({
12597
+ kind: _enum(SHARE_VIEW_KINDS),
12598
+ deviceIds: array(number().int().nonnegative()).min(1).max(64),
12599
+ /** Talk-back, opt-in at mint time; absent means off. */
12600
+ talk: boolean().optional()
12601
+ });
12602
+ var ShareViewScopeSchema = object({
12603
+ type: literal("share-view"),
12604
+ grant: ShareViewGrantSchema
12605
+ });
12606
+ var AddonRoutesScopeSchema = object({
12607
+ type: literal("addon-routes"),
12608
+ access: array(MethodAccessSchema).min(1)
12609
+ });
12610
+ var CredentialScopeSchema = union([
12611
+ literal("*"),
12612
+ ShareViewScopeSchema,
12613
+ AddonRoutesScopeSchema,
12614
+ TokenScopeSchema
12615
+ ]);
12616
+ object({
12617
+ kind: literal("credential"),
12618
+ sub: string().min(1),
12619
+ jti: string().min(16),
12620
+ scopes: array(CredentialScopeSchema).min(1)
12621
+ });
12393
12622
  _enum(["new-session", "step-up"]);
12394
12623
  /** The languages the hub's app landing pages are written in (D858). */
12395
12624
  var AppPageLangSchema = _enum(["en", "it"]);
@@ -43645,202 +43874,6 @@ method(object({}), object({ rules: array(NcRuleSchema) }), { auth: "admin" }), m
43645
43874
  auth: "admin"
43646
43875
  }), method(NcAlarmSensorsInputSchema, NcAlarmSensorsSchema, { auth: "admin" });
43647
43876
  /**
43648
- * Zod schemas for persisted record types.
43649
- *
43650
- * These schemas serve as the single source of truth for types that are
43651
- * stored in the settings-store backend and retrieved via tRPC. They
43652
- * replace the manual TypeScript interfaces with schema-derived types,
43653
- * enabling runtime validation when reading from the backend.
43654
- *
43655
- * Convention: each schema is named `<Type>Schema`, the inferred TS type
43656
- * keeps the original name for backward compatibility.
43657
- */
43658
- /**
43659
- * Auth model (v2 — 2026-05-12 caps-only):
43660
- *
43661
- * Two principals:
43662
- * - `isAdmin: true` — full bypass. Admin scope set is ignored.
43663
- * - `isAdmin: false` — every call gated by `scopes` (see TokenScope).
43664
- *
43665
- * No role enum. There used to be `viewer / agent / scoped` and earlier
43666
- * `super_admin` — collapsed onto the single boolean because every
43667
- * non-admin caller is governed by the same scope-check rules; the
43668
- * distinction was only ever used to route role-specific procedures
43669
- * which we no longer have. CLI / webhook integrations are `cst_*` tokens
43670
- * with `isAdmin: false` + an explicit scope list.
43671
- */
43672
- /** Per-method access flavour. Materialised on every cap method via codegen. */
43673
- var MethodAccessSchema = _enum([
43674
- "view",
43675
- "create",
43676
- "delete"
43677
- ]);
43678
- /**
43679
- * A single scope grant. Three forms — checked in matcher with OR
43680
- * semantics; the first match decides whether the call passes:
43681
- *
43682
- * - `category` — broadest. `target: 'device' | 'system'` selects every
43683
- * cap with the matching `scope` declaration. New caps inherit grants
43684
- * automatically — adding a device cap to the codebase makes it
43685
- * reachable to every user with `category:device [...]` without a
43686
- * re-grant. Use this for "family viewer" / "operator" tiers.
43687
- *
43688
- * - `addon` — every cap that ships inside a given addon id. Niche;
43689
- * useful when an integration needs to interact with one specific
43690
- * addon's surface regardless of how many caps it exports.
43691
- *
43692
- * - `capability` — the most precise form. Single cap name. Use for
43693
- * integration tokens where you want to grant `addons.installPackage`
43694
- * and nothing else.
43695
- *
43696
- * `access` is REQUIRED with min 1 element. `admin` bypass is the
43697
- * "give me everything" escape; there is no wildcard scope.
43698
- */
43699
- var AllowedProviderSchema = union([literal("*"), array(string())]);
43700
- var AllowedDevicesSchema = record(string(), union([literal("*"), array(string())]));
43701
- var CapScopeSchema = _enum(["device", "system"]);
43702
- /**
43703
- * DeviceSelector (scope model v3 — 2026-08-12).
43704
- *
43705
- * A `device` grant no longer carries a frozen list of deviceIds. It carries
43706
- * a SELECTOR the matcher resolves against the live fleet, so the grant can be
43707
- * DYNAMIC: a `types:['camera']` selector automatically covers a camera added
43708
- * AFTER the grant was minted — no re-grant, no re-login.
43709
- *
43710
- * - `all` — every device in the deployment. The broad viewer/operator
43711
- * lever without a `category` grant (a `category` grant also covers device
43712
- * caps that carry no deviceId; `all` is specifically the device set).
43713
- * - `ids` — an explicit deviceId list. This is what a v2 `device:[…]`
43714
- * grant migrates to (see {@link TokenScopeSchema}); STATIC — a new camera
43715
- * is NOT covered until the grant is edited.
43716
- * - `types` — every device of a `DeviceType` (e.g. every `camera`).
43717
- * DYNAMIC. A device that changes type, or a new device of the type,
43718
- * re-resolves on the next request.
43719
- * - `locations` — every device whose operator-assigned `location` label is
43720
- * in the set (e.g. "Garden", "Front door"). DYNAMIC. A device with a
43721
- * null/unset location matches NO `locations` selector.
43722
- */
43723
- var DeviceSelectorSchema = discriminatedUnion("kind", [
43724
- object({ kind: literal("all") }),
43725
- object({
43726
- kind: literal("ids"),
43727
- ids: array(number().int()).min(1)
43728
- }),
43729
- object({
43730
- kind: literal("types"),
43731
- types: array(_enum(DeviceType)).min(1)
43732
- }),
43733
- object({
43734
- kind: literal("locations"),
43735
- locations: array(string().min(1)).min(1)
43736
- })
43737
- ]);
43738
- var DeviceTokenScopeSchema = object({
43739
- type: literal("device"),
43740
- /** The device SET this grant covers — resolved against the live fleet. */
43741
- selector: DeviceSelectorSchema,
43742
- access: array(MethodAccessSchema).min(1),
43743
- /**
43744
- * Whether a grant on a PARENT device transparently covers its accessory
43745
- * CHILDREN (siren / floodlight / PIR) via the persisted-parentage walk.
43746
- * Direction is parent → children ONLY.
43747
- *
43748
- * Absent → the matcher DERIVES it from the access flavour: `view`
43749
- * inherits (a camera viewer sees the camera's accessories), `create` /
43750
- * `delete` do NOT (actuating/removing a child is an explicit act the
43751
- * operator must grant on the child, not inherit from the parent). Set it
43752
- * explicitly to override that default per grant.
43753
- */
43754
- includeLinked: boolean().optional()
43755
- });
43756
- /**
43757
- * v2 → v3 lazy migration. A pre-v3 `device` grant carried
43758
- * `targets: string[]` (stringified deviceIds); it rewrites to the equivalent
43759
- * `selector: {kind:'ids', ids}`. Applied as a `preprocess` so it runs on
43760
- * EVERY parse path — stored records AND the JWT-carried scope arrays
43761
- * normalised at the request boundary ({@link normalizeTokenScopes} in
43762
- * `device-selector.ts`). Chosen over a one-time DB migration because a
43763
- * migration cannot reach a JWT already in a client's hands; parse-time
43764
- * migration covers both without a flag day. No cast — the raw object is read
43765
- * through `Reflect.get` (its static type is `unknown`).
43766
- */
43767
- function migrateLegacyTokenScope(raw) {
43768
- if (raw === null || typeof raw !== "object" || Array.isArray(raw)) return raw;
43769
- if (Reflect.get(raw, "type") !== "device") return raw;
43770
- if (Reflect.get(raw, "selector") !== void 0) return raw;
43771
- const targets = Reflect.get(raw, "targets");
43772
- if (!Array.isArray(targets)) return raw;
43773
- return {
43774
- type: "device",
43775
- selector: {
43776
- kind: "ids",
43777
- ids: targets.map((t) => typeof t === "string" ? Number(t) : t).filter((n) => typeof n === "number" && Number.isInteger(n))
43778
- },
43779
- access: Reflect.get(raw, "access")
43780
- };
43781
- }
43782
- var TokenScopeSchema = preprocess(migrateLegacyTokenScope, discriminatedUnion("type", [
43783
- object({
43784
- type: literal("category"),
43785
- target: CapScopeSchema,
43786
- access: array(MethodAccessSchema).min(1)
43787
- }),
43788
- object({
43789
- type: literal("capability"),
43790
- target: string(),
43791
- access: array(MethodAccessSchema).min(1)
43792
- }),
43793
- object({
43794
- type: literal("addon"),
43795
- target: string(),
43796
- access: array(MethodAccessSchema).min(1)
43797
- }),
43798
- DeviceTokenScopeSchema
43799
- ]));
43800
- object({
43801
- id: string(),
43802
- username: string(),
43803
- passwordHash: string(),
43804
- /**
43805
- * Admin bypass. When true, the middleware skips the scope-access
43806
- * check entirely. There is no other axis of privilege; the legacy
43807
- * role enum collapsed onto this boolean in v2.
43808
- */
43809
- isAdmin: boolean().default(false),
43810
- allowedProviders: AllowedProviderSchema,
43811
- allowedDevices: AllowedDevicesSchema,
43812
- /**
43813
- * Scopes granted to this user. Admins bypass; their `scopes` is
43814
- * ignored. Non-admins without scopes are locked out of every
43815
- * protected call.
43816
- */
43817
- scopes: array(TokenScopeSchema).default([]),
43818
- createdAt: number(),
43819
- updatedAt: number()
43820
- });
43821
- object({
43822
- id: string(),
43823
- label: string(),
43824
- isAdmin: boolean().default(false),
43825
- allowedProviders: AllowedProviderSchema,
43826
- allowedDevices: AllowedDevicesSchema,
43827
- tokenHash: string(),
43828
- tokenPrefix: string(),
43829
- createdAt: number(),
43830
- lastUsedAt: number().optional()
43831
- });
43832
- object({
43833
- id: string(),
43834
- userId: string(),
43835
- name: string(),
43836
- tokenHash: string(),
43837
- tokenPrefix: string(),
43838
- scopes: array(TokenScopeSchema),
43839
- expiresAt: number().nullish(),
43840
- lastUsedAt: number().nullish(),
43841
- createdAt: number()
43842
- });
43843
- /**
43844
43877
  * `oauth-integration` — a collection cap by which an addon declares
43845
43878
  * itself a linkable OAuth client of the hub's core `/oauth2/*` server.
43846
43879
  * 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-decoder-nodeav",
3
- "version": "1.2.125",
3
+ "version": "1.2.126",
4
4
  "description": "Standalone in-process node-av decoder addon for CamStack",
5
5
  "keywords": [
6
6
  "camstack",