@camstack/addon-provider-hikvision 1.2.155 → 1.2.156

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
@@ -7831,6 +7831,12 @@ function normalizeAddonInitResult(result) {
7831
7831
  if (Array.isArray(result)) return { providers: result };
7832
7832
  return result;
7833
7833
  }
7834
+ /**
7835
+ * The share-view scope kinds a `csv_*` share token can carry. The hub mints
7836
+ * and validates them (`share-token.service.ts` builds its enum from this
7837
+ * list); a data plane names the kinds it ACCEPTS in `share`.
7838
+ */
7839
+ var SHARE_VIEW_KINDS = ["grid-view", "events-view"];
7834
7840
  /** The wire shape of {@link PeerBytesTicket} — see the type for what it is. */
7835
7841
  var PeerBytesTicketSchema = object({
7836
7842
  /** `http://127.0.0.1:<port>/<token>`. One `GET` takes it. */
@@ -12813,6 +12819,229 @@ var ConvertResultSchema = object({
12813
12819
  files: array(string()).readonly()
12814
12820
  })).readonly()
12815
12821
  });
12822
+ /**
12823
+ * Zod schemas for persisted record types.
12824
+ *
12825
+ * These schemas serve as the single source of truth for types that are
12826
+ * stored in the settings-store backend and retrieved via tRPC. They
12827
+ * replace the manual TypeScript interfaces with schema-derived types,
12828
+ * enabling runtime validation when reading from the backend.
12829
+ *
12830
+ * Convention: each schema is named `<Type>Schema`, the inferred TS type
12831
+ * keeps the original name for backward compatibility.
12832
+ */
12833
+ /**
12834
+ * Auth model (v2 — 2026-05-12 caps-only):
12835
+ *
12836
+ * Two principals:
12837
+ * - `isAdmin: true` — full bypass. Admin scope set is ignored.
12838
+ * - `isAdmin: false` — every call gated by `scopes` (see TokenScope).
12839
+ *
12840
+ * No role enum. There used to be `viewer / agent / scoped` and earlier
12841
+ * `super_admin` — collapsed onto the single boolean because every
12842
+ * non-admin caller is governed by the same scope-check rules; the
12843
+ * distinction was only ever used to route role-specific procedures
12844
+ * which we no longer have. CLI / webhook integrations are `cst_*` tokens
12845
+ * with `isAdmin: false` + an explicit scope list.
12846
+ */
12847
+ /** Per-method access flavour. Materialised on every cap method via codegen. */
12848
+ var MethodAccessSchema = _enum([
12849
+ "view",
12850
+ "create",
12851
+ "delete"
12852
+ ]);
12853
+ /**
12854
+ * A single scope grant. Three forms — checked in matcher with OR
12855
+ * semantics; the first match decides whether the call passes:
12856
+ *
12857
+ * - `category` — broadest. `target: 'device' | 'system'` selects every
12858
+ * cap with the matching `scope` declaration. New caps inherit grants
12859
+ * automatically — adding a device cap to the codebase makes it
12860
+ * reachable to every user with `category:device [...]` without a
12861
+ * re-grant. Use this for "family viewer" / "operator" tiers.
12862
+ *
12863
+ * - `addon` — every cap that ships inside a given addon id. Niche;
12864
+ * useful when an integration needs to interact with one specific
12865
+ * addon's surface regardless of how many caps it exports.
12866
+ *
12867
+ * - `capability` — the most precise form. Single cap name. Use for
12868
+ * integration tokens where you want to grant `addons.installPackage`
12869
+ * and nothing else.
12870
+ *
12871
+ * `access` is REQUIRED with min 1 element. `admin` bypass is the
12872
+ * "give me everything" escape; there is no wildcard scope.
12873
+ */
12874
+ var AllowedProviderSchema = union([literal("*"), array(string())]);
12875
+ var AllowedDevicesSchema = record(string(), union([literal("*"), array(string())]));
12876
+ var CapScopeSchema = _enum(["device", "system"]);
12877
+ /**
12878
+ * DeviceSelector (scope model v3 — 2026-08-12).
12879
+ *
12880
+ * A `device` grant no longer carries a frozen list of deviceIds. It carries
12881
+ * a SELECTOR the matcher resolves against the live fleet, so the grant can be
12882
+ * DYNAMIC: a `types:['camera']` selector automatically covers a camera added
12883
+ * AFTER the grant was minted — no re-grant, no re-login.
12884
+ *
12885
+ * - `all` — every device in the deployment. The broad viewer/operator
12886
+ * lever without a `category` grant (a `category` grant also covers device
12887
+ * caps that carry no deviceId; `all` is specifically the device set).
12888
+ * - `ids` — an explicit deviceId list. This is what a v2 `device:[…]`
12889
+ * grant migrates to (see {@link TokenScopeSchema}); STATIC — a new camera
12890
+ * is NOT covered until the grant is edited.
12891
+ * - `types` — every device of a `DeviceType` (e.g. every `camera`).
12892
+ * DYNAMIC. A device that changes type, or a new device of the type,
12893
+ * re-resolves on the next request.
12894
+ * - `locations` — every device whose operator-assigned `location` label is
12895
+ * in the set (e.g. "Garden", "Front door"). DYNAMIC. A device with a
12896
+ * null/unset location matches NO `locations` selector.
12897
+ */
12898
+ var DeviceSelectorSchema = discriminatedUnion("kind", [
12899
+ object({ kind: literal("all") }),
12900
+ object({
12901
+ kind: literal("ids"),
12902
+ ids: array(number().int()).min(1)
12903
+ }),
12904
+ object({
12905
+ kind: literal("types"),
12906
+ types: array(_enum(DeviceType)).min(1)
12907
+ }),
12908
+ object({
12909
+ kind: literal("locations"),
12910
+ locations: array(string().min(1)).min(1)
12911
+ })
12912
+ ]);
12913
+ var DeviceTokenScopeSchema = object({
12914
+ type: literal("device"),
12915
+ /** The device SET this grant covers — resolved against the live fleet. */
12916
+ selector: DeviceSelectorSchema,
12917
+ access: array(MethodAccessSchema).min(1),
12918
+ /**
12919
+ * Whether a grant on a PARENT device transparently covers its accessory
12920
+ * CHILDREN (siren / floodlight / PIR) via the persisted-parentage walk.
12921
+ * Direction is parent → children ONLY.
12922
+ *
12923
+ * Absent → the matcher DERIVES it from the access flavour: `view`
12924
+ * inherits (a camera viewer sees the camera's accessories), `create` /
12925
+ * `delete` do NOT (actuating/removing a child is an explicit act the
12926
+ * operator must grant on the child, not inherit from the parent). Set it
12927
+ * explicitly to override that default per grant.
12928
+ */
12929
+ includeLinked: boolean().optional()
12930
+ });
12931
+ /**
12932
+ * v2 → v3 lazy migration. A pre-v3 `device` grant carried
12933
+ * `targets: string[]` (stringified deviceIds); it rewrites to the equivalent
12934
+ * `selector: {kind:'ids', ids}`. Applied as a `preprocess` so it runs on
12935
+ * EVERY parse path — stored records AND the JWT-carried scope arrays
12936
+ * normalised at the request boundary ({@link normalizeTokenScopes} in
12937
+ * `device-selector.ts`). Chosen over a one-time DB migration because a
12938
+ * migration cannot reach a JWT already in a client's hands; parse-time
12939
+ * migration covers both without a flag day. No cast — the raw object is read
12940
+ * through `Reflect.get` (its static type is `unknown`).
12941
+ */
12942
+ function migrateLegacyTokenScope(raw) {
12943
+ if (raw === null || typeof raw !== "object" || Array.isArray(raw)) return raw;
12944
+ if (Reflect.get(raw, "type") !== "device") return raw;
12945
+ if (Reflect.get(raw, "selector") !== void 0) return raw;
12946
+ const targets = Reflect.get(raw, "targets");
12947
+ if (!Array.isArray(targets)) return raw;
12948
+ return {
12949
+ type: "device",
12950
+ selector: {
12951
+ kind: "ids",
12952
+ ids: targets.map((t) => typeof t === "string" ? Number(t) : t).filter((n) => typeof n === "number" && Number.isInteger(n))
12953
+ },
12954
+ access: Reflect.get(raw, "access")
12955
+ };
12956
+ }
12957
+ var TokenScopeSchema = preprocess(migrateLegacyTokenScope, discriminatedUnion("type", [
12958
+ object({
12959
+ type: literal("category"),
12960
+ target: CapScopeSchema,
12961
+ access: array(MethodAccessSchema).min(1)
12962
+ }),
12963
+ object({
12964
+ type: literal("capability"),
12965
+ target: string(),
12966
+ access: array(MethodAccessSchema).min(1)
12967
+ }),
12968
+ object({
12969
+ type: literal("addon"),
12970
+ target: string(),
12971
+ access: array(MethodAccessSchema).min(1)
12972
+ }),
12973
+ DeviceTokenScopeSchema
12974
+ ]));
12975
+ object({
12976
+ id: string(),
12977
+ username: string(),
12978
+ passwordHash: string(),
12979
+ /**
12980
+ * Admin bypass. When true, the middleware skips the scope-access
12981
+ * check entirely. There is no other axis of privilege; the legacy
12982
+ * role enum collapsed onto this boolean in v2.
12983
+ */
12984
+ isAdmin: boolean().default(false),
12985
+ allowedProviders: AllowedProviderSchema,
12986
+ allowedDevices: AllowedDevicesSchema,
12987
+ /**
12988
+ * Scopes granted to this user. Admins bypass; their `scopes` is
12989
+ * ignored. Non-admins without scopes are locked out of every
12990
+ * protected call.
12991
+ */
12992
+ scopes: array(TokenScopeSchema).default([]),
12993
+ createdAt: number(),
12994
+ updatedAt: number()
12995
+ });
12996
+ object({
12997
+ id: string(),
12998
+ label: string(),
12999
+ isAdmin: boolean().default(false),
13000
+ allowedProviders: AllowedProviderSchema,
13001
+ allowedDevices: AllowedDevicesSchema,
13002
+ tokenHash: string(),
13003
+ tokenPrefix: string(),
13004
+ createdAt: number(),
13005
+ lastUsedAt: number().optional()
13006
+ });
13007
+ object({
13008
+ id: string(),
13009
+ userId: string(),
13010
+ name: string(),
13011
+ tokenHash: string(),
13012
+ tokenPrefix: string(),
13013
+ scopes: array(TokenScopeSchema),
13014
+ expiresAt: number().nullish(),
13015
+ lastUsedAt: number().nullish(),
13016
+ createdAt: number()
13017
+ });
13018
+ /** What a share-view grant lets its holder see. */
13019
+ var ShareViewGrantSchema = object({
13020
+ kind: _enum(SHARE_VIEW_KINDS),
13021
+ deviceIds: array(number().int().nonnegative()).min(1).max(64),
13022
+ /** Talk-back, opt-in at mint time; absent means off. */
13023
+ talk: boolean().optional()
13024
+ });
13025
+ var ShareViewScopeSchema = object({
13026
+ type: literal("share-view"),
13027
+ grant: ShareViewGrantSchema
13028
+ });
13029
+ var AddonRoutesScopeSchema = object({
13030
+ type: literal("addon-routes"),
13031
+ access: array(MethodAccessSchema).min(1)
13032
+ });
13033
+ var CredentialScopeSchema = union([
13034
+ literal("*"),
13035
+ ShareViewScopeSchema,
13036
+ AddonRoutesScopeSchema,
13037
+ TokenScopeSchema
13038
+ ]);
13039
+ object({
13040
+ kind: literal("credential"),
13041
+ sub: string().min(1),
13042
+ jti: string().min(16),
13043
+ scopes: array(CredentialScopeSchema).min(1)
13044
+ });
12816
13045
  _enum(["new-session", "step-up"]);
12817
13046
  /** The languages the hub's app landing pages are written in (D858). */
12818
13047
  var AppPageLangSchema = _enum(["en", "it"]);
@@ -44422,202 +44651,6 @@ method(object({}), object({ rules: array(NcRuleSchema) }), { auth: "admin" }), m
44422
44651
  auth: "admin"
44423
44652
  }), method(NcAlarmSensorsInputSchema, NcAlarmSensorsSchema, { auth: "admin" });
44424
44653
  /**
44425
- * Zod schemas for persisted record types.
44426
- *
44427
- * These schemas serve as the single source of truth for types that are
44428
- * stored in the settings-store backend and retrieved via tRPC. They
44429
- * replace the manual TypeScript interfaces with schema-derived types,
44430
- * enabling runtime validation when reading from the backend.
44431
- *
44432
- * Convention: each schema is named `<Type>Schema`, the inferred TS type
44433
- * keeps the original name for backward compatibility.
44434
- */
44435
- /**
44436
- * Auth model (v2 — 2026-05-12 caps-only):
44437
- *
44438
- * Two principals:
44439
- * - `isAdmin: true` — full bypass. Admin scope set is ignored.
44440
- * - `isAdmin: false` — every call gated by `scopes` (see TokenScope).
44441
- *
44442
- * No role enum. There used to be `viewer / agent / scoped` and earlier
44443
- * `super_admin` — collapsed onto the single boolean because every
44444
- * non-admin caller is governed by the same scope-check rules; the
44445
- * distinction was only ever used to route role-specific procedures
44446
- * which we no longer have. CLI / webhook integrations are `cst_*` tokens
44447
- * with `isAdmin: false` + an explicit scope list.
44448
- */
44449
- /** Per-method access flavour. Materialised on every cap method via codegen. */
44450
- var MethodAccessSchema = _enum([
44451
- "view",
44452
- "create",
44453
- "delete"
44454
- ]);
44455
- /**
44456
- * A single scope grant. Three forms — checked in matcher with OR
44457
- * semantics; the first match decides whether the call passes:
44458
- *
44459
- * - `category` — broadest. `target: 'device' | 'system'` selects every
44460
- * cap with the matching `scope` declaration. New caps inherit grants
44461
- * automatically — adding a device cap to the codebase makes it
44462
- * reachable to every user with `category:device [...]` without a
44463
- * re-grant. Use this for "family viewer" / "operator" tiers.
44464
- *
44465
- * - `addon` — every cap that ships inside a given addon id. Niche;
44466
- * useful when an integration needs to interact with one specific
44467
- * addon's surface regardless of how many caps it exports.
44468
- *
44469
- * - `capability` — the most precise form. Single cap name. Use for
44470
- * integration tokens where you want to grant `addons.installPackage`
44471
- * and nothing else.
44472
- *
44473
- * `access` is REQUIRED with min 1 element. `admin` bypass is the
44474
- * "give me everything" escape; there is no wildcard scope.
44475
- */
44476
- var AllowedProviderSchema = union([literal("*"), array(string())]);
44477
- var AllowedDevicesSchema = record(string(), union([literal("*"), array(string())]));
44478
- var CapScopeSchema = _enum(["device", "system"]);
44479
- /**
44480
- * DeviceSelector (scope model v3 — 2026-08-12).
44481
- *
44482
- * A `device` grant no longer carries a frozen list of deviceIds. It carries
44483
- * a SELECTOR the matcher resolves against the live fleet, so the grant can be
44484
- * DYNAMIC: a `types:['camera']` selector automatically covers a camera added
44485
- * AFTER the grant was minted — no re-grant, no re-login.
44486
- *
44487
- * - `all` — every device in the deployment. The broad viewer/operator
44488
- * lever without a `category` grant (a `category` grant also covers device
44489
- * caps that carry no deviceId; `all` is specifically the device set).
44490
- * - `ids` — an explicit deviceId list. This is what a v2 `device:[…]`
44491
- * grant migrates to (see {@link TokenScopeSchema}); STATIC — a new camera
44492
- * is NOT covered until the grant is edited.
44493
- * - `types` — every device of a `DeviceType` (e.g. every `camera`).
44494
- * DYNAMIC. A device that changes type, or a new device of the type,
44495
- * re-resolves on the next request.
44496
- * - `locations` — every device whose operator-assigned `location` label is
44497
- * in the set (e.g. "Garden", "Front door"). DYNAMIC. A device with a
44498
- * null/unset location matches NO `locations` selector.
44499
- */
44500
- var DeviceSelectorSchema = discriminatedUnion("kind", [
44501
- object({ kind: literal("all") }),
44502
- object({
44503
- kind: literal("ids"),
44504
- ids: array(number().int()).min(1)
44505
- }),
44506
- object({
44507
- kind: literal("types"),
44508
- types: array(_enum(DeviceType)).min(1)
44509
- }),
44510
- object({
44511
- kind: literal("locations"),
44512
- locations: array(string().min(1)).min(1)
44513
- })
44514
- ]);
44515
- var DeviceTokenScopeSchema = object({
44516
- type: literal("device"),
44517
- /** The device SET this grant covers — resolved against the live fleet. */
44518
- selector: DeviceSelectorSchema,
44519
- access: array(MethodAccessSchema).min(1),
44520
- /**
44521
- * Whether a grant on a PARENT device transparently covers its accessory
44522
- * CHILDREN (siren / floodlight / PIR) via the persisted-parentage walk.
44523
- * Direction is parent → children ONLY.
44524
- *
44525
- * Absent → the matcher DERIVES it from the access flavour: `view`
44526
- * inherits (a camera viewer sees the camera's accessories), `create` /
44527
- * `delete` do NOT (actuating/removing a child is an explicit act the
44528
- * operator must grant on the child, not inherit from the parent). Set it
44529
- * explicitly to override that default per grant.
44530
- */
44531
- includeLinked: boolean().optional()
44532
- });
44533
- /**
44534
- * v2 → v3 lazy migration. A pre-v3 `device` grant carried
44535
- * `targets: string[]` (stringified deviceIds); it rewrites to the equivalent
44536
- * `selector: {kind:'ids', ids}`. Applied as a `preprocess` so it runs on
44537
- * EVERY parse path — stored records AND the JWT-carried scope arrays
44538
- * normalised at the request boundary ({@link normalizeTokenScopes} in
44539
- * `device-selector.ts`). Chosen over a one-time DB migration because a
44540
- * migration cannot reach a JWT already in a client's hands; parse-time
44541
- * migration covers both without a flag day. No cast — the raw object is read
44542
- * through `Reflect.get` (its static type is `unknown`).
44543
- */
44544
- function migrateLegacyTokenScope(raw) {
44545
- if (raw === null || typeof raw !== "object" || Array.isArray(raw)) return raw;
44546
- if (Reflect.get(raw, "type") !== "device") return raw;
44547
- if (Reflect.get(raw, "selector") !== void 0) return raw;
44548
- const targets = Reflect.get(raw, "targets");
44549
- if (!Array.isArray(targets)) return raw;
44550
- return {
44551
- type: "device",
44552
- selector: {
44553
- kind: "ids",
44554
- ids: targets.map((t) => typeof t === "string" ? Number(t) : t).filter((n) => typeof n === "number" && Number.isInteger(n))
44555
- },
44556
- access: Reflect.get(raw, "access")
44557
- };
44558
- }
44559
- var TokenScopeSchema = preprocess(migrateLegacyTokenScope, discriminatedUnion("type", [
44560
- object({
44561
- type: literal("category"),
44562
- target: CapScopeSchema,
44563
- access: array(MethodAccessSchema).min(1)
44564
- }),
44565
- object({
44566
- type: literal("capability"),
44567
- target: string(),
44568
- access: array(MethodAccessSchema).min(1)
44569
- }),
44570
- object({
44571
- type: literal("addon"),
44572
- target: string(),
44573
- access: array(MethodAccessSchema).min(1)
44574
- }),
44575
- DeviceTokenScopeSchema
44576
- ]));
44577
- object({
44578
- id: string(),
44579
- username: string(),
44580
- passwordHash: string(),
44581
- /**
44582
- * Admin bypass. When true, the middleware skips the scope-access
44583
- * check entirely. There is no other axis of privilege; the legacy
44584
- * role enum collapsed onto this boolean in v2.
44585
- */
44586
- isAdmin: boolean().default(false),
44587
- allowedProviders: AllowedProviderSchema,
44588
- allowedDevices: AllowedDevicesSchema,
44589
- /**
44590
- * Scopes granted to this user. Admins bypass; their `scopes` is
44591
- * ignored. Non-admins without scopes are locked out of every
44592
- * protected call.
44593
- */
44594
- scopes: array(TokenScopeSchema).default([]),
44595
- createdAt: number(),
44596
- updatedAt: number()
44597
- });
44598
- object({
44599
- id: string(),
44600
- label: string(),
44601
- isAdmin: boolean().default(false),
44602
- allowedProviders: AllowedProviderSchema,
44603
- allowedDevices: AllowedDevicesSchema,
44604
- tokenHash: string(),
44605
- tokenPrefix: string(),
44606
- createdAt: number(),
44607
- lastUsedAt: number().optional()
44608
- });
44609
- object({
44610
- id: string(),
44611
- userId: string(),
44612
- name: string(),
44613
- tokenHash: string(),
44614
- tokenPrefix: string(),
44615
- scopes: array(TokenScopeSchema),
44616
- expiresAt: number().nullish(),
44617
- lastUsedAt: number().nullish(),
44618
- createdAt: number()
44619
- });
44620
- /**
44621
44654
  * `oauth-integration` — a collection cap by which an addon declares
44622
44655
  * itself a linkable OAuth client of the hub's core `/oauth2/*` server.
44623
44656
  * Each provider returns a static descriptor; the core enumerates them
package/dist/addon.mjs CHANGED
@@ -7810,6 +7810,12 @@ function normalizeAddonInitResult(result) {
7810
7810
  if (Array.isArray(result)) return { providers: result };
7811
7811
  return result;
7812
7812
  }
7813
+ /**
7814
+ * The share-view scope kinds a `csv_*` share token can carry. The hub mints
7815
+ * and validates them (`share-token.service.ts` builds its enum from this
7816
+ * list); a data plane names the kinds it ACCEPTS in `share`.
7817
+ */
7818
+ var SHARE_VIEW_KINDS = ["grid-view", "events-view"];
7813
7819
  /** The wire shape of {@link PeerBytesTicket} — see the type for what it is. */
7814
7820
  var PeerBytesTicketSchema = object({
7815
7821
  /** `http://127.0.0.1:<port>/<token>`. One `GET` takes it. */
@@ -12792,6 +12798,229 @@ var ConvertResultSchema = object({
12792
12798
  files: array(string()).readonly()
12793
12799
  })).readonly()
12794
12800
  });
12801
+ /**
12802
+ * Zod schemas for persisted record types.
12803
+ *
12804
+ * These schemas serve as the single source of truth for types that are
12805
+ * stored in the settings-store backend and retrieved via tRPC. They
12806
+ * replace the manual TypeScript interfaces with schema-derived types,
12807
+ * enabling runtime validation when reading from the backend.
12808
+ *
12809
+ * Convention: each schema is named `<Type>Schema`, the inferred TS type
12810
+ * keeps the original name for backward compatibility.
12811
+ */
12812
+ /**
12813
+ * Auth model (v2 — 2026-05-12 caps-only):
12814
+ *
12815
+ * Two principals:
12816
+ * - `isAdmin: true` — full bypass. Admin scope set is ignored.
12817
+ * - `isAdmin: false` — every call gated by `scopes` (see TokenScope).
12818
+ *
12819
+ * No role enum. There used to be `viewer / agent / scoped` and earlier
12820
+ * `super_admin` — collapsed onto the single boolean because every
12821
+ * non-admin caller is governed by the same scope-check rules; the
12822
+ * distinction was only ever used to route role-specific procedures
12823
+ * which we no longer have. CLI / webhook integrations are `cst_*` tokens
12824
+ * with `isAdmin: false` + an explicit scope list.
12825
+ */
12826
+ /** Per-method access flavour. Materialised on every cap method via codegen. */
12827
+ var MethodAccessSchema = _enum([
12828
+ "view",
12829
+ "create",
12830
+ "delete"
12831
+ ]);
12832
+ /**
12833
+ * A single scope grant. Three forms — checked in matcher with OR
12834
+ * semantics; the first match decides whether the call passes:
12835
+ *
12836
+ * - `category` — broadest. `target: 'device' | 'system'` selects every
12837
+ * cap with the matching `scope` declaration. New caps inherit grants
12838
+ * automatically — adding a device cap to the codebase makes it
12839
+ * reachable to every user with `category:device [...]` without a
12840
+ * re-grant. Use this for "family viewer" / "operator" tiers.
12841
+ *
12842
+ * - `addon` — every cap that ships inside a given addon id. Niche;
12843
+ * useful when an integration needs to interact with one specific
12844
+ * addon's surface regardless of how many caps it exports.
12845
+ *
12846
+ * - `capability` — the most precise form. Single cap name. Use for
12847
+ * integration tokens where you want to grant `addons.installPackage`
12848
+ * and nothing else.
12849
+ *
12850
+ * `access` is REQUIRED with min 1 element. `admin` bypass is the
12851
+ * "give me everything" escape; there is no wildcard scope.
12852
+ */
12853
+ var AllowedProviderSchema = union([literal("*"), array(string())]);
12854
+ var AllowedDevicesSchema = record(string(), union([literal("*"), array(string())]));
12855
+ var CapScopeSchema = _enum(["device", "system"]);
12856
+ /**
12857
+ * DeviceSelector (scope model v3 — 2026-08-12).
12858
+ *
12859
+ * A `device` grant no longer carries a frozen list of deviceIds. It carries
12860
+ * a SELECTOR the matcher resolves against the live fleet, so the grant can be
12861
+ * DYNAMIC: a `types:['camera']` selector automatically covers a camera added
12862
+ * AFTER the grant was minted — no re-grant, no re-login.
12863
+ *
12864
+ * - `all` — every device in the deployment. The broad viewer/operator
12865
+ * lever without a `category` grant (a `category` grant also covers device
12866
+ * caps that carry no deviceId; `all` is specifically the device set).
12867
+ * - `ids` — an explicit deviceId list. This is what a v2 `device:[…]`
12868
+ * grant migrates to (see {@link TokenScopeSchema}); STATIC — a new camera
12869
+ * is NOT covered until the grant is edited.
12870
+ * - `types` — every device of a `DeviceType` (e.g. every `camera`).
12871
+ * DYNAMIC. A device that changes type, or a new device of the type,
12872
+ * re-resolves on the next request.
12873
+ * - `locations` — every device whose operator-assigned `location` label is
12874
+ * in the set (e.g. "Garden", "Front door"). DYNAMIC. A device with a
12875
+ * null/unset location matches NO `locations` selector.
12876
+ */
12877
+ var DeviceSelectorSchema = discriminatedUnion("kind", [
12878
+ object({ kind: literal("all") }),
12879
+ object({
12880
+ kind: literal("ids"),
12881
+ ids: array(number().int()).min(1)
12882
+ }),
12883
+ object({
12884
+ kind: literal("types"),
12885
+ types: array(_enum(DeviceType)).min(1)
12886
+ }),
12887
+ object({
12888
+ kind: literal("locations"),
12889
+ locations: array(string().min(1)).min(1)
12890
+ })
12891
+ ]);
12892
+ var DeviceTokenScopeSchema = object({
12893
+ type: literal("device"),
12894
+ /** The device SET this grant covers — resolved against the live fleet. */
12895
+ selector: DeviceSelectorSchema,
12896
+ access: array(MethodAccessSchema).min(1),
12897
+ /**
12898
+ * Whether a grant on a PARENT device transparently covers its accessory
12899
+ * CHILDREN (siren / floodlight / PIR) via the persisted-parentage walk.
12900
+ * Direction is parent → children ONLY.
12901
+ *
12902
+ * Absent → the matcher DERIVES it from the access flavour: `view`
12903
+ * inherits (a camera viewer sees the camera's accessories), `create` /
12904
+ * `delete` do NOT (actuating/removing a child is an explicit act the
12905
+ * operator must grant on the child, not inherit from the parent). Set it
12906
+ * explicitly to override that default per grant.
12907
+ */
12908
+ includeLinked: boolean().optional()
12909
+ });
12910
+ /**
12911
+ * v2 → v3 lazy migration. A pre-v3 `device` grant carried
12912
+ * `targets: string[]` (stringified deviceIds); it rewrites to the equivalent
12913
+ * `selector: {kind:'ids', ids}`. Applied as a `preprocess` so it runs on
12914
+ * EVERY parse path — stored records AND the JWT-carried scope arrays
12915
+ * normalised at the request boundary ({@link normalizeTokenScopes} in
12916
+ * `device-selector.ts`). Chosen over a one-time DB migration because a
12917
+ * migration cannot reach a JWT already in a client's hands; parse-time
12918
+ * migration covers both without a flag day. No cast — the raw object is read
12919
+ * through `Reflect.get` (its static type is `unknown`).
12920
+ */
12921
+ function migrateLegacyTokenScope(raw) {
12922
+ if (raw === null || typeof raw !== "object" || Array.isArray(raw)) return raw;
12923
+ if (Reflect.get(raw, "type") !== "device") return raw;
12924
+ if (Reflect.get(raw, "selector") !== void 0) return raw;
12925
+ const targets = Reflect.get(raw, "targets");
12926
+ if (!Array.isArray(targets)) return raw;
12927
+ return {
12928
+ type: "device",
12929
+ selector: {
12930
+ kind: "ids",
12931
+ ids: targets.map((t) => typeof t === "string" ? Number(t) : t).filter((n) => typeof n === "number" && Number.isInteger(n))
12932
+ },
12933
+ access: Reflect.get(raw, "access")
12934
+ };
12935
+ }
12936
+ var TokenScopeSchema = preprocess(migrateLegacyTokenScope, discriminatedUnion("type", [
12937
+ object({
12938
+ type: literal("category"),
12939
+ target: CapScopeSchema,
12940
+ access: array(MethodAccessSchema).min(1)
12941
+ }),
12942
+ object({
12943
+ type: literal("capability"),
12944
+ target: string(),
12945
+ access: array(MethodAccessSchema).min(1)
12946
+ }),
12947
+ object({
12948
+ type: literal("addon"),
12949
+ target: string(),
12950
+ access: array(MethodAccessSchema).min(1)
12951
+ }),
12952
+ DeviceTokenScopeSchema
12953
+ ]));
12954
+ object({
12955
+ id: string(),
12956
+ username: string(),
12957
+ passwordHash: string(),
12958
+ /**
12959
+ * Admin bypass. When true, the middleware skips the scope-access
12960
+ * check entirely. There is no other axis of privilege; the legacy
12961
+ * role enum collapsed onto this boolean in v2.
12962
+ */
12963
+ isAdmin: boolean().default(false),
12964
+ allowedProviders: AllowedProviderSchema,
12965
+ allowedDevices: AllowedDevicesSchema,
12966
+ /**
12967
+ * Scopes granted to this user. Admins bypass; their `scopes` is
12968
+ * ignored. Non-admins without scopes are locked out of every
12969
+ * protected call.
12970
+ */
12971
+ scopes: array(TokenScopeSchema).default([]),
12972
+ createdAt: number(),
12973
+ updatedAt: number()
12974
+ });
12975
+ object({
12976
+ id: string(),
12977
+ label: string(),
12978
+ isAdmin: boolean().default(false),
12979
+ allowedProviders: AllowedProviderSchema,
12980
+ allowedDevices: AllowedDevicesSchema,
12981
+ tokenHash: string(),
12982
+ tokenPrefix: string(),
12983
+ createdAt: number(),
12984
+ lastUsedAt: number().optional()
12985
+ });
12986
+ object({
12987
+ id: string(),
12988
+ userId: string(),
12989
+ name: string(),
12990
+ tokenHash: string(),
12991
+ tokenPrefix: string(),
12992
+ scopes: array(TokenScopeSchema),
12993
+ expiresAt: number().nullish(),
12994
+ lastUsedAt: number().nullish(),
12995
+ createdAt: number()
12996
+ });
12997
+ /** What a share-view grant lets its holder see. */
12998
+ var ShareViewGrantSchema = object({
12999
+ kind: _enum(SHARE_VIEW_KINDS),
13000
+ deviceIds: array(number().int().nonnegative()).min(1).max(64),
13001
+ /** Talk-back, opt-in at mint time; absent means off. */
13002
+ talk: boolean().optional()
13003
+ });
13004
+ var ShareViewScopeSchema = object({
13005
+ type: literal("share-view"),
13006
+ grant: ShareViewGrantSchema
13007
+ });
13008
+ var AddonRoutesScopeSchema = object({
13009
+ type: literal("addon-routes"),
13010
+ access: array(MethodAccessSchema).min(1)
13011
+ });
13012
+ var CredentialScopeSchema = union([
13013
+ literal("*"),
13014
+ ShareViewScopeSchema,
13015
+ AddonRoutesScopeSchema,
13016
+ TokenScopeSchema
13017
+ ]);
13018
+ object({
13019
+ kind: literal("credential"),
13020
+ sub: string().min(1),
13021
+ jti: string().min(16),
13022
+ scopes: array(CredentialScopeSchema).min(1)
13023
+ });
12795
13024
  _enum(["new-session", "step-up"]);
12796
13025
  /** The languages the hub's app landing pages are written in (D858). */
12797
13026
  var AppPageLangSchema = _enum(["en", "it"]);
@@ -44401,202 +44630,6 @@ method(object({}), object({ rules: array(NcRuleSchema) }), { auth: "admin" }), m
44401
44630
  auth: "admin"
44402
44631
  }), method(NcAlarmSensorsInputSchema, NcAlarmSensorsSchema, { auth: "admin" });
44403
44632
  /**
44404
- * Zod schemas for persisted record types.
44405
- *
44406
- * These schemas serve as the single source of truth for types that are
44407
- * stored in the settings-store backend and retrieved via tRPC. They
44408
- * replace the manual TypeScript interfaces with schema-derived types,
44409
- * enabling runtime validation when reading from the backend.
44410
- *
44411
- * Convention: each schema is named `<Type>Schema`, the inferred TS type
44412
- * keeps the original name for backward compatibility.
44413
- */
44414
- /**
44415
- * Auth model (v2 — 2026-05-12 caps-only):
44416
- *
44417
- * Two principals:
44418
- * - `isAdmin: true` — full bypass. Admin scope set is ignored.
44419
- * - `isAdmin: false` — every call gated by `scopes` (see TokenScope).
44420
- *
44421
- * No role enum. There used to be `viewer / agent / scoped` and earlier
44422
- * `super_admin` — collapsed onto the single boolean because every
44423
- * non-admin caller is governed by the same scope-check rules; the
44424
- * distinction was only ever used to route role-specific procedures
44425
- * which we no longer have. CLI / webhook integrations are `cst_*` tokens
44426
- * with `isAdmin: false` + an explicit scope list.
44427
- */
44428
- /** Per-method access flavour. Materialised on every cap method via codegen. */
44429
- var MethodAccessSchema = _enum([
44430
- "view",
44431
- "create",
44432
- "delete"
44433
- ]);
44434
- /**
44435
- * A single scope grant. Three forms — checked in matcher with OR
44436
- * semantics; the first match decides whether the call passes:
44437
- *
44438
- * - `category` — broadest. `target: 'device' | 'system'` selects every
44439
- * cap with the matching `scope` declaration. New caps inherit grants
44440
- * automatically — adding a device cap to the codebase makes it
44441
- * reachable to every user with `category:device [...]` without a
44442
- * re-grant. Use this for "family viewer" / "operator" tiers.
44443
- *
44444
- * - `addon` — every cap that ships inside a given addon id. Niche;
44445
- * useful when an integration needs to interact with one specific
44446
- * addon's surface regardless of how many caps it exports.
44447
- *
44448
- * - `capability` — the most precise form. Single cap name. Use for
44449
- * integration tokens where you want to grant `addons.installPackage`
44450
- * and nothing else.
44451
- *
44452
- * `access` is REQUIRED with min 1 element. `admin` bypass is the
44453
- * "give me everything" escape; there is no wildcard scope.
44454
- */
44455
- var AllowedProviderSchema = union([literal("*"), array(string())]);
44456
- var AllowedDevicesSchema = record(string(), union([literal("*"), array(string())]));
44457
- var CapScopeSchema = _enum(["device", "system"]);
44458
- /**
44459
- * DeviceSelector (scope model v3 — 2026-08-12).
44460
- *
44461
- * A `device` grant no longer carries a frozen list of deviceIds. It carries
44462
- * a SELECTOR the matcher resolves against the live fleet, so the grant can be
44463
- * DYNAMIC: a `types:['camera']` selector automatically covers a camera added
44464
- * AFTER the grant was minted — no re-grant, no re-login.
44465
- *
44466
- * - `all` — every device in the deployment. The broad viewer/operator
44467
- * lever without a `category` grant (a `category` grant also covers device
44468
- * caps that carry no deviceId; `all` is specifically the device set).
44469
- * - `ids` — an explicit deviceId list. This is what a v2 `device:[…]`
44470
- * grant migrates to (see {@link TokenScopeSchema}); STATIC — a new camera
44471
- * is NOT covered until the grant is edited.
44472
- * - `types` — every device of a `DeviceType` (e.g. every `camera`).
44473
- * DYNAMIC. A device that changes type, or a new device of the type,
44474
- * re-resolves on the next request.
44475
- * - `locations` — every device whose operator-assigned `location` label is
44476
- * in the set (e.g. "Garden", "Front door"). DYNAMIC. A device with a
44477
- * null/unset location matches NO `locations` selector.
44478
- */
44479
- var DeviceSelectorSchema = discriminatedUnion("kind", [
44480
- object({ kind: literal("all") }),
44481
- object({
44482
- kind: literal("ids"),
44483
- ids: array(number().int()).min(1)
44484
- }),
44485
- object({
44486
- kind: literal("types"),
44487
- types: array(_enum(DeviceType)).min(1)
44488
- }),
44489
- object({
44490
- kind: literal("locations"),
44491
- locations: array(string().min(1)).min(1)
44492
- })
44493
- ]);
44494
- var DeviceTokenScopeSchema = object({
44495
- type: literal("device"),
44496
- /** The device SET this grant covers — resolved against the live fleet. */
44497
- selector: DeviceSelectorSchema,
44498
- access: array(MethodAccessSchema).min(1),
44499
- /**
44500
- * Whether a grant on a PARENT device transparently covers its accessory
44501
- * CHILDREN (siren / floodlight / PIR) via the persisted-parentage walk.
44502
- * Direction is parent → children ONLY.
44503
- *
44504
- * Absent → the matcher DERIVES it from the access flavour: `view`
44505
- * inherits (a camera viewer sees the camera's accessories), `create` /
44506
- * `delete` do NOT (actuating/removing a child is an explicit act the
44507
- * operator must grant on the child, not inherit from the parent). Set it
44508
- * explicitly to override that default per grant.
44509
- */
44510
- includeLinked: boolean().optional()
44511
- });
44512
- /**
44513
- * v2 → v3 lazy migration. A pre-v3 `device` grant carried
44514
- * `targets: string[]` (stringified deviceIds); it rewrites to the equivalent
44515
- * `selector: {kind:'ids', ids}`. Applied as a `preprocess` so it runs on
44516
- * EVERY parse path — stored records AND the JWT-carried scope arrays
44517
- * normalised at the request boundary ({@link normalizeTokenScopes} in
44518
- * `device-selector.ts`). Chosen over a one-time DB migration because a
44519
- * migration cannot reach a JWT already in a client's hands; parse-time
44520
- * migration covers both without a flag day. No cast — the raw object is read
44521
- * through `Reflect.get` (its static type is `unknown`).
44522
- */
44523
- function migrateLegacyTokenScope(raw) {
44524
- if (raw === null || typeof raw !== "object" || Array.isArray(raw)) return raw;
44525
- if (Reflect.get(raw, "type") !== "device") return raw;
44526
- if (Reflect.get(raw, "selector") !== void 0) return raw;
44527
- const targets = Reflect.get(raw, "targets");
44528
- if (!Array.isArray(targets)) return raw;
44529
- return {
44530
- type: "device",
44531
- selector: {
44532
- kind: "ids",
44533
- ids: targets.map((t) => typeof t === "string" ? Number(t) : t).filter((n) => typeof n === "number" && Number.isInteger(n))
44534
- },
44535
- access: Reflect.get(raw, "access")
44536
- };
44537
- }
44538
- var TokenScopeSchema = preprocess(migrateLegacyTokenScope, discriminatedUnion("type", [
44539
- object({
44540
- type: literal("category"),
44541
- target: CapScopeSchema,
44542
- access: array(MethodAccessSchema).min(1)
44543
- }),
44544
- object({
44545
- type: literal("capability"),
44546
- target: string(),
44547
- access: array(MethodAccessSchema).min(1)
44548
- }),
44549
- object({
44550
- type: literal("addon"),
44551
- target: string(),
44552
- access: array(MethodAccessSchema).min(1)
44553
- }),
44554
- DeviceTokenScopeSchema
44555
- ]));
44556
- object({
44557
- id: string(),
44558
- username: string(),
44559
- passwordHash: string(),
44560
- /**
44561
- * Admin bypass. When true, the middleware skips the scope-access
44562
- * check entirely. There is no other axis of privilege; the legacy
44563
- * role enum collapsed onto this boolean in v2.
44564
- */
44565
- isAdmin: boolean().default(false),
44566
- allowedProviders: AllowedProviderSchema,
44567
- allowedDevices: AllowedDevicesSchema,
44568
- /**
44569
- * Scopes granted to this user. Admins bypass; their `scopes` is
44570
- * ignored. Non-admins without scopes are locked out of every
44571
- * protected call.
44572
- */
44573
- scopes: array(TokenScopeSchema).default([]),
44574
- createdAt: number(),
44575
- updatedAt: number()
44576
- });
44577
- object({
44578
- id: string(),
44579
- label: string(),
44580
- isAdmin: boolean().default(false),
44581
- allowedProviders: AllowedProviderSchema,
44582
- allowedDevices: AllowedDevicesSchema,
44583
- tokenHash: string(),
44584
- tokenPrefix: string(),
44585
- createdAt: number(),
44586
- lastUsedAt: number().optional()
44587
- });
44588
- object({
44589
- id: string(),
44590
- userId: string(),
44591
- name: string(),
44592
- tokenHash: string(),
44593
- tokenPrefix: string(),
44594
- scopes: array(TokenScopeSchema),
44595
- expiresAt: number().nullish(),
44596
- lastUsedAt: number().nullish(),
44597
- createdAt: number()
44598
- });
44599
- /**
44600
44633
  * `oauth-integration` — a collection cap by which an addon declares
44601
44634
  * itself a linkable OAuth client of the hub's core `/oauth2/*` server.
44602
44635
  * 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-hikvision",
3
- "version": "1.2.155",
3
+ "version": "1.2.156",
4
4
  "description": "Hikvision camera device provider addon for CamStack — ISAPI over HTTP(S) with digest auth (snapshot, alarm stream, RTSP discovery)",
5
5
  "keywords": [
6
6
  "camstack",