@camstack/addon-notifiers 1.2.603 → 1.2.604
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/addon.js +229 -196
- package/dist/addon.mjs +229 -196
- package/package.json +1 -1
package/dist/addon.js
CHANGED
|
@@ -7959,6 +7959,12 @@ function normalizeAddonInitResult(result) {
|
|
|
7959
7959
|
if (Array.isArray(result)) return { providers: result };
|
|
7960
7960
|
return result;
|
|
7961
7961
|
}
|
|
7962
|
+
/**
|
|
7963
|
+
* The share-view scope kinds a `csv_*` share token can carry. The hub mints
|
|
7964
|
+
* and validates them (`share-token.service.ts` builds its enum from this
|
|
7965
|
+
* list); a data plane names the kinds it ACCEPTS in `share`.
|
|
7966
|
+
*/
|
|
7967
|
+
var SHARE_VIEW_KINDS = ["grid-view", "events-view"];
|
|
7962
7968
|
/** The wire shape of {@link PeerBytesTicket} — see the type for what it is. */
|
|
7963
7969
|
var PeerBytesTicketSchema = object({
|
|
7964
7970
|
/** `http://127.0.0.1:<port>/<token>`. One `GET` takes it. */
|
|
@@ -12910,6 +12916,229 @@ var ConvertResultSchema = object({
|
|
|
12910
12916
|
files: array(string()).readonly()
|
|
12911
12917
|
})).readonly()
|
|
12912
12918
|
});
|
|
12919
|
+
/**
|
|
12920
|
+
* Zod schemas for persisted record types.
|
|
12921
|
+
*
|
|
12922
|
+
* These schemas serve as the single source of truth for types that are
|
|
12923
|
+
* stored in the settings-store backend and retrieved via tRPC. They
|
|
12924
|
+
* replace the manual TypeScript interfaces with schema-derived types,
|
|
12925
|
+
* enabling runtime validation when reading from the backend.
|
|
12926
|
+
*
|
|
12927
|
+
* Convention: each schema is named `<Type>Schema`, the inferred TS type
|
|
12928
|
+
* keeps the original name for backward compatibility.
|
|
12929
|
+
*/
|
|
12930
|
+
/**
|
|
12931
|
+
* Auth model (v2 — 2026-05-12 caps-only):
|
|
12932
|
+
*
|
|
12933
|
+
* Two principals:
|
|
12934
|
+
* - `isAdmin: true` — full bypass. Admin scope set is ignored.
|
|
12935
|
+
* - `isAdmin: false` — every call gated by `scopes` (see TokenScope).
|
|
12936
|
+
*
|
|
12937
|
+
* No role enum. There used to be `viewer / agent / scoped` and earlier
|
|
12938
|
+
* `super_admin` — collapsed onto the single boolean because every
|
|
12939
|
+
* non-admin caller is governed by the same scope-check rules; the
|
|
12940
|
+
* distinction was only ever used to route role-specific procedures
|
|
12941
|
+
* which we no longer have. CLI / webhook integrations are `cst_*` tokens
|
|
12942
|
+
* with `isAdmin: false` + an explicit scope list.
|
|
12943
|
+
*/
|
|
12944
|
+
/** Per-method access flavour. Materialised on every cap method via codegen. */
|
|
12945
|
+
var MethodAccessSchema = _enum([
|
|
12946
|
+
"view",
|
|
12947
|
+
"create",
|
|
12948
|
+
"delete"
|
|
12949
|
+
]);
|
|
12950
|
+
/**
|
|
12951
|
+
* A single scope grant. Three forms — checked in matcher with OR
|
|
12952
|
+
* semantics; the first match decides whether the call passes:
|
|
12953
|
+
*
|
|
12954
|
+
* - `category` — broadest. `target: 'device' | 'system'` selects every
|
|
12955
|
+
* cap with the matching `scope` declaration. New caps inherit grants
|
|
12956
|
+
* automatically — adding a device cap to the codebase makes it
|
|
12957
|
+
* reachable to every user with `category:device [...]` without a
|
|
12958
|
+
* re-grant. Use this for "family viewer" / "operator" tiers.
|
|
12959
|
+
*
|
|
12960
|
+
* - `addon` — every cap that ships inside a given addon id. Niche;
|
|
12961
|
+
* useful when an integration needs to interact with one specific
|
|
12962
|
+
* addon's surface regardless of how many caps it exports.
|
|
12963
|
+
*
|
|
12964
|
+
* - `capability` — the most precise form. Single cap name. Use for
|
|
12965
|
+
* integration tokens where you want to grant `addons.installPackage`
|
|
12966
|
+
* and nothing else.
|
|
12967
|
+
*
|
|
12968
|
+
* `access` is REQUIRED with min 1 element. `admin` bypass is the
|
|
12969
|
+
* "give me everything" escape; there is no wildcard scope.
|
|
12970
|
+
*/
|
|
12971
|
+
var AllowedProviderSchema = union([literal("*"), array(string())]);
|
|
12972
|
+
var AllowedDevicesSchema = record(string(), union([literal("*"), array(string())]));
|
|
12973
|
+
var CapScopeSchema = _enum(["device", "system"]);
|
|
12974
|
+
/**
|
|
12975
|
+
* DeviceSelector (scope model v3 — 2026-08-12).
|
|
12976
|
+
*
|
|
12977
|
+
* A `device` grant no longer carries a frozen list of deviceIds. It carries
|
|
12978
|
+
* a SELECTOR the matcher resolves against the live fleet, so the grant can be
|
|
12979
|
+
* DYNAMIC: a `types:['camera']` selector automatically covers a camera added
|
|
12980
|
+
* AFTER the grant was minted — no re-grant, no re-login.
|
|
12981
|
+
*
|
|
12982
|
+
* - `all` — every device in the deployment. The broad viewer/operator
|
|
12983
|
+
* lever without a `category` grant (a `category` grant also covers device
|
|
12984
|
+
* caps that carry no deviceId; `all` is specifically the device set).
|
|
12985
|
+
* - `ids` — an explicit deviceId list. This is what a v2 `device:[…]`
|
|
12986
|
+
* grant migrates to (see {@link TokenScopeSchema}); STATIC — a new camera
|
|
12987
|
+
* is NOT covered until the grant is edited.
|
|
12988
|
+
* - `types` — every device of a `DeviceType` (e.g. every `camera`).
|
|
12989
|
+
* DYNAMIC. A device that changes type, or a new device of the type,
|
|
12990
|
+
* re-resolves on the next request.
|
|
12991
|
+
* - `locations` — every device whose operator-assigned `location` label is
|
|
12992
|
+
* in the set (e.g. "Garden", "Front door"). DYNAMIC. A device with a
|
|
12993
|
+
* null/unset location matches NO `locations` selector.
|
|
12994
|
+
*/
|
|
12995
|
+
var DeviceSelectorSchema = discriminatedUnion("kind", [
|
|
12996
|
+
object({ kind: literal("all") }),
|
|
12997
|
+
object({
|
|
12998
|
+
kind: literal("ids"),
|
|
12999
|
+
ids: array(number().int()).min(1)
|
|
13000
|
+
}),
|
|
13001
|
+
object({
|
|
13002
|
+
kind: literal("types"),
|
|
13003
|
+
types: array(_enum(DeviceType)).min(1)
|
|
13004
|
+
}),
|
|
13005
|
+
object({
|
|
13006
|
+
kind: literal("locations"),
|
|
13007
|
+
locations: array(string().min(1)).min(1)
|
|
13008
|
+
})
|
|
13009
|
+
]);
|
|
13010
|
+
var DeviceTokenScopeSchema = object({
|
|
13011
|
+
type: literal("device"),
|
|
13012
|
+
/** The device SET this grant covers — resolved against the live fleet. */
|
|
13013
|
+
selector: DeviceSelectorSchema,
|
|
13014
|
+
access: array(MethodAccessSchema).min(1),
|
|
13015
|
+
/**
|
|
13016
|
+
* Whether a grant on a PARENT device transparently covers its accessory
|
|
13017
|
+
* CHILDREN (siren / floodlight / PIR) via the persisted-parentage walk.
|
|
13018
|
+
* Direction is parent → children ONLY.
|
|
13019
|
+
*
|
|
13020
|
+
* Absent → the matcher DERIVES it from the access flavour: `view`
|
|
13021
|
+
* inherits (a camera viewer sees the camera's accessories), `create` /
|
|
13022
|
+
* `delete` do NOT (actuating/removing a child is an explicit act the
|
|
13023
|
+
* operator must grant on the child, not inherit from the parent). Set it
|
|
13024
|
+
* explicitly to override that default per grant.
|
|
13025
|
+
*/
|
|
13026
|
+
includeLinked: boolean().optional()
|
|
13027
|
+
});
|
|
13028
|
+
/**
|
|
13029
|
+
* v2 → v3 lazy migration. A pre-v3 `device` grant carried
|
|
13030
|
+
* `targets: string[]` (stringified deviceIds); it rewrites to the equivalent
|
|
13031
|
+
* `selector: {kind:'ids', ids}`. Applied as a `preprocess` so it runs on
|
|
13032
|
+
* EVERY parse path — stored records AND the JWT-carried scope arrays
|
|
13033
|
+
* normalised at the request boundary ({@link normalizeTokenScopes} in
|
|
13034
|
+
* `device-selector.ts`). Chosen over a one-time DB migration because a
|
|
13035
|
+
* migration cannot reach a JWT already in a client's hands; parse-time
|
|
13036
|
+
* migration covers both without a flag day. No cast — the raw object is read
|
|
13037
|
+
* through `Reflect.get` (its static type is `unknown`).
|
|
13038
|
+
*/
|
|
13039
|
+
function migrateLegacyTokenScope(raw) {
|
|
13040
|
+
if (raw === null || typeof raw !== "object" || Array.isArray(raw)) return raw;
|
|
13041
|
+
if (Reflect.get(raw, "type") !== "device") return raw;
|
|
13042
|
+
if (Reflect.get(raw, "selector") !== void 0) return raw;
|
|
13043
|
+
const targets = Reflect.get(raw, "targets");
|
|
13044
|
+
if (!Array.isArray(targets)) return raw;
|
|
13045
|
+
return {
|
|
13046
|
+
type: "device",
|
|
13047
|
+
selector: {
|
|
13048
|
+
kind: "ids",
|
|
13049
|
+
ids: targets.map((t) => typeof t === "string" ? Number(t) : t).filter((n) => typeof n === "number" && Number.isInteger(n))
|
|
13050
|
+
},
|
|
13051
|
+
access: Reflect.get(raw, "access")
|
|
13052
|
+
};
|
|
13053
|
+
}
|
|
13054
|
+
var TokenScopeSchema = preprocess(migrateLegacyTokenScope, discriminatedUnion("type", [
|
|
13055
|
+
object({
|
|
13056
|
+
type: literal("category"),
|
|
13057
|
+
target: CapScopeSchema,
|
|
13058
|
+
access: array(MethodAccessSchema).min(1)
|
|
13059
|
+
}),
|
|
13060
|
+
object({
|
|
13061
|
+
type: literal("capability"),
|
|
13062
|
+
target: string(),
|
|
13063
|
+
access: array(MethodAccessSchema).min(1)
|
|
13064
|
+
}),
|
|
13065
|
+
object({
|
|
13066
|
+
type: literal("addon"),
|
|
13067
|
+
target: string(),
|
|
13068
|
+
access: array(MethodAccessSchema).min(1)
|
|
13069
|
+
}),
|
|
13070
|
+
DeviceTokenScopeSchema
|
|
13071
|
+
]));
|
|
13072
|
+
object({
|
|
13073
|
+
id: string(),
|
|
13074
|
+
username: string(),
|
|
13075
|
+
passwordHash: string(),
|
|
13076
|
+
/**
|
|
13077
|
+
* Admin bypass. When true, the middleware skips the scope-access
|
|
13078
|
+
* check entirely. There is no other axis of privilege; the legacy
|
|
13079
|
+
* role enum collapsed onto this boolean in v2.
|
|
13080
|
+
*/
|
|
13081
|
+
isAdmin: boolean().default(false),
|
|
13082
|
+
allowedProviders: AllowedProviderSchema,
|
|
13083
|
+
allowedDevices: AllowedDevicesSchema,
|
|
13084
|
+
/**
|
|
13085
|
+
* Scopes granted to this user. Admins bypass; their `scopes` is
|
|
13086
|
+
* ignored. Non-admins without scopes are locked out of every
|
|
13087
|
+
* protected call.
|
|
13088
|
+
*/
|
|
13089
|
+
scopes: array(TokenScopeSchema).default([]),
|
|
13090
|
+
createdAt: number(),
|
|
13091
|
+
updatedAt: number()
|
|
13092
|
+
});
|
|
13093
|
+
object({
|
|
13094
|
+
id: string(),
|
|
13095
|
+
label: string(),
|
|
13096
|
+
isAdmin: boolean().default(false),
|
|
13097
|
+
allowedProviders: AllowedProviderSchema,
|
|
13098
|
+
allowedDevices: AllowedDevicesSchema,
|
|
13099
|
+
tokenHash: string(),
|
|
13100
|
+
tokenPrefix: string(),
|
|
13101
|
+
createdAt: number(),
|
|
13102
|
+
lastUsedAt: number().optional()
|
|
13103
|
+
});
|
|
13104
|
+
object({
|
|
13105
|
+
id: string(),
|
|
13106
|
+
userId: string(),
|
|
13107
|
+
name: string(),
|
|
13108
|
+
tokenHash: string(),
|
|
13109
|
+
tokenPrefix: string(),
|
|
13110
|
+
scopes: array(TokenScopeSchema),
|
|
13111
|
+
expiresAt: number().nullish(),
|
|
13112
|
+
lastUsedAt: number().nullish(),
|
|
13113
|
+
createdAt: number()
|
|
13114
|
+
});
|
|
13115
|
+
/** What a share-view grant lets its holder see. */
|
|
13116
|
+
var ShareViewGrantSchema = object({
|
|
13117
|
+
kind: _enum(SHARE_VIEW_KINDS),
|
|
13118
|
+
deviceIds: array(number().int().nonnegative()).min(1).max(64),
|
|
13119
|
+
/** Talk-back, opt-in at mint time; absent means off. */
|
|
13120
|
+
talk: boolean().optional()
|
|
13121
|
+
});
|
|
13122
|
+
var ShareViewScopeSchema = object({
|
|
13123
|
+
type: literal("share-view"),
|
|
13124
|
+
grant: ShareViewGrantSchema
|
|
13125
|
+
});
|
|
13126
|
+
var AddonRoutesScopeSchema = object({
|
|
13127
|
+
type: literal("addon-routes"),
|
|
13128
|
+
access: array(MethodAccessSchema).min(1)
|
|
13129
|
+
});
|
|
13130
|
+
var CredentialScopeSchema = union([
|
|
13131
|
+
literal("*"),
|
|
13132
|
+
ShareViewScopeSchema,
|
|
13133
|
+
AddonRoutesScopeSchema,
|
|
13134
|
+
TokenScopeSchema
|
|
13135
|
+
]);
|
|
13136
|
+
object({
|
|
13137
|
+
kind: literal("credential"),
|
|
13138
|
+
sub: string().min(1),
|
|
13139
|
+
jti: string().min(16),
|
|
13140
|
+
scopes: array(CredentialScopeSchema).min(1)
|
|
13141
|
+
});
|
|
12913
13142
|
_enum(["new-session", "step-up"]);
|
|
12914
13143
|
/** The languages the hub's app landing pages are written in (D858). */
|
|
12915
13144
|
var AppPageLangSchema = _enum(["en", "it"]);
|
|
@@ -44088,202 +44317,6 @@ method(object({}), object({ rules: array(NcRuleSchema) }), { auth: "admin" }), m
|
|
|
44088
44317
|
auth: "admin"
|
|
44089
44318
|
}), method(NcAlarmSensorsInputSchema, NcAlarmSensorsSchema, { auth: "admin" });
|
|
44090
44319
|
/**
|
|
44091
|
-
* Zod schemas for persisted record types.
|
|
44092
|
-
*
|
|
44093
|
-
* These schemas serve as the single source of truth for types that are
|
|
44094
|
-
* stored in the settings-store backend and retrieved via tRPC. They
|
|
44095
|
-
* replace the manual TypeScript interfaces with schema-derived types,
|
|
44096
|
-
* enabling runtime validation when reading from the backend.
|
|
44097
|
-
*
|
|
44098
|
-
* Convention: each schema is named `<Type>Schema`, the inferred TS type
|
|
44099
|
-
* keeps the original name for backward compatibility.
|
|
44100
|
-
*/
|
|
44101
|
-
/**
|
|
44102
|
-
* Auth model (v2 — 2026-05-12 caps-only):
|
|
44103
|
-
*
|
|
44104
|
-
* Two principals:
|
|
44105
|
-
* - `isAdmin: true` — full bypass. Admin scope set is ignored.
|
|
44106
|
-
* - `isAdmin: false` — every call gated by `scopes` (see TokenScope).
|
|
44107
|
-
*
|
|
44108
|
-
* No role enum. There used to be `viewer / agent / scoped` and earlier
|
|
44109
|
-
* `super_admin` — collapsed onto the single boolean because every
|
|
44110
|
-
* non-admin caller is governed by the same scope-check rules; the
|
|
44111
|
-
* distinction was only ever used to route role-specific procedures
|
|
44112
|
-
* which we no longer have. CLI / webhook integrations are `cst_*` tokens
|
|
44113
|
-
* with `isAdmin: false` + an explicit scope list.
|
|
44114
|
-
*/
|
|
44115
|
-
/** Per-method access flavour. Materialised on every cap method via codegen. */
|
|
44116
|
-
var MethodAccessSchema = _enum([
|
|
44117
|
-
"view",
|
|
44118
|
-
"create",
|
|
44119
|
-
"delete"
|
|
44120
|
-
]);
|
|
44121
|
-
/**
|
|
44122
|
-
* A single scope grant. Three forms — checked in matcher with OR
|
|
44123
|
-
* semantics; the first match decides whether the call passes:
|
|
44124
|
-
*
|
|
44125
|
-
* - `category` — broadest. `target: 'device' | 'system'` selects every
|
|
44126
|
-
* cap with the matching `scope` declaration. New caps inherit grants
|
|
44127
|
-
* automatically — adding a device cap to the codebase makes it
|
|
44128
|
-
* reachable to every user with `category:device [...]` without a
|
|
44129
|
-
* re-grant. Use this for "family viewer" / "operator" tiers.
|
|
44130
|
-
*
|
|
44131
|
-
* - `addon` — every cap that ships inside a given addon id. Niche;
|
|
44132
|
-
* useful when an integration needs to interact with one specific
|
|
44133
|
-
* addon's surface regardless of how many caps it exports.
|
|
44134
|
-
*
|
|
44135
|
-
* - `capability` — the most precise form. Single cap name. Use for
|
|
44136
|
-
* integration tokens where you want to grant `addons.installPackage`
|
|
44137
|
-
* and nothing else.
|
|
44138
|
-
*
|
|
44139
|
-
* `access` is REQUIRED with min 1 element. `admin` bypass is the
|
|
44140
|
-
* "give me everything" escape; there is no wildcard scope.
|
|
44141
|
-
*/
|
|
44142
|
-
var AllowedProviderSchema = union([literal("*"), array(string())]);
|
|
44143
|
-
var AllowedDevicesSchema = record(string(), union([literal("*"), array(string())]));
|
|
44144
|
-
var CapScopeSchema = _enum(["device", "system"]);
|
|
44145
|
-
/**
|
|
44146
|
-
* DeviceSelector (scope model v3 — 2026-08-12).
|
|
44147
|
-
*
|
|
44148
|
-
* A `device` grant no longer carries a frozen list of deviceIds. It carries
|
|
44149
|
-
* a SELECTOR the matcher resolves against the live fleet, so the grant can be
|
|
44150
|
-
* DYNAMIC: a `types:['camera']` selector automatically covers a camera added
|
|
44151
|
-
* AFTER the grant was minted — no re-grant, no re-login.
|
|
44152
|
-
*
|
|
44153
|
-
* - `all` — every device in the deployment. The broad viewer/operator
|
|
44154
|
-
* lever without a `category` grant (a `category` grant also covers device
|
|
44155
|
-
* caps that carry no deviceId; `all` is specifically the device set).
|
|
44156
|
-
* - `ids` — an explicit deviceId list. This is what a v2 `device:[…]`
|
|
44157
|
-
* grant migrates to (see {@link TokenScopeSchema}); STATIC — a new camera
|
|
44158
|
-
* is NOT covered until the grant is edited.
|
|
44159
|
-
* - `types` — every device of a `DeviceType` (e.g. every `camera`).
|
|
44160
|
-
* DYNAMIC. A device that changes type, or a new device of the type,
|
|
44161
|
-
* re-resolves on the next request.
|
|
44162
|
-
* - `locations` — every device whose operator-assigned `location` label is
|
|
44163
|
-
* in the set (e.g. "Garden", "Front door"). DYNAMIC. A device with a
|
|
44164
|
-
* null/unset location matches NO `locations` selector.
|
|
44165
|
-
*/
|
|
44166
|
-
var DeviceSelectorSchema = discriminatedUnion("kind", [
|
|
44167
|
-
object({ kind: literal("all") }),
|
|
44168
|
-
object({
|
|
44169
|
-
kind: literal("ids"),
|
|
44170
|
-
ids: array(number().int()).min(1)
|
|
44171
|
-
}),
|
|
44172
|
-
object({
|
|
44173
|
-
kind: literal("types"),
|
|
44174
|
-
types: array(_enum(DeviceType)).min(1)
|
|
44175
|
-
}),
|
|
44176
|
-
object({
|
|
44177
|
-
kind: literal("locations"),
|
|
44178
|
-
locations: array(string().min(1)).min(1)
|
|
44179
|
-
})
|
|
44180
|
-
]);
|
|
44181
|
-
var DeviceTokenScopeSchema = object({
|
|
44182
|
-
type: literal("device"),
|
|
44183
|
-
/** The device SET this grant covers — resolved against the live fleet. */
|
|
44184
|
-
selector: DeviceSelectorSchema,
|
|
44185
|
-
access: array(MethodAccessSchema).min(1),
|
|
44186
|
-
/**
|
|
44187
|
-
* Whether a grant on a PARENT device transparently covers its accessory
|
|
44188
|
-
* CHILDREN (siren / floodlight / PIR) via the persisted-parentage walk.
|
|
44189
|
-
* Direction is parent → children ONLY.
|
|
44190
|
-
*
|
|
44191
|
-
* Absent → the matcher DERIVES it from the access flavour: `view`
|
|
44192
|
-
* inherits (a camera viewer sees the camera's accessories), `create` /
|
|
44193
|
-
* `delete` do NOT (actuating/removing a child is an explicit act the
|
|
44194
|
-
* operator must grant on the child, not inherit from the parent). Set it
|
|
44195
|
-
* explicitly to override that default per grant.
|
|
44196
|
-
*/
|
|
44197
|
-
includeLinked: boolean().optional()
|
|
44198
|
-
});
|
|
44199
|
-
/**
|
|
44200
|
-
* v2 → v3 lazy migration. A pre-v3 `device` grant carried
|
|
44201
|
-
* `targets: string[]` (stringified deviceIds); it rewrites to the equivalent
|
|
44202
|
-
* `selector: {kind:'ids', ids}`. Applied as a `preprocess` so it runs on
|
|
44203
|
-
* EVERY parse path — stored records AND the JWT-carried scope arrays
|
|
44204
|
-
* normalised at the request boundary ({@link normalizeTokenScopes} in
|
|
44205
|
-
* `device-selector.ts`). Chosen over a one-time DB migration because a
|
|
44206
|
-
* migration cannot reach a JWT already in a client's hands; parse-time
|
|
44207
|
-
* migration covers both without a flag day. No cast — the raw object is read
|
|
44208
|
-
* through `Reflect.get` (its static type is `unknown`).
|
|
44209
|
-
*/
|
|
44210
|
-
function migrateLegacyTokenScope(raw) {
|
|
44211
|
-
if (raw === null || typeof raw !== "object" || Array.isArray(raw)) return raw;
|
|
44212
|
-
if (Reflect.get(raw, "type") !== "device") return raw;
|
|
44213
|
-
if (Reflect.get(raw, "selector") !== void 0) return raw;
|
|
44214
|
-
const targets = Reflect.get(raw, "targets");
|
|
44215
|
-
if (!Array.isArray(targets)) return raw;
|
|
44216
|
-
return {
|
|
44217
|
-
type: "device",
|
|
44218
|
-
selector: {
|
|
44219
|
-
kind: "ids",
|
|
44220
|
-
ids: targets.map((t) => typeof t === "string" ? Number(t) : t).filter((n) => typeof n === "number" && Number.isInteger(n))
|
|
44221
|
-
},
|
|
44222
|
-
access: Reflect.get(raw, "access")
|
|
44223
|
-
};
|
|
44224
|
-
}
|
|
44225
|
-
var TokenScopeSchema = preprocess(migrateLegacyTokenScope, discriminatedUnion("type", [
|
|
44226
|
-
object({
|
|
44227
|
-
type: literal("category"),
|
|
44228
|
-
target: CapScopeSchema,
|
|
44229
|
-
access: array(MethodAccessSchema).min(1)
|
|
44230
|
-
}),
|
|
44231
|
-
object({
|
|
44232
|
-
type: literal("capability"),
|
|
44233
|
-
target: string(),
|
|
44234
|
-
access: array(MethodAccessSchema).min(1)
|
|
44235
|
-
}),
|
|
44236
|
-
object({
|
|
44237
|
-
type: literal("addon"),
|
|
44238
|
-
target: string(),
|
|
44239
|
-
access: array(MethodAccessSchema).min(1)
|
|
44240
|
-
}),
|
|
44241
|
-
DeviceTokenScopeSchema
|
|
44242
|
-
]));
|
|
44243
|
-
object({
|
|
44244
|
-
id: string(),
|
|
44245
|
-
username: string(),
|
|
44246
|
-
passwordHash: string(),
|
|
44247
|
-
/**
|
|
44248
|
-
* Admin bypass. When true, the middleware skips the scope-access
|
|
44249
|
-
* check entirely. There is no other axis of privilege; the legacy
|
|
44250
|
-
* role enum collapsed onto this boolean in v2.
|
|
44251
|
-
*/
|
|
44252
|
-
isAdmin: boolean().default(false),
|
|
44253
|
-
allowedProviders: AllowedProviderSchema,
|
|
44254
|
-
allowedDevices: AllowedDevicesSchema,
|
|
44255
|
-
/**
|
|
44256
|
-
* Scopes granted to this user. Admins bypass; their `scopes` is
|
|
44257
|
-
* ignored. Non-admins without scopes are locked out of every
|
|
44258
|
-
* protected call.
|
|
44259
|
-
*/
|
|
44260
|
-
scopes: array(TokenScopeSchema).default([]),
|
|
44261
|
-
createdAt: number(),
|
|
44262
|
-
updatedAt: number()
|
|
44263
|
-
});
|
|
44264
|
-
object({
|
|
44265
|
-
id: string(),
|
|
44266
|
-
label: string(),
|
|
44267
|
-
isAdmin: boolean().default(false),
|
|
44268
|
-
allowedProviders: AllowedProviderSchema,
|
|
44269
|
-
allowedDevices: AllowedDevicesSchema,
|
|
44270
|
-
tokenHash: string(),
|
|
44271
|
-
tokenPrefix: string(),
|
|
44272
|
-
createdAt: number(),
|
|
44273
|
-
lastUsedAt: number().optional()
|
|
44274
|
-
});
|
|
44275
|
-
object({
|
|
44276
|
-
id: string(),
|
|
44277
|
-
userId: string(),
|
|
44278
|
-
name: string(),
|
|
44279
|
-
tokenHash: string(),
|
|
44280
|
-
tokenPrefix: string(),
|
|
44281
|
-
scopes: array(TokenScopeSchema),
|
|
44282
|
-
expiresAt: number().nullish(),
|
|
44283
|
-
lastUsedAt: number().nullish(),
|
|
44284
|
-
createdAt: number()
|
|
44285
|
-
});
|
|
44286
|
-
/**
|
|
44287
44320
|
* `oauth-integration` — a collection cap by which an addon declares
|
|
44288
44321
|
* itself a linkable OAuth client of the hub's core `/oauth2/*` server.
|
|
44289
44322
|
* Each provider returns a static descriptor; the core enumerates them
|
package/dist/addon.mjs
CHANGED
|
@@ -7932,6 +7932,12 @@ function normalizeAddonInitResult(result) {
|
|
|
7932
7932
|
if (Array.isArray(result)) return { providers: result };
|
|
7933
7933
|
return result;
|
|
7934
7934
|
}
|
|
7935
|
+
/**
|
|
7936
|
+
* The share-view scope kinds a `csv_*` share token can carry. The hub mints
|
|
7937
|
+
* and validates them (`share-token.service.ts` builds its enum from this
|
|
7938
|
+
* list); a data plane names the kinds it ACCEPTS in `share`.
|
|
7939
|
+
*/
|
|
7940
|
+
var SHARE_VIEW_KINDS = ["grid-view", "events-view"];
|
|
7935
7941
|
/** The wire shape of {@link PeerBytesTicket} — see the type for what it is. */
|
|
7936
7942
|
var PeerBytesTicketSchema = object({
|
|
7937
7943
|
/** `http://127.0.0.1:<port>/<token>`. One `GET` takes it. */
|
|
@@ -12883,6 +12889,229 @@ var ConvertResultSchema = object({
|
|
|
12883
12889
|
files: array(string()).readonly()
|
|
12884
12890
|
})).readonly()
|
|
12885
12891
|
});
|
|
12892
|
+
/**
|
|
12893
|
+
* Zod schemas for persisted record types.
|
|
12894
|
+
*
|
|
12895
|
+
* These schemas serve as the single source of truth for types that are
|
|
12896
|
+
* stored in the settings-store backend and retrieved via tRPC. They
|
|
12897
|
+
* replace the manual TypeScript interfaces with schema-derived types,
|
|
12898
|
+
* enabling runtime validation when reading from the backend.
|
|
12899
|
+
*
|
|
12900
|
+
* Convention: each schema is named `<Type>Schema`, the inferred TS type
|
|
12901
|
+
* keeps the original name for backward compatibility.
|
|
12902
|
+
*/
|
|
12903
|
+
/**
|
|
12904
|
+
* Auth model (v2 — 2026-05-12 caps-only):
|
|
12905
|
+
*
|
|
12906
|
+
* Two principals:
|
|
12907
|
+
* - `isAdmin: true` — full bypass. Admin scope set is ignored.
|
|
12908
|
+
* - `isAdmin: false` — every call gated by `scopes` (see TokenScope).
|
|
12909
|
+
*
|
|
12910
|
+
* No role enum. There used to be `viewer / agent / scoped` and earlier
|
|
12911
|
+
* `super_admin` — collapsed onto the single boolean because every
|
|
12912
|
+
* non-admin caller is governed by the same scope-check rules; the
|
|
12913
|
+
* distinction was only ever used to route role-specific procedures
|
|
12914
|
+
* which we no longer have. CLI / webhook integrations are `cst_*` tokens
|
|
12915
|
+
* with `isAdmin: false` + an explicit scope list.
|
|
12916
|
+
*/
|
|
12917
|
+
/** Per-method access flavour. Materialised on every cap method via codegen. */
|
|
12918
|
+
var MethodAccessSchema = _enum([
|
|
12919
|
+
"view",
|
|
12920
|
+
"create",
|
|
12921
|
+
"delete"
|
|
12922
|
+
]);
|
|
12923
|
+
/**
|
|
12924
|
+
* A single scope grant. Three forms — checked in matcher with OR
|
|
12925
|
+
* semantics; the first match decides whether the call passes:
|
|
12926
|
+
*
|
|
12927
|
+
* - `category` — broadest. `target: 'device' | 'system'` selects every
|
|
12928
|
+
* cap with the matching `scope` declaration. New caps inherit grants
|
|
12929
|
+
* automatically — adding a device cap to the codebase makes it
|
|
12930
|
+
* reachable to every user with `category:device [...]` without a
|
|
12931
|
+
* re-grant. Use this for "family viewer" / "operator" tiers.
|
|
12932
|
+
*
|
|
12933
|
+
* - `addon` — every cap that ships inside a given addon id. Niche;
|
|
12934
|
+
* useful when an integration needs to interact with one specific
|
|
12935
|
+
* addon's surface regardless of how many caps it exports.
|
|
12936
|
+
*
|
|
12937
|
+
* - `capability` — the most precise form. Single cap name. Use for
|
|
12938
|
+
* integration tokens where you want to grant `addons.installPackage`
|
|
12939
|
+
* and nothing else.
|
|
12940
|
+
*
|
|
12941
|
+
* `access` is REQUIRED with min 1 element. `admin` bypass is the
|
|
12942
|
+
* "give me everything" escape; there is no wildcard scope.
|
|
12943
|
+
*/
|
|
12944
|
+
var AllowedProviderSchema = union([literal("*"), array(string())]);
|
|
12945
|
+
var AllowedDevicesSchema = record(string(), union([literal("*"), array(string())]));
|
|
12946
|
+
var CapScopeSchema = _enum(["device", "system"]);
|
|
12947
|
+
/**
|
|
12948
|
+
* DeviceSelector (scope model v3 — 2026-08-12).
|
|
12949
|
+
*
|
|
12950
|
+
* A `device` grant no longer carries a frozen list of deviceIds. It carries
|
|
12951
|
+
* a SELECTOR the matcher resolves against the live fleet, so the grant can be
|
|
12952
|
+
* DYNAMIC: a `types:['camera']` selector automatically covers a camera added
|
|
12953
|
+
* AFTER the grant was minted — no re-grant, no re-login.
|
|
12954
|
+
*
|
|
12955
|
+
* - `all` — every device in the deployment. The broad viewer/operator
|
|
12956
|
+
* lever without a `category` grant (a `category` grant also covers device
|
|
12957
|
+
* caps that carry no deviceId; `all` is specifically the device set).
|
|
12958
|
+
* - `ids` — an explicit deviceId list. This is what a v2 `device:[…]`
|
|
12959
|
+
* grant migrates to (see {@link TokenScopeSchema}); STATIC — a new camera
|
|
12960
|
+
* is NOT covered until the grant is edited.
|
|
12961
|
+
* - `types` — every device of a `DeviceType` (e.g. every `camera`).
|
|
12962
|
+
* DYNAMIC. A device that changes type, or a new device of the type,
|
|
12963
|
+
* re-resolves on the next request.
|
|
12964
|
+
* - `locations` — every device whose operator-assigned `location` label is
|
|
12965
|
+
* in the set (e.g. "Garden", "Front door"). DYNAMIC. A device with a
|
|
12966
|
+
* null/unset location matches NO `locations` selector.
|
|
12967
|
+
*/
|
|
12968
|
+
var DeviceSelectorSchema = discriminatedUnion("kind", [
|
|
12969
|
+
object({ kind: literal("all") }),
|
|
12970
|
+
object({
|
|
12971
|
+
kind: literal("ids"),
|
|
12972
|
+
ids: array(number().int()).min(1)
|
|
12973
|
+
}),
|
|
12974
|
+
object({
|
|
12975
|
+
kind: literal("types"),
|
|
12976
|
+
types: array(_enum(DeviceType)).min(1)
|
|
12977
|
+
}),
|
|
12978
|
+
object({
|
|
12979
|
+
kind: literal("locations"),
|
|
12980
|
+
locations: array(string().min(1)).min(1)
|
|
12981
|
+
})
|
|
12982
|
+
]);
|
|
12983
|
+
var DeviceTokenScopeSchema = object({
|
|
12984
|
+
type: literal("device"),
|
|
12985
|
+
/** The device SET this grant covers — resolved against the live fleet. */
|
|
12986
|
+
selector: DeviceSelectorSchema,
|
|
12987
|
+
access: array(MethodAccessSchema).min(1),
|
|
12988
|
+
/**
|
|
12989
|
+
* Whether a grant on a PARENT device transparently covers its accessory
|
|
12990
|
+
* CHILDREN (siren / floodlight / PIR) via the persisted-parentage walk.
|
|
12991
|
+
* Direction is parent → children ONLY.
|
|
12992
|
+
*
|
|
12993
|
+
* Absent → the matcher DERIVES it from the access flavour: `view`
|
|
12994
|
+
* inherits (a camera viewer sees the camera's accessories), `create` /
|
|
12995
|
+
* `delete` do NOT (actuating/removing a child is an explicit act the
|
|
12996
|
+
* operator must grant on the child, not inherit from the parent). Set it
|
|
12997
|
+
* explicitly to override that default per grant.
|
|
12998
|
+
*/
|
|
12999
|
+
includeLinked: boolean().optional()
|
|
13000
|
+
});
|
|
13001
|
+
/**
|
|
13002
|
+
* v2 → v3 lazy migration. A pre-v3 `device` grant carried
|
|
13003
|
+
* `targets: string[]` (stringified deviceIds); it rewrites to the equivalent
|
|
13004
|
+
* `selector: {kind:'ids', ids}`. Applied as a `preprocess` so it runs on
|
|
13005
|
+
* EVERY parse path — stored records AND the JWT-carried scope arrays
|
|
13006
|
+
* normalised at the request boundary ({@link normalizeTokenScopes} in
|
|
13007
|
+
* `device-selector.ts`). Chosen over a one-time DB migration because a
|
|
13008
|
+
* migration cannot reach a JWT already in a client's hands; parse-time
|
|
13009
|
+
* migration covers both without a flag day. No cast — the raw object is read
|
|
13010
|
+
* through `Reflect.get` (its static type is `unknown`).
|
|
13011
|
+
*/
|
|
13012
|
+
function migrateLegacyTokenScope(raw) {
|
|
13013
|
+
if (raw === null || typeof raw !== "object" || Array.isArray(raw)) return raw;
|
|
13014
|
+
if (Reflect.get(raw, "type") !== "device") return raw;
|
|
13015
|
+
if (Reflect.get(raw, "selector") !== void 0) return raw;
|
|
13016
|
+
const targets = Reflect.get(raw, "targets");
|
|
13017
|
+
if (!Array.isArray(targets)) return raw;
|
|
13018
|
+
return {
|
|
13019
|
+
type: "device",
|
|
13020
|
+
selector: {
|
|
13021
|
+
kind: "ids",
|
|
13022
|
+
ids: targets.map((t) => typeof t === "string" ? Number(t) : t).filter((n) => typeof n === "number" && Number.isInteger(n))
|
|
13023
|
+
},
|
|
13024
|
+
access: Reflect.get(raw, "access")
|
|
13025
|
+
};
|
|
13026
|
+
}
|
|
13027
|
+
var TokenScopeSchema = preprocess(migrateLegacyTokenScope, discriminatedUnion("type", [
|
|
13028
|
+
object({
|
|
13029
|
+
type: literal("category"),
|
|
13030
|
+
target: CapScopeSchema,
|
|
13031
|
+
access: array(MethodAccessSchema).min(1)
|
|
13032
|
+
}),
|
|
13033
|
+
object({
|
|
13034
|
+
type: literal("capability"),
|
|
13035
|
+
target: string(),
|
|
13036
|
+
access: array(MethodAccessSchema).min(1)
|
|
13037
|
+
}),
|
|
13038
|
+
object({
|
|
13039
|
+
type: literal("addon"),
|
|
13040
|
+
target: string(),
|
|
13041
|
+
access: array(MethodAccessSchema).min(1)
|
|
13042
|
+
}),
|
|
13043
|
+
DeviceTokenScopeSchema
|
|
13044
|
+
]));
|
|
13045
|
+
object({
|
|
13046
|
+
id: string(),
|
|
13047
|
+
username: string(),
|
|
13048
|
+
passwordHash: string(),
|
|
13049
|
+
/**
|
|
13050
|
+
* Admin bypass. When true, the middleware skips the scope-access
|
|
13051
|
+
* check entirely. There is no other axis of privilege; the legacy
|
|
13052
|
+
* role enum collapsed onto this boolean in v2.
|
|
13053
|
+
*/
|
|
13054
|
+
isAdmin: boolean().default(false),
|
|
13055
|
+
allowedProviders: AllowedProviderSchema,
|
|
13056
|
+
allowedDevices: AllowedDevicesSchema,
|
|
13057
|
+
/**
|
|
13058
|
+
* Scopes granted to this user. Admins bypass; their `scopes` is
|
|
13059
|
+
* ignored. Non-admins without scopes are locked out of every
|
|
13060
|
+
* protected call.
|
|
13061
|
+
*/
|
|
13062
|
+
scopes: array(TokenScopeSchema).default([]),
|
|
13063
|
+
createdAt: number(),
|
|
13064
|
+
updatedAt: number()
|
|
13065
|
+
});
|
|
13066
|
+
object({
|
|
13067
|
+
id: string(),
|
|
13068
|
+
label: string(),
|
|
13069
|
+
isAdmin: boolean().default(false),
|
|
13070
|
+
allowedProviders: AllowedProviderSchema,
|
|
13071
|
+
allowedDevices: AllowedDevicesSchema,
|
|
13072
|
+
tokenHash: string(),
|
|
13073
|
+
tokenPrefix: string(),
|
|
13074
|
+
createdAt: number(),
|
|
13075
|
+
lastUsedAt: number().optional()
|
|
13076
|
+
});
|
|
13077
|
+
object({
|
|
13078
|
+
id: string(),
|
|
13079
|
+
userId: string(),
|
|
13080
|
+
name: string(),
|
|
13081
|
+
tokenHash: string(),
|
|
13082
|
+
tokenPrefix: string(),
|
|
13083
|
+
scopes: array(TokenScopeSchema),
|
|
13084
|
+
expiresAt: number().nullish(),
|
|
13085
|
+
lastUsedAt: number().nullish(),
|
|
13086
|
+
createdAt: number()
|
|
13087
|
+
});
|
|
13088
|
+
/** What a share-view grant lets its holder see. */
|
|
13089
|
+
var ShareViewGrantSchema = object({
|
|
13090
|
+
kind: _enum(SHARE_VIEW_KINDS),
|
|
13091
|
+
deviceIds: array(number().int().nonnegative()).min(1).max(64),
|
|
13092
|
+
/** Talk-back, opt-in at mint time; absent means off. */
|
|
13093
|
+
talk: boolean().optional()
|
|
13094
|
+
});
|
|
13095
|
+
var ShareViewScopeSchema = object({
|
|
13096
|
+
type: literal("share-view"),
|
|
13097
|
+
grant: ShareViewGrantSchema
|
|
13098
|
+
});
|
|
13099
|
+
var AddonRoutesScopeSchema = object({
|
|
13100
|
+
type: literal("addon-routes"),
|
|
13101
|
+
access: array(MethodAccessSchema).min(1)
|
|
13102
|
+
});
|
|
13103
|
+
var CredentialScopeSchema = union([
|
|
13104
|
+
literal("*"),
|
|
13105
|
+
ShareViewScopeSchema,
|
|
13106
|
+
AddonRoutesScopeSchema,
|
|
13107
|
+
TokenScopeSchema
|
|
13108
|
+
]);
|
|
13109
|
+
object({
|
|
13110
|
+
kind: literal("credential"),
|
|
13111
|
+
sub: string().min(1),
|
|
13112
|
+
jti: string().min(16),
|
|
13113
|
+
scopes: array(CredentialScopeSchema).min(1)
|
|
13114
|
+
});
|
|
12886
13115
|
_enum(["new-session", "step-up"]);
|
|
12887
13116
|
/** The languages the hub's app landing pages are written in (D858). */
|
|
12888
13117
|
var AppPageLangSchema = _enum(["en", "it"]);
|
|
@@ -44061,202 +44290,6 @@ method(object({}), object({ rules: array(NcRuleSchema) }), { auth: "admin" }), m
|
|
|
44061
44290
|
auth: "admin"
|
|
44062
44291
|
}), method(NcAlarmSensorsInputSchema, NcAlarmSensorsSchema, { auth: "admin" });
|
|
44063
44292
|
/**
|
|
44064
|
-
* Zod schemas for persisted record types.
|
|
44065
|
-
*
|
|
44066
|
-
* These schemas serve as the single source of truth for types that are
|
|
44067
|
-
* stored in the settings-store backend and retrieved via tRPC. They
|
|
44068
|
-
* replace the manual TypeScript interfaces with schema-derived types,
|
|
44069
|
-
* enabling runtime validation when reading from the backend.
|
|
44070
|
-
*
|
|
44071
|
-
* Convention: each schema is named `<Type>Schema`, the inferred TS type
|
|
44072
|
-
* keeps the original name for backward compatibility.
|
|
44073
|
-
*/
|
|
44074
|
-
/**
|
|
44075
|
-
* Auth model (v2 — 2026-05-12 caps-only):
|
|
44076
|
-
*
|
|
44077
|
-
* Two principals:
|
|
44078
|
-
* - `isAdmin: true` — full bypass. Admin scope set is ignored.
|
|
44079
|
-
* - `isAdmin: false` — every call gated by `scopes` (see TokenScope).
|
|
44080
|
-
*
|
|
44081
|
-
* No role enum. There used to be `viewer / agent / scoped` and earlier
|
|
44082
|
-
* `super_admin` — collapsed onto the single boolean because every
|
|
44083
|
-
* non-admin caller is governed by the same scope-check rules; the
|
|
44084
|
-
* distinction was only ever used to route role-specific procedures
|
|
44085
|
-
* which we no longer have. CLI / webhook integrations are `cst_*` tokens
|
|
44086
|
-
* with `isAdmin: false` + an explicit scope list.
|
|
44087
|
-
*/
|
|
44088
|
-
/** Per-method access flavour. Materialised on every cap method via codegen. */
|
|
44089
|
-
var MethodAccessSchema = _enum([
|
|
44090
|
-
"view",
|
|
44091
|
-
"create",
|
|
44092
|
-
"delete"
|
|
44093
|
-
]);
|
|
44094
|
-
/**
|
|
44095
|
-
* A single scope grant. Three forms — checked in matcher with OR
|
|
44096
|
-
* semantics; the first match decides whether the call passes:
|
|
44097
|
-
*
|
|
44098
|
-
* - `category` — broadest. `target: 'device' | 'system'` selects every
|
|
44099
|
-
* cap with the matching `scope` declaration. New caps inherit grants
|
|
44100
|
-
* automatically — adding a device cap to the codebase makes it
|
|
44101
|
-
* reachable to every user with `category:device [...]` without a
|
|
44102
|
-
* re-grant. Use this for "family viewer" / "operator" tiers.
|
|
44103
|
-
*
|
|
44104
|
-
* - `addon` — every cap that ships inside a given addon id. Niche;
|
|
44105
|
-
* useful when an integration needs to interact with one specific
|
|
44106
|
-
* addon's surface regardless of how many caps it exports.
|
|
44107
|
-
*
|
|
44108
|
-
* - `capability` — the most precise form. Single cap name. Use for
|
|
44109
|
-
* integration tokens where you want to grant `addons.installPackage`
|
|
44110
|
-
* and nothing else.
|
|
44111
|
-
*
|
|
44112
|
-
* `access` is REQUIRED with min 1 element. `admin` bypass is the
|
|
44113
|
-
* "give me everything" escape; there is no wildcard scope.
|
|
44114
|
-
*/
|
|
44115
|
-
var AllowedProviderSchema = union([literal("*"), array(string())]);
|
|
44116
|
-
var AllowedDevicesSchema = record(string(), union([literal("*"), array(string())]));
|
|
44117
|
-
var CapScopeSchema = _enum(["device", "system"]);
|
|
44118
|
-
/**
|
|
44119
|
-
* DeviceSelector (scope model v3 — 2026-08-12).
|
|
44120
|
-
*
|
|
44121
|
-
* A `device` grant no longer carries a frozen list of deviceIds. It carries
|
|
44122
|
-
* a SELECTOR the matcher resolves against the live fleet, so the grant can be
|
|
44123
|
-
* DYNAMIC: a `types:['camera']` selector automatically covers a camera added
|
|
44124
|
-
* AFTER the grant was minted — no re-grant, no re-login.
|
|
44125
|
-
*
|
|
44126
|
-
* - `all` — every device in the deployment. The broad viewer/operator
|
|
44127
|
-
* lever without a `category` grant (a `category` grant also covers device
|
|
44128
|
-
* caps that carry no deviceId; `all` is specifically the device set).
|
|
44129
|
-
* - `ids` — an explicit deviceId list. This is what a v2 `device:[…]`
|
|
44130
|
-
* grant migrates to (see {@link TokenScopeSchema}); STATIC — a new camera
|
|
44131
|
-
* is NOT covered until the grant is edited.
|
|
44132
|
-
* - `types` — every device of a `DeviceType` (e.g. every `camera`).
|
|
44133
|
-
* DYNAMIC. A device that changes type, or a new device of the type,
|
|
44134
|
-
* re-resolves on the next request.
|
|
44135
|
-
* - `locations` — every device whose operator-assigned `location` label is
|
|
44136
|
-
* in the set (e.g. "Garden", "Front door"). DYNAMIC. A device with a
|
|
44137
|
-
* null/unset location matches NO `locations` selector.
|
|
44138
|
-
*/
|
|
44139
|
-
var DeviceSelectorSchema = discriminatedUnion("kind", [
|
|
44140
|
-
object({ kind: literal("all") }),
|
|
44141
|
-
object({
|
|
44142
|
-
kind: literal("ids"),
|
|
44143
|
-
ids: array(number().int()).min(1)
|
|
44144
|
-
}),
|
|
44145
|
-
object({
|
|
44146
|
-
kind: literal("types"),
|
|
44147
|
-
types: array(_enum(DeviceType)).min(1)
|
|
44148
|
-
}),
|
|
44149
|
-
object({
|
|
44150
|
-
kind: literal("locations"),
|
|
44151
|
-
locations: array(string().min(1)).min(1)
|
|
44152
|
-
})
|
|
44153
|
-
]);
|
|
44154
|
-
var DeviceTokenScopeSchema = object({
|
|
44155
|
-
type: literal("device"),
|
|
44156
|
-
/** The device SET this grant covers — resolved against the live fleet. */
|
|
44157
|
-
selector: DeviceSelectorSchema,
|
|
44158
|
-
access: array(MethodAccessSchema).min(1),
|
|
44159
|
-
/**
|
|
44160
|
-
* Whether a grant on a PARENT device transparently covers its accessory
|
|
44161
|
-
* CHILDREN (siren / floodlight / PIR) via the persisted-parentage walk.
|
|
44162
|
-
* Direction is parent → children ONLY.
|
|
44163
|
-
*
|
|
44164
|
-
* Absent → the matcher DERIVES it from the access flavour: `view`
|
|
44165
|
-
* inherits (a camera viewer sees the camera's accessories), `create` /
|
|
44166
|
-
* `delete` do NOT (actuating/removing a child is an explicit act the
|
|
44167
|
-
* operator must grant on the child, not inherit from the parent). Set it
|
|
44168
|
-
* explicitly to override that default per grant.
|
|
44169
|
-
*/
|
|
44170
|
-
includeLinked: boolean().optional()
|
|
44171
|
-
});
|
|
44172
|
-
/**
|
|
44173
|
-
* v2 → v3 lazy migration. A pre-v3 `device` grant carried
|
|
44174
|
-
* `targets: string[]` (stringified deviceIds); it rewrites to the equivalent
|
|
44175
|
-
* `selector: {kind:'ids', ids}`. Applied as a `preprocess` so it runs on
|
|
44176
|
-
* EVERY parse path — stored records AND the JWT-carried scope arrays
|
|
44177
|
-
* normalised at the request boundary ({@link normalizeTokenScopes} in
|
|
44178
|
-
* `device-selector.ts`). Chosen over a one-time DB migration because a
|
|
44179
|
-
* migration cannot reach a JWT already in a client's hands; parse-time
|
|
44180
|
-
* migration covers both without a flag day. No cast — the raw object is read
|
|
44181
|
-
* through `Reflect.get` (its static type is `unknown`).
|
|
44182
|
-
*/
|
|
44183
|
-
function migrateLegacyTokenScope(raw) {
|
|
44184
|
-
if (raw === null || typeof raw !== "object" || Array.isArray(raw)) return raw;
|
|
44185
|
-
if (Reflect.get(raw, "type") !== "device") return raw;
|
|
44186
|
-
if (Reflect.get(raw, "selector") !== void 0) return raw;
|
|
44187
|
-
const targets = Reflect.get(raw, "targets");
|
|
44188
|
-
if (!Array.isArray(targets)) return raw;
|
|
44189
|
-
return {
|
|
44190
|
-
type: "device",
|
|
44191
|
-
selector: {
|
|
44192
|
-
kind: "ids",
|
|
44193
|
-
ids: targets.map((t) => typeof t === "string" ? Number(t) : t).filter((n) => typeof n === "number" && Number.isInteger(n))
|
|
44194
|
-
},
|
|
44195
|
-
access: Reflect.get(raw, "access")
|
|
44196
|
-
};
|
|
44197
|
-
}
|
|
44198
|
-
var TokenScopeSchema = preprocess(migrateLegacyTokenScope, discriminatedUnion("type", [
|
|
44199
|
-
object({
|
|
44200
|
-
type: literal("category"),
|
|
44201
|
-
target: CapScopeSchema,
|
|
44202
|
-
access: array(MethodAccessSchema).min(1)
|
|
44203
|
-
}),
|
|
44204
|
-
object({
|
|
44205
|
-
type: literal("capability"),
|
|
44206
|
-
target: string(),
|
|
44207
|
-
access: array(MethodAccessSchema).min(1)
|
|
44208
|
-
}),
|
|
44209
|
-
object({
|
|
44210
|
-
type: literal("addon"),
|
|
44211
|
-
target: string(),
|
|
44212
|
-
access: array(MethodAccessSchema).min(1)
|
|
44213
|
-
}),
|
|
44214
|
-
DeviceTokenScopeSchema
|
|
44215
|
-
]));
|
|
44216
|
-
object({
|
|
44217
|
-
id: string(),
|
|
44218
|
-
username: string(),
|
|
44219
|
-
passwordHash: string(),
|
|
44220
|
-
/**
|
|
44221
|
-
* Admin bypass. When true, the middleware skips the scope-access
|
|
44222
|
-
* check entirely. There is no other axis of privilege; the legacy
|
|
44223
|
-
* role enum collapsed onto this boolean in v2.
|
|
44224
|
-
*/
|
|
44225
|
-
isAdmin: boolean().default(false),
|
|
44226
|
-
allowedProviders: AllowedProviderSchema,
|
|
44227
|
-
allowedDevices: AllowedDevicesSchema,
|
|
44228
|
-
/**
|
|
44229
|
-
* Scopes granted to this user. Admins bypass; their `scopes` is
|
|
44230
|
-
* ignored. Non-admins without scopes are locked out of every
|
|
44231
|
-
* protected call.
|
|
44232
|
-
*/
|
|
44233
|
-
scopes: array(TokenScopeSchema).default([]),
|
|
44234
|
-
createdAt: number(),
|
|
44235
|
-
updatedAt: number()
|
|
44236
|
-
});
|
|
44237
|
-
object({
|
|
44238
|
-
id: string(),
|
|
44239
|
-
label: string(),
|
|
44240
|
-
isAdmin: boolean().default(false),
|
|
44241
|
-
allowedProviders: AllowedProviderSchema,
|
|
44242
|
-
allowedDevices: AllowedDevicesSchema,
|
|
44243
|
-
tokenHash: string(),
|
|
44244
|
-
tokenPrefix: string(),
|
|
44245
|
-
createdAt: number(),
|
|
44246
|
-
lastUsedAt: number().optional()
|
|
44247
|
-
});
|
|
44248
|
-
object({
|
|
44249
|
-
id: string(),
|
|
44250
|
-
userId: string(),
|
|
44251
|
-
name: string(),
|
|
44252
|
-
tokenHash: string(),
|
|
44253
|
-
tokenPrefix: string(),
|
|
44254
|
-
scopes: array(TokenScopeSchema),
|
|
44255
|
-
expiresAt: number().nullish(),
|
|
44256
|
-
lastUsedAt: number().nullish(),
|
|
44257
|
-
createdAt: number()
|
|
44258
|
-
});
|
|
44259
|
-
/**
|
|
44260
44293
|
* `oauth-integration` — a collection cap by which an addon declares
|
|
44261
44294
|
* itself a linkable OAuth client of the hub's core `/oauth2/*` server.
|
|
44262
44295
|
* 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-notifiers",
|
|
3
|
-
"version": "1.2.
|
|
3
|
+
"version": "1.2.604",
|
|
4
4
|
"description": "System notifiers addon for CamStack — a `notification-output` collection provider hosting per-kind notifier adapters (ntfy, pushover, gotify, telegram, discord, webhook, zentik).",
|
|
5
5
|
"keywords": [
|
|
6
6
|
"camstack",
|