@camstack/addon-provider-reolink 1.2.190 → 1.2.191

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
@@ -7837,6 +7837,12 @@ function normalizeAddonInitResult(result) {
7837
7837
  if (Array.isArray(result)) return { providers: result };
7838
7838
  return result;
7839
7839
  }
7840
+ /**
7841
+ * The share-view scope kinds a `csv_*` share token can carry. The hub mints
7842
+ * and validates them (`share-token.service.ts` builds its enum from this
7843
+ * list); a data plane names the kinds it ACCEPTS in `share`.
7844
+ */
7845
+ var SHARE_VIEW_KINDS = ["grid-view", "events-view"];
7840
7846
  /** The wire shape of {@link PeerBytesTicket} — see the type for what it is. */
7841
7847
  var PeerBytesTicketSchema = object({
7842
7848
  /** `http://127.0.0.1:<port>/<token>`. One `GET` takes it. */
@@ -13116,6 +13122,229 @@ var ConvertResultSchema = object({
13116
13122
  files: array(string()).readonly()
13117
13123
  })).readonly()
13118
13124
  });
13125
+ /**
13126
+ * Zod schemas for persisted record types.
13127
+ *
13128
+ * These schemas serve as the single source of truth for types that are
13129
+ * stored in the settings-store backend and retrieved via tRPC. They
13130
+ * replace the manual TypeScript interfaces with schema-derived types,
13131
+ * enabling runtime validation when reading from the backend.
13132
+ *
13133
+ * Convention: each schema is named `<Type>Schema`, the inferred TS type
13134
+ * keeps the original name for backward compatibility.
13135
+ */
13136
+ /**
13137
+ * Auth model (v2 — 2026-05-12 caps-only):
13138
+ *
13139
+ * Two principals:
13140
+ * - `isAdmin: true` — full bypass. Admin scope set is ignored.
13141
+ * - `isAdmin: false` — every call gated by `scopes` (see TokenScope).
13142
+ *
13143
+ * No role enum. There used to be `viewer / agent / scoped` and earlier
13144
+ * `super_admin` — collapsed onto the single boolean because every
13145
+ * non-admin caller is governed by the same scope-check rules; the
13146
+ * distinction was only ever used to route role-specific procedures
13147
+ * which we no longer have. CLI / webhook integrations are `cst_*` tokens
13148
+ * with `isAdmin: false` + an explicit scope list.
13149
+ */
13150
+ /** Per-method access flavour. Materialised on every cap method via codegen. */
13151
+ var MethodAccessSchema = _enum([
13152
+ "view",
13153
+ "create",
13154
+ "delete"
13155
+ ]);
13156
+ /**
13157
+ * A single scope grant. Three forms — checked in matcher with OR
13158
+ * semantics; the first match decides whether the call passes:
13159
+ *
13160
+ * - `category` — broadest. `target: 'device' | 'system'` selects every
13161
+ * cap with the matching `scope` declaration. New caps inherit grants
13162
+ * automatically — adding a device cap to the codebase makes it
13163
+ * reachable to every user with `category:device [...]` without a
13164
+ * re-grant. Use this for "family viewer" / "operator" tiers.
13165
+ *
13166
+ * - `addon` — every cap that ships inside a given addon id. Niche;
13167
+ * useful when an integration needs to interact with one specific
13168
+ * addon's surface regardless of how many caps it exports.
13169
+ *
13170
+ * - `capability` — the most precise form. Single cap name. Use for
13171
+ * integration tokens where you want to grant `addons.installPackage`
13172
+ * and nothing else.
13173
+ *
13174
+ * `access` is REQUIRED with min 1 element. `admin` bypass is the
13175
+ * "give me everything" escape; there is no wildcard scope.
13176
+ */
13177
+ var AllowedProviderSchema = union([literal("*"), array(string())]);
13178
+ var AllowedDevicesSchema = record(string(), union([literal("*"), array(string())]));
13179
+ var CapScopeSchema = _enum(["device", "system"]);
13180
+ /**
13181
+ * DeviceSelector (scope model v3 — 2026-08-12).
13182
+ *
13183
+ * A `device` grant no longer carries a frozen list of deviceIds. It carries
13184
+ * a SELECTOR the matcher resolves against the live fleet, so the grant can be
13185
+ * DYNAMIC: a `types:['camera']` selector automatically covers a camera added
13186
+ * AFTER the grant was minted — no re-grant, no re-login.
13187
+ *
13188
+ * - `all` — every device in the deployment. The broad viewer/operator
13189
+ * lever without a `category` grant (a `category` grant also covers device
13190
+ * caps that carry no deviceId; `all` is specifically the device set).
13191
+ * - `ids` — an explicit deviceId list. This is what a v2 `device:[…]`
13192
+ * grant migrates to (see {@link TokenScopeSchema}); STATIC — a new camera
13193
+ * is NOT covered until the grant is edited.
13194
+ * - `types` — every device of a `DeviceType` (e.g. every `camera`).
13195
+ * DYNAMIC. A device that changes type, or a new device of the type,
13196
+ * re-resolves on the next request.
13197
+ * - `locations` — every device whose operator-assigned `location` label is
13198
+ * in the set (e.g. "Garden", "Front door"). DYNAMIC. A device with a
13199
+ * null/unset location matches NO `locations` selector.
13200
+ */
13201
+ var DeviceSelectorSchema = discriminatedUnion("kind", [
13202
+ object({ kind: literal("all") }),
13203
+ object({
13204
+ kind: literal("ids"),
13205
+ ids: array(number().int()).min(1)
13206
+ }),
13207
+ object({
13208
+ kind: literal("types"),
13209
+ types: array(_enum(DeviceType)).min(1)
13210
+ }),
13211
+ object({
13212
+ kind: literal("locations"),
13213
+ locations: array(string().min(1)).min(1)
13214
+ })
13215
+ ]);
13216
+ var DeviceTokenScopeSchema = object({
13217
+ type: literal("device"),
13218
+ /** The device SET this grant covers — resolved against the live fleet. */
13219
+ selector: DeviceSelectorSchema,
13220
+ access: array(MethodAccessSchema).min(1),
13221
+ /**
13222
+ * Whether a grant on a PARENT device transparently covers its accessory
13223
+ * CHILDREN (siren / floodlight / PIR) via the persisted-parentage walk.
13224
+ * Direction is parent → children ONLY.
13225
+ *
13226
+ * Absent → the matcher DERIVES it from the access flavour: `view`
13227
+ * inherits (a camera viewer sees the camera's accessories), `create` /
13228
+ * `delete` do NOT (actuating/removing a child is an explicit act the
13229
+ * operator must grant on the child, not inherit from the parent). Set it
13230
+ * explicitly to override that default per grant.
13231
+ */
13232
+ includeLinked: boolean().optional()
13233
+ });
13234
+ /**
13235
+ * v2 → v3 lazy migration. A pre-v3 `device` grant carried
13236
+ * `targets: string[]` (stringified deviceIds); it rewrites to the equivalent
13237
+ * `selector: {kind:'ids', ids}`. Applied as a `preprocess` so it runs on
13238
+ * EVERY parse path — stored records AND the JWT-carried scope arrays
13239
+ * normalised at the request boundary ({@link normalizeTokenScopes} in
13240
+ * `device-selector.ts`). Chosen over a one-time DB migration because a
13241
+ * migration cannot reach a JWT already in a client's hands; parse-time
13242
+ * migration covers both without a flag day. No cast — the raw object is read
13243
+ * through `Reflect.get` (its static type is `unknown`).
13244
+ */
13245
+ function migrateLegacyTokenScope(raw) {
13246
+ if (raw === null || typeof raw !== "object" || Array.isArray(raw)) return raw;
13247
+ if (Reflect.get(raw, "type") !== "device") return raw;
13248
+ if (Reflect.get(raw, "selector") !== void 0) return raw;
13249
+ const targets = Reflect.get(raw, "targets");
13250
+ if (!Array.isArray(targets)) return raw;
13251
+ return {
13252
+ type: "device",
13253
+ selector: {
13254
+ kind: "ids",
13255
+ ids: targets.map((t) => typeof t === "string" ? Number(t) : t).filter((n) => typeof n === "number" && Number.isInteger(n))
13256
+ },
13257
+ access: Reflect.get(raw, "access")
13258
+ };
13259
+ }
13260
+ var TokenScopeSchema = preprocess(migrateLegacyTokenScope, discriminatedUnion("type", [
13261
+ object({
13262
+ type: literal("category"),
13263
+ target: CapScopeSchema,
13264
+ access: array(MethodAccessSchema).min(1)
13265
+ }),
13266
+ object({
13267
+ type: literal("capability"),
13268
+ target: string(),
13269
+ access: array(MethodAccessSchema).min(1)
13270
+ }),
13271
+ object({
13272
+ type: literal("addon"),
13273
+ target: string(),
13274
+ access: array(MethodAccessSchema).min(1)
13275
+ }),
13276
+ DeviceTokenScopeSchema
13277
+ ]));
13278
+ object({
13279
+ id: string(),
13280
+ username: string(),
13281
+ passwordHash: string(),
13282
+ /**
13283
+ * Admin bypass. When true, the middleware skips the scope-access
13284
+ * check entirely. There is no other axis of privilege; the legacy
13285
+ * role enum collapsed onto this boolean in v2.
13286
+ */
13287
+ isAdmin: boolean().default(false),
13288
+ allowedProviders: AllowedProviderSchema,
13289
+ allowedDevices: AllowedDevicesSchema,
13290
+ /**
13291
+ * Scopes granted to this user. Admins bypass; their `scopes` is
13292
+ * ignored. Non-admins without scopes are locked out of every
13293
+ * protected call.
13294
+ */
13295
+ scopes: array(TokenScopeSchema).default([]),
13296
+ createdAt: number(),
13297
+ updatedAt: number()
13298
+ });
13299
+ object({
13300
+ id: string(),
13301
+ label: string(),
13302
+ isAdmin: boolean().default(false),
13303
+ allowedProviders: AllowedProviderSchema,
13304
+ allowedDevices: AllowedDevicesSchema,
13305
+ tokenHash: string(),
13306
+ tokenPrefix: string(),
13307
+ createdAt: number(),
13308
+ lastUsedAt: number().optional()
13309
+ });
13310
+ object({
13311
+ id: string(),
13312
+ userId: string(),
13313
+ name: string(),
13314
+ tokenHash: string(),
13315
+ tokenPrefix: string(),
13316
+ scopes: array(TokenScopeSchema),
13317
+ expiresAt: number().nullish(),
13318
+ lastUsedAt: number().nullish(),
13319
+ createdAt: number()
13320
+ });
13321
+ /** What a share-view grant lets its holder see. */
13322
+ var ShareViewGrantSchema = object({
13323
+ kind: _enum(SHARE_VIEW_KINDS),
13324
+ deviceIds: array(number().int().nonnegative()).min(1).max(64),
13325
+ /** Talk-back, opt-in at mint time; absent means off. */
13326
+ talk: boolean().optional()
13327
+ });
13328
+ var ShareViewScopeSchema = object({
13329
+ type: literal("share-view"),
13330
+ grant: ShareViewGrantSchema
13331
+ });
13332
+ var AddonRoutesScopeSchema = object({
13333
+ type: literal("addon-routes"),
13334
+ access: array(MethodAccessSchema).min(1)
13335
+ });
13336
+ var CredentialScopeSchema = union([
13337
+ literal("*"),
13338
+ ShareViewScopeSchema,
13339
+ AddonRoutesScopeSchema,
13340
+ TokenScopeSchema
13341
+ ]);
13342
+ object({
13343
+ kind: literal("credential"),
13344
+ sub: string().min(1),
13345
+ jti: string().min(16),
13346
+ scopes: array(CredentialScopeSchema).min(1)
13347
+ });
13119
13348
  _enum(["new-session", "step-up"]);
13120
13349
  /** The languages the hub's app landing pages are written in (D858). */
13121
13350
  var AppPageLangSchema = _enum(["en", "it"]);
@@ -44746,202 +44975,6 @@ method(object({}), object({ rules: array(NcRuleSchema) }), { auth: "admin" }), m
44746
44975
  auth: "admin"
44747
44976
  }), method(NcAlarmSensorsInputSchema, NcAlarmSensorsSchema, { auth: "admin" });
44748
44977
  /**
44749
- * Zod schemas for persisted record types.
44750
- *
44751
- * These schemas serve as the single source of truth for types that are
44752
- * stored in the settings-store backend and retrieved via tRPC. They
44753
- * replace the manual TypeScript interfaces with schema-derived types,
44754
- * enabling runtime validation when reading from the backend.
44755
- *
44756
- * Convention: each schema is named `<Type>Schema`, the inferred TS type
44757
- * keeps the original name for backward compatibility.
44758
- */
44759
- /**
44760
- * Auth model (v2 — 2026-05-12 caps-only):
44761
- *
44762
- * Two principals:
44763
- * - `isAdmin: true` — full bypass. Admin scope set is ignored.
44764
- * - `isAdmin: false` — every call gated by `scopes` (see TokenScope).
44765
- *
44766
- * No role enum. There used to be `viewer / agent / scoped` and earlier
44767
- * `super_admin` — collapsed onto the single boolean because every
44768
- * non-admin caller is governed by the same scope-check rules; the
44769
- * distinction was only ever used to route role-specific procedures
44770
- * which we no longer have. CLI / webhook integrations are `cst_*` tokens
44771
- * with `isAdmin: false` + an explicit scope list.
44772
- */
44773
- /** Per-method access flavour. Materialised on every cap method via codegen. */
44774
- var MethodAccessSchema = _enum([
44775
- "view",
44776
- "create",
44777
- "delete"
44778
- ]);
44779
- /**
44780
- * A single scope grant. Three forms — checked in matcher with OR
44781
- * semantics; the first match decides whether the call passes:
44782
- *
44783
- * - `category` — broadest. `target: 'device' | 'system'` selects every
44784
- * cap with the matching `scope` declaration. New caps inherit grants
44785
- * automatically — adding a device cap to the codebase makes it
44786
- * reachable to every user with `category:device [...]` without a
44787
- * re-grant. Use this for "family viewer" / "operator" tiers.
44788
- *
44789
- * - `addon` — every cap that ships inside a given addon id. Niche;
44790
- * useful when an integration needs to interact with one specific
44791
- * addon's surface regardless of how many caps it exports.
44792
- *
44793
- * - `capability` — the most precise form. Single cap name. Use for
44794
- * integration tokens where you want to grant `addons.installPackage`
44795
- * and nothing else.
44796
- *
44797
- * `access` is REQUIRED with min 1 element. `admin` bypass is the
44798
- * "give me everything" escape; there is no wildcard scope.
44799
- */
44800
- var AllowedProviderSchema = union([literal("*"), array(string())]);
44801
- var AllowedDevicesSchema = record(string(), union([literal("*"), array(string())]));
44802
- var CapScopeSchema = _enum(["device", "system"]);
44803
- /**
44804
- * DeviceSelector (scope model v3 — 2026-08-12).
44805
- *
44806
- * A `device` grant no longer carries a frozen list of deviceIds. It carries
44807
- * a SELECTOR the matcher resolves against the live fleet, so the grant can be
44808
- * DYNAMIC: a `types:['camera']` selector automatically covers a camera added
44809
- * AFTER the grant was minted — no re-grant, no re-login.
44810
- *
44811
- * - `all` — every device in the deployment. The broad viewer/operator
44812
- * lever without a `category` grant (a `category` grant also covers device
44813
- * caps that carry no deviceId; `all` is specifically the device set).
44814
- * - `ids` — an explicit deviceId list. This is what a v2 `device:[…]`
44815
- * grant migrates to (see {@link TokenScopeSchema}); STATIC — a new camera
44816
- * is NOT covered until the grant is edited.
44817
- * - `types` — every device of a `DeviceType` (e.g. every `camera`).
44818
- * DYNAMIC. A device that changes type, or a new device of the type,
44819
- * re-resolves on the next request.
44820
- * - `locations` — every device whose operator-assigned `location` label is
44821
- * in the set (e.g. "Garden", "Front door"). DYNAMIC. A device with a
44822
- * null/unset location matches NO `locations` selector.
44823
- */
44824
- var DeviceSelectorSchema = discriminatedUnion("kind", [
44825
- object({ kind: literal("all") }),
44826
- object({
44827
- kind: literal("ids"),
44828
- ids: array(number().int()).min(1)
44829
- }),
44830
- object({
44831
- kind: literal("types"),
44832
- types: array(_enum(DeviceType)).min(1)
44833
- }),
44834
- object({
44835
- kind: literal("locations"),
44836
- locations: array(string().min(1)).min(1)
44837
- })
44838
- ]);
44839
- var DeviceTokenScopeSchema = object({
44840
- type: literal("device"),
44841
- /** The device SET this grant covers — resolved against the live fleet. */
44842
- selector: DeviceSelectorSchema,
44843
- access: array(MethodAccessSchema).min(1),
44844
- /**
44845
- * Whether a grant on a PARENT device transparently covers its accessory
44846
- * CHILDREN (siren / floodlight / PIR) via the persisted-parentage walk.
44847
- * Direction is parent → children ONLY.
44848
- *
44849
- * Absent → the matcher DERIVES it from the access flavour: `view`
44850
- * inherits (a camera viewer sees the camera's accessories), `create` /
44851
- * `delete` do NOT (actuating/removing a child is an explicit act the
44852
- * operator must grant on the child, not inherit from the parent). Set it
44853
- * explicitly to override that default per grant.
44854
- */
44855
- includeLinked: boolean().optional()
44856
- });
44857
- /**
44858
- * v2 → v3 lazy migration. A pre-v3 `device` grant carried
44859
- * `targets: string[]` (stringified deviceIds); it rewrites to the equivalent
44860
- * `selector: {kind:'ids', ids}`. Applied as a `preprocess` so it runs on
44861
- * EVERY parse path — stored records AND the JWT-carried scope arrays
44862
- * normalised at the request boundary ({@link normalizeTokenScopes} in
44863
- * `device-selector.ts`). Chosen over a one-time DB migration because a
44864
- * migration cannot reach a JWT already in a client's hands; parse-time
44865
- * migration covers both without a flag day. No cast — the raw object is read
44866
- * through `Reflect.get` (its static type is `unknown`).
44867
- */
44868
- function migrateLegacyTokenScope(raw) {
44869
- if (raw === null || typeof raw !== "object" || Array.isArray(raw)) return raw;
44870
- if (Reflect.get(raw, "type") !== "device") return raw;
44871
- if (Reflect.get(raw, "selector") !== void 0) return raw;
44872
- const targets = Reflect.get(raw, "targets");
44873
- if (!Array.isArray(targets)) return raw;
44874
- return {
44875
- type: "device",
44876
- selector: {
44877
- kind: "ids",
44878
- ids: targets.map((t) => typeof t === "string" ? Number(t) : t).filter((n) => typeof n === "number" && Number.isInteger(n))
44879
- },
44880
- access: Reflect.get(raw, "access")
44881
- };
44882
- }
44883
- var TokenScopeSchema = preprocess(migrateLegacyTokenScope, discriminatedUnion("type", [
44884
- object({
44885
- type: literal("category"),
44886
- target: CapScopeSchema,
44887
- access: array(MethodAccessSchema).min(1)
44888
- }),
44889
- object({
44890
- type: literal("capability"),
44891
- target: string(),
44892
- access: array(MethodAccessSchema).min(1)
44893
- }),
44894
- object({
44895
- type: literal("addon"),
44896
- target: string(),
44897
- access: array(MethodAccessSchema).min(1)
44898
- }),
44899
- DeviceTokenScopeSchema
44900
- ]));
44901
- object({
44902
- id: string(),
44903
- username: string(),
44904
- passwordHash: string(),
44905
- /**
44906
- * Admin bypass. When true, the middleware skips the scope-access
44907
- * check entirely. There is no other axis of privilege; the legacy
44908
- * role enum collapsed onto this boolean in v2.
44909
- */
44910
- isAdmin: boolean().default(false),
44911
- allowedProviders: AllowedProviderSchema,
44912
- allowedDevices: AllowedDevicesSchema,
44913
- /**
44914
- * Scopes granted to this user. Admins bypass; their `scopes` is
44915
- * ignored. Non-admins without scopes are locked out of every
44916
- * protected call.
44917
- */
44918
- scopes: array(TokenScopeSchema).default([]),
44919
- createdAt: number(),
44920
- updatedAt: number()
44921
- });
44922
- object({
44923
- id: string(),
44924
- label: string(),
44925
- isAdmin: boolean().default(false),
44926
- allowedProviders: AllowedProviderSchema,
44927
- allowedDevices: AllowedDevicesSchema,
44928
- tokenHash: string(),
44929
- tokenPrefix: string(),
44930
- createdAt: number(),
44931
- lastUsedAt: number().optional()
44932
- });
44933
- object({
44934
- id: string(),
44935
- userId: string(),
44936
- name: string(),
44937
- tokenHash: string(),
44938
- tokenPrefix: string(),
44939
- scopes: array(TokenScopeSchema),
44940
- expiresAt: number().nullish(),
44941
- lastUsedAt: number().nullish(),
44942
- createdAt: number()
44943
- });
44944
- /**
44945
44978
  * `oauth-integration` — a collection cap by which an addon declares
44946
44979
  * itself a linkable OAuth client of the hub's core `/oauth2/*` server.
44947
44980
  * Each provider returns a static descriptor; the core enumerates them
package/dist/addon.mjs CHANGED
@@ -7829,6 +7829,12 @@ function normalizeAddonInitResult(result) {
7829
7829
  if (Array.isArray(result)) return { providers: result };
7830
7830
  return result;
7831
7831
  }
7832
+ /**
7833
+ * The share-view scope kinds a `csv_*` share token can carry. The hub mints
7834
+ * and validates them (`share-token.service.ts` builds its enum from this
7835
+ * list); a data plane names the kinds it ACCEPTS in `share`.
7836
+ */
7837
+ var SHARE_VIEW_KINDS = ["grid-view", "events-view"];
7832
7838
  /** The wire shape of {@link PeerBytesTicket} — see the type for what it is. */
7833
7839
  var PeerBytesTicketSchema = object({
7834
7840
  /** `http://127.0.0.1:<port>/<token>`. One `GET` takes it. */
@@ -13108,6 +13114,229 @@ var ConvertResultSchema = object({
13108
13114
  files: array(string()).readonly()
13109
13115
  })).readonly()
13110
13116
  });
13117
+ /**
13118
+ * Zod schemas for persisted record types.
13119
+ *
13120
+ * These schemas serve as the single source of truth for types that are
13121
+ * stored in the settings-store backend and retrieved via tRPC. They
13122
+ * replace the manual TypeScript interfaces with schema-derived types,
13123
+ * enabling runtime validation when reading from the backend.
13124
+ *
13125
+ * Convention: each schema is named `<Type>Schema`, the inferred TS type
13126
+ * keeps the original name for backward compatibility.
13127
+ */
13128
+ /**
13129
+ * Auth model (v2 — 2026-05-12 caps-only):
13130
+ *
13131
+ * Two principals:
13132
+ * - `isAdmin: true` — full bypass. Admin scope set is ignored.
13133
+ * - `isAdmin: false` — every call gated by `scopes` (see TokenScope).
13134
+ *
13135
+ * No role enum. There used to be `viewer / agent / scoped` and earlier
13136
+ * `super_admin` — collapsed onto the single boolean because every
13137
+ * non-admin caller is governed by the same scope-check rules; the
13138
+ * distinction was only ever used to route role-specific procedures
13139
+ * which we no longer have. CLI / webhook integrations are `cst_*` tokens
13140
+ * with `isAdmin: false` + an explicit scope list.
13141
+ */
13142
+ /** Per-method access flavour. Materialised on every cap method via codegen. */
13143
+ var MethodAccessSchema = _enum([
13144
+ "view",
13145
+ "create",
13146
+ "delete"
13147
+ ]);
13148
+ /**
13149
+ * A single scope grant. Three forms — checked in matcher with OR
13150
+ * semantics; the first match decides whether the call passes:
13151
+ *
13152
+ * - `category` — broadest. `target: 'device' | 'system'` selects every
13153
+ * cap with the matching `scope` declaration. New caps inherit grants
13154
+ * automatically — adding a device cap to the codebase makes it
13155
+ * reachable to every user with `category:device [...]` without a
13156
+ * re-grant. Use this for "family viewer" / "operator" tiers.
13157
+ *
13158
+ * - `addon` — every cap that ships inside a given addon id. Niche;
13159
+ * useful when an integration needs to interact with one specific
13160
+ * addon's surface regardless of how many caps it exports.
13161
+ *
13162
+ * - `capability` — the most precise form. Single cap name. Use for
13163
+ * integration tokens where you want to grant `addons.installPackage`
13164
+ * and nothing else.
13165
+ *
13166
+ * `access` is REQUIRED with min 1 element. `admin` bypass is the
13167
+ * "give me everything" escape; there is no wildcard scope.
13168
+ */
13169
+ var AllowedProviderSchema = union([literal("*"), array(string())]);
13170
+ var AllowedDevicesSchema = record(string(), union([literal("*"), array(string())]));
13171
+ var CapScopeSchema = _enum(["device", "system"]);
13172
+ /**
13173
+ * DeviceSelector (scope model v3 — 2026-08-12).
13174
+ *
13175
+ * A `device` grant no longer carries a frozen list of deviceIds. It carries
13176
+ * a SELECTOR the matcher resolves against the live fleet, so the grant can be
13177
+ * DYNAMIC: a `types:['camera']` selector automatically covers a camera added
13178
+ * AFTER the grant was minted — no re-grant, no re-login.
13179
+ *
13180
+ * - `all` — every device in the deployment. The broad viewer/operator
13181
+ * lever without a `category` grant (a `category` grant also covers device
13182
+ * caps that carry no deviceId; `all` is specifically the device set).
13183
+ * - `ids` — an explicit deviceId list. This is what a v2 `device:[…]`
13184
+ * grant migrates to (see {@link TokenScopeSchema}); STATIC — a new camera
13185
+ * is NOT covered until the grant is edited.
13186
+ * - `types` — every device of a `DeviceType` (e.g. every `camera`).
13187
+ * DYNAMIC. A device that changes type, or a new device of the type,
13188
+ * re-resolves on the next request.
13189
+ * - `locations` — every device whose operator-assigned `location` label is
13190
+ * in the set (e.g. "Garden", "Front door"). DYNAMIC. A device with a
13191
+ * null/unset location matches NO `locations` selector.
13192
+ */
13193
+ var DeviceSelectorSchema = discriminatedUnion("kind", [
13194
+ object({ kind: literal("all") }),
13195
+ object({
13196
+ kind: literal("ids"),
13197
+ ids: array(number().int()).min(1)
13198
+ }),
13199
+ object({
13200
+ kind: literal("types"),
13201
+ types: array(_enum(DeviceType)).min(1)
13202
+ }),
13203
+ object({
13204
+ kind: literal("locations"),
13205
+ locations: array(string().min(1)).min(1)
13206
+ })
13207
+ ]);
13208
+ var DeviceTokenScopeSchema = object({
13209
+ type: literal("device"),
13210
+ /** The device SET this grant covers — resolved against the live fleet. */
13211
+ selector: DeviceSelectorSchema,
13212
+ access: array(MethodAccessSchema).min(1),
13213
+ /**
13214
+ * Whether a grant on a PARENT device transparently covers its accessory
13215
+ * CHILDREN (siren / floodlight / PIR) via the persisted-parentage walk.
13216
+ * Direction is parent → children ONLY.
13217
+ *
13218
+ * Absent → the matcher DERIVES it from the access flavour: `view`
13219
+ * inherits (a camera viewer sees the camera's accessories), `create` /
13220
+ * `delete` do NOT (actuating/removing a child is an explicit act the
13221
+ * operator must grant on the child, not inherit from the parent). Set it
13222
+ * explicitly to override that default per grant.
13223
+ */
13224
+ includeLinked: boolean().optional()
13225
+ });
13226
+ /**
13227
+ * v2 → v3 lazy migration. A pre-v3 `device` grant carried
13228
+ * `targets: string[]` (stringified deviceIds); it rewrites to the equivalent
13229
+ * `selector: {kind:'ids', ids}`. Applied as a `preprocess` so it runs on
13230
+ * EVERY parse path — stored records AND the JWT-carried scope arrays
13231
+ * normalised at the request boundary ({@link normalizeTokenScopes} in
13232
+ * `device-selector.ts`). Chosen over a one-time DB migration because a
13233
+ * migration cannot reach a JWT already in a client's hands; parse-time
13234
+ * migration covers both without a flag day. No cast — the raw object is read
13235
+ * through `Reflect.get` (its static type is `unknown`).
13236
+ */
13237
+ function migrateLegacyTokenScope(raw) {
13238
+ if (raw === null || typeof raw !== "object" || Array.isArray(raw)) return raw;
13239
+ if (Reflect.get(raw, "type") !== "device") return raw;
13240
+ if (Reflect.get(raw, "selector") !== void 0) return raw;
13241
+ const targets = Reflect.get(raw, "targets");
13242
+ if (!Array.isArray(targets)) return raw;
13243
+ return {
13244
+ type: "device",
13245
+ selector: {
13246
+ kind: "ids",
13247
+ ids: targets.map((t) => typeof t === "string" ? Number(t) : t).filter((n) => typeof n === "number" && Number.isInteger(n))
13248
+ },
13249
+ access: Reflect.get(raw, "access")
13250
+ };
13251
+ }
13252
+ var TokenScopeSchema = preprocess(migrateLegacyTokenScope, discriminatedUnion("type", [
13253
+ object({
13254
+ type: literal("category"),
13255
+ target: CapScopeSchema,
13256
+ access: array(MethodAccessSchema).min(1)
13257
+ }),
13258
+ object({
13259
+ type: literal("capability"),
13260
+ target: string(),
13261
+ access: array(MethodAccessSchema).min(1)
13262
+ }),
13263
+ object({
13264
+ type: literal("addon"),
13265
+ target: string(),
13266
+ access: array(MethodAccessSchema).min(1)
13267
+ }),
13268
+ DeviceTokenScopeSchema
13269
+ ]));
13270
+ object({
13271
+ id: string(),
13272
+ username: string(),
13273
+ passwordHash: string(),
13274
+ /**
13275
+ * Admin bypass. When true, the middleware skips the scope-access
13276
+ * check entirely. There is no other axis of privilege; the legacy
13277
+ * role enum collapsed onto this boolean in v2.
13278
+ */
13279
+ isAdmin: boolean().default(false),
13280
+ allowedProviders: AllowedProviderSchema,
13281
+ allowedDevices: AllowedDevicesSchema,
13282
+ /**
13283
+ * Scopes granted to this user. Admins bypass; their `scopes` is
13284
+ * ignored. Non-admins without scopes are locked out of every
13285
+ * protected call.
13286
+ */
13287
+ scopes: array(TokenScopeSchema).default([]),
13288
+ createdAt: number(),
13289
+ updatedAt: number()
13290
+ });
13291
+ object({
13292
+ id: string(),
13293
+ label: string(),
13294
+ isAdmin: boolean().default(false),
13295
+ allowedProviders: AllowedProviderSchema,
13296
+ allowedDevices: AllowedDevicesSchema,
13297
+ tokenHash: string(),
13298
+ tokenPrefix: string(),
13299
+ createdAt: number(),
13300
+ lastUsedAt: number().optional()
13301
+ });
13302
+ object({
13303
+ id: string(),
13304
+ userId: string(),
13305
+ name: string(),
13306
+ tokenHash: string(),
13307
+ tokenPrefix: string(),
13308
+ scopes: array(TokenScopeSchema),
13309
+ expiresAt: number().nullish(),
13310
+ lastUsedAt: number().nullish(),
13311
+ createdAt: number()
13312
+ });
13313
+ /** What a share-view grant lets its holder see. */
13314
+ var ShareViewGrantSchema = object({
13315
+ kind: _enum(SHARE_VIEW_KINDS),
13316
+ deviceIds: array(number().int().nonnegative()).min(1).max(64),
13317
+ /** Talk-back, opt-in at mint time; absent means off. */
13318
+ talk: boolean().optional()
13319
+ });
13320
+ var ShareViewScopeSchema = object({
13321
+ type: literal("share-view"),
13322
+ grant: ShareViewGrantSchema
13323
+ });
13324
+ var AddonRoutesScopeSchema = object({
13325
+ type: literal("addon-routes"),
13326
+ access: array(MethodAccessSchema).min(1)
13327
+ });
13328
+ var CredentialScopeSchema = union([
13329
+ literal("*"),
13330
+ ShareViewScopeSchema,
13331
+ AddonRoutesScopeSchema,
13332
+ TokenScopeSchema
13333
+ ]);
13334
+ object({
13335
+ kind: literal("credential"),
13336
+ sub: string().min(1),
13337
+ jti: string().min(16),
13338
+ scopes: array(CredentialScopeSchema).min(1)
13339
+ });
13111
13340
  _enum(["new-session", "step-up"]);
13112
13341
  /** The languages the hub's app landing pages are written in (D858). */
13113
13342
  var AppPageLangSchema = _enum(["en", "it"]);
@@ -44738,202 +44967,6 @@ method(object({}), object({ rules: array(NcRuleSchema) }), { auth: "admin" }), m
44738
44967
  auth: "admin"
44739
44968
  }), method(NcAlarmSensorsInputSchema, NcAlarmSensorsSchema, { auth: "admin" });
44740
44969
  /**
44741
- * Zod schemas for persisted record types.
44742
- *
44743
- * These schemas serve as the single source of truth for types that are
44744
- * stored in the settings-store backend and retrieved via tRPC. They
44745
- * replace the manual TypeScript interfaces with schema-derived types,
44746
- * enabling runtime validation when reading from the backend.
44747
- *
44748
- * Convention: each schema is named `<Type>Schema`, the inferred TS type
44749
- * keeps the original name for backward compatibility.
44750
- */
44751
- /**
44752
- * Auth model (v2 — 2026-05-12 caps-only):
44753
- *
44754
- * Two principals:
44755
- * - `isAdmin: true` — full bypass. Admin scope set is ignored.
44756
- * - `isAdmin: false` — every call gated by `scopes` (see TokenScope).
44757
- *
44758
- * No role enum. There used to be `viewer / agent / scoped` and earlier
44759
- * `super_admin` — collapsed onto the single boolean because every
44760
- * non-admin caller is governed by the same scope-check rules; the
44761
- * distinction was only ever used to route role-specific procedures
44762
- * which we no longer have. CLI / webhook integrations are `cst_*` tokens
44763
- * with `isAdmin: false` + an explicit scope list.
44764
- */
44765
- /** Per-method access flavour. Materialised on every cap method via codegen. */
44766
- var MethodAccessSchema = _enum([
44767
- "view",
44768
- "create",
44769
- "delete"
44770
- ]);
44771
- /**
44772
- * A single scope grant. Three forms — checked in matcher with OR
44773
- * semantics; the first match decides whether the call passes:
44774
- *
44775
- * - `category` — broadest. `target: 'device' | 'system'` selects every
44776
- * cap with the matching `scope` declaration. New caps inherit grants
44777
- * automatically — adding a device cap to the codebase makes it
44778
- * reachable to every user with `category:device [...]` without a
44779
- * re-grant. Use this for "family viewer" / "operator" tiers.
44780
- *
44781
- * - `addon` — every cap that ships inside a given addon id. Niche;
44782
- * useful when an integration needs to interact with one specific
44783
- * addon's surface regardless of how many caps it exports.
44784
- *
44785
- * - `capability` — the most precise form. Single cap name. Use for
44786
- * integration tokens where you want to grant `addons.installPackage`
44787
- * and nothing else.
44788
- *
44789
- * `access` is REQUIRED with min 1 element. `admin` bypass is the
44790
- * "give me everything" escape; there is no wildcard scope.
44791
- */
44792
- var AllowedProviderSchema = union([literal("*"), array(string())]);
44793
- var AllowedDevicesSchema = record(string(), union([literal("*"), array(string())]));
44794
- var CapScopeSchema = _enum(["device", "system"]);
44795
- /**
44796
- * DeviceSelector (scope model v3 — 2026-08-12).
44797
- *
44798
- * A `device` grant no longer carries a frozen list of deviceIds. It carries
44799
- * a SELECTOR the matcher resolves against the live fleet, so the grant can be
44800
- * DYNAMIC: a `types:['camera']` selector automatically covers a camera added
44801
- * AFTER the grant was minted — no re-grant, no re-login.
44802
- *
44803
- * - `all` — every device in the deployment. The broad viewer/operator
44804
- * lever without a `category` grant (a `category` grant also covers device
44805
- * caps that carry no deviceId; `all` is specifically the device set).
44806
- * - `ids` — an explicit deviceId list. This is what a v2 `device:[…]`
44807
- * grant migrates to (see {@link TokenScopeSchema}); STATIC — a new camera
44808
- * is NOT covered until the grant is edited.
44809
- * - `types` — every device of a `DeviceType` (e.g. every `camera`).
44810
- * DYNAMIC. A device that changes type, or a new device of the type,
44811
- * re-resolves on the next request.
44812
- * - `locations` — every device whose operator-assigned `location` label is
44813
- * in the set (e.g. "Garden", "Front door"). DYNAMIC. A device with a
44814
- * null/unset location matches NO `locations` selector.
44815
- */
44816
- var DeviceSelectorSchema = discriminatedUnion("kind", [
44817
- object({ kind: literal("all") }),
44818
- object({
44819
- kind: literal("ids"),
44820
- ids: array(number().int()).min(1)
44821
- }),
44822
- object({
44823
- kind: literal("types"),
44824
- types: array(_enum(DeviceType)).min(1)
44825
- }),
44826
- object({
44827
- kind: literal("locations"),
44828
- locations: array(string().min(1)).min(1)
44829
- })
44830
- ]);
44831
- var DeviceTokenScopeSchema = object({
44832
- type: literal("device"),
44833
- /** The device SET this grant covers — resolved against the live fleet. */
44834
- selector: DeviceSelectorSchema,
44835
- access: array(MethodAccessSchema).min(1),
44836
- /**
44837
- * Whether a grant on a PARENT device transparently covers its accessory
44838
- * CHILDREN (siren / floodlight / PIR) via the persisted-parentage walk.
44839
- * Direction is parent → children ONLY.
44840
- *
44841
- * Absent → the matcher DERIVES it from the access flavour: `view`
44842
- * inherits (a camera viewer sees the camera's accessories), `create` /
44843
- * `delete` do NOT (actuating/removing a child is an explicit act the
44844
- * operator must grant on the child, not inherit from the parent). Set it
44845
- * explicitly to override that default per grant.
44846
- */
44847
- includeLinked: boolean().optional()
44848
- });
44849
- /**
44850
- * v2 → v3 lazy migration. A pre-v3 `device` grant carried
44851
- * `targets: string[]` (stringified deviceIds); it rewrites to the equivalent
44852
- * `selector: {kind:'ids', ids}`. Applied as a `preprocess` so it runs on
44853
- * EVERY parse path — stored records AND the JWT-carried scope arrays
44854
- * normalised at the request boundary ({@link normalizeTokenScopes} in
44855
- * `device-selector.ts`). Chosen over a one-time DB migration because a
44856
- * migration cannot reach a JWT already in a client's hands; parse-time
44857
- * migration covers both without a flag day. No cast — the raw object is read
44858
- * through `Reflect.get` (its static type is `unknown`).
44859
- */
44860
- function migrateLegacyTokenScope(raw) {
44861
- if (raw === null || typeof raw !== "object" || Array.isArray(raw)) return raw;
44862
- if (Reflect.get(raw, "type") !== "device") return raw;
44863
- if (Reflect.get(raw, "selector") !== void 0) return raw;
44864
- const targets = Reflect.get(raw, "targets");
44865
- if (!Array.isArray(targets)) return raw;
44866
- return {
44867
- type: "device",
44868
- selector: {
44869
- kind: "ids",
44870
- ids: targets.map((t) => typeof t === "string" ? Number(t) : t).filter((n) => typeof n === "number" && Number.isInteger(n))
44871
- },
44872
- access: Reflect.get(raw, "access")
44873
- };
44874
- }
44875
- var TokenScopeSchema = preprocess(migrateLegacyTokenScope, discriminatedUnion("type", [
44876
- object({
44877
- type: literal("category"),
44878
- target: CapScopeSchema,
44879
- access: array(MethodAccessSchema).min(1)
44880
- }),
44881
- object({
44882
- type: literal("capability"),
44883
- target: string(),
44884
- access: array(MethodAccessSchema).min(1)
44885
- }),
44886
- object({
44887
- type: literal("addon"),
44888
- target: string(),
44889
- access: array(MethodAccessSchema).min(1)
44890
- }),
44891
- DeviceTokenScopeSchema
44892
- ]));
44893
- object({
44894
- id: string(),
44895
- username: string(),
44896
- passwordHash: string(),
44897
- /**
44898
- * Admin bypass. When true, the middleware skips the scope-access
44899
- * check entirely. There is no other axis of privilege; the legacy
44900
- * role enum collapsed onto this boolean in v2.
44901
- */
44902
- isAdmin: boolean().default(false),
44903
- allowedProviders: AllowedProviderSchema,
44904
- allowedDevices: AllowedDevicesSchema,
44905
- /**
44906
- * Scopes granted to this user. Admins bypass; their `scopes` is
44907
- * ignored. Non-admins without scopes are locked out of every
44908
- * protected call.
44909
- */
44910
- scopes: array(TokenScopeSchema).default([]),
44911
- createdAt: number(),
44912
- updatedAt: number()
44913
- });
44914
- object({
44915
- id: string(),
44916
- label: string(),
44917
- isAdmin: boolean().default(false),
44918
- allowedProviders: AllowedProviderSchema,
44919
- allowedDevices: AllowedDevicesSchema,
44920
- tokenHash: string(),
44921
- tokenPrefix: string(),
44922
- createdAt: number(),
44923
- lastUsedAt: number().optional()
44924
- });
44925
- object({
44926
- id: string(),
44927
- userId: string(),
44928
- name: string(),
44929
- tokenHash: string(),
44930
- tokenPrefix: string(),
44931
- scopes: array(TokenScopeSchema),
44932
- expiresAt: number().nullish(),
44933
- lastUsedAt: number().nullish(),
44934
- createdAt: number()
44935
- });
44936
- /**
44937
44970
  * `oauth-integration` — a collection cap by which an addon declares
44938
44971
  * itself a linkable OAuth client of the hub's core `/oauth2/*` server.
44939
44972
  * 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-reolink",
3
- "version": "1.2.190",
3
+ "version": "1.2.191",
4
4
  "description": "Reolink camera device provider addon for CamStack — native Baichuan protocol",
5
5
  "keywords": [
6
6
  "camstack",