@camstack/addon-export-alexa 1.2.148 → 1.2.149
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/export-alexa.addon.js +229 -196
- package/dist/export-alexa.addon.mjs +229 -196
- package/package.json +1 -1
|
@@ -7831,6 +7831,12 @@ function normalizeAddonInitResult(result) {
|
|
|
7831
7831
|
if (Array.isArray(result)) return { providers: result };
|
|
7832
7832
|
return result;
|
|
7833
7833
|
}
|
|
7834
|
+
/**
|
|
7835
|
+
* The share-view scope kinds a `csv_*` share token can carry. The hub mints
|
|
7836
|
+
* and validates them (`share-token.service.ts` builds its enum from this
|
|
7837
|
+
* list); a data plane names the kinds it ACCEPTS in `share`.
|
|
7838
|
+
*/
|
|
7839
|
+
var SHARE_VIEW_KINDS = ["grid-view", "events-view"];
|
|
7834
7840
|
/** The wire shape of {@link PeerBytesTicket} — see the type for what it is. */
|
|
7835
7841
|
var PeerBytesTicketSchema = object({
|
|
7836
7842
|
/** `http://127.0.0.1:<port>/<token>`. One `GET` takes it. */
|
|
@@ -12711,6 +12717,229 @@ var ConvertResultSchema = object({
|
|
|
12711
12717
|
function scopesAllowDeviceCap(scopes, access) {
|
|
12712
12718
|
return scopes.some((s) => s.type === "category" && s.target === "device" && s.access.includes(access));
|
|
12713
12719
|
}
|
|
12720
|
+
/**
|
|
12721
|
+
* Zod schemas for persisted record types.
|
|
12722
|
+
*
|
|
12723
|
+
* These schemas serve as the single source of truth for types that are
|
|
12724
|
+
* stored in the settings-store backend and retrieved via tRPC. They
|
|
12725
|
+
* replace the manual TypeScript interfaces with schema-derived types,
|
|
12726
|
+
* enabling runtime validation when reading from the backend.
|
|
12727
|
+
*
|
|
12728
|
+
* Convention: each schema is named `<Type>Schema`, the inferred TS type
|
|
12729
|
+
* keeps the original name for backward compatibility.
|
|
12730
|
+
*/
|
|
12731
|
+
/**
|
|
12732
|
+
* Auth model (v2 — 2026-05-12 caps-only):
|
|
12733
|
+
*
|
|
12734
|
+
* Two principals:
|
|
12735
|
+
* - `isAdmin: true` — full bypass. Admin scope set is ignored.
|
|
12736
|
+
* - `isAdmin: false` — every call gated by `scopes` (see TokenScope).
|
|
12737
|
+
*
|
|
12738
|
+
* No role enum. There used to be `viewer / agent / scoped` and earlier
|
|
12739
|
+
* `super_admin` — collapsed onto the single boolean because every
|
|
12740
|
+
* non-admin caller is governed by the same scope-check rules; the
|
|
12741
|
+
* distinction was only ever used to route role-specific procedures
|
|
12742
|
+
* which we no longer have. CLI / webhook integrations are `cst_*` tokens
|
|
12743
|
+
* with `isAdmin: false` + an explicit scope list.
|
|
12744
|
+
*/
|
|
12745
|
+
/** Per-method access flavour. Materialised on every cap method via codegen. */
|
|
12746
|
+
var MethodAccessSchema = _enum([
|
|
12747
|
+
"view",
|
|
12748
|
+
"create",
|
|
12749
|
+
"delete"
|
|
12750
|
+
]);
|
|
12751
|
+
/**
|
|
12752
|
+
* A single scope grant. Three forms — checked in matcher with OR
|
|
12753
|
+
* semantics; the first match decides whether the call passes:
|
|
12754
|
+
*
|
|
12755
|
+
* - `category` — broadest. `target: 'device' | 'system'` selects every
|
|
12756
|
+
* cap with the matching `scope` declaration. New caps inherit grants
|
|
12757
|
+
* automatically — adding a device cap to the codebase makes it
|
|
12758
|
+
* reachable to every user with `category:device [...]` without a
|
|
12759
|
+
* re-grant. Use this for "family viewer" / "operator" tiers.
|
|
12760
|
+
*
|
|
12761
|
+
* - `addon` — every cap that ships inside a given addon id. Niche;
|
|
12762
|
+
* useful when an integration needs to interact with one specific
|
|
12763
|
+
* addon's surface regardless of how many caps it exports.
|
|
12764
|
+
*
|
|
12765
|
+
* - `capability` — the most precise form. Single cap name. Use for
|
|
12766
|
+
* integration tokens where you want to grant `addons.installPackage`
|
|
12767
|
+
* and nothing else.
|
|
12768
|
+
*
|
|
12769
|
+
* `access` is REQUIRED with min 1 element. `admin` bypass is the
|
|
12770
|
+
* "give me everything" escape; there is no wildcard scope.
|
|
12771
|
+
*/
|
|
12772
|
+
var AllowedProviderSchema = union([literal("*"), array(string())]);
|
|
12773
|
+
var AllowedDevicesSchema = record(string(), union([literal("*"), array(string())]));
|
|
12774
|
+
var CapScopeSchema = _enum(["device", "system"]);
|
|
12775
|
+
/**
|
|
12776
|
+
* DeviceSelector (scope model v3 — 2026-08-12).
|
|
12777
|
+
*
|
|
12778
|
+
* A `device` grant no longer carries a frozen list of deviceIds. It carries
|
|
12779
|
+
* a SELECTOR the matcher resolves against the live fleet, so the grant can be
|
|
12780
|
+
* DYNAMIC: a `types:['camera']` selector automatically covers a camera added
|
|
12781
|
+
* AFTER the grant was minted — no re-grant, no re-login.
|
|
12782
|
+
*
|
|
12783
|
+
* - `all` — every device in the deployment. The broad viewer/operator
|
|
12784
|
+
* lever without a `category` grant (a `category` grant also covers device
|
|
12785
|
+
* caps that carry no deviceId; `all` is specifically the device set).
|
|
12786
|
+
* - `ids` — an explicit deviceId list. This is what a v2 `device:[…]`
|
|
12787
|
+
* grant migrates to (see {@link TokenScopeSchema}); STATIC — a new camera
|
|
12788
|
+
* is NOT covered until the grant is edited.
|
|
12789
|
+
* - `types` — every device of a `DeviceType` (e.g. every `camera`).
|
|
12790
|
+
* DYNAMIC. A device that changes type, or a new device of the type,
|
|
12791
|
+
* re-resolves on the next request.
|
|
12792
|
+
* - `locations` — every device whose operator-assigned `location` label is
|
|
12793
|
+
* in the set (e.g. "Garden", "Front door"). DYNAMIC. A device with a
|
|
12794
|
+
* null/unset location matches NO `locations` selector.
|
|
12795
|
+
*/
|
|
12796
|
+
var DeviceSelectorSchema = discriminatedUnion("kind", [
|
|
12797
|
+
object({ kind: literal("all") }),
|
|
12798
|
+
object({
|
|
12799
|
+
kind: literal("ids"),
|
|
12800
|
+
ids: array(number().int()).min(1)
|
|
12801
|
+
}),
|
|
12802
|
+
object({
|
|
12803
|
+
kind: literal("types"),
|
|
12804
|
+
types: array(_enum(DeviceType)).min(1)
|
|
12805
|
+
}),
|
|
12806
|
+
object({
|
|
12807
|
+
kind: literal("locations"),
|
|
12808
|
+
locations: array(string().min(1)).min(1)
|
|
12809
|
+
})
|
|
12810
|
+
]);
|
|
12811
|
+
var DeviceTokenScopeSchema = object({
|
|
12812
|
+
type: literal("device"),
|
|
12813
|
+
/** The device SET this grant covers — resolved against the live fleet. */
|
|
12814
|
+
selector: DeviceSelectorSchema,
|
|
12815
|
+
access: array(MethodAccessSchema).min(1),
|
|
12816
|
+
/**
|
|
12817
|
+
* Whether a grant on a PARENT device transparently covers its accessory
|
|
12818
|
+
* CHILDREN (siren / floodlight / PIR) via the persisted-parentage walk.
|
|
12819
|
+
* Direction is parent → children ONLY.
|
|
12820
|
+
*
|
|
12821
|
+
* Absent → the matcher DERIVES it from the access flavour: `view`
|
|
12822
|
+
* inherits (a camera viewer sees the camera's accessories), `create` /
|
|
12823
|
+
* `delete` do NOT (actuating/removing a child is an explicit act the
|
|
12824
|
+
* operator must grant on the child, not inherit from the parent). Set it
|
|
12825
|
+
* explicitly to override that default per grant.
|
|
12826
|
+
*/
|
|
12827
|
+
includeLinked: boolean().optional()
|
|
12828
|
+
});
|
|
12829
|
+
/**
|
|
12830
|
+
* v2 → v3 lazy migration. A pre-v3 `device` grant carried
|
|
12831
|
+
* `targets: string[]` (stringified deviceIds); it rewrites to the equivalent
|
|
12832
|
+
* `selector: {kind:'ids', ids}`. Applied as a `preprocess` so it runs on
|
|
12833
|
+
* EVERY parse path — stored records AND the JWT-carried scope arrays
|
|
12834
|
+
* normalised at the request boundary ({@link normalizeTokenScopes} in
|
|
12835
|
+
* `device-selector.ts`). Chosen over a one-time DB migration because a
|
|
12836
|
+
* migration cannot reach a JWT already in a client's hands; parse-time
|
|
12837
|
+
* migration covers both without a flag day. No cast — the raw object is read
|
|
12838
|
+
* through `Reflect.get` (its static type is `unknown`).
|
|
12839
|
+
*/
|
|
12840
|
+
function migrateLegacyTokenScope(raw) {
|
|
12841
|
+
if (raw === null || typeof raw !== "object" || Array.isArray(raw)) return raw;
|
|
12842
|
+
if (Reflect.get(raw, "type") !== "device") return raw;
|
|
12843
|
+
if (Reflect.get(raw, "selector") !== void 0) return raw;
|
|
12844
|
+
const targets = Reflect.get(raw, "targets");
|
|
12845
|
+
if (!Array.isArray(targets)) return raw;
|
|
12846
|
+
return {
|
|
12847
|
+
type: "device",
|
|
12848
|
+
selector: {
|
|
12849
|
+
kind: "ids",
|
|
12850
|
+
ids: targets.map((t) => typeof t === "string" ? Number(t) : t).filter((n) => typeof n === "number" && Number.isInteger(n))
|
|
12851
|
+
},
|
|
12852
|
+
access: Reflect.get(raw, "access")
|
|
12853
|
+
};
|
|
12854
|
+
}
|
|
12855
|
+
var TokenScopeSchema = preprocess(migrateLegacyTokenScope, discriminatedUnion("type", [
|
|
12856
|
+
object({
|
|
12857
|
+
type: literal("category"),
|
|
12858
|
+
target: CapScopeSchema,
|
|
12859
|
+
access: array(MethodAccessSchema).min(1)
|
|
12860
|
+
}),
|
|
12861
|
+
object({
|
|
12862
|
+
type: literal("capability"),
|
|
12863
|
+
target: string(),
|
|
12864
|
+
access: array(MethodAccessSchema).min(1)
|
|
12865
|
+
}),
|
|
12866
|
+
object({
|
|
12867
|
+
type: literal("addon"),
|
|
12868
|
+
target: string(),
|
|
12869
|
+
access: array(MethodAccessSchema).min(1)
|
|
12870
|
+
}),
|
|
12871
|
+
DeviceTokenScopeSchema
|
|
12872
|
+
]));
|
|
12873
|
+
object({
|
|
12874
|
+
id: string(),
|
|
12875
|
+
username: string(),
|
|
12876
|
+
passwordHash: string(),
|
|
12877
|
+
/**
|
|
12878
|
+
* Admin bypass. When true, the middleware skips the scope-access
|
|
12879
|
+
* check entirely. There is no other axis of privilege; the legacy
|
|
12880
|
+
* role enum collapsed onto this boolean in v2.
|
|
12881
|
+
*/
|
|
12882
|
+
isAdmin: boolean().default(false),
|
|
12883
|
+
allowedProviders: AllowedProviderSchema,
|
|
12884
|
+
allowedDevices: AllowedDevicesSchema,
|
|
12885
|
+
/**
|
|
12886
|
+
* Scopes granted to this user. Admins bypass; their `scopes` is
|
|
12887
|
+
* ignored. Non-admins without scopes are locked out of every
|
|
12888
|
+
* protected call.
|
|
12889
|
+
*/
|
|
12890
|
+
scopes: array(TokenScopeSchema).default([]),
|
|
12891
|
+
createdAt: number(),
|
|
12892
|
+
updatedAt: number()
|
|
12893
|
+
});
|
|
12894
|
+
object({
|
|
12895
|
+
id: string(),
|
|
12896
|
+
label: string(),
|
|
12897
|
+
isAdmin: boolean().default(false),
|
|
12898
|
+
allowedProviders: AllowedProviderSchema,
|
|
12899
|
+
allowedDevices: AllowedDevicesSchema,
|
|
12900
|
+
tokenHash: string(),
|
|
12901
|
+
tokenPrefix: string(),
|
|
12902
|
+
createdAt: number(),
|
|
12903
|
+
lastUsedAt: number().optional()
|
|
12904
|
+
});
|
|
12905
|
+
object({
|
|
12906
|
+
id: string(),
|
|
12907
|
+
userId: string(),
|
|
12908
|
+
name: string(),
|
|
12909
|
+
tokenHash: string(),
|
|
12910
|
+
tokenPrefix: string(),
|
|
12911
|
+
scopes: array(TokenScopeSchema),
|
|
12912
|
+
expiresAt: number().nullish(),
|
|
12913
|
+
lastUsedAt: number().nullish(),
|
|
12914
|
+
createdAt: number()
|
|
12915
|
+
});
|
|
12916
|
+
/** What a share-view grant lets its holder see. */
|
|
12917
|
+
var ShareViewGrantSchema = object({
|
|
12918
|
+
kind: _enum(SHARE_VIEW_KINDS),
|
|
12919
|
+
deviceIds: array(number().int().nonnegative()).min(1).max(64),
|
|
12920
|
+
/** Talk-back, opt-in at mint time; absent means off. */
|
|
12921
|
+
talk: boolean().optional()
|
|
12922
|
+
});
|
|
12923
|
+
var ShareViewScopeSchema = object({
|
|
12924
|
+
type: literal("share-view"),
|
|
12925
|
+
grant: ShareViewGrantSchema
|
|
12926
|
+
});
|
|
12927
|
+
var AddonRoutesScopeSchema = object({
|
|
12928
|
+
type: literal("addon-routes"),
|
|
12929
|
+
access: array(MethodAccessSchema).min(1)
|
|
12930
|
+
});
|
|
12931
|
+
var CredentialScopeSchema = union([
|
|
12932
|
+
literal("*"),
|
|
12933
|
+
ShareViewScopeSchema,
|
|
12934
|
+
AddonRoutesScopeSchema,
|
|
12935
|
+
TokenScopeSchema
|
|
12936
|
+
]);
|
|
12937
|
+
object({
|
|
12938
|
+
kind: literal("credential"),
|
|
12939
|
+
sub: string().min(1),
|
|
12940
|
+
jti: string().min(16),
|
|
12941
|
+
scopes: array(CredentialScopeSchema).min(1)
|
|
12942
|
+
});
|
|
12714
12943
|
_enum(["new-session", "step-up"]);
|
|
12715
12944
|
/** The languages the hub's app landing pages are written in (D858). */
|
|
12716
12945
|
var AppPageLangSchema = _enum(["en", "it"]);
|
|
@@ -43892,202 +44121,6 @@ method(object({}), object({ rules: array(NcRuleSchema) }), { auth: "admin" }), m
|
|
|
43892
44121
|
auth: "admin"
|
|
43893
44122
|
}), method(NcAlarmSensorsInputSchema, NcAlarmSensorsSchema, { auth: "admin" });
|
|
43894
44123
|
/**
|
|
43895
|
-
* Zod schemas for persisted record types.
|
|
43896
|
-
*
|
|
43897
|
-
* These schemas serve as the single source of truth for types that are
|
|
43898
|
-
* stored in the settings-store backend and retrieved via tRPC. They
|
|
43899
|
-
* replace the manual TypeScript interfaces with schema-derived types,
|
|
43900
|
-
* enabling runtime validation when reading from the backend.
|
|
43901
|
-
*
|
|
43902
|
-
* Convention: each schema is named `<Type>Schema`, the inferred TS type
|
|
43903
|
-
* keeps the original name for backward compatibility.
|
|
43904
|
-
*/
|
|
43905
|
-
/**
|
|
43906
|
-
* Auth model (v2 — 2026-05-12 caps-only):
|
|
43907
|
-
*
|
|
43908
|
-
* Two principals:
|
|
43909
|
-
* - `isAdmin: true` — full bypass. Admin scope set is ignored.
|
|
43910
|
-
* - `isAdmin: false` — every call gated by `scopes` (see TokenScope).
|
|
43911
|
-
*
|
|
43912
|
-
* No role enum. There used to be `viewer / agent / scoped` and earlier
|
|
43913
|
-
* `super_admin` — collapsed onto the single boolean because every
|
|
43914
|
-
* non-admin caller is governed by the same scope-check rules; the
|
|
43915
|
-
* distinction was only ever used to route role-specific procedures
|
|
43916
|
-
* which we no longer have. CLI / webhook integrations are `cst_*` tokens
|
|
43917
|
-
* with `isAdmin: false` + an explicit scope list.
|
|
43918
|
-
*/
|
|
43919
|
-
/** Per-method access flavour. Materialised on every cap method via codegen. */
|
|
43920
|
-
var MethodAccessSchema = _enum([
|
|
43921
|
-
"view",
|
|
43922
|
-
"create",
|
|
43923
|
-
"delete"
|
|
43924
|
-
]);
|
|
43925
|
-
/**
|
|
43926
|
-
* A single scope grant. Three forms — checked in matcher with OR
|
|
43927
|
-
* semantics; the first match decides whether the call passes:
|
|
43928
|
-
*
|
|
43929
|
-
* - `category` — broadest. `target: 'device' | 'system'` selects every
|
|
43930
|
-
* cap with the matching `scope` declaration. New caps inherit grants
|
|
43931
|
-
* automatically — adding a device cap to the codebase makes it
|
|
43932
|
-
* reachable to every user with `category:device [...]` without a
|
|
43933
|
-
* re-grant. Use this for "family viewer" / "operator" tiers.
|
|
43934
|
-
*
|
|
43935
|
-
* - `addon` — every cap that ships inside a given addon id. Niche;
|
|
43936
|
-
* useful when an integration needs to interact with one specific
|
|
43937
|
-
* addon's surface regardless of how many caps it exports.
|
|
43938
|
-
*
|
|
43939
|
-
* - `capability` — the most precise form. Single cap name. Use for
|
|
43940
|
-
* integration tokens where you want to grant `addons.installPackage`
|
|
43941
|
-
* and nothing else.
|
|
43942
|
-
*
|
|
43943
|
-
* `access` is REQUIRED with min 1 element. `admin` bypass is the
|
|
43944
|
-
* "give me everything" escape; there is no wildcard scope.
|
|
43945
|
-
*/
|
|
43946
|
-
var AllowedProviderSchema = union([literal("*"), array(string())]);
|
|
43947
|
-
var AllowedDevicesSchema = record(string(), union([literal("*"), array(string())]));
|
|
43948
|
-
var CapScopeSchema = _enum(["device", "system"]);
|
|
43949
|
-
/**
|
|
43950
|
-
* DeviceSelector (scope model v3 — 2026-08-12).
|
|
43951
|
-
*
|
|
43952
|
-
* A `device` grant no longer carries a frozen list of deviceIds. It carries
|
|
43953
|
-
* a SELECTOR the matcher resolves against the live fleet, so the grant can be
|
|
43954
|
-
* DYNAMIC: a `types:['camera']` selector automatically covers a camera added
|
|
43955
|
-
* AFTER the grant was minted — no re-grant, no re-login.
|
|
43956
|
-
*
|
|
43957
|
-
* - `all` — every device in the deployment. The broad viewer/operator
|
|
43958
|
-
* lever without a `category` grant (a `category` grant also covers device
|
|
43959
|
-
* caps that carry no deviceId; `all` is specifically the device set).
|
|
43960
|
-
* - `ids` — an explicit deviceId list. This is what a v2 `device:[…]`
|
|
43961
|
-
* grant migrates to (see {@link TokenScopeSchema}); STATIC — a new camera
|
|
43962
|
-
* is NOT covered until the grant is edited.
|
|
43963
|
-
* - `types` — every device of a `DeviceType` (e.g. every `camera`).
|
|
43964
|
-
* DYNAMIC. A device that changes type, or a new device of the type,
|
|
43965
|
-
* re-resolves on the next request.
|
|
43966
|
-
* - `locations` — every device whose operator-assigned `location` label is
|
|
43967
|
-
* in the set (e.g. "Garden", "Front door"). DYNAMIC. A device with a
|
|
43968
|
-
* null/unset location matches NO `locations` selector.
|
|
43969
|
-
*/
|
|
43970
|
-
var DeviceSelectorSchema = discriminatedUnion("kind", [
|
|
43971
|
-
object({ kind: literal("all") }),
|
|
43972
|
-
object({
|
|
43973
|
-
kind: literal("ids"),
|
|
43974
|
-
ids: array(number().int()).min(1)
|
|
43975
|
-
}),
|
|
43976
|
-
object({
|
|
43977
|
-
kind: literal("types"),
|
|
43978
|
-
types: array(_enum(DeviceType)).min(1)
|
|
43979
|
-
}),
|
|
43980
|
-
object({
|
|
43981
|
-
kind: literal("locations"),
|
|
43982
|
-
locations: array(string().min(1)).min(1)
|
|
43983
|
-
})
|
|
43984
|
-
]);
|
|
43985
|
-
var DeviceTokenScopeSchema = object({
|
|
43986
|
-
type: literal("device"),
|
|
43987
|
-
/** The device SET this grant covers — resolved against the live fleet. */
|
|
43988
|
-
selector: DeviceSelectorSchema,
|
|
43989
|
-
access: array(MethodAccessSchema).min(1),
|
|
43990
|
-
/**
|
|
43991
|
-
* Whether a grant on a PARENT device transparently covers its accessory
|
|
43992
|
-
* CHILDREN (siren / floodlight / PIR) via the persisted-parentage walk.
|
|
43993
|
-
* Direction is parent → children ONLY.
|
|
43994
|
-
*
|
|
43995
|
-
* Absent → the matcher DERIVES it from the access flavour: `view`
|
|
43996
|
-
* inherits (a camera viewer sees the camera's accessories), `create` /
|
|
43997
|
-
* `delete` do NOT (actuating/removing a child is an explicit act the
|
|
43998
|
-
* operator must grant on the child, not inherit from the parent). Set it
|
|
43999
|
-
* explicitly to override that default per grant.
|
|
44000
|
-
*/
|
|
44001
|
-
includeLinked: boolean().optional()
|
|
44002
|
-
});
|
|
44003
|
-
/**
|
|
44004
|
-
* v2 → v3 lazy migration. A pre-v3 `device` grant carried
|
|
44005
|
-
* `targets: string[]` (stringified deviceIds); it rewrites to the equivalent
|
|
44006
|
-
* `selector: {kind:'ids', ids}`. Applied as a `preprocess` so it runs on
|
|
44007
|
-
* EVERY parse path — stored records AND the JWT-carried scope arrays
|
|
44008
|
-
* normalised at the request boundary ({@link normalizeTokenScopes} in
|
|
44009
|
-
* `device-selector.ts`). Chosen over a one-time DB migration because a
|
|
44010
|
-
* migration cannot reach a JWT already in a client's hands; parse-time
|
|
44011
|
-
* migration covers both without a flag day. No cast — the raw object is read
|
|
44012
|
-
* through `Reflect.get` (its static type is `unknown`).
|
|
44013
|
-
*/
|
|
44014
|
-
function migrateLegacyTokenScope(raw) {
|
|
44015
|
-
if (raw === null || typeof raw !== "object" || Array.isArray(raw)) return raw;
|
|
44016
|
-
if (Reflect.get(raw, "type") !== "device") return raw;
|
|
44017
|
-
if (Reflect.get(raw, "selector") !== void 0) return raw;
|
|
44018
|
-
const targets = Reflect.get(raw, "targets");
|
|
44019
|
-
if (!Array.isArray(targets)) return raw;
|
|
44020
|
-
return {
|
|
44021
|
-
type: "device",
|
|
44022
|
-
selector: {
|
|
44023
|
-
kind: "ids",
|
|
44024
|
-
ids: targets.map((t) => typeof t === "string" ? Number(t) : t).filter((n) => typeof n === "number" && Number.isInteger(n))
|
|
44025
|
-
},
|
|
44026
|
-
access: Reflect.get(raw, "access")
|
|
44027
|
-
};
|
|
44028
|
-
}
|
|
44029
|
-
var TokenScopeSchema = preprocess(migrateLegacyTokenScope, discriminatedUnion("type", [
|
|
44030
|
-
object({
|
|
44031
|
-
type: literal("category"),
|
|
44032
|
-
target: CapScopeSchema,
|
|
44033
|
-
access: array(MethodAccessSchema).min(1)
|
|
44034
|
-
}),
|
|
44035
|
-
object({
|
|
44036
|
-
type: literal("capability"),
|
|
44037
|
-
target: string(),
|
|
44038
|
-
access: array(MethodAccessSchema).min(1)
|
|
44039
|
-
}),
|
|
44040
|
-
object({
|
|
44041
|
-
type: literal("addon"),
|
|
44042
|
-
target: string(),
|
|
44043
|
-
access: array(MethodAccessSchema).min(1)
|
|
44044
|
-
}),
|
|
44045
|
-
DeviceTokenScopeSchema
|
|
44046
|
-
]));
|
|
44047
|
-
object({
|
|
44048
|
-
id: string(),
|
|
44049
|
-
username: string(),
|
|
44050
|
-
passwordHash: string(),
|
|
44051
|
-
/**
|
|
44052
|
-
* Admin bypass. When true, the middleware skips the scope-access
|
|
44053
|
-
* check entirely. There is no other axis of privilege; the legacy
|
|
44054
|
-
* role enum collapsed onto this boolean in v2.
|
|
44055
|
-
*/
|
|
44056
|
-
isAdmin: boolean().default(false),
|
|
44057
|
-
allowedProviders: AllowedProviderSchema,
|
|
44058
|
-
allowedDevices: AllowedDevicesSchema,
|
|
44059
|
-
/**
|
|
44060
|
-
* Scopes granted to this user. Admins bypass; their `scopes` is
|
|
44061
|
-
* ignored. Non-admins without scopes are locked out of every
|
|
44062
|
-
* protected call.
|
|
44063
|
-
*/
|
|
44064
|
-
scopes: array(TokenScopeSchema).default([]),
|
|
44065
|
-
createdAt: number(),
|
|
44066
|
-
updatedAt: number()
|
|
44067
|
-
});
|
|
44068
|
-
object({
|
|
44069
|
-
id: string(),
|
|
44070
|
-
label: string(),
|
|
44071
|
-
isAdmin: boolean().default(false),
|
|
44072
|
-
allowedProviders: AllowedProviderSchema,
|
|
44073
|
-
allowedDevices: AllowedDevicesSchema,
|
|
44074
|
-
tokenHash: string(),
|
|
44075
|
-
tokenPrefix: string(),
|
|
44076
|
-
createdAt: number(),
|
|
44077
|
-
lastUsedAt: number().optional()
|
|
44078
|
-
});
|
|
44079
|
-
object({
|
|
44080
|
-
id: string(),
|
|
44081
|
-
userId: string(),
|
|
44082
|
-
name: string(),
|
|
44083
|
-
tokenHash: string(),
|
|
44084
|
-
tokenPrefix: string(),
|
|
44085
|
-
scopes: array(TokenScopeSchema),
|
|
44086
|
-
expiresAt: number().nullish(),
|
|
44087
|
-
lastUsedAt: number().nullish(),
|
|
44088
|
-
createdAt: number()
|
|
44089
|
-
});
|
|
44090
|
-
/**
|
|
44091
44124
|
* `oauth-integration` — a collection cap by which an addon declares
|
|
44092
44125
|
* itself a linkable OAuth client of the hub's core `/oauth2/*` server.
|
|
44093
44126
|
* Each provider returns a static descriptor; the core enumerates them
|
|
@@ -7802,6 +7802,12 @@ function normalizeAddonInitResult(result) {
|
|
|
7802
7802
|
if (Array.isArray(result)) return { providers: result };
|
|
7803
7803
|
return result;
|
|
7804
7804
|
}
|
|
7805
|
+
/**
|
|
7806
|
+
* The share-view scope kinds a `csv_*` share token can carry. The hub mints
|
|
7807
|
+
* and validates them (`share-token.service.ts` builds its enum from this
|
|
7808
|
+
* list); a data plane names the kinds it ACCEPTS in `share`.
|
|
7809
|
+
*/
|
|
7810
|
+
var SHARE_VIEW_KINDS = ["grid-view", "events-view"];
|
|
7805
7811
|
/** The wire shape of {@link PeerBytesTicket} — see the type for what it is. */
|
|
7806
7812
|
var PeerBytesTicketSchema = object({
|
|
7807
7813
|
/** `http://127.0.0.1:<port>/<token>`. One `GET` takes it. */
|
|
@@ -12682,6 +12688,229 @@ var ConvertResultSchema = object({
|
|
|
12682
12688
|
function scopesAllowDeviceCap(scopes, access) {
|
|
12683
12689
|
return scopes.some((s) => s.type === "category" && s.target === "device" && s.access.includes(access));
|
|
12684
12690
|
}
|
|
12691
|
+
/**
|
|
12692
|
+
* Zod schemas for persisted record types.
|
|
12693
|
+
*
|
|
12694
|
+
* These schemas serve as the single source of truth for types that are
|
|
12695
|
+
* stored in the settings-store backend and retrieved via tRPC. They
|
|
12696
|
+
* replace the manual TypeScript interfaces with schema-derived types,
|
|
12697
|
+
* enabling runtime validation when reading from the backend.
|
|
12698
|
+
*
|
|
12699
|
+
* Convention: each schema is named `<Type>Schema`, the inferred TS type
|
|
12700
|
+
* keeps the original name for backward compatibility.
|
|
12701
|
+
*/
|
|
12702
|
+
/**
|
|
12703
|
+
* Auth model (v2 — 2026-05-12 caps-only):
|
|
12704
|
+
*
|
|
12705
|
+
* Two principals:
|
|
12706
|
+
* - `isAdmin: true` — full bypass. Admin scope set is ignored.
|
|
12707
|
+
* - `isAdmin: false` — every call gated by `scopes` (see TokenScope).
|
|
12708
|
+
*
|
|
12709
|
+
* No role enum. There used to be `viewer / agent / scoped` and earlier
|
|
12710
|
+
* `super_admin` — collapsed onto the single boolean because every
|
|
12711
|
+
* non-admin caller is governed by the same scope-check rules; the
|
|
12712
|
+
* distinction was only ever used to route role-specific procedures
|
|
12713
|
+
* which we no longer have. CLI / webhook integrations are `cst_*` tokens
|
|
12714
|
+
* with `isAdmin: false` + an explicit scope list.
|
|
12715
|
+
*/
|
|
12716
|
+
/** Per-method access flavour. Materialised on every cap method via codegen. */
|
|
12717
|
+
var MethodAccessSchema = _enum([
|
|
12718
|
+
"view",
|
|
12719
|
+
"create",
|
|
12720
|
+
"delete"
|
|
12721
|
+
]);
|
|
12722
|
+
/**
|
|
12723
|
+
* A single scope grant. Three forms — checked in matcher with OR
|
|
12724
|
+
* semantics; the first match decides whether the call passes:
|
|
12725
|
+
*
|
|
12726
|
+
* - `category` — broadest. `target: 'device' | 'system'` selects every
|
|
12727
|
+
* cap with the matching `scope` declaration. New caps inherit grants
|
|
12728
|
+
* automatically — adding a device cap to the codebase makes it
|
|
12729
|
+
* reachable to every user with `category:device [...]` without a
|
|
12730
|
+
* re-grant. Use this for "family viewer" / "operator" tiers.
|
|
12731
|
+
*
|
|
12732
|
+
* - `addon` — every cap that ships inside a given addon id. Niche;
|
|
12733
|
+
* useful when an integration needs to interact with one specific
|
|
12734
|
+
* addon's surface regardless of how many caps it exports.
|
|
12735
|
+
*
|
|
12736
|
+
* - `capability` — the most precise form. Single cap name. Use for
|
|
12737
|
+
* integration tokens where you want to grant `addons.installPackage`
|
|
12738
|
+
* and nothing else.
|
|
12739
|
+
*
|
|
12740
|
+
* `access` is REQUIRED with min 1 element. `admin` bypass is the
|
|
12741
|
+
* "give me everything" escape; there is no wildcard scope.
|
|
12742
|
+
*/
|
|
12743
|
+
var AllowedProviderSchema = union([literal("*"), array(string())]);
|
|
12744
|
+
var AllowedDevicesSchema = record(string(), union([literal("*"), array(string())]));
|
|
12745
|
+
var CapScopeSchema = _enum(["device", "system"]);
|
|
12746
|
+
/**
|
|
12747
|
+
* DeviceSelector (scope model v3 — 2026-08-12).
|
|
12748
|
+
*
|
|
12749
|
+
* A `device` grant no longer carries a frozen list of deviceIds. It carries
|
|
12750
|
+
* a SELECTOR the matcher resolves against the live fleet, so the grant can be
|
|
12751
|
+
* DYNAMIC: a `types:['camera']` selector automatically covers a camera added
|
|
12752
|
+
* AFTER the grant was minted — no re-grant, no re-login.
|
|
12753
|
+
*
|
|
12754
|
+
* - `all` — every device in the deployment. The broad viewer/operator
|
|
12755
|
+
* lever without a `category` grant (a `category` grant also covers device
|
|
12756
|
+
* caps that carry no deviceId; `all` is specifically the device set).
|
|
12757
|
+
* - `ids` — an explicit deviceId list. This is what a v2 `device:[…]`
|
|
12758
|
+
* grant migrates to (see {@link TokenScopeSchema}); STATIC — a new camera
|
|
12759
|
+
* is NOT covered until the grant is edited.
|
|
12760
|
+
* - `types` — every device of a `DeviceType` (e.g. every `camera`).
|
|
12761
|
+
* DYNAMIC. A device that changes type, or a new device of the type,
|
|
12762
|
+
* re-resolves on the next request.
|
|
12763
|
+
* - `locations` — every device whose operator-assigned `location` label is
|
|
12764
|
+
* in the set (e.g. "Garden", "Front door"). DYNAMIC. A device with a
|
|
12765
|
+
* null/unset location matches NO `locations` selector.
|
|
12766
|
+
*/
|
|
12767
|
+
var DeviceSelectorSchema = discriminatedUnion("kind", [
|
|
12768
|
+
object({ kind: literal("all") }),
|
|
12769
|
+
object({
|
|
12770
|
+
kind: literal("ids"),
|
|
12771
|
+
ids: array(number().int()).min(1)
|
|
12772
|
+
}),
|
|
12773
|
+
object({
|
|
12774
|
+
kind: literal("types"),
|
|
12775
|
+
types: array(_enum(DeviceType)).min(1)
|
|
12776
|
+
}),
|
|
12777
|
+
object({
|
|
12778
|
+
kind: literal("locations"),
|
|
12779
|
+
locations: array(string().min(1)).min(1)
|
|
12780
|
+
})
|
|
12781
|
+
]);
|
|
12782
|
+
var DeviceTokenScopeSchema = object({
|
|
12783
|
+
type: literal("device"),
|
|
12784
|
+
/** The device SET this grant covers — resolved against the live fleet. */
|
|
12785
|
+
selector: DeviceSelectorSchema,
|
|
12786
|
+
access: array(MethodAccessSchema).min(1),
|
|
12787
|
+
/**
|
|
12788
|
+
* Whether a grant on a PARENT device transparently covers its accessory
|
|
12789
|
+
* CHILDREN (siren / floodlight / PIR) via the persisted-parentage walk.
|
|
12790
|
+
* Direction is parent → children ONLY.
|
|
12791
|
+
*
|
|
12792
|
+
* Absent → the matcher DERIVES it from the access flavour: `view`
|
|
12793
|
+
* inherits (a camera viewer sees the camera's accessories), `create` /
|
|
12794
|
+
* `delete` do NOT (actuating/removing a child is an explicit act the
|
|
12795
|
+
* operator must grant on the child, not inherit from the parent). Set it
|
|
12796
|
+
* explicitly to override that default per grant.
|
|
12797
|
+
*/
|
|
12798
|
+
includeLinked: boolean().optional()
|
|
12799
|
+
});
|
|
12800
|
+
/**
|
|
12801
|
+
* v2 → v3 lazy migration. A pre-v3 `device` grant carried
|
|
12802
|
+
* `targets: string[]` (stringified deviceIds); it rewrites to the equivalent
|
|
12803
|
+
* `selector: {kind:'ids', ids}`. Applied as a `preprocess` so it runs on
|
|
12804
|
+
* EVERY parse path — stored records AND the JWT-carried scope arrays
|
|
12805
|
+
* normalised at the request boundary ({@link normalizeTokenScopes} in
|
|
12806
|
+
* `device-selector.ts`). Chosen over a one-time DB migration because a
|
|
12807
|
+
* migration cannot reach a JWT already in a client's hands; parse-time
|
|
12808
|
+
* migration covers both without a flag day. No cast — the raw object is read
|
|
12809
|
+
* through `Reflect.get` (its static type is `unknown`).
|
|
12810
|
+
*/
|
|
12811
|
+
function migrateLegacyTokenScope(raw) {
|
|
12812
|
+
if (raw === null || typeof raw !== "object" || Array.isArray(raw)) return raw;
|
|
12813
|
+
if (Reflect.get(raw, "type") !== "device") return raw;
|
|
12814
|
+
if (Reflect.get(raw, "selector") !== void 0) return raw;
|
|
12815
|
+
const targets = Reflect.get(raw, "targets");
|
|
12816
|
+
if (!Array.isArray(targets)) return raw;
|
|
12817
|
+
return {
|
|
12818
|
+
type: "device",
|
|
12819
|
+
selector: {
|
|
12820
|
+
kind: "ids",
|
|
12821
|
+
ids: targets.map((t) => typeof t === "string" ? Number(t) : t).filter((n) => typeof n === "number" && Number.isInteger(n))
|
|
12822
|
+
},
|
|
12823
|
+
access: Reflect.get(raw, "access")
|
|
12824
|
+
};
|
|
12825
|
+
}
|
|
12826
|
+
var TokenScopeSchema = preprocess(migrateLegacyTokenScope, discriminatedUnion("type", [
|
|
12827
|
+
object({
|
|
12828
|
+
type: literal("category"),
|
|
12829
|
+
target: CapScopeSchema,
|
|
12830
|
+
access: array(MethodAccessSchema).min(1)
|
|
12831
|
+
}),
|
|
12832
|
+
object({
|
|
12833
|
+
type: literal("capability"),
|
|
12834
|
+
target: string(),
|
|
12835
|
+
access: array(MethodAccessSchema).min(1)
|
|
12836
|
+
}),
|
|
12837
|
+
object({
|
|
12838
|
+
type: literal("addon"),
|
|
12839
|
+
target: string(),
|
|
12840
|
+
access: array(MethodAccessSchema).min(1)
|
|
12841
|
+
}),
|
|
12842
|
+
DeviceTokenScopeSchema
|
|
12843
|
+
]));
|
|
12844
|
+
object({
|
|
12845
|
+
id: string(),
|
|
12846
|
+
username: string(),
|
|
12847
|
+
passwordHash: string(),
|
|
12848
|
+
/**
|
|
12849
|
+
* Admin bypass. When true, the middleware skips the scope-access
|
|
12850
|
+
* check entirely. There is no other axis of privilege; the legacy
|
|
12851
|
+
* role enum collapsed onto this boolean in v2.
|
|
12852
|
+
*/
|
|
12853
|
+
isAdmin: boolean().default(false),
|
|
12854
|
+
allowedProviders: AllowedProviderSchema,
|
|
12855
|
+
allowedDevices: AllowedDevicesSchema,
|
|
12856
|
+
/**
|
|
12857
|
+
* Scopes granted to this user. Admins bypass; their `scopes` is
|
|
12858
|
+
* ignored. Non-admins without scopes are locked out of every
|
|
12859
|
+
* protected call.
|
|
12860
|
+
*/
|
|
12861
|
+
scopes: array(TokenScopeSchema).default([]),
|
|
12862
|
+
createdAt: number(),
|
|
12863
|
+
updatedAt: number()
|
|
12864
|
+
});
|
|
12865
|
+
object({
|
|
12866
|
+
id: string(),
|
|
12867
|
+
label: string(),
|
|
12868
|
+
isAdmin: boolean().default(false),
|
|
12869
|
+
allowedProviders: AllowedProviderSchema,
|
|
12870
|
+
allowedDevices: AllowedDevicesSchema,
|
|
12871
|
+
tokenHash: string(),
|
|
12872
|
+
tokenPrefix: string(),
|
|
12873
|
+
createdAt: number(),
|
|
12874
|
+
lastUsedAt: number().optional()
|
|
12875
|
+
});
|
|
12876
|
+
object({
|
|
12877
|
+
id: string(),
|
|
12878
|
+
userId: string(),
|
|
12879
|
+
name: string(),
|
|
12880
|
+
tokenHash: string(),
|
|
12881
|
+
tokenPrefix: string(),
|
|
12882
|
+
scopes: array(TokenScopeSchema),
|
|
12883
|
+
expiresAt: number().nullish(),
|
|
12884
|
+
lastUsedAt: number().nullish(),
|
|
12885
|
+
createdAt: number()
|
|
12886
|
+
});
|
|
12887
|
+
/** What a share-view grant lets its holder see. */
|
|
12888
|
+
var ShareViewGrantSchema = object({
|
|
12889
|
+
kind: _enum(SHARE_VIEW_KINDS),
|
|
12890
|
+
deviceIds: array(number().int().nonnegative()).min(1).max(64),
|
|
12891
|
+
/** Talk-back, opt-in at mint time; absent means off. */
|
|
12892
|
+
talk: boolean().optional()
|
|
12893
|
+
});
|
|
12894
|
+
var ShareViewScopeSchema = object({
|
|
12895
|
+
type: literal("share-view"),
|
|
12896
|
+
grant: ShareViewGrantSchema
|
|
12897
|
+
});
|
|
12898
|
+
var AddonRoutesScopeSchema = object({
|
|
12899
|
+
type: literal("addon-routes"),
|
|
12900
|
+
access: array(MethodAccessSchema).min(1)
|
|
12901
|
+
});
|
|
12902
|
+
var CredentialScopeSchema = union([
|
|
12903
|
+
literal("*"),
|
|
12904
|
+
ShareViewScopeSchema,
|
|
12905
|
+
AddonRoutesScopeSchema,
|
|
12906
|
+
TokenScopeSchema
|
|
12907
|
+
]);
|
|
12908
|
+
object({
|
|
12909
|
+
kind: literal("credential"),
|
|
12910
|
+
sub: string().min(1),
|
|
12911
|
+
jti: string().min(16),
|
|
12912
|
+
scopes: array(CredentialScopeSchema).min(1)
|
|
12913
|
+
});
|
|
12685
12914
|
_enum(["new-session", "step-up"]);
|
|
12686
12915
|
/** The languages the hub's app landing pages are written in (D858). */
|
|
12687
12916
|
var AppPageLangSchema = _enum(["en", "it"]);
|
|
@@ -43863,202 +44092,6 @@ method(object({}), object({ rules: array(NcRuleSchema) }), { auth: "admin" }), m
|
|
|
43863
44092
|
auth: "admin"
|
|
43864
44093
|
}), method(NcAlarmSensorsInputSchema, NcAlarmSensorsSchema, { auth: "admin" });
|
|
43865
44094
|
/**
|
|
43866
|
-
* Zod schemas for persisted record types.
|
|
43867
|
-
*
|
|
43868
|
-
* These schemas serve as the single source of truth for types that are
|
|
43869
|
-
* stored in the settings-store backend and retrieved via tRPC. They
|
|
43870
|
-
* replace the manual TypeScript interfaces with schema-derived types,
|
|
43871
|
-
* enabling runtime validation when reading from the backend.
|
|
43872
|
-
*
|
|
43873
|
-
* Convention: each schema is named `<Type>Schema`, the inferred TS type
|
|
43874
|
-
* keeps the original name for backward compatibility.
|
|
43875
|
-
*/
|
|
43876
|
-
/**
|
|
43877
|
-
* Auth model (v2 — 2026-05-12 caps-only):
|
|
43878
|
-
*
|
|
43879
|
-
* Two principals:
|
|
43880
|
-
* - `isAdmin: true` — full bypass. Admin scope set is ignored.
|
|
43881
|
-
* - `isAdmin: false` — every call gated by `scopes` (see TokenScope).
|
|
43882
|
-
*
|
|
43883
|
-
* No role enum. There used to be `viewer / agent / scoped` and earlier
|
|
43884
|
-
* `super_admin` — collapsed onto the single boolean because every
|
|
43885
|
-
* non-admin caller is governed by the same scope-check rules; the
|
|
43886
|
-
* distinction was only ever used to route role-specific procedures
|
|
43887
|
-
* which we no longer have. CLI / webhook integrations are `cst_*` tokens
|
|
43888
|
-
* with `isAdmin: false` + an explicit scope list.
|
|
43889
|
-
*/
|
|
43890
|
-
/** Per-method access flavour. Materialised on every cap method via codegen. */
|
|
43891
|
-
var MethodAccessSchema = _enum([
|
|
43892
|
-
"view",
|
|
43893
|
-
"create",
|
|
43894
|
-
"delete"
|
|
43895
|
-
]);
|
|
43896
|
-
/**
|
|
43897
|
-
* A single scope grant. Three forms — checked in matcher with OR
|
|
43898
|
-
* semantics; the first match decides whether the call passes:
|
|
43899
|
-
*
|
|
43900
|
-
* - `category` — broadest. `target: 'device' | 'system'` selects every
|
|
43901
|
-
* cap with the matching `scope` declaration. New caps inherit grants
|
|
43902
|
-
* automatically — adding a device cap to the codebase makes it
|
|
43903
|
-
* reachable to every user with `category:device [...]` without a
|
|
43904
|
-
* re-grant. Use this for "family viewer" / "operator" tiers.
|
|
43905
|
-
*
|
|
43906
|
-
* - `addon` — every cap that ships inside a given addon id. Niche;
|
|
43907
|
-
* useful when an integration needs to interact with one specific
|
|
43908
|
-
* addon's surface regardless of how many caps it exports.
|
|
43909
|
-
*
|
|
43910
|
-
* - `capability` — the most precise form. Single cap name. Use for
|
|
43911
|
-
* integration tokens where you want to grant `addons.installPackage`
|
|
43912
|
-
* and nothing else.
|
|
43913
|
-
*
|
|
43914
|
-
* `access` is REQUIRED with min 1 element. `admin` bypass is the
|
|
43915
|
-
* "give me everything" escape; there is no wildcard scope.
|
|
43916
|
-
*/
|
|
43917
|
-
var AllowedProviderSchema = union([literal("*"), array(string())]);
|
|
43918
|
-
var AllowedDevicesSchema = record(string(), union([literal("*"), array(string())]));
|
|
43919
|
-
var CapScopeSchema = _enum(["device", "system"]);
|
|
43920
|
-
/**
|
|
43921
|
-
* DeviceSelector (scope model v3 — 2026-08-12).
|
|
43922
|
-
*
|
|
43923
|
-
* A `device` grant no longer carries a frozen list of deviceIds. It carries
|
|
43924
|
-
* a SELECTOR the matcher resolves against the live fleet, so the grant can be
|
|
43925
|
-
* DYNAMIC: a `types:['camera']` selector automatically covers a camera added
|
|
43926
|
-
* AFTER the grant was minted — no re-grant, no re-login.
|
|
43927
|
-
*
|
|
43928
|
-
* - `all` — every device in the deployment. The broad viewer/operator
|
|
43929
|
-
* lever without a `category` grant (a `category` grant also covers device
|
|
43930
|
-
* caps that carry no deviceId; `all` is specifically the device set).
|
|
43931
|
-
* - `ids` — an explicit deviceId list. This is what a v2 `device:[…]`
|
|
43932
|
-
* grant migrates to (see {@link TokenScopeSchema}); STATIC — a new camera
|
|
43933
|
-
* is NOT covered until the grant is edited.
|
|
43934
|
-
* - `types` — every device of a `DeviceType` (e.g. every `camera`).
|
|
43935
|
-
* DYNAMIC. A device that changes type, or a new device of the type,
|
|
43936
|
-
* re-resolves on the next request.
|
|
43937
|
-
* - `locations` — every device whose operator-assigned `location` label is
|
|
43938
|
-
* in the set (e.g. "Garden", "Front door"). DYNAMIC. A device with a
|
|
43939
|
-
* null/unset location matches NO `locations` selector.
|
|
43940
|
-
*/
|
|
43941
|
-
var DeviceSelectorSchema = discriminatedUnion("kind", [
|
|
43942
|
-
object({ kind: literal("all") }),
|
|
43943
|
-
object({
|
|
43944
|
-
kind: literal("ids"),
|
|
43945
|
-
ids: array(number().int()).min(1)
|
|
43946
|
-
}),
|
|
43947
|
-
object({
|
|
43948
|
-
kind: literal("types"),
|
|
43949
|
-
types: array(_enum(DeviceType)).min(1)
|
|
43950
|
-
}),
|
|
43951
|
-
object({
|
|
43952
|
-
kind: literal("locations"),
|
|
43953
|
-
locations: array(string().min(1)).min(1)
|
|
43954
|
-
})
|
|
43955
|
-
]);
|
|
43956
|
-
var DeviceTokenScopeSchema = object({
|
|
43957
|
-
type: literal("device"),
|
|
43958
|
-
/** The device SET this grant covers — resolved against the live fleet. */
|
|
43959
|
-
selector: DeviceSelectorSchema,
|
|
43960
|
-
access: array(MethodAccessSchema).min(1),
|
|
43961
|
-
/**
|
|
43962
|
-
* Whether a grant on a PARENT device transparently covers its accessory
|
|
43963
|
-
* CHILDREN (siren / floodlight / PIR) via the persisted-parentage walk.
|
|
43964
|
-
* Direction is parent → children ONLY.
|
|
43965
|
-
*
|
|
43966
|
-
* Absent → the matcher DERIVES it from the access flavour: `view`
|
|
43967
|
-
* inherits (a camera viewer sees the camera's accessories), `create` /
|
|
43968
|
-
* `delete` do NOT (actuating/removing a child is an explicit act the
|
|
43969
|
-
* operator must grant on the child, not inherit from the parent). Set it
|
|
43970
|
-
* explicitly to override that default per grant.
|
|
43971
|
-
*/
|
|
43972
|
-
includeLinked: boolean().optional()
|
|
43973
|
-
});
|
|
43974
|
-
/**
|
|
43975
|
-
* v2 → v3 lazy migration. A pre-v3 `device` grant carried
|
|
43976
|
-
* `targets: string[]` (stringified deviceIds); it rewrites to the equivalent
|
|
43977
|
-
* `selector: {kind:'ids', ids}`. Applied as a `preprocess` so it runs on
|
|
43978
|
-
* EVERY parse path — stored records AND the JWT-carried scope arrays
|
|
43979
|
-
* normalised at the request boundary ({@link normalizeTokenScopes} in
|
|
43980
|
-
* `device-selector.ts`). Chosen over a one-time DB migration because a
|
|
43981
|
-
* migration cannot reach a JWT already in a client's hands; parse-time
|
|
43982
|
-
* migration covers both without a flag day. No cast — the raw object is read
|
|
43983
|
-
* through `Reflect.get` (its static type is `unknown`).
|
|
43984
|
-
*/
|
|
43985
|
-
function migrateLegacyTokenScope(raw) {
|
|
43986
|
-
if (raw === null || typeof raw !== "object" || Array.isArray(raw)) return raw;
|
|
43987
|
-
if (Reflect.get(raw, "type") !== "device") return raw;
|
|
43988
|
-
if (Reflect.get(raw, "selector") !== void 0) return raw;
|
|
43989
|
-
const targets = Reflect.get(raw, "targets");
|
|
43990
|
-
if (!Array.isArray(targets)) return raw;
|
|
43991
|
-
return {
|
|
43992
|
-
type: "device",
|
|
43993
|
-
selector: {
|
|
43994
|
-
kind: "ids",
|
|
43995
|
-
ids: targets.map((t) => typeof t === "string" ? Number(t) : t).filter((n) => typeof n === "number" && Number.isInteger(n))
|
|
43996
|
-
},
|
|
43997
|
-
access: Reflect.get(raw, "access")
|
|
43998
|
-
};
|
|
43999
|
-
}
|
|
44000
|
-
var TokenScopeSchema = preprocess(migrateLegacyTokenScope, discriminatedUnion("type", [
|
|
44001
|
-
object({
|
|
44002
|
-
type: literal("category"),
|
|
44003
|
-
target: CapScopeSchema,
|
|
44004
|
-
access: array(MethodAccessSchema).min(1)
|
|
44005
|
-
}),
|
|
44006
|
-
object({
|
|
44007
|
-
type: literal("capability"),
|
|
44008
|
-
target: string(),
|
|
44009
|
-
access: array(MethodAccessSchema).min(1)
|
|
44010
|
-
}),
|
|
44011
|
-
object({
|
|
44012
|
-
type: literal("addon"),
|
|
44013
|
-
target: string(),
|
|
44014
|
-
access: array(MethodAccessSchema).min(1)
|
|
44015
|
-
}),
|
|
44016
|
-
DeviceTokenScopeSchema
|
|
44017
|
-
]));
|
|
44018
|
-
object({
|
|
44019
|
-
id: string(),
|
|
44020
|
-
username: string(),
|
|
44021
|
-
passwordHash: string(),
|
|
44022
|
-
/**
|
|
44023
|
-
* Admin bypass. When true, the middleware skips the scope-access
|
|
44024
|
-
* check entirely. There is no other axis of privilege; the legacy
|
|
44025
|
-
* role enum collapsed onto this boolean in v2.
|
|
44026
|
-
*/
|
|
44027
|
-
isAdmin: boolean().default(false),
|
|
44028
|
-
allowedProviders: AllowedProviderSchema,
|
|
44029
|
-
allowedDevices: AllowedDevicesSchema,
|
|
44030
|
-
/**
|
|
44031
|
-
* Scopes granted to this user. Admins bypass; their `scopes` is
|
|
44032
|
-
* ignored. Non-admins without scopes are locked out of every
|
|
44033
|
-
* protected call.
|
|
44034
|
-
*/
|
|
44035
|
-
scopes: array(TokenScopeSchema).default([]),
|
|
44036
|
-
createdAt: number(),
|
|
44037
|
-
updatedAt: number()
|
|
44038
|
-
});
|
|
44039
|
-
object({
|
|
44040
|
-
id: string(),
|
|
44041
|
-
label: string(),
|
|
44042
|
-
isAdmin: boolean().default(false),
|
|
44043
|
-
allowedProviders: AllowedProviderSchema,
|
|
44044
|
-
allowedDevices: AllowedDevicesSchema,
|
|
44045
|
-
tokenHash: string(),
|
|
44046
|
-
tokenPrefix: string(),
|
|
44047
|
-
createdAt: number(),
|
|
44048
|
-
lastUsedAt: number().optional()
|
|
44049
|
-
});
|
|
44050
|
-
object({
|
|
44051
|
-
id: string(),
|
|
44052
|
-
userId: string(),
|
|
44053
|
-
name: string(),
|
|
44054
|
-
tokenHash: string(),
|
|
44055
|
-
tokenPrefix: string(),
|
|
44056
|
-
scopes: array(TokenScopeSchema),
|
|
44057
|
-
expiresAt: number().nullish(),
|
|
44058
|
-
lastUsedAt: number().nullish(),
|
|
44059
|
-
createdAt: number()
|
|
44060
|
-
});
|
|
44061
|
-
/**
|
|
44062
44095
|
* `oauth-integration` — a collection cap by which an addon declares
|
|
44063
44096
|
* itself a linkable OAuth client of the hub's core `/oauth2/*` server.
|
|
44064
44097
|
* 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-export-alexa",
|
|
3
|
-
"version": "1.2.
|
|
3
|
+
"version": "1.2.149",
|
|
4
4
|
"description": "Alexa Smart Home Skill export — hub-side OAuth provider + directive handler. The companion AWS Lambda forwards Alexa directives to this addon's /addon/export-alexa/directive endpoint.",
|
|
5
5
|
"keywords": [
|
|
6
6
|
"camstack",
|