@camstack/addon-auth 1.2.151 → 1.2.152

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.
@@ -7928,6 +7928,12 @@ function normalizeAddonInitResult(result) {
7928
7928
  if (Array.isArray(result)) return { providers: result };
7929
7929
  return result;
7930
7930
  }
7931
+ /**
7932
+ * The share-view scope kinds a `csv_*` share token can carry. The hub mints
7933
+ * and validates them (`share-token.service.ts` builds its enum from this
7934
+ * list); a data plane names the kinds it ACCEPTS in `share`.
7935
+ */
7936
+ var SHARE_VIEW_KINDS = ["grid-view", "events-view"];
7931
7937
  /** The wire shape of {@link PeerBytesTicket} — see the type for what it is. */
7932
7938
  var PeerBytesTicketSchema = object({
7933
7939
  /** `http://127.0.0.1:<port>/<token>`. One `GET` takes it. */
@@ -12892,6 +12898,229 @@ var ConvertResultSchema = object({
12892
12898
  })).readonly()
12893
12899
  });
12894
12900
  /**
12901
+ * Zod schemas for persisted record types.
12902
+ *
12903
+ * These schemas serve as the single source of truth for types that are
12904
+ * stored in the settings-store backend and retrieved via tRPC. They
12905
+ * replace the manual TypeScript interfaces with schema-derived types,
12906
+ * enabling runtime validation when reading from the backend.
12907
+ *
12908
+ * Convention: each schema is named `<Type>Schema`, the inferred TS type
12909
+ * keeps the original name for backward compatibility.
12910
+ */
12911
+ /**
12912
+ * Auth model (v2 — 2026-05-12 caps-only):
12913
+ *
12914
+ * Two principals:
12915
+ * - `isAdmin: true` — full bypass. Admin scope set is ignored.
12916
+ * - `isAdmin: false` — every call gated by `scopes` (see TokenScope).
12917
+ *
12918
+ * No role enum. There used to be `viewer / agent / scoped` and earlier
12919
+ * `super_admin` — collapsed onto the single boolean because every
12920
+ * non-admin caller is governed by the same scope-check rules; the
12921
+ * distinction was only ever used to route role-specific procedures
12922
+ * which we no longer have. CLI / webhook integrations are `cst_*` tokens
12923
+ * with `isAdmin: false` + an explicit scope list.
12924
+ */
12925
+ /** Per-method access flavour. Materialised on every cap method via codegen. */
12926
+ var MethodAccessSchema = _enum([
12927
+ "view",
12928
+ "create",
12929
+ "delete"
12930
+ ]);
12931
+ /**
12932
+ * A single scope grant. Three forms — checked in matcher with OR
12933
+ * semantics; the first match decides whether the call passes:
12934
+ *
12935
+ * - `category` — broadest. `target: 'device' | 'system'` selects every
12936
+ * cap with the matching `scope` declaration. New caps inherit grants
12937
+ * automatically — adding a device cap to the codebase makes it
12938
+ * reachable to every user with `category:device [...]` without a
12939
+ * re-grant. Use this for "family viewer" / "operator" tiers.
12940
+ *
12941
+ * - `addon` — every cap that ships inside a given addon id. Niche;
12942
+ * useful when an integration needs to interact with one specific
12943
+ * addon's surface regardless of how many caps it exports.
12944
+ *
12945
+ * - `capability` — the most precise form. Single cap name. Use for
12946
+ * integration tokens where you want to grant `addons.installPackage`
12947
+ * and nothing else.
12948
+ *
12949
+ * `access` is REQUIRED with min 1 element. `admin` bypass is the
12950
+ * "give me everything" escape; there is no wildcard scope.
12951
+ */
12952
+ var AllowedProviderSchema = union([literal("*"), array(string())]);
12953
+ var AllowedDevicesSchema = record(string(), union([literal("*"), array(string())]));
12954
+ var CapScopeSchema = _enum(["device", "system"]);
12955
+ /**
12956
+ * DeviceSelector (scope model v3 — 2026-08-12).
12957
+ *
12958
+ * A `device` grant no longer carries a frozen list of deviceIds. It carries
12959
+ * a SELECTOR the matcher resolves against the live fleet, so the grant can be
12960
+ * DYNAMIC: a `types:['camera']` selector automatically covers a camera added
12961
+ * AFTER the grant was minted — no re-grant, no re-login.
12962
+ *
12963
+ * - `all` — every device in the deployment. The broad viewer/operator
12964
+ * lever without a `category` grant (a `category` grant also covers device
12965
+ * caps that carry no deviceId; `all` is specifically the device set).
12966
+ * - `ids` — an explicit deviceId list. This is what a v2 `device:[…]`
12967
+ * grant migrates to (see {@link TokenScopeSchema}); STATIC — a new camera
12968
+ * is NOT covered until the grant is edited.
12969
+ * - `types` — every device of a `DeviceType` (e.g. every `camera`).
12970
+ * DYNAMIC. A device that changes type, or a new device of the type,
12971
+ * re-resolves on the next request.
12972
+ * - `locations` — every device whose operator-assigned `location` label is
12973
+ * in the set (e.g. "Garden", "Front door"). DYNAMIC. A device with a
12974
+ * null/unset location matches NO `locations` selector.
12975
+ */
12976
+ var DeviceSelectorSchema = discriminatedUnion("kind", [
12977
+ object({ kind: literal("all") }),
12978
+ object({
12979
+ kind: literal("ids"),
12980
+ ids: array(number().int()).min(1)
12981
+ }),
12982
+ object({
12983
+ kind: literal("types"),
12984
+ types: array(_enum(DeviceType)).min(1)
12985
+ }),
12986
+ object({
12987
+ kind: literal("locations"),
12988
+ locations: array(string().min(1)).min(1)
12989
+ })
12990
+ ]);
12991
+ var DeviceTokenScopeSchema = object({
12992
+ type: literal("device"),
12993
+ /** The device SET this grant covers — resolved against the live fleet. */
12994
+ selector: DeviceSelectorSchema,
12995
+ access: array(MethodAccessSchema).min(1),
12996
+ /**
12997
+ * Whether a grant on a PARENT device transparently covers its accessory
12998
+ * CHILDREN (siren / floodlight / PIR) via the persisted-parentage walk.
12999
+ * Direction is parent → children ONLY.
13000
+ *
13001
+ * Absent → the matcher DERIVES it from the access flavour: `view`
13002
+ * inherits (a camera viewer sees the camera's accessories), `create` /
13003
+ * `delete` do NOT (actuating/removing a child is an explicit act the
13004
+ * operator must grant on the child, not inherit from the parent). Set it
13005
+ * explicitly to override that default per grant.
13006
+ */
13007
+ includeLinked: boolean().optional()
13008
+ });
13009
+ /**
13010
+ * v2 → v3 lazy migration. A pre-v3 `device` grant carried
13011
+ * `targets: string[]` (stringified deviceIds); it rewrites to the equivalent
13012
+ * `selector: {kind:'ids', ids}`. Applied as a `preprocess` so it runs on
13013
+ * EVERY parse path — stored records AND the JWT-carried scope arrays
13014
+ * normalised at the request boundary ({@link normalizeTokenScopes} in
13015
+ * `device-selector.ts`). Chosen over a one-time DB migration because a
13016
+ * migration cannot reach a JWT already in a client's hands; parse-time
13017
+ * migration covers both without a flag day. No cast — the raw object is read
13018
+ * through `Reflect.get` (its static type is `unknown`).
13019
+ */
13020
+ function migrateLegacyTokenScope(raw) {
13021
+ if (raw === null || typeof raw !== "object" || Array.isArray(raw)) return raw;
13022
+ if (Reflect.get(raw, "type") !== "device") return raw;
13023
+ if (Reflect.get(raw, "selector") !== void 0) return raw;
13024
+ const targets = Reflect.get(raw, "targets");
13025
+ if (!Array.isArray(targets)) return raw;
13026
+ return {
13027
+ type: "device",
13028
+ selector: {
13029
+ kind: "ids",
13030
+ ids: targets.map((t) => typeof t === "string" ? Number(t) : t).filter((n) => typeof n === "number" && Number.isInteger(n))
13031
+ },
13032
+ access: Reflect.get(raw, "access")
13033
+ };
13034
+ }
13035
+ var TokenScopeSchema = preprocess(migrateLegacyTokenScope, discriminatedUnion("type", [
13036
+ object({
13037
+ type: literal("category"),
13038
+ target: CapScopeSchema,
13039
+ access: array(MethodAccessSchema).min(1)
13040
+ }),
13041
+ object({
13042
+ type: literal("capability"),
13043
+ target: string(),
13044
+ access: array(MethodAccessSchema).min(1)
13045
+ }),
13046
+ object({
13047
+ type: literal("addon"),
13048
+ target: string(),
13049
+ access: array(MethodAccessSchema).min(1)
13050
+ }),
13051
+ DeviceTokenScopeSchema
13052
+ ]));
13053
+ object({
13054
+ id: string(),
13055
+ username: string(),
13056
+ passwordHash: string(),
13057
+ /**
13058
+ * Admin bypass. When true, the middleware skips the scope-access
13059
+ * check entirely. There is no other axis of privilege; the legacy
13060
+ * role enum collapsed onto this boolean in v2.
13061
+ */
13062
+ isAdmin: boolean().default(false),
13063
+ allowedProviders: AllowedProviderSchema,
13064
+ allowedDevices: AllowedDevicesSchema,
13065
+ /**
13066
+ * Scopes granted to this user. Admins bypass; their `scopes` is
13067
+ * ignored. Non-admins without scopes are locked out of every
13068
+ * protected call.
13069
+ */
13070
+ scopes: array(TokenScopeSchema).default([]),
13071
+ createdAt: number(),
13072
+ updatedAt: number()
13073
+ });
13074
+ object({
13075
+ id: string(),
13076
+ label: string(),
13077
+ isAdmin: boolean().default(false),
13078
+ allowedProviders: AllowedProviderSchema,
13079
+ allowedDevices: AllowedDevicesSchema,
13080
+ tokenHash: string(),
13081
+ tokenPrefix: string(),
13082
+ createdAt: number(),
13083
+ lastUsedAt: number().optional()
13084
+ });
13085
+ object({
13086
+ id: string(),
13087
+ userId: string(),
13088
+ name: string(),
13089
+ tokenHash: string(),
13090
+ tokenPrefix: string(),
13091
+ scopes: array(TokenScopeSchema),
13092
+ expiresAt: number().nullish(),
13093
+ lastUsedAt: number().nullish(),
13094
+ createdAt: number()
13095
+ });
13096
+ /** What a share-view grant lets its holder see. */
13097
+ var ShareViewGrantSchema = object({
13098
+ kind: _enum(SHARE_VIEW_KINDS),
13099
+ deviceIds: array(number().int().nonnegative()).min(1).max(64),
13100
+ /** Talk-back, opt-in at mint time; absent means off. */
13101
+ talk: boolean().optional()
13102
+ });
13103
+ var ShareViewScopeSchema = object({
13104
+ type: literal("share-view"),
13105
+ grant: ShareViewGrantSchema
13106
+ });
13107
+ var AddonRoutesScopeSchema = object({
13108
+ type: literal("addon-routes"),
13109
+ access: array(MethodAccessSchema).min(1)
13110
+ });
13111
+ var CredentialScopeSchema = union([
13112
+ literal("*"),
13113
+ ShareViewScopeSchema,
13114
+ AddonRoutesScopeSchema,
13115
+ TokenScopeSchema
13116
+ ]);
13117
+ object({
13118
+ kind: literal("credential"),
13119
+ sub: string().min(1),
13120
+ jti: string().min(16),
13121
+ scopes: array(CredentialScopeSchema).min(1)
13122
+ });
13123
+ /**
12895
13124
  * The viewer app's custom-scheme callback — the ONE list of URLs a hub flow
12896
13125
  * may hand a browser back to the native app at.
12897
13126
  *
@@ -44313,202 +44542,6 @@ method(object({}), object({ rules: array(NcRuleSchema) }), { auth: "admin" }), m
44313
44542
  auth: "admin"
44314
44543
  }), method(NcAlarmSensorsInputSchema, NcAlarmSensorsSchema, { auth: "admin" });
44315
44544
  /**
44316
- * Zod schemas for persisted record types.
44317
- *
44318
- * These schemas serve as the single source of truth for types that are
44319
- * stored in the settings-store backend and retrieved via tRPC. They
44320
- * replace the manual TypeScript interfaces with schema-derived types,
44321
- * enabling runtime validation when reading from the backend.
44322
- *
44323
- * Convention: each schema is named `<Type>Schema`, the inferred TS type
44324
- * keeps the original name for backward compatibility.
44325
- */
44326
- /**
44327
- * Auth model (v2 — 2026-05-12 caps-only):
44328
- *
44329
- * Two principals:
44330
- * - `isAdmin: true` — full bypass. Admin scope set is ignored.
44331
- * - `isAdmin: false` — every call gated by `scopes` (see TokenScope).
44332
- *
44333
- * No role enum. There used to be `viewer / agent / scoped` and earlier
44334
- * `super_admin` — collapsed onto the single boolean because every
44335
- * non-admin caller is governed by the same scope-check rules; the
44336
- * distinction was only ever used to route role-specific procedures
44337
- * which we no longer have. CLI / webhook integrations are `cst_*` tokens
44338
- * with `isAdmin: false` + an explicit scope list.
44339
- */
44340
- /** Per-method access flavour. Materialised on every cap method via codegen. */
44341
- var MethodAccessSchema = _enum([
44342
- "view",
44343
- "create",
44344
- "delete"
44345
- ]);
44346
- /**
44347
- * A single scope grant. Three forms — checked in matcher with OR
44348
- * semantics; the first match decides whether the call passes:
44349
- *
44350
- * - `category` — broadest. `target: 'device' | 'system'` selects every
44351
- * cap with the matching `scope` declaration. New caps inherit grants
44352
- * automatically — adding a device cap to the codebase makes it
44353
- * reachable to every user with `category:device [...]` without a
44354
- * re-grant. Use this for "family viewer" / "operator" tiers.
44355
- *
44356
- * - `addon` — every cap that ships inside a given addon id. Niche;
44357
- * useful when an integration needs to interact with one specific
44358
- * addon's surface regardless of how many caps it exports.
44359
- *
44360
- * - `capability` — the most precise form. Single cap name. Use for
44361
- * integration tokens where you want to grant `addons.installPackage`
44362
- * and nothing else.
44363
- *
44364
- * `access` is REQUIRED with min 1 element. `admin` bypass is the
44365
- * "give me everything" escape; there is no wildcard scope.
44366
- */
44367
- var AllowedProviderSchema = union([literal("*"), array(string())]);
44368
- var AllowedDevicesSchema = record(string(), union([literal("*"), array(string())]));
44369
- var CapScopeSchema = _enum(["device", "system"]);
44370
- /**
44371
- * DeviceSelector (scope model v3 — 2026-08-12).
44372
- *
44373
- * A `device` grant no longer carries a frozen list of deviceIds. It carries
44374
- * a SELECTOR the matcher resolves against the live fleet, so the grant can be
44375
- * DYNAMIC: a `types:['camera']` selector automatically covers a camera added
44376
- * AFTER the grant was minted — no re-grant, no re-login.
44377
- *
44378
- * - `all` — every device in the deployment. The broad viewer/operator
44379
- * lever without a `category` grant (a `category` grant also covers device
44380
- * caps that carry no deviceId; `all` is specifically the device set).
44381
- * - `ids` — an explicit deviceId list. This is what a v2 `device:[…]`
44382
- * grant migrates to (see {@link TokenScopeSchema}); STATIC — a new camera
44383
- * is NOT covered until the grant is edited.
44384
- * - `types` — every device of a `DeviceType` (e.g. every `camera`).
44385
- * DYNAMIC. A device that changes type, or a new device of the type,
44386
- * re-resolves on the next request.
44387
- * - `locations` — every device whose operator-assigned `location` label is
44388
- * in the set (e.g. "Garden", "Front door"). DYNAMIC. A device with a
44389
- * null/unset location matches NO `locations` selector.
44390
- */
44391
- var DeviceSelectorSchema = discriminatedUnion("kind", [
44392
- object({ kind: literal("all") }),
44393
- object({
44394
- kind: literal("ids"),
44395
- ids: array(number().int()).min(1)
44396
- }),
44397
- object({
44398
- kind: literal("types"),
44399
- types: array(_enum(DeviceType)).min(1)
44400
- }),
44401
- object({
44402
- kind: literal("locations"),
44403
- locations: array(string().min(1)).min(1)
44404
- })
44405
- ]);
44406
- var DeviceTokenScopeSchema = object({
44407
- type: literal("device"),
44408
- /** The device SET this grant covers — resolved against the live fleet. */
44409
- selector: DeviceSelectorSchema,
44410
- access: array(MethodAccessSchema).min(1),
44411
- /**
44412
- * Whether a grant on a PARENT device transparently covers its accessory
44413
- * CHILDREN (siren / floodlight / PIR) via the persisted-parentage walk.
44414
- * Direction is parent → children ONLY.
44415
- *
44416
- * Absent → the matcher DERIVES it from the access flavour: `view`
44417
- * inherits (a camera viewer sees the camera's accessories), `create` /
44418
- * `delete` do NOT (actuating/removing a child is an explicit act the
44419
- * operator must grant on the child, not inherit from the parent). Set it
44420
- * explicitly to override that default per grant.
44421
- */
44422
- includeLinked: boolean().optional()
44423
- });
44424
- /**
44425
- * v2 → v3 lazy migration. A pre-v3 `device` grant carried
44426
- * `targets: string[]` (stringified deviceIds); it rewrites to the equivalent
44427
- * `selector: {kind:'ids', ids}`. Applied as a `preprocess` so it runs on
44428
- * EVERY parse path — stored records AND the JWT-carried scope arrays
44429
- * normalised at the request boundary ({@link normalizeTokenScopes} in
44430
- * `device-selector.ts`). Chosen over a one-time DB migration because a
44431
- * migration cannot reach a JWT already in a client's hands; parse-time
44432
- * migration covers both without a flag day. No cast — the raw object is read
44433
- * through `Reflect.get` (its static type is `unknown`).
44434
- */
44435
- function migrateLegacyTokenScope(raw) {
44436
- if (raw === null || typeof raw !== "object" || Array.isArray(raw)) return raw;
44437
- if (Reflect.get(raw, "type") !== "device") return raw;
44438
- if (Reflect.get(raw, "selector") !== void 0) return raw;
44439
- const targets = Reflect.get(raw, "targets");
44440
- if (!Array.isArray(targets)) return raw;
44441
- return {
44442
- type: "device",
44443
- selector: {
44444
- kind: "ids",
44445
- ids: targets.map((t) => typeof t === "string" ? Number(t) : t).filter((n) => typeof n === "number" && Number.isInteger(n))
44446
- },
44447
- access: Reflect.get(raw, "access")
44448
- };
44449
- }
44450
- var TokenScopeSchema = preprocess(migrateLegacyTokenScope, discriminatedUnion("type", [
44451
- object({
44452
- type: literal("category"),
44453
- target: CapScopeSchema,
44454
- access: array(MethodAccessSchema).min(1)
44455
- }),
44456
- object({
44457
- type: literal("capability"),
44458
- target: string(),
44459
- access: array(MethodAccessSchema).min(1)
44460
- }),
44461
- object({
44462
- type: literal("addon"),
44463
- target: string(),
44464
- access: array(MethodAccessSchema).min(1)
44465
- }),
44466
- DeviceTokenScopeSchema
44467
- ]));
44468
- object({
44469
- id: string(),
44470
- username: string(),
44471
- passwordHash: string(),
44472
- /**
44473
- * Admin bypass. When true, the middleware skips the scope-access
44474
- * check entirely. There is no other axis of privilege; the legacy
44475
- * role enum collapsed onto this boolean in v2.
44476
- */
44477
- isAdmin: boolean().default(false),
44478
- allowedProviders: AllowedProviderSchema,
44479
- allowedDevices: AllowedDevicesSchema,
44480
- /**
44481
- * Scopes granted to this user. Admins bypass; their `scopes` is
44482
- * ignored. Non-admins without scopes are locked out of every
44483
- * protected call.
44484
- */
44485
- scopes: array(TokenScopeSchema).default([]),
44486
- createdAt: number(),
44487
- updatedAt: number()
44488
- });
44489
- object({
44490
- id: string(),
44491
- label: string(),
44492
- isAdmin: boolean().default(false),
44493
- allowedProviders: AllowedProviderSchema,
44494
- allowedDevices: AllowedDevicesSchema,
44495
- tokenHash: string(),
44496
- tokenPrefix: string(),
44497
- createdAt: number(),
44498
- lastUsedAt: number().optional()
44499
- });
44500
- object({
44501
- id: string(),
44502
- userId: string(),
44503
- name: string(),
44504
- tokenHash: string(),
44505
- tokenPrefix: string(),
44506
- scopes: array(TokenScopeSchema),
44507
- expiresAt: number().nullish(),
44508
- lastUsedAt: number().nullish(),
44509
- createdAt: number()
44510
- });
44511
- /**
44512
44545
  * `oauth-integration` — a collection cap by which an addon declares
44513
44546
  * itself a linkable OAuth client of the hub's core `/oauth2/*` server.
44514
44547
  * Each provider returns a static descriptor; the core enumerates them
@@ -7962,6 +7962,12 @@ function normalizeAddonInitResult(result) {
7962
7962
  if (Array.isArray(result)) return { providers: result };
7963
7963
  return result;
7964
7964
  }
7965
+ /**
7966
+ * The share-view scope kinds a `csv_*` share token can carry. The hub mints
7967
+ * and validates them (`share-token.service.ts` builds its enum from this
7968
+ * list); a data plane names the kinds it ACCEPTS in `share`.
7969
+ */
7970
+ var SHARE_VIEW_KINDS = ["grid-view", "events-view"];
7965
7971
  /** The wire shape of {@link PeerBytesTicket} — see the type for what it is. */
7966
7972
  var PeerBytesTicketSchema = object({
7967
7973
  /** `http://127.0.0.1:<port>/<token>`. One `GET` takes it. */
@@ -12926,6 +12932,229 @@ var ConvertResultSchema = object({
12926
12932
  })).readonly()
12927
12933
  });
12928
12934
  /**
12935
+ * Zod schemas for persisted record types.
12936
+ *
12937
+ * These schemas serve as the single source of truth for types that are
12938
+ * stored in the settings-store backend and retrieved via tRPC. They
12939
+ * replace the manual TypeScript interfaces with schema-derived types,
12940
+ * enabling runtime validation when reading from the backend.
12941
+ *
12942
+ * Convention: each schema is named `<Type>Schema`, the inferred TS type
12943
+ * keeps the original name for backward compatibility.
12944
+ */
12945
+ /**
12946
+ * Auth model (v2 — 2026-05-12 caps-only):
12947
+ *
12948
+ * Two principals:
12949
+ * - `isAdmin: true` — full bypass. Admin scope set is ignored.
12950
+ * - `isAdmin: false` — every call gated by `scopes` (see TokenScope).
12951
+ *
12952
+ * No role enum. There used to be `viewer / agent / scoped` and earlier
12953
+ * `super_admin` — collapsed onto the single boolean because every
12954
+ * non-admin caller is governed by the same scope-check rules; the
12955
+ * distinction was only ever used to route role-specific procedures
12956
+ * which we no longer have. CLI / webhook integrations are `cst_*` tokens
12957
+ * with `isAdmin: false` + an explicit scope list.
12958
+ */
12959
+ /** Per-method access flavour. Materialised on every cap method via codegen. */
12960
+ var MethodAccessSchema = _enum([
12961
+ "view",
12962
+ "create",
12963
+ "delete"
12964
+ ]);
12965
+ /**
12966
+ * A single scope grant. Three forms — checked in matcher with OR
12967
+ * semantics; the first match decides whether the call passes:
12968
+ *
12969
+ * - `category` — broadest. `target: 'device' | 'system'` selects every
12970
+ * cap with the matching `scope` declaration. New caps inherit grants
12971
+ * automatically — adding a device cap to the codebase makes it
12972
+ * reachable to every user with `category:device [...]` without a
12973
+ * re-grant. Use this for "family viewer" / "operator" tiers.
12974
+ *
12975
+ * - `addon` — every cap that ships inside a given addon id. Niche;
12976
+ * useful when an integration needs to interact with one specific
12977
+ * addon's surface regardless of how many caps it exports.
12978
+ *
12979
+ * - `capability` — the most precise form. Single cap name. Use for
12980
+ * integration tokens where you want to grant `addons.installPackage`
12981
+ * and nothing else.
12982
+ *
12983
+ * `access` is REQUIRED with min 1 element. `admin` bypass is the
12984
+ * "give me everything" escape; there is no wildcard scope.
12985
+ */
12986
+ var AllowedProviderSchema = union([literal("*"), array(string())]);
12987
+ var AllowedDevicesSchema = record(string(), union([literal("*"), array(string())]));
12988
+ var CapScopeSchema = _enum(["device", "system"]);
12989
+ /**
12990
+ * DeviceSelector (scope model v3 — 2026-08-12).
12991
+ *
12992
+ * A `device` grant no longer carries a frozen list of deviceIds. It carries
12993
+ * a SELECTOR the matcher resolves against the live fleet, so the grant can be
12994
+ * DYNAMIC: a `types:['camera']` selector automatically covers a camera added
12995
+ * AFTER the grant was minted — no re-grant, no re-login.
12996
+ *
12997
+ * - `all` — every device in the deployment. The broad viewer/operator
12998
+ * lever without a `category` grant (a `category` grant also covers device
12999
+ * caps that carry no deviceId; `all` is specifically the device set).
13000
+ * - `ids` — an explicit deviceId list. This is what a v2 `device:[…]`
13001
+ * grant migrates to (see {@link TokenScopeSchema}); STATIC — a new camera
13002
+ * is NOT covered until the grant is edited.
13003
+ * - `types` — every device of a `DeviceType` (e.g. every `camera`).
13004
+ * DYNAMIC. A device that changes type, or a new device of the type,
13005
+ * re-resolves on the next request.
13006
+ * - `locations` — every device whose operator-assigned `location` label is
13007
+ * in the set (e.g. "Garden", "Front door"). DYNAMIC. A device with a
13008
+ * null/unset location matches NO `locations` selector.
13009
+ */
13010
+ var DeviceSelectorSchema = discriminatedUnion("kind", [
13011
+ object({ kind: literal("all") }),
13012
+ object({
13013
+ kind: literal("ids"),
13014
+ ids: array(number().int()).min(1)
13015
+ }),
13016
+ object({
13017
+ kind: literal("types"),
13018
+ types: array(_enum(DeviceType)).min(1)
13019
+ }),
13020
+ object({
13021
+ kind: literal("locations"),
13022
+ locations: array(string().min(1)).min(1)
13023
+ })
13024
+ ]);
13025
+ var DeviceTokenScopeSchema = object({
13026
+ type: literal("device"),
13027
+ /** The device SET this grant covers — resolved against the live fleet. */
13028
+ selector: DeviceSelectorSchema,
13029
+ access: array(MethodAccessSchema).min(1),
13030
+ /**
13031
+ * Whether a grant on a PARENT device transparently covers its accessory
13032
+ * CHILDREN (siren / floodlight / PIR) via the persisted-parentage walk.
13033
+ * Direction is parent → children ONLY.
13034
+ *
13035
+ * Absent → the matcher DERIVES it from the access flavour: `view`
13036
+ * inherits (a camera viewer sees the camera's accessories), `create` /
13037
+ * `delete` do NOT (actuating/removing a child is an explicit act the
13038
+ * operator must grant on the child, not inherit from the parent). Set it
13039
+ * explicitly to override that default per grant.
13040
+ */
13041
+ includeLinked: boolean().optional()
13042
+ });
13043
+ /**
13044
+ * v2 → v3 lazy migration. A pre-v3 `device` grant carried
13045
+ * `targets: string[]` (stringified deviceIds); it rewrites to the equivalent
13046
+ * `selector: {kind:'ids', ids}`. Applied as a `preprocess` so it runs on
13047
+ * EVERY parse path — stored records AND the JWT-carried scope arrays
13048
+ * normalised at the request boundary ({@link normalizeTokenScopes} in
13049
+ * `device-selector.ts`). Chosen over a one-time DB migration because a
13050
+ * migration cannot reach a JWT already in a client's hands; parse-time
13051
+ * migration covers both without a flag day. No cast — the raw object is read
13052
+ * through `Reflect.get` (its static type is `unknown`).
13053
+ */
13054
+ function migrateLegacyTokenScope(raw) {
13055
+ if (raw === null || typeof raw !== "object" || Array.isArray(raw)) return raw;
13056
+ if (Reflect.get(raw, "type") !== "device") return raw;
13057
+ if (Reflect.get(raw, "selector") !== void 0) return raw;
13058
+ const targets = Reflect.get(raw, "targets");
13059
+ if (!Array.isArray(targets)) return raw;
13060
+ return {
13061
+ type: "device",
13062
+ selector: {
13063
+ kind: "ids",
13064
+ ids: targets.map((t) => typeof t === "string" ? Number(t) : t).filter((n) => typeof n === "number" && Number.isInteger(n))
13065
+ },
13066
+ access: Reflect.get(raw, "access")
13067
+ };
13068
+ }
13069
+ var TokenScopeSchema = preprocess(migrateLegacyTokenScope, discriminatedUnion("type", [
13070
+ object({
13071
+ type: literal("category"),
13072
+ target: CapScopeSchema,
13073
+ access: array(MethodAccessSchema).min(1)
13074
+ }),
13075
+ object({
13076
+ type: literal("capability"),
13077
+ target: string(),
13078
+ access: array(MethodAccessSchema).min(1)
13079
+ }),
13080
+ object({
13081
+ type: literal("addon"),
13082
+ target: string(),
13083
+ access: array(MethodAccessSchema).min(1)
13084
+ }),
13085
+ DeviceTokenScopeSchema
13086
+ ]));
13087
+ object({
13088
+ id: string(),
13089
+ username: string(),
13090
+ passwordHash: string(),
13091
+ /**
13092
+ * Admin bypass. When true, the middleware skips the scope-access
13093
+ * check entirely. There is no other axis of privilege; the legacy
13094
+ * role enum collapsed onto this boolean in v2.
13095
+ */
13096
+ isAdmin: boolean().default(false),
13097
+ allowedProviders: AllowedProviderSchema,
13098
+ allowedDevices: AllowedDevicesSchema,
13099
+ /**
13100
+ * Scopes granted to this user. Admins bypass; their `scopes` is
13101
+ * ignored. Non-admins without scopes are locked out of every
13102
+ * protected call.
13103
+ */
13104
+ scopes: array(TokenScopeSchema).default([]),
13105
+ createdAt: number(),
13106
+ updatedAt: number()
13107
+ });
13108
+ object({
13109
+ id: string(),
13110
+ label: string(),
13111
+ isAdmin: boolean().default(false),
13112
+ allowedProviders: AllowedProviderSchema,
13113
+ allowedDevices: AllowedDevicesSchema,
13114
+ tokenHash: string(),
13115
+ tokenPrefix: string(),
13116
+ createdAt: number(),
13117
+ lastUsedAt: number().optional()
13118
+ });
13119
+ object({
13120
+ id: string(),
13121
+ userId: string(),
13122
+ name: string(),
13123
+ tokenHash: string(),
13124
+ tokenPrefix: string(),
13125
+ scopes: array(TokenScopeSchema),
13126
+ expiresAt: number().nullish(),
13127
+ lastUsedAt: number().nullish(),
13128
+ createdAt: number()
13129
+ });
13130
+ /** What a share-view grant lets its holder see. */
13131
+ var ShareViewGrantSchema = object({
13132
+ kind: _enum(SHARE_VIEW_KINDS),
13133
+ deviceIds: array(number().int().nonnegative()).min(1).max(64),
13134
+ /** Talk-back, opt-in at mint time; absent means off. */
13135
+ talk: boolean().optional()
13136
+ });
13137
+ var ShareViewScopeSchema = object({
13138
+ type: literal("share-view"),
13139
+ grant: ShareViewGrantSchema
13140
+ });
13141
+ var AddonRoutesScopeSchema = object({
13142
+ type: literal("addon-routes"),
13143
+ access: array(MethodAccessSchema).min(1)
13144
+ });
13145
+ var CredentialScopeSchema = union([
13146
+ literal("*"),
13147
+ ShareViewScopeSchema,
13148
+ AddonRoutesScopeSchema,
13149
+ TokenScopeSchema
13150
+ ]);
13151
+ object({
13152
+ kind: literal("credential"),
13153
+ sub: string().min(1),
13154
+ jti: string().min(16),
13155
+ scopes: array(CredentialScopeSchema).min(1)
13156
+ });
13157
+ /**
12929
13158
  * The viewer app's custom-scheme callback — the ONE list of URLs a hub flow
12930
13159
  * may hand a browser back to the native app at.
12931
13160
  *
@@ -44347,202 +44576,6 @@ method(object({}), object({ rules: array(NcRuleSchema) }), { auth: "admin" }), m
44347
44576
  auth: "admin"
44348
44577
  }), method(NcAlarmSensorsInputSchema, NcAlarmSensorsSchema, { auth: "admin" });
44349
44578
  /**
44350
- * Zod schemas for persisted record types.
44351
- *
44352
- * These schemas serve as the single source of truth for types that are
44353
- * stored in the settings-store backend and retrieved via tRPC. They
44354
- * replace the manual TypeScript interfaces with schema-derived types,
44355
- * enabling runtime validation when reading from the backend.
44356
- *
44357
- * Convention: each schema is named `<Type>Schema`, the inferred TS type
44358
- * keeps the original name for backward compatibility.
44359
- */
44360
- /**
44361
- * Auth model (v2 — 2026-05-12 caps-only):
44362
- *
44363
- * Two principals:
44364
- * - `isAdmin: true` — full bypass. Admin scope set is ignored.
44365
- * - `isAdmin: false` — every call gated by `scopes` (see TokenScope).
44366
- *
44367
- * No role enum. There used to be `viewer / agent / scoped` and earlier
44368
- * `super_admin` — collapsed onto the single boolean because every
44369
- * non-admin caller is governed by the same scope-check rules; the
44370
- * distinction was only ever used to route role-specific procedures
44371
- * which we no longer have. CLI / webhook integrations are `cst_*` tokens
44372
- * with `isAdmin: false` + an explicit scope list.
44373
- */
44374
- /** Per-method access flavour. Materialised on every cap method via codegen. */
44375
- var MethodAccessSchema = _enum([
44376
- "view",
44377
- "create",
44378
- "delete"
44379
- ]);
44380
- /**
44381
- * A single scope grant. Three forms — checked in matcher with OR
44382
- * semantics; the first match decides whether the call passes:
44383
- *
44384
- * - `category` — broadest. `target: 'device' | 'system'` selects every
44385
- * cap with the matching `scope` declaration. New caps inherit grants
44386
- * automatically — adding a device cap to the codebase makes it
44387
- * reachable to every user with `category:device [...]` without a
44388
- * re-grant. Use this for "family viewer" / "operator" tiers.
44389
- *
44390
- * - `addon` — every cap that ships inside a given addon id. Niche;
44391
- * useful when an integration needs to interact with one specific
44392
- * addon's surface regardless of how many caps it exports.
44393
- *
44394
- * - `capability` — the most precise form. Single cap name. Use for
44395
- * integration tokens where you want to grant `addons.installPackage`
44396
- * and nothing else.
44397
- *
44398
- * `access` is REQUIRED with min 1 element. `admin` bypass is the
44399
- * "give me everything" escape; there is no wildcard scope.
44400
- */
44401
- var AllowedProviderSchema = union([literal("*"), array(string())]);
44402
- var AllowedDevicesSchema = record(string(), union([literal("*"), array(string())]));
44403
- var CapScopeSchema = _enum(["device", "system"]);
44404
- /**
44405
- * DeviceSelector (scope model v3 — 2026-08-12).
44406
- *
44407
- * A `device` grant no longer carries a frozen list of deviceIds. It carries
44408
- * a SELECTOR the matcher resolves against the live fleet, so the grant can be
44409
- * DYNAMIC: a `types:['camera']` selector automatically covers a camera added
44410
- * AFTER the grant was minted — no re-grant, no re-login.
44411
- *
44412
- * - `all` — every device in the deployment. The broad viewer/operator
44413
- * lever without a `category` grant (a `category` grant also covers device
44414
- * caps that carry no deviceId; `all` is specifically the device set).
44415
- * - `ids` — an explicit deviceId list. This is what a v2 `device:[…]`
44416
- * grant migrates to (see {@link TokenScopeSchema}); STATIC — a new camera
44417
- * is NOT covered until the grant is edited.
44418
- * - `types` — every device of a `DeviceType` (e.g. every `camera`).
44419
- * DYNAMIC. A device that changes type, or a new device of the type,
44420
- * re-resolves on the next request.
44421
- * - `locations` — every device whose operator-assigned `location` label is
44422
- * in the set (e.g. "Garden", "Front door"). DYNAMIC. A device with a
44423
- * null/unset location matches NO `locations` selector.
44424
- */
44425
- var DeviceSelectorSchema = discriminatedUnion("kind", [
44426
- object({ kind: literal("all") }),
44427
- object({
44428
- kind: literal("ids"),
44429
- ids: array(number().int()).min(1)
44430
- }),
44431
- object({
44432
- kind: literal("types"),
44433
- types: array(_enum(DeviceType)).min(1)
44434
- }),
44435
- object({
44436
- kind: literal("locations"),
44437
- locations: array(string().min(1)).min(1)
44438
- })
44439
- ]);
44440
- var DeviceTokenScopeSchema = object({
44441
- type: literal("device"),
44442
- /** The device SET this grant covers — resolved against the live fleet. */
44443
- selector: DeviceSelectorSchema,
44444
- access: array(MethodAccessSchema).min(1),
44445
- /**
44446
- * Whether a grant on a PARENT device transparently covers its accessory
44447
- * CHILDREN (siren / floodlight / PIR) via the persisted-parentage walk.
44448
- * Direction is parent → children ONLY.
44449
- *
44450
- * Absent → the matcher DERIVES it from the access flavour: `view`
44451
- * inherits (a camera viewer sees the camera's accessories), `create` /
44452
- * `delete` do NOT (actuating/removing a child is an explicit act the
44453
- * operator must grant on the child, not inherit from the parent). Set it
44454
- * explicitly to override that default per grant.
44455
- */
44456
- includeLinked: boolean().optional()
44457
- });
44458
- /**
44459
- * v2 → v3 lazy migration. A pre-v3 `device` grant carried
44460
- * `targets: string[]` (stringified deviceIds); it rewrites to the equivalent
44461
- * `selector: {kind:'ids', ids}`. Applied as a `preprocess` so it runs on
44462
- * EVERY parse path — stored records AND the JWT-carried scope arrays
44463
- * normalised at the request boundary ({@link normalizeTokenScopes} in
44464
- * `device-selector.ts`). Chosen over a one-time DB migration because a
44465
- * migration cannot reach a JWT already in a client's hands; parse-time
44466
- * migration covers both without a flag day. No cast — the raw object is read
44467
- * through `Reflect.get` (its static type is `unknown`).
44468
- */
44469
- function migrateLegacyTokenScope(raw) {
44470
- if (raw === null || typeof raw !== "object" || Array.isArray(raw)) return raw;
44471
- if (Reflect.get(raw, "type") !== "device") return raw;
44472
- if (Reflect.get(raw, "selector") !== void 0) return raw;
44473
- const targets = Reflect.get(raw, "targets");
44474
- if (!Array.isArray(targets)) return raw;
44475
- return {
44476
- type: "device",
44477
- selector: {
44478
- kind: "ids",
44479
- ids: targets.map((t) => typeof t === "string" ? Number(t) : t).filter((n) => typeof n === "number" && Number.isInteger(n))
44480
- },
44481
- access: Reflect.get(raw, "access")
44482
- };
44483
- }
44484
- var TokenScopeSchema = preprocess(migrateLegacyTokenScope, discriminatedUnion("type", [
44485
- object({
44486
- type: literal("category"),
44487
- target: CapScopeSchema,
44488
- access: array(MethodAccessSchema).min(1)
44489
- }),
44490
- object({
44491
- type: literal("capability"),
44492
- target: string(),
44493
- access: array(MethodAccessSchema).min(1)
44494
- }),
44495
- object({
44496
- type: literal("addon"),
44497
- target: string(),
44498
- access: array(MethodAccessSchema).min(1)
44499
- }),
44500
- DeviceTokenScopeSchema
44501
- ]));
44502
- object({
44503
- id: string(),
44504
- username: string(),
44505
- passwordHash: string(),
44506
- /**
44507
- * Admin bypass. When true, the middleware skips the scope-access
44508
- * check entirely. There is no other axis of privilege; the legacy
44509
- * role enum collapsed onto this boolean in v2.
44510
- */
44511
- isAdmin: boolean().default(false),
44512
- allowedProviders: AllowedProviderSchema,
44513
- allowedDevices: AllowedDevicesSchema,
44514
- /**
44515
- * Scopes granted to this user. Admins bypass; their `scopes` is
44516
- * ignored. Non-admins without scopes are locked out of every
44517
- * protected call.
44518
- */
44519
- scopes: array(TokenScopeSchema).default([]),
44520
- createdAt: number(),
44521
- updatedAt: number()
44522
- });
44523
- object({
44524
- id: string(),
44525
- label: string(),
44526
- isAdmin: boolean().default(false),
44527
- allowedProviders: AllowedProviderSchema,
44528
- allowedDevices: AllowedDevicesSchema,
44529
- tokenHash: string(),
44530
- tokenPrefix: string(),
44531
- createdAt: number(),
44532
- lastUsedAt: number().optional()
44533
- });
44534
- object({
44535
- id: string(),
44536
- userId: string(),
44537
- name: string(),
44538
- tokenHash: string(),
44539
- tokenPrefix: string(),
44540
- scopes: array(TokenScopeSchema),
44541
- expiresAt: number().nullish(),
44542
- lastUsedAt: number().nullish(),
44543
- createdAt: number()
44544
- });
44545
- /**
44546
44579
  * `oauth-integration` — a collection cap by which an addon declares
44547
44580
  * itself a linkable OAuth client of the hub's core `/oauth2/*` server.
44548
44581
  * Each provider returns a static descriptor; the core enumerates them
@@ -2,7 +2,7 @@ Object.defineProperties(exports, {
2
2
  __esModule: { value: true },
3
3
  [Symbol.toStringTag]: { value: "Module" }
4
4
  });
5
- const require_dist = require("../dist-Cqh4HRZm.js");
5
+ const require_dist = require("../dist-CbO7FEWb.js");
6
6
  let node_crypto = require("node:crypto");
7
7
  node_crypto = require_dist.__toESM(node_crypto);
8
8
  //#region ../../node_modules/jose/dist/webapi/lib/buffer_utils.js
@@ -1,4 +1,4 @@
1
- import { A as settingsArrayAdoptsFrom, C as SECRET_CLEAR, D as globalSecretScope, I as object, L as string, M as _enum, O as isSecretClear, S as RecordSecretUnavailableError, T as defineEntryKind, _ as requestMountPrefix, b as errMsg, c as authProviderCapability, d as loginMethodCapability, f as normalizeOrigin, g as pickRequestOrigin, h as parseAppPageLang, i as addonRoutesCapability, j as toSecretFieldView, k as isSecretMarker, l as buildAddonRouteProvider, m as parseAppFlowRequest, n as APP_REFUSED_PATH, o as advertisedHubOrigins, p as oidcConnectionsCapability, r as SSO_STATE_COOKIE, s as appFlowLocation, t as APP_FLOW_DEFAULT_REDIRECT, u as claimedRequestOrigins, v as resolveIconKey, w as arrayItemFieldPath, x as BaseAddon } from "../dist-DruFJKLr.mjs";
1
+ import { A as settingsArrayAdoptsFrom, C as SECRET_CLEAR, D as globalSecretScope, I as object, L as string, M as _enum, O as isSecretClear, S as RecordSecretUnavailableError, T as defineEntryKind, _ as requestMountPrefix, b as errMsg, c as authProviderCapability, d as loginMethodCapability, f as normalizeOrigin, g as pickRequestOrigin, h as parseAppPageLang, i as addonRoutesCapability, j as toSecretFieldView, k as isSecretMarker, l as buildAddonRouteProvider, m as parseAppFlowRequest, n as APP_REFUSED_PATH, o as advertisedHubOrigins, p as oidcConnectionsCapability, r as SSO_STATE_COOKIE, s as appFlowLocation, t as APP_FLOW_DEFAULT_REDIRECT, u as claimedRequestOrigins, v as resolveIconKey, w as arrayItemFieldPath, x as BaseAddon } from "../dist-Bl63xJc3.mjs";
2
2
  import * as crypto$1 from "node:crypto";
3
3
  //#region ../../node_modules/jose/dist/webapi/lib/buffer_utils.js
4
4
  var encoder = new TextEncoder(), decoder = new TextDecoder(), strictDecoder = new TextDecoder("utf-8", { fatal: !0 });
@@ -3,7 +3,7 @@ import "./dist-CYZr2fwk.mjs";
3
3
  var e = {
4
4
  "@camstack/sdk": {
5
5
  name: "@camstack/sdk",
6
- version: "1.2.135",
6
+ version: "1.2.136",
7
7
  scope: ["default"],
8
8
  loaded: !1,
9
9
  from: "addon_auth_webauthn_widgets",
@@ -18,7 +18,7 @@ var e = {
18
18
  },
19
19
  "@camstack/types": {
20
20
  name: "@camstack/types",
21
- version: "1.2.385",
21
+ version: "1.2.386",
22
22
  scope: ["default"],
23
23
  loaded: !1,
24
24
  from: "addon_auth_webauthn_widgets",
@@ -33,7 +33,7 @@ var e = {
33
33
  },
34
34
  "@camstack/ui-library": {
35
35
  name: "@camstack/ui-library",
36
- version: "1.2.302",
36
+ version: "1.2.303",
37
37
  scope: ["default"],
38
38
  loaded: !1,
39
39
  from: "addon_auth_webauthn_widgets",
@@ -2,7 +2,7 @@ Object.defineProperties(exports, {
2
2
  __esModule: { value: true },
3
3
  [Symbol.toStringTag]: { value: "Module" }
4
4
  });
5
- const require_dist = require("../dist-Cqh4HRZm.js");
5
+ const require_dist = require("../dist-CbO7FEWb.js");
6
6
  let stream = require("stream");
7
7
  stream = require_dist.__toESM(stream, 1);
8
8
  let http = require("http");
@@ -1,4 +1,4 @@
1
- import { E as defineRecordKinds, F as number, I as object, L as string, N as array, P as boolean, a as addonWidgetsSourceCapability, d as loginMethodCapability, x as BaseAddon, y as userPasskeysCapability } from "../dist-DruFJKLr.mjs";
1
+ import { E as defineRecordKinds, F as number, I as object, L as string, N as array, P as boolean, a as addonWidgetsSourceCapability, d as loginMethodCapability, x as BaseAddon, y as userPasskeysCapability } from "../dist-Bl63xJc3.mjs";
2
2
  import { createRequire } from "node:module";
3
3
  import Stream from "stream";
4
4
  import http from "http";
@@ -36,7 +36,7 @@ async function r() {
36
36
  }
37
37
  },
38
38
  "@camstack/types": {
39
- version: "1.2.385",
39
+ version: "1.2.386",
40
40
  scope: "default",
41
41
  shareConfig: {
42
42
  singleton: !0,
@@ -45,7 +45,7 @@ async function r() {
45
45
  }
46
46
  },
47
47
  "@camstack/sdk": {
48
- version: "1.2.135",
48
+ version: "1.2.136",
49
49
  scope: "default",
50
50
  shareConfig: {
51
51
  singleton: !0,
@@ -81,7 +81,7 @@ async function r() {
81
81
  }
82
82
  },
83
83
  "@camstack/ui-library": {
84
- version: "1.2.302",
84
+ version: "1.2.303",
85
85
  scope: "default",
86
86
  shareConfig: {
87
87
  singleton: !0,
@@ -30,7 +30,7 @@ async function d(e) {
30
30
  }
31
31
  }
32
32
  async function f() {
33
- return l ||= d(() => import("./_virtual_mf-localSharedImportMap___mfe_internal__addon_auth_webauthn_widgets-Cj3Uofr7.mjs")).catch((e) => {
33
+ return l ||= d(() => import("./_virtual_mf-localSharedImportMap___mfe_internal__addon_auth_webauthn_widgets-DN95hHbV.mjs")).catch((e) => {
34
34
  throw l = void 0, e;
35
35
  }), l;
36
36
  }
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@camstack/addon-auth",
3
- "version": "1.2.151",
3
+ "version": "1.2.152",
4
4
  "description": "Authentication bundle — OIDC and WebAuthn/passkey. Multi-entry npm package shipping 2 addons under a single bundle; each addon keeps its own id, capabilities, and runner.",
5
5
  "keywords": [
6
6
  "camstack",