@camstack/types 1.2.385 → 1.2.386

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.
package/dist/index.js CHANGED
@@ -6637,6 +6637,312 @@ function principalMayReachAddon(input) {
6637
6637
  };
6638
6638
  }
6639
6639
  //#endregion
6640
+ //#region src/schemas/auth-records.ts
6641
+ /**
6642
+ * Zod schemas for persisted record types.
6643
+ *
6644
+ * These schemas serve as the single source of truth for types that are
6645
+ * stored in the settings-store backend and retrieved via tRPC. They
6646
+ * replace the manual TypeScript interfaces with schema-derived types,
6647
+ * enabling runtime validation when reading from the backend.
6648
+ *
6649
+ * Convention: each schema is named `<Type>Schema`, the inferred TS type
6650
+ * keeps the original name for backward compatibility.
6651
+ */
6652
+ /**
6653
+ * Auth model (v2 — 2026-05-12 caps-only):
6654
+ *
6655
+ * Two principals:
6656
+ * - `isAdmin: true` — full bypass. Admin scope set is ignored.
6657
+ * - `isAdmin: false` — every call gated by `scopes` (see TokenScope).
6658
+ *
6659
+ * No role enum. There used to be `viewer / agent / scoped` and earlier
6660
+ * `super_admin` — collapsed onto the single boolean because every
6661
+ * non-admin caller is governed by the same scope-check rules; the
6662
+ * distinction was only ever used to route role-specific procedures
6663
+ * which we no longer have. CLI / webhook integrations are `cst_*` tokens
6664
+ * with `isAdmin: false` + an explicit scope list.
6665
+ */
6666
+ /** Per-method access flavour. Materialised on every cap method via codegen. */
6667
+ var MethodAccessSchema = zod.z.enum([
6668
+ "view",
6669
+ "create",
6670
+ "delete"
6671
+ ]);
6672
+ /**
6673
+ * A single scope grant. Three forms — checked in matcher with OR
6674
+ * semantics; the first match decides whether the call passes:
6675
+ *
6676
+ * - `category` — broadest. `target: 'device' | 'system'` selects every
6677
+ * cap with the matching `scope` declaration. New caps inherit grants
6678
+ * automatically — adding a device cap to the codebase makes it
6679
+ * reachable to every user with `category:device [...]` without a
6680
+ * re-grant. Use this for "family viewer" / "operator" tiers.
6681
+ *
6682
+ * - `addon` — every cap that ships inside a given addon id. Niche;
6683
+ * useful when an integration needs to interact with one specific
6684
+ * addon's surface regardless of how many caps it exports.
6685
+ *
6686
+ * - `capability` — the most precise form. Single cap name. Use for
6687
+ * integration tokens where you want to grant `addons.installPackage`
6688
+ * and nothing else.
6689
+ *
6690
+ * `access` is REQUIRED with min 1 element. `admin` bypass is the
6691
+ * "give me everything" escape; there is no wildcard scope.
6692
+ */
6693
+ var AllowedProviderSchema = zod.z.union([zod.z.literal("*"), zod.z.array(zod.z.string())]);
6694
+ var AllowedDevicesSchema = zod.z.record(zod.z.string(), zod.z.union([zod.z.literal("*"), zod.z.array(zod.z.string())]));
6695
+ var CapScopeSchema = zod.z.enum(["device", "system"]);
6696
+ /**
6697
+ * DeviceSelector (scope model v3 — 2026-08-12).
6698
+ *
6699
+ * A `device` grant no longer carries a frozen list of deviceIds. It carries
6700
+ * a SELECTOR the matcher resolves against the live fleet, so the grant can be
6701
+ * DYNAMIC: a `types:['camera']` selector automatically covers a camera added
6702
+ * AFTER the grant was minted — no re-grant, no re-login.
6703
+ *
6704
+ * - `all` — every device in the deployment. The broad viewer/operator
6705
+ * lever without a `category` grant (a `category` grant also covers device
6706
+ * caps that carry no deviceId; `all` is specifically the device set).
6707
+ * - `ids` — an explicit deviceId list. This is what a v2 `device:[…]`
6708
+ * grant migrates to (see {@link TokenScopeSchema}); STATIC — a new camera
6709
+ * is NOT covered until the grant is edited.
6710
+ * - `types` — every device of a `DeviceType` (e.g. every `camera`).
6711
+ * DYNAMIC. A device that changes type, or a new device of the type,
6712
+ * re-resolves on the next request.
6713
+ * - `locations` — every device whose operator-assigned `location` label is
6714
+ * in the set (e.g. "Garden", "Front door"). DYNAMIC. A device with a
6715
+ * null/unset location matches NO `locations` selector.
6716
+ */
6717
+ var DeviceSelectorSchema = zod.z.discriminatedUnion("kind", [
6718
+ zod.z.object({ kind: zod.z.literal("all") }),
6719
+ zod.z.object({
6720
+ kind: zod.z.literal("ids"),
6721
+ ids: zod.z.array(zod.z.number().int()).min(1)
6722
+ }),
6723
+ zod.z.object({
6724
+ kind: zod.z.literal("types"),
6725
+ types: zod.z.array(zod.z.enum(require_err_msg.DeviceType)).min(1)
6726
+ }),
6727
+ zod.z.object({
6728
+ kind: zod.z.literal("locations"),
6729
+ locations: zod.z.array(zod.z.string().min(1)).min(1)
6730
+ })
6731
+ ]);
6732
+ var DeviceTokenScopeSchema = zod.z.object({
6733
+ type: zod.z.literal("device"),
6734
+ /** The device SET this grant covers — resolved against the live fleet. */
6735
+ selector: DeviceSelectorSchema,
6736
+ access: zod.z.array(MethodAccessSchema).min(1),
6737
+ /**
6738
+ * Whether a grant on a PARENT device transparently covers its accessory
6739
+ * CHILDREN (siren / floodlight / PIR) via the persisted-parentage walk.
6740
+ * Direction is parent → children ONLY.
6741
+ *
6742
+ * Absent → the matcher DERIVES it from the access flavour: `view`
6743
+ * inherits (a camera viewer sees the camera's accessories), `create` /
6744
+ * `delete` do NOT (actuating/removing a child is an explicit act the
6745
+ * operator must grant on the child, not inherit from the parent). Set it
6746
+ * explicitly to override that default per grant.
6747
+ */
6748
+ includeLinked: zod.z.boolean().optional()
6749
+ });
6750
+ /**
6751
+ * v2 → v3 lazy migration. A pre-v3 `device` grant carried
6752
+ * `targets: string[]` (stringified deviceIds); it rewrites to the equivalent
6753
+ * `selector: {kind:'ids', ids}`. Applied as a `preprocess` so it runs on
6754
+ * EVERY parse path — stored records AND the JWT-carried scope arrays
6755
+ * normalised at the request boundary ({@link normalizeTokenScopes} in
6756
+ * `device-selector.ts`). Chosen over a one-time DB migration because a
6757
+ * migration cannot reach a JWT already in a client's hands; parse-time
6758
+ * migration covers both without a flag day. No cast — the raw object is read
6759
+ * through `Reflect.get` (its static type is `unknown`).
6760
+ */
6761
+ function migrateLegacyTokenScope(raw) {
6762
+ if (raw === null || typeof raw !== "object" || Array.isArray(raw)) return raw;
6763
+ if (Reflect.get(raw, "type") !== "device") return raw;
6764
+ if (Reflect.get(raw, "selector") !== void 0) return raw;
6765
+ const targets = Reflect.get(raw, "targets");
6766
+ if (!Array.isArray(targets)) return raw;
6767
+ return {
6768
+ type: "device",
6769
+ selector: {
6770
+ kind: "ids",
6771
+ ids: targets.map((t) => typeof t === "string" ? Number(t) : t).filter((n) => typeof n === "number" && Number.isInteger(n))
6772
+ },
6773
+ access: Reflect.get(raw, "access")
6774
+ };
6775
+ }
6776
+ var TokenScopeSchema = zod.z.preprocess(migrateLegacyTokenScope, zod.z.discriminatedUnion("type", [
6777
+ zod.z.object({
6778
+ type: zod.z.literal("category"),
6779
+ target: CapScopeSchema,
6780
+ access: zod.z.array(MethodAccessSchema).min(1)
6781
+ }),
6782
+ zod.z.object({
6783
+ type: zod.z.literal("capability"),
6784
+ target: zod.z.string(),
6785
+ access: zod.z.array(MethodAccessSchema).min(1)
6786
+ }),
6787
+ zod.z.object({
6788
+ type: zod.z.literal("addon"),
6789
+ target: zod.z.string(),
6790
+ access: zod.z.array(MethodAccessSchema).min(1)
6791
+ }),
6792
+ DeviceTokenScopeSchema
6793
+ ]));
6794
+ var UserRecordSchema = zod.z.object({
6795
+ id: zod.z.string(),
6796
+ username: zod.z.string(),
6797
+ passwordHash: zod.z.string(),
6798
+ /**
6799
+ * Admin bypass. When true, the middleware skips the scope-access
6800
+ * check entirely. There is no other axis of privilege; the legacy
6801
+ * role enum collapsed onto this boolean in v2.
6802
+ */
6803
+ isAdmin: zod.z.boolean().default(false),
6804
+ allowedProviders: AllowedProviderSchema,
6805
+ allowedDevices: AllowedDevicesSchema,
6806
+ /**
6807
+ * Scopes granted to this user. Admins bypass; their `scopes` is
6808
+ * ignored. Non-admins without scopes are locked out of every
6809
+ * protected call.
6810
+ */
6811
+ scopes: zod.z.array(TokenScopeSchema).default([]),
6812
+ createdAt: zod.z.number(),
6813
+ updatedAt: zod.z.number()
6814
+ });
6815
+ var ApiKeyRecordSchema = zod.z.object({
6816
+ id: zod.z.string(),
6817
+ label: zod.z.string(),
6818
+ isAdmin: zod.z.boolean().default(false),
6819
+ allowedProviders: AllowedProviderSchema,
6820
+ allowedDevices: AllowedDevicesSchema,
6821
+ tokenHash: zod.z.string(),
6822
+ tokenPrefix: zod.z.string(),
6823
+ createdAt: zod.z.number(),
6824
+ lastUsedAt: zod.z.number().optional()
6825
+ });
6826
+ var ScopedTokenSchema = zod.z.object({
6827
+ id: zod.z.string(),
6828
+ userId: zod.z.string(),
6829
+ name: zod.z.string(),
6830
+ tokenHash: zod.z.string(),
6831
+ tokenPrefix: zod.z.string(),
6832
+ scopes: zod.z.array(TokenScopeSchema),
6833
+ expiresAt: zod.z.number().nullish(),
6834
+ lastUsedAt: zod.z.number().nullish(),
6835
+ createdAt: zod.z.number()
6836
+ });
6837
+ //#endregion
6838
+ //#region src/auth/credential-scope.ts
6839
+ /**
6840
+ * The ONE permission vocabulary every credential is reduced to (D892).
6841
+ *
6842
+ * A credential — a login session, an account-link token, a legacy `csa_` /
6843
+ * `cst_` / `csv_` token, or the unified token `auth.mintToken` issues — is
6844
+ * verified into a principal whose permissions are a `CredentialScope[]`, and
6845
+ * nothing else. What KIND of credential it was never decides what it may do:
6846
+ *
6847
+ * - `'*'` — everything (the admin bypass). Held by an admin's session, a
6848
+ * legacy admin token, and a unified token minted with it.
6849
+ * - a {@link TokenScope} — the v3 capability grants (`category`,
6850
+ * `capability`, `addon`, `device`) the tRPC matcher has always applied.
6851
+ * - `share-view` — one fail-closed embed perimeter (`grid-view` /
6852
+ * `events-view`) over a few devices. A principal that holds one is
6853
+ * RESTRICTED to it: the matcher honours nothing else it holds.
6854
+ * - `addon-routes` — may reach any addon's own `authenticated` HTTP routes
6855
+ * and data planes (never an `admin` one). A person's session has always
6856
+ * had this; an integration token never had it and must hold
6857
+ * `addon:<id>` instead.
6858
+ *
6859
+ * Pure: no I/O. It lives in `@camstack/types` so the hub, the kernel and any
6860
+ * addon read the same vocabulary.
6861
+ */
6862
+ /** The admin scope: every permission. */
6863
+ var ADMIN_SCOPE = "*";
6864
+ /** At most this many devices in one share-view grant (the share-link bound). */
6865
+ var SHARE_VIEW_MAX_DEVICES = 64;
6866
+ /** What a share-view grant lets its holder see. */
6867
+ var ShareViewGrantSchema = zod.z.object({
6868
+ kind: zod.z.enum(require_sleep.SHARE_VIEW_KINDS),
6869
+ deviceIds: zod.z.array(zod.z.number().int().nonnegative()).min(1).max(64),
6870
+ /** Talk-back, opt-in at mint time; absent means off. */
6871
+ talk: zod.z.boolean().optional()
6872
+ });
6873
+ var ShareViewScopeSchema = zod.z.object({
6874
+ type: zod.z.literal("share-view"),
6875
+ grant: ShareViewGrantSchema
6876
+ });
6877
+ var AddonRoutesScopeSchema = zod.z.object({
6878
+ type: zod.z.literal("addon-routes"),
6879
+ access: zod.z.array(MethodAccessSchema).min(1)
6880
+ });
6881
+ var CredentialScopeSchema = zod.z.union([
6882
+ zod.z.literal("*"),
6883
+ ShareViewScopeSchema,
6884
+ AddonRoutesScopeSchema,
6885
+ TokenScopeSchema
6886
+ ]);
6887
+ /** Every access flavour — what a person's session holds on addon routes. */
6888
+ var ALL_METHOD_ACCESS = [
6889
+ "view",
6890
+ "create",
6891
+ "delete"
6892
+ ];
6893
+ function isTokenScope(scope) {
6894
+ return scope !== "*" && scope.type !== "share-view" && scope.type !== "addon-routes";
6895
+ }
6896
+ /** True iff the scope set holds `'*'`. */
6897
+ function scopesGrantAdmin(scopes) {
6898
+ return scopes.includes("*");
6899
+ }
6900
+ /**
6901
+ * The share-view grant that RESTRICTS this principal, or `null` when it holds
6902
+ * none. Fail closed: a set that mixes a share-view grant with anything else
6903
+ * is still restricted to its FIRST share-view grant, never widened by the rest.
6904
+ */
6905
+ function shareViewGrantOf(scopes) {
6906
+ for (const scope of scopes) if (scope !== "*" && scope.type === "share-view") return scope.grant;
6907
+ return null;
6908
+ }
6909
+ /** The capability grants the tRPC scope matcher reads. */
6910
+ function capabilityScopesOf(scopes) {
6911
+ return scopes.filter(isTokenScope);
6912
+ }
6913
+ /** True iff the set reaches every addon's own routes at `access`. */
6914
+ function scopesAllowAddonRoutes(scopes, access) {
6915
+ return scopes.some((s) => s !== "*" && s.type === "addon-routes" && s.access.includes(access));
6916
+ }
6917
+ /**
6918
+ * Parse a scope array from an untrusted source (a JWT claim, a stored row).
6919
+ * Any element that does not parse makes the WHOLE set unusable — `null` — so
6920
+ * a corrupt grant can never degrade into a partial one.
6921
+ */
6922
+ function parseCredentialScopes(raw) {
6923
+ const parsed = zod.z.array(CredentialScopeSchema).safeParse(raw);
6924
+ return parsed.success ? parsed.data : null;
6925
+ }
6926
+ /**
6927
+ * The `kind` claim of a unified token. It names the TOKEN FAMILY (so every
6928
+ * older gate that classifies a hub JWT refuses it — `classifyBearerPrincipal`
6929
+ * treats any `kind` it does not know as not-a-credential), never what the
6930
+ * token may do: that is its `scopes`, and only its `scopes`.
6931
+ */
6932
+ var CREDENTIAL_TOKEN_KIND = "credential";
6933
+ /**
6934
+ * The claims of a unified token (`auth.mintToken`). It carries no `exp`: its
6935
+ * row (looked up by `jti` on every verify, for revocation) holds the ONE
6936
+ * expiry, so a share link can be extended and a JWT clock can never disagree
6937
+ * with the row.
6938
+ */
6939
+ var CredentialTokenClaimsSchema = zod.z.object({
6940
+ kind: zod.z.literal(CREDENTIAL_TOKEN_KIND),
6941
+ sub: zod.z.string().min(1),
6942
+ jti: zod.z.string().min(16),
6943
+ scopes: zod.z.array(CredentialScopeSchema).min(1)
6944
+ });
6945
+ //#endregion
6640
6946
  //#region src/auth/app-callback.ts
6641
6947
  /**
6642
6948
  * The viewer app's custom-scheme callback — the ONE list of URLs a hub flow
@@ -45899,204 +46205,6 @@ var notificationRulesCapability = {
45899
46205
  }
45900
46206
  };
45901
46207
  //#endregion
45902
- //#region src/schemas/auth-records.ts
45903
- /**
45904
- * Zod schemas for persisted record types.
45905
- *
45906
- * These schemas serve as the single source of truth for types that are
45907
- * stored in the settings-store backend and retrieved via tRPC. They
45908
- * replace the manual TypeScript interfaces with schema-derived types,
45909
- * enabling runtime validation when reading from the backend.
45910
- *
45911
- * Convention: each schema is named `<Type>Schema`, the inferred TS type
45912
- * keeps the original name for backward compatibility.
45913
- */
45914
- /**
45915
- * Auth model (v2 — 2026-05-12 caps-only):
45916
- *
45917
- * Two principals:
45918
- * - `isAdmin: true` — full bypass. Admin scope set is ignored.
45919
- * - `isAdmin: false` — every call gated by `scopes` (see TokenScope).
45920
- *
45921
- * No role enum. There used to be `viewer / agent / scoped` and earlier
45922
- * `super_admin` — collapsed onto the single boolean because every
45923
- * non-admin caller is governed by the same scope-check rules; the
45924
- * distinction was only ever used to route role-specific procedures
45925
- * which we no longer have. CLI / webhook integrations are `cst_*` tokens
45926
- * with `isAdmin: false` + an explicit scope list.
45927
- */
45928
- /** Per-method access flavour. Materialised on every cap method via codegen. */
45929
- var MethodAccessSchema = zod.z.enum([
45930
- "view",
45931
- "create",
45932
- "delete"
45933
- ]);
45934
- /**
45935
- * A single scope grant. Three forms — checked in matcher with OR
45936
- * semantics; the first match decides whether the call passes:
45937
- *
45938
- * - `category` — broadest. `target: 'device' | 'system'` selects every
45939
- * cap with the matching `scope` declaration. New caps inherit grants
45940
- * automatically — adding a device cap to the codebase makes it
45941
- * reachable to every user with `category:device [...]` without a
45942
- * re-grant. Use this for "family viewer" / "operator" tiers.
45943
- *
45944
- * - `addon` — every cap that ships inside a given addon id. Niche;
45945
- * useful when an integration needs to interact with one specific
45946
- * addon's surface regardless of how many caps it exports.
45947
- *
45948
- * - `capability` — the most precise form. Single cap name. Use for
45949
- * integration tokens where you want to grant `addons.installPackage`
45950
- * and nothing else.
45951
- *
45952
- * `access` is REQUIRED with min 1 element. `admin` bypass is the
45953
- * "give me everything" escape; there is no wildcard scope.
45954
- */
45955
- var AllowedProviderSchema = zod.z.union([zod.z.literal("*"), zod.z.array(zod.z.string())]);
45956
- var AllowedDevicesSchema = zod.z.record(zod.z.string(), zod.z.union([zod.z.literal("*"), zod.z.array(zod.z.string())]));
45957
- var CapScopeSchema = zod.z.enum(["device", "system"]);
45958
- /**
45959
- * DeviceSelector (scope model v3 — 2026-08-12).
45960
- *
45961
- * A `device` grant no longer carries a frozen list of deviceIds. It carries
45962
- * a SELECTOR the matcher resolves against the live fleet, so the grant can be
45963
- * DYNAMIC: a `types:['camera']` selector automatically covers a camera added
45964
- * AFTER the grant was minted — no re-grant, no re-login.
45965
- *
45966
- * - `all` — every device in the deployment. The broad viewer/operator
45967
- * lever without a `category` grant (a `category` grant also covers device
45968
- * caps that carry no deviceId; `all` is specifically the device set).
45969
- * - `ids` — an explicit deviceId list. This is what a v2 `device:[…]`
45970
- * grant migrates to (see {@link TokenScopeSchema}); STATIC — a new camera
45971
- * is NOT covered until the grant is edited.
45972
- * - `types` — every device of a `DeviceType` (e.g. every `camera`).
45973
- * DYNAMIC. A device that changes type, or a new device of the type,
45974
- * re-resolves on the next request.
45975
- * - `locations` — every device whose operator-assigned `location` label is
45976
- * in the set (e.g. "Garden", "Front door"). DYNAMIC. A device with a
45977
- * null/unset location matches NO `locations` selector.
45978
- */
45979
- var DeviceSelectorSchema = zod.z.discriminatedUnion("kind", [
45980
- zod.z.object({ kind: zod.z.literal("all") }),
45981
- zod.z.object({
45982
- kind: zod.z.literal("ids"),
45983
- ids: zod.z.array(zod.z.number().int()).min(1)
45984
- }),
45985
- zod.z.object({
45986
- kind: zod.z.literal("types"),
45987
- types: zod.z.array(zod.z.enum(require_err_msg.DeviceType)).min(1)
45988
- }),
45989
- zod.z.object({
45990
- kind: zod.z.literal("locations"),
45991
- locations: zod.z.array(zod.z.string().min(1)).min(1)
45992
- })
45993
- ]);
45994
- var DeviceTokenScopeSchema = zod.z.object({
45995
- type: zod.z.literal("device"),
45996
- /** The device SET this grant covers — resolved against the live fleet. */
45997
- selector: DeviceSelectorSchema,
45998
- access: zod.z.array(MethodAccessSchema).min(1),
45999
- /**
46000
- * Whether a grant on a PARENT device transparently covers its accessory
46001
- * CHILDREN (siren / floodlight / PIR) via the persisted-parentage walk.
46002
- * Direction is parent → children ONLY.
46003
- *
46004
- * Absent → the matcher DERIVES it from the access flavour: `view`
46005
- * inherits (a camera viewer sees the camera's accessories), `create` /
46006
- * `delete` do NOT (actuating/removing a child is an explicit act the
46007
- * operator must grant on the child, not inherit from the parent). Set it
46008
- * explicitly to override that default per grant.
46009
- */
46010
- includeLinked: zod.z.boolean().optional()
46011
- });
46012
- /**
46013
- * v2 → v3 lazy migration. A pre-v3 `device` grant carried
46014
- * `targets: string[]` (stringified deviceIds); it rewrites to the equivalent
46015
- * `selector: {kind:'ids', ids}`. Applied as a `preprocess` so it runs on
46016
- * EVERY parse path — stored records AND the JWT-carried scope arrays
46017
- * normalised at the request boundary ({@link normalizeTokenScopes} in
46018
- * `device-selector.ts`). Chosen over a one-time DB migration because a
46019
- * migration cannot reach a JWT already in a client's hands; parse-time
46020
- * migration covers both without a flag day. No cast — the raw object is read
46021
- * through `Reflect.get` (its static type is `unknown`).
46022
- */
46023
- function migrateLegacyTokenScope(raw) {
46024
- if (raw === null || typeof raw !== "object" || Array.isArray(raw)) return raw;
46025
- if (Reflect.get(raw, "type") !== "device") return raw;
46026
- if (Reflect.get(raw, "selector") !== void 0) return raw;
46027
- const targets = Reflect.get(raw, "targets");
46028
- if (!Array.isArray(targets)) return raw;
46029
- return {
46030
- type: "device",
46031
- selector: {
46032
- kind: "ids",
46033
- ids: targets.map((t) => typeof t === "string" ? Number(t) : t).filter((n) => typeof n === "number" && Number.isInteger(n))
46034
- },
46035
- access: Reflect.get(raw, "access")
46036
- };
46037
- }
46038
- var TokenScopeSchema = zod.z.preprocess(migrateLegacyTokenScope, zod.z.discriminatedUnion("type", [
46039
- zod.z.object({
46040
- type: zod.z.literal("category"),
46041
- target: CapScopeSchema,
46042
- access: zod.z.array(MethodAccessSchema).min(1)
46043
- }),
46044
- zod.z.object({
46045
- type: zod.z.literal("capability"),
46046
- target: zod.z.string(),
46047
- access: zod.z.array(MethodAccessSchema).min(1)
46048
- }),
46049
- zod.z.object({
46050
- type: zod.z.literal("addon"),
46051
- target: zod.z.string(),
46052
- access: zod.z.array(MethodAccessSchema).min(1)
46053
- }),
46054
- DeviceTokenScopeSchema
46055
- ]));
46056
- var UserRecordSchema = zod.z.object({
46057
- id: zod.z.string(),
46058
- username: zod.z.string(),
46059
- passwordHash: zod.z.string(),
46060
- /**
46061
- * Admin bypass. When true, the middleware skips the scope-access
46062
- * check entirely. There is no other axis of privilege; the legacy
46063
- * role enum collapsed onto this boolean in v2.
46064
- */
46065
- isAdmin: zod.z.boolean().default(false),
46066
- allowedProviders: AllowedProviderSchema,
46067
- allowedDevices: AllowedDevicesSchema,
46068
- /**
46069
- * Scopes granted to this user. Admins bypass; their `scopes` is
46070
- * ignored. Non-admins without scopes are locked out of every
46071
- * protected call.
46072
- */
46073
- scopes: zod.z.array(TokenScopeSchema).default([]),
46074
- createdAt: zod.z.number(),
46075
- updatedAt: zod.z.number()
46076
- });
46077
- var ApiKeyRecordSchema = zod.z.object({
46078
- id: zod.z.string(),
46079
- label: zod.z.string(),
46080
- isAdmin: zod.z.boolean().default(false),
46081
- allowedProviders: AllowedProviderSchema,
46082
- allowedDevices: AllowedDevicesSchema,
46083
- tokenHash: zod.z.string(),
46084
- tokenPrefix: zod.z.string(),
46085
- createdAt: zod.z.number(),
46086
- lastUsedAt: zod.z.number().optional()
46087
- });
46088
- var ScopedTokenSchema = zod.z.object({
46089
- id: zod.z.string(),
46090
- userId: zod.z.string(),
46091
- name: zod.z.string(),
46092
- tokenHash: zod.z.string(),
46093
- tokenPrefix: zod.z.string(),
46094
- scopes: zod.z.array(TokenScopeSchema),
46095
- expiresAt: zod.z.number().nullish(),
46096
- lastUsedAt: zod.z.number().nullish(),
46097
- createdAt: zod.z.number()
46098
- });
46099
- //#endregion
46100
46208
  //#region src/capabilities/oauth-integration.cap.ts
46101
46209
  /**
46102
46210
  * `oauth-integration` — a collection cap by which an addon declares
@@ -102878,11 +102986,13 @@ function armRemovalReconcile(opts) {
102878
102986
  //#endregion
102879
102987
  exports.ACCESSORY_LABEL = ACCESSORY_LABEL;
102880
102988
  exports.ACCESS_ROLES = ACCESS_ROLES;
102989
+ exports.ADMIN_SCOPE = ADMIN_SCOPE;
102881
102990
  exports.AGENT_MDNS_QUERY_NAME = AGENT_MDNS_QUERY_NAME;
102882
102991
  exports.AGENT_MDNS_SERVICE_TYPE = AGENT_MDNS_SERVICE_TYPE;
102883
102992
  exports.AGENT_MDNS_TXT_KEYS = AGENT_MDNS_TXT_KEYS;
102884
102993
  exports.ALEXA_EGRESS_PROFILE = ALEXA_EGRESS_PROFILE;
102885
102994
  exports.ALL_CAPABILITY_DEFINITIONS = ALL_CAPABILITY_DEFINITIONS;
102995
+ exports.ALL_METHOD_ACCESS = ALL_METHOD_ACCESS;
102886
102996
  exports.APPEARANCE_BIN_COUNT = APPEARANCE_BIN_COUNT;
102887
102997
  exports.APPEARANCE_BLOCKS = APPEARANCE_BLOCKS;
102888
102998
  exports.APPEARANCE_DESCRIPTOR_VERSION = APPEARANCE_DESCRIPTOR_VERSION;
@@ -102916,6 +103026,7 @@ exports.AddonAutoUpdateSchema = AddonAutoUpdateSchema;
102916
103026
  exports.AddonListItemSchema = AddonListItemSchema;
102917
103027
  exports.AddonPageDeclarationSchema = AddonPageDeclarationSchema;
102918
103028
  exports.AddonPageInfoSchema = AddonPageInfoSchema;
103029
+ exports.AddonRoutesScopeSchema = AddonRoutesScopeSchema;
102919
103030
  exports.AdminLinkTargetEnum = AdminLinkTargetEnum;
102920
103031
  exports.AdoptionAdoptInputSchema = AdoptInputSchema;
102921
103032
  exports.AdoptionAdoptResultSchema = AdoptResultSchema;
@@ -103090,6 +103201,7 @@ exports.CONNECTION_TEST_TIMEOUT_MS = CONNECTION_TEST_TIMEOUT_MS;
103090
103201
  exports.CONTAINER_CHILD_PRIORITY = CONTAINER_CHILD_PRIORITY;
103091
103202
  exports.CORE_BLOCKS_ADDON_ID = CORE_BLOCKS_ADDON_ID;
103092
103203
  exports.CORE_BLOCK_ADDON_PREFIX = CORE_BLOCK_ADDON_PREFIX;
103204
+ exports.CREDENTIAL_TOKEN_KIND = CREDENTIAL_TOKEN_KIND;
103093
103205
  exports.CROP_SUPPLY_SOURCES = CROP_SUPPLY_SOURCES;
103094
103206
  exports.CROP_SUPPLY_STEP_IDS = CROP_SUPPLY_STEP_IDS;
103095
103207
  exports.CUSTOMIZATION_BLOCK_NAME_PREFIX = require_composition.CUSTOMIZATION_BLOCK_NAME_PREFIX;
@@ -103270,6 +103382,8 @@ exports.CreateIntegrationInputSchema = CreateIntegrationInputSchema;
103270
103382
  exports.CreateScopedTokenInputSchema = CreateScopedTokenInputSchema;
103271
103383
  exports.CreateScopedTokenResultSchema = CreateScopedTokenResultSchema;
103272
103384
  exports.CreateUserInputSchema = CreateUserInputSchema;
103385
+ exports.CredentialScopeSchema = CredentialScopeSchema;
103386
+ exports.CredentialTokenClaimsSchema = CredentialTokenClaimsSchema;
103273
103387
  exports.CustomActionInputSchema = CustomActionInputSchema;
103274
103388
  exports.CustomModelDescriptorSchema = CustomModelDescriptorSchema;
103275
103389
  exports.DATABASE_SNAPSHOT_PARTIAL_SUFFIX = DATABASE_SNAPSHOT_PARTIAL_SUFFIX;
@@ -104434,6 +104548,7 @@ exports.SETTINGS_ARRAY_ADOPTS_PREFIX = require_sleep.SETTINGS_ARRAY_ADOPTS_PREFI
104434
104548
  exports.SETTINGS_BROKERS_ADOPTS_PREFIX = require_sleep.SETTINGS_BROKERS_ADOPTS_PREFIX;
104435
104549
  exports.SHARE_SOURCE_SETTING_KEY = SHARE_SOURCE_SETTING_KEY;
104436
104550
  exports.SHARE_VIEW_KINDS = require_sleep.SHARE_VIEW_KINDS;
104551
+ exports.SHARE_VIEW_MAX_DEVICES = SHARE_VIEW_MAX_DEVICES;
104437
104552
  exports.SINGLE_HUB_ADDRESS_ROLES = SINGLE_HUB_ADDRESS_ROLES;
104438
104553
  exports.SOURCE_CAPS = require_composition.SOURCE_CAPS;
104439
104554
  exports.SOURCE_CAP_ACTIVE_FIELD = require_composition.SOURCE_CAP_ACTIVE_FIELD;
@@ -104498,6 +104613,8 @@ exports.SettingsRecordSchema = SettingsRecordSchema;
104498
104613
  exports.SettingsSchemaWithValuesSchema = SettingsSchemaWithValuesSchema;
104499
104614
  exports.SettingsUpdateResultSchema = SettingsUpdateResultSchema;
104500
104615
  exports.ShareSourceSchema = ShareSourceSchema;
104616
+ exports.ShareViewGrantSchema = ShareViewGrantSchema;
104617
+ exports.ShareViewScopeSchema = ShareViewScopeSchema;
104501
104618
  exports.ShareWeightsSchema = ShareWeightsSchema;
104502
104619
  exports.SiteLocationSchema = SiteLocationSchema;
104503
104620
  exports.SiteLocationSourceSchema = SiteLocationSourceSchema;
@@ -104858,6 +104975,7 @@ exports.canConvertUnit = canConvertUnit;
104858
104975
  exports.canonicalEgressPlan = canonicalEgressPlan;
104859
104976
  exports.canonicalIconKey = canonicalIconKey;
104860
104977
  exports.canonicalizeAppCallback = canonicalizeAppCallback;
104978
+ exports.capabilityScopesOf = capabilityScopesOf;
104861
104979
  exports.capacitySessionsOf = capacitySessionsOf;
104862
104980
  exports.carbonMonoxideCapability = carbonMonoxideCapability;
104863
104981
  exports.cellsToRects = cellsToRects;
@@ -105312,6 +105430,7 @@ exports.parseAppAuthCallback = parseAppAuthCallback;
105312
105430
  exports.parseAppFlowRequest = parseAppFlowRequest;
105313
105431
  exports.parseAppPageLang = parseAppPageLang;
105314
105432
  exports.parseCameraStreamConfig = parseCameraStreamConfig;
105433
+ exports.parseCredentialScopes = parseCredentialScopes;
105315
105434
  exports.parseDeviceEnrollmentLink = parseDeviceEnrollmentLink;
105316
105435
  exports.parseExpression = require_composition.parseExpression;
105317
105436
  exports.parseJsonArray = require_sleep.parseJsonArray;
@@ -105483,7 +105602,9 @@ exports.schemaDeclaresAnyField = require_sleep.schemaDeclaresAnyField;
105483
105602
  exports.scopeInherits = scopeInherits;
105484
105603
  exports.scopeKey = require_sleep.scopeKey;
105485
105604
  exports.scopesAllowAddon = scopesAllowAddon;
105605
+ exports.scopesAllowAddonRoutes = scopesAllowAddonRoutes;
105486
105606
  exports.scopesAllowDeviceCap = scopesAllowDeviceCap;
105607
+ exports.scopesGrantAdmin = scopesGrantAdmin;
105487
105608
  exports.scoreRuntimes = scoreRuntimes;
105488
105609
  exports.scriptRunnerCapability = scriptRunnerCapability;
105489
105610
  exports.scrubKnownSecrets = require_sleep.scrubKnownSecrets;
@@ -105507,6 +105628,7 @@ exports.settingsArrayAdoptsFrom = require_sleep.settingsArrayAdoptsFrom;
105507
105628
  exports.settingsBelow = settingsBelow;
105508
105629
  exports.settingsBrokersAdoptsFrom = require_sleep.settingsBrokersAdoptsFrom;
105509
105630
  exports.settingsStoreCapability = settingsStoreCapability;
105631
+ exports.shareViewGrantOf = shareViewGrantOf;
105510
105632
  exports.shortHostname = shortHostname;
105511
105633
  exports.shortSecretRefHash = require_sleep.shortSecretRefHash;
105512
105634
  exports.signalPercentFromBars = signalPercentFromBars;