@camstack/addon-provider-homeassistant 1.2.604 → 1.2.605
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 +1 -1
- package/dist/addon.mjs +1 -1
- package/dist/{dist-CA_cJwK-.mjs → dist-DV_2NKnd.mjs} +229 -196
- package/dist/{dist-BUoXKXFs.js → dist-DWBNf9hd.js} +229 -196
- package/dist/ha-export/ha-export.addon.js +1 -1
- package/dist/ha-export/ha-export.addon.mjs +1 -1
- package/package.json +1 -1
package/dist/addon.js
CHANGED
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
Object.defineProperty(exports, Symbol.toStringTag, { value: "Module" });
|
|
2
|
-
const require_dist = require("./dist-
|
|
2
|
+
const require_dist = require("./dist-DWBNf9hd.js");
|
|
3
3
|
let node_crypto = require("node:crypto");
|
|
4
4
|
let node_zlib = require("node:zlib");
|
|
5
5
|
//#region src/ha-admin-link.ts
|
package/dist/addon.mjs
CHANGED
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import { A as connectivityCapability, At as boolean, B as floodCapability, Bt as EventCategory, C as buildAddonRouteProvider, Ct as defineEntryKind, D as carbonMonoxideCapability, Dt as settingsBrokersAdoptsFrom, E as calendarSourceCapability, F as deviceAdoptionCapability, Ft as record, G as lawnMowerControlCapability, H as humidifierCapability, It as string, J as motionCapability, K as lockControlCapability, L as enumSensorCapability, Lt as union, M as controlCapability, Mt as literal, N as coverCapability, Nt as number, O as climateControlCapability, Ot as _enum, P as deviceAdminLinkCapability, Pt as object, Q as numericSensorCapability, R as eventEmitterCapability, Rt as unknown, S as brokerCapability, St as createEvent, T as buttonCapability, Tt as entryBody, U as humiditySensorCapability, V as gasCapability, W as imageCapability, X as notificationOutputCapability, Y as normalizeUnit, Z as notifierCapability, _ as automationControlCapability, _t as DeviceRole, at as scriptRunnerCapability, b as binaryCapability, ct as tamperCapability, d as TargetSchema, dt as vacuumControlCapability, et as parseAdminBase, f as accessoriesCapability, ft as valveCapability, g as ambientLightSensorCapability, gt as DeviceFeature, h as alarmPanelCapability, ht as weatherCapability, it as pressureSensorCapability, j as contactCapability, jt as discriminatedUnion, k as colorCapability, kt as array, lt as temperatureSensorCapability, m as airQualitySensorCapability, mt as waterHeaterCapability, n as BaseDevice, nt as prepareNotification, ot as smokeCapability, p as addonRoutesCapability, pt as vibrationCapability, q as mediaPlayerCapability, r as BaseDeviceProvider, rt as presenceCapability, s as EnumSensorDateTimeFormatSchema, st as switchCapability, tt as powerMeterCapability, ut as updateCapability, v as batteryCapability, vt as DeviceType, w as buildDeviceAdminUrl, wt as defineRecordKinds, x as brightnessCapability, xt as RecordSecretUnavailableError, y as bestLocationMatch, yt as errMsg, z as fanControlCapability, zt as url } from "./dist-
|
|
1
|
+
import { A as connectivityCapability, At as boolean, B as floodCapability, Bt as EventCategory, C as buildAddonRouteProvider, Ct as defineEntryKind, D as carbonMonoxideCapability, Dt as settingsBrokersAdoptsFrom, E as calendarSourceCapability, F as deviceAdoptionCapability, Ft as record, G as lawnMowerControlCapability, H as humidifierCapability, It as string, J as motionCapability, K as lockControlCapability, L as enumSensorCapability, Lt as union, M as controlCapability, Mt as literal, N as coverCapability, Nt as number, O as climateControlCapability, Ot as _enum, P as deviceAdminLinkCapability, Pt as object, Q as numericSensorCapability, R as eventEmitterCapability, Rt as unknown, S as brokerCapability, St as createEvent, T as buttonCapability, Tt as entryBody, U as humiditySensorCapability, V as gasCapability, W as imageCapability, X as notificationOutputCapability, Y as normalizeUnit, Z as notifierCapability, _ as automationControlCapability, _t as DeviceRole, at as scriptRunnerCapability, b as binaryCapability, ct as tamperCapability, d as TargetSchema, dt as vacuumControlCapability, et as parseAdminBase, f as accessoriesCapability, ft as valveCapability, g as ambientLightSensorCapability, gt as DeviceFeature, h as alarmPanelCapability, ht as weatherCapability, it as pressureSensorCapability, j as contactCapability, jt as discriminatedUnion, k as colorCapability, kt as array, lt as temperatureSensorCapability, m as airQualitySensorCapability, mt as waterHeaterCapability, n as BaseDevice, nt as prepareNotification, ot as smokeCapability, p as addonRoutesCapability, pt as vibrationCapability, q as mediaPlayerCapability, r as BaseDeviceProvider, rt as presenceCapability, s as EnumSensorDateTimeFormatSchema, st as switchCapability, tt as powerMeterCapability, ut as updateCapability, v as batteryCapability, vt as DeviceType, w as buildDeviceAdminUrl, wt as defineRecordKinds, x as brightnessCapability, xt as RecordSecretUnavailableError, y as bestLocationMatch, yt as errMsg, z as fanControlCapability, zt as url } from "./dist-DV_2NKnd.mjs";
|
|
2
2
|
import { randomUUID } from "node:crypto";
|
|
3
3
|
import { brotliCompressSync, deflateSync, gzipSync } from "node:zlib";
|
|
4
4
|
//#region src/ha-admin-link.ts
|
|
@@ -7928,6 +7928,12 @@ function normalizeAddonInitResult(result) {
|
|
|
7928
7928
|
if (Array.isArray(result)) return { providers: result };
|
|
7929
7929
|
return result;
|
|
7930
7930
|
}
|
|
7931
|
+
/**
|
|
7932
|
+
* The share-view scope kinds a `csv_*` share token can carry. The hub mints
|
|
7933
|
+
* and validates them (`share-token.service.ts` builds its enum from this
|
|
7934
|
+
* list); a data plane names the kinds it ACCEPTS in `share`.
|
|
7935
|
+
*/
|
|
7936
|
+
var SHARE_VIEW_KINDS = ["grid-view", "events-view"];
|
|
7931
7937
|
/** The wire shape of {@link PeerBytesTicket} — see the type for what it is. */
|
|
7932
7938
|
var PeerBytesTicketSchema = object({
|
|
7933
7939
|
/** `http://127.0.0.1:<port>/<token>`. One `GET` takes it. */
|
|
@@ -12996,6 +13002,229 @@ var ConvertResultSchema = object({
|
|
|
12996
13002
|
files: array(string()).readonly()
|
|
12997
13003
|
})).readonly()
|
|
12998
13004
|
});
|
|
13005
|
+
/**
|
|
13006
|
+
* Zod schemas for persisted record types.
|
|
13007
|
+
*
|
|
13008
|
+
* These schemas serve as the single source of truth for types that are
|
|
13009
|
+
* stored in the settings-store backend and retrieved via tRPC. They
|
|
13010
|
+
* replace the manual TypeScript interfaces with schema-derived types,
|
|
13011
|
+
* enabling runtime validation when reading from the backend.
|
|
13012
|
+
*
|
|
13013
|
+
* Convention: each schema is named `<Type>Schema`, the inferred TS type
|
|
13014
|
+
* keeps the original name for backward compatibility.
|
|
13015
|
+
*/
|
|
13016
|
+
/**
|
|
13017
|
+
* Auth model (v2 — 2026-05-12 caps-only):
|
|
13018
|
+
*
|
|
13019
|
+
* Two principals:
|
|
13020
|
+
* - `isAdmin: true` — full bypass. Admin scope set is ignored.
|
|
13021
|
+
* - `isAdmin: false` — every call gated by `scopes` (see TokenScope).
|
|
13022
|
+
*
|
|
13023
|
+
* No role enum. There used to be `viewer / agent / scoped` and earlier
|
|
13024
|
+
* `super_admin` — collapsed onto the single boolean because every
|
|
13025
|
+
* non-admin caller is governed by the same scope-check rules; the
|
|
13026
|
+
* distinction was only ever used to route role-specific procedures
|
|
13027
|
+
* which we no longer have. CLI / webhook integrations are `cst_*` tokens
|
|
13028
|
+
* with `isAdmin: false` + an explicit scope list.
|
|
13029
|
+
*/
|
|
13030
|
+
/** Per-method access flavour. Materialised on every cap method via codegen. */
|
|
13031
|
+
var MethodAccessSchema = _enum([
|
|
13032
|
+
"view",
|
|
13033
|
+
"create",
|
|
13034
|
+
"delete"
|
|
13035
|
+
]);
|
|
13036
|
+
/**
|
|
13037
|
+
* A single scope grant. Three forms — checked in matcher with OR
|
|
13038
|
+
* semantics; the first match decides whether the call passes:
|
|
13039
|
+
*
|
|
13040
|
+
* - `category` — broadest. `target: 'device' | 'system'` selects every
|
|
13041
|
+
* cap with the matching `scope` declaration. New caps inherit grants
|
|
13042
|
+
* automatically — adding a device cap to the codebase makes it
|
|
13043
|
+
* reachable to every user with `category:device [...]` without a
|
|
13044
|
+
* re-grant. Use this for "family viewer" / "operator" tiers.
|
|
13045
|
+
*
|
|
13046
|
+
* - `addon` — every cap that ships inside a given addon id. Niche;
|
|
13047
|
+
* useful when an integration needs to interact with one specific
|
|
13048
|
+
* addon's surface regardless of how many caps it exports.
|
|
13049
|
+
*
|
|
13050
|
+
* - `capability` — the most precise form. Single cap name. Use for
|
|
13051
|
+
* integration tokens where you want to grant `addons.installPackage`
|
|
13052
|
+
* and nothing else.
|
|
13053
|
+
*
|
|
13054
|
+
* `access` is REQUIRED with min 1 element. `admin` bypass is the
|
|
13055
|
+
* "give me everything" escape; there is no wildcard scope.
|
|
13056
|
+
*/
|
|
13057
|
+
var AllowedProviderSchema = union([literal("*"), array(string())]);
|
|
13058
|
+
var AllowedDevicesSchema = record(string(), union([literal("*"), array(string())]));
|
|
13059
|
+
var CapScopeSchema = _enum(["device", "system"]);
|
|
13060
|
+
/**
|
|
13061
|
+
* DeviceSelector (scope model v3 — 2026-08-12).
|
|
13062
|
+
*
|
|
13063
|
+
* A `device` grant no longer carries a frozen list of deviceIds. It carries
|
|
13064
|
+
* a SELECTOR the matcher resolves against the live fleet, so the grant can be
|
|
13065
|
+
* DYNAMIC: a `types:['camera']` selector automatically covers a camera added
|
|
13066
|
+
* AFTER the grant was minted — no re-grant, no re-login.
|
|
13067
|
+
*
|
|
13068
|
+
* - `all` — every device in the deployment. The broad viewer/operator
|
|
13069
|
+
* lever without a `category` grant (a `category` grant also covers device
|
|
13070
|
+
* caps that carry no deviceId; `all` is specifically the device set).
|
|
13071
|
+
* - `ids` — an explicit deviceId list. This is what a v2 `device:[…]`
|
|
13072
|
+
* grant migrates to (see {@link TokenScopeSchema}); STATIC — a new camera
|
|
13073
|
+
* is NOT covered until the grant is edited.
|
|
13074
|
+
* - `types` — every device of a `DeviceType` (e.g. every `camera`).
|
|
13075
|
+
* DYNAMIC. A device that changes type, or a new device of the type,
|
|
13076
|
+
* re-resolves on the next request.
|
|
13077
|
+
* - `locations` — every device whose operator-assigned `location` label is
|
|
13078
|
+
* in the set (e.g. "Garden", "Front door"). DYNAMIC. A device with a
|
|
13079
|
+
* null/unset location matches NO `locations` selector.
|
|
13080
|
+
*/
|
|
13081
|
+
var DeviceSelectorSchema = discriminatedUnion("kind", [
|
|
13082
|
+
object({ kind: literal("all") }),
|
|
13083
|
+
object({
|
|
13084
|
+
kind: literal("ids"),
|
|
13085
|
+
ids: array(number().int()).min(1)
|
|
13086
|
+
}),
|
|
13087
|
+
object({
|
|
13088
|
+
kind: literal("types"),
|
|
13089
|
+
types: array(_enum(DeviceType)).min(1)
|
|
13090
|
+
}),
|
|
13091
|
+
object({
|
|
13092
|
+
kind: literal("locations"),
|
|
13093
|
+
locations: array(string().min(1)).min(1)
|
|
13094
|
+
})
|
|
13095
|
+
]);
|
|
13096
|
+
var DeviceTokenScopeSchema = object({
|
|
13097
|
+
type: literal("device"),
|
|
13098
|
+
/** The device SET this grant covers — resolved against the live fleet. */
|
|
13099
|
+
selector: DeviceSelectorSchema,
|
|
13100
|
+
access: array(MethodAccessSchema).min(1),
|
|
13101
|
+
/**
|
|
13102
|
+
* Whether a grant on a PARENT device transparently covers its accessory
|
|
13103
|
+
* CHILDREN (siren / floodlight / PIR) via the persisted-parentage walk.
|
|
13104
|
+
* Direction is parent → children ONLY.
|
|
13105
|
+
*
|
|
13106
|
+
* Absent → the matcher DERIVES it from the access flavour: `view`
|
|
13107
|
+
* inherits (a camera viewer sees the camera's accessories), `create` /
|
|
13108
|
+
* `delete` do NOT (actuating/removing a child is an explicit act the
|
|
13109
|
+
* operator must grant on the child, not inherit from the parent). Set it
|
|
13110
|
+
* explicitly to override that default per grant.
|
|
13111
|
+
*/
|
|
13112
|
+
includeLinked: boolean().optional()
|
|
13113
|
+
});
|
|
13114
|
+
/**
|
|
13115
|
+
* v2 → v3 lazy migration. A pre-v3 `device` grant carried
|
|
13116
|
+
* `targets: string[]` (stringified deviceIds); it rewrites to the equivalent
|
|
13117
|
+
* `selector: {kind:'ids', ids}`. Applied as a `preprocess` so it runs on
|
|
13118
|
+
* EVERY parse path — stored records AND the JWT-carried scope arrays
|
|
13119
|
+
* normalised at the request boundary ({@link normalizeTokenScopes} in
|
|
13120
|
+
* `device-selector.ts`). Chosen over a one-time DB migration because a
|
|
13121
|
+
* migration cannot reach a JWT already in a client's hands; parse-time
|
|
13122
|
+
* migration covers both without a flag day. No cast — the raw object is read
|
|
13123
|
+
* through `Reflect.get` (its static type is `unknown`).
|
|
13124
|
+
*/
|
|
13125
|
+
function migrateLegacyTokenScope(raw) {
|
|
13126
|
+
if (raw === null || typeof raw !== "object" || Array.isArray(raw)) return raw;
|
|
13127
|
+
if (Reflect.get(raw, "type") !== "device") return raw;
|
|
13128
|
+
if (Reflect.get(raw, "selector") !== void 0) return raw;
|
|
13129
|
+
const targets = Reflect.get(raw, "targets");
|
|
13130
|
+
if (!Array.isArray(targets)) return raw;
|
|
13131
|
+
return {
|
|
13132
|
+
type: "device",
|
|
13133
|
+
selector: {
|
|
13134
|
+
kind: "ids",
|
|
13135
|
+
ids: targets.map((t) => typeof t === "string" ? Number(t) : t).filter((n) => typeof n === "number" && Number.isInteger(n))
|
|
13136
|
+
},
|
|
13137
|
+
access: Reflect.get(raw, "access")
|
|
13138
|
+
};
|
|
13139
|
+
}
|
|
13140
|
+
var TokenScopeSchema = preprocess(migrateLegacyTokenScope, discriminatedUnion("type", [
|
|
13141
|
+
object({
|
|
13142
|
+
type: literal("category"),
|
|
13143
|
+
target: CapScopeSchema,
|
|
13144
|
+
access: array(MethodAccessSchema).min(1)
|
|
13145
|
+
}),
|
|
13146
|
+
object({
|
|
13147
|
+
type: literal("capability"),
|
|
13148
|
+
target: string(),
|
|
13149
|
+
access: array(MethodAccessSchema).min(1)
|
|
13150
|
+
}),
|
|
13151
|
+
object({
|
|
13152
|
+
type: literal("addon"),
|
|
13153
|
+
target: string(),
|
|
13154
|
+
access: array(MethodAccessSchema).min(1)
|
|
13155
|
+
}),
|
|
13156
|
+
DeviceTokenScopeSchema
|
|
13157
|
+
]));
|
|
13158
|
+
object({
|
|
13159
|
+
id: string(),
|
|
13160
|
+
username: string(),
|
|
13161
|
+
passwordHash: string(),
|
|
13162
|
+
/**
|
|
13163
|
+
* Admin bypass. When true, the middleware skips the scope-access
|
|
13164
|
+
* check entirely. There is no other axis of privilege; the legacy
|
|
13165
|
+
* role enum collapsed onto this boolean in v2.
|
|
13166
|
+
*/
|
|
13167
|
+
isAdmin: boolean().default(false),
|
|
13168
|
+
allowedProviders: AllowedProviderSchema,
|
|
13169
|
+
allowedDevices: AllowedDevicesSchema,
|
|
13170
|
+
/**
|
|
13171
|
+
* Scopes granted to this user. Admins bypass; their `scopes` is
|
|
13172
|
+
* ignored. Non-admins without scopes are locked out of every
|
|
13173
|
+
* protected call.
|
|
13174
|
+
*/
|
|
13175
|
+
scopes: array(TokenScopeSchema).default([]),
|
|
13176
|
+
createdAt: number(),
|
|
13177
|
+
updatedAt: number()
|
|
13178
|
+
});
|
|
13179
|
+
object({
|
|
13180
|
+
id: string(),
|
|
13181
|
+
label: string(),
|
|
13182
|
+
isAdmin: boolean().default(false),
|
|
13183
|
+
allowedProviders: AllowedProviderSchema,
|
|
13184
|
+
allowedDevices: AllowedDevicesSchema,
|
|
13185
|
+
tokenHash: string(),
|
|
13186
|
+
tokenPrefix: string(),
|
|
13187
|
+
createdAt: number(),
|
|
13188
|
+
lastUsedAt: number().optional()
|
|
13189
|
+
});
|
|
13190
|
+
object({
|
|
13191
|
+
id: string(),
|
|
13192
|
+
userId: string(),
|
|
13193
|
+
name: string(),
|
|
13194
|
+
tokenHash: string(),
|
|
13195
|
+
tokenPrefix: string(),
|
|
13196
|
+
scopes: array(TokenScopeSchema),
|
|
13197
|
+
expiresAt: number().nullish(),
|
|
13198
|
+
lastUsedAt: number().nullish(),
|
|
13199
|
+
createdAt: number()
|
|
13200
|
+
});
|
|
13201
|
+
/** What a share-view grant lets its holder see. */
|
|
13202
|
+
var ShareViewGrantSchema = object({
|
|
13203
|
+
kind: _enum(SHARE_VIEW_KINDS),
|
|
13204
|
+
deviceIds: array(number().int().nonnegative()).min(1).max(64),
|
|
13205
|
+
/** Talk-back, opt-in at mint time; absent means off. */
|
|
13206
|
+
talk: boolean().optional()
|
|
13207
|
+
});
|
|
13208
|
+
var ShareViewScopeSchema = object({
|
|
13209
|
+
type: literal("share-view"),
|
|
13210
|
+
grant: ShareViewGrantSchema
|
|
13211
|
+
});
|
|
13212
|
+
var AddonRoutesScopeSchema = object({
|
|
13213
|
+
type: literal("addon-routes"),
|
|
13214
|
+
access: array(MethodAccessSchema).min(1)
|
|
13215
|
+
});
|
|
13216
|
+
var CredentialScopeSchema = union([
|
|
13217
|
+
literal("*"),
|
|
13218
|
+
ShareViewScopeSchema,
|
|
13219
|
+
AddonRoutesScopeSchema,
|
|
13220
|
+
TokenScopeSchema
|
|
13221
|
+
]);
|
|
13222
|
+
object({
|
|
13223
|
+
kind: literal("credential"),
|
|
13224
|
+
sub: string().min(1),
|
|
13225
|
+
jti: string().min(16),
|
|
13226
|
+
scopes: array(CredentialScopeSchema).min(1)
|
|
13227
|
+
});
|
|
12999
13228
|
_enum(["new-session", "step-up"]);
|
|
13000
13229
|
/** The languages the hub's app landing pages are written in (D858). */
|
|
13001
13230
|
var AppPageLangSchema = _enum(["en", "it"]);
|
|
@@ -44797,202 +45026,6 @@ method(object({}), object({ rules: array(NcRuleSchema) }), { auth: "admin" }), m
|
|
|
44797
45026
|
auth: "admin"
|
|
44798
45027
|
}), method(NcAlarmSensorsInputSchema, NcAlarmSensorsSchema, { auth: "admin" });
|
|
44799
45028
|
/**
|
|
44800
|
-
* Zod schemas for persisted record types.
|
|
44801
|
-
*
|
|
44802
|
-
* These schemas serve as the single source of truth for types that are
|
|
44803
|
-
* stored in the settings-store backend and retrieved via tRPC. They
|
|
44804
|
-
* replace the manual TypeScript interfaces with schema-derived types,
|
|
44805
|
-
* enabling runtime validation when reading from the backend.
|
|
44806
|
-
*
|
|
44807
|
-
* Convention: each schema is named `<Type>Schema`, the inferred TS type
|
|
44808
|
-
* keeps the original name for backward compatibility.
|
|
44809
|
-
*/
|
|
44810
|
-
/**
|
|
44811
|
-
* Auth model (v2 — 2026-05-12 caps-only):
|
|
44812
|
-
*
|
|
44813
|
-
* Two principals:
|
|
44814
|
-
* - `isAdmin: true` — full bypass. Admin scope set is ignored.
|
|
44815
|
-
* - `isAdmin: false` — every call gated by `scopes` (see TokenScope).
|
|
44816
|
-
*
|
|
44817
|
-
* No role enum. There used to be `viewer / agent / scoped` and earlier
|
|
44818
|
-
* `super_admin` — collapsed onto the single boolean because every
|
|
44819
|
-
* non-admin caller is governed by the same scope-check rules; the
|
|
44820
|
-
* distinction was only ever used to route role-specific procedures
|
|
44821
|
-
* which we no longer have. CLI / webhook integrations are `cst_*` tokens
|
|
44822
|
-
* with `isAdmin: false` + an explicit scope list.
|
|
44823
|
-
*/
|
|
44824
|
-
/** Per-method access flavour. Materialised on every cap method via codegen. */
|
|
44825
|
-
var MethodAccessSchema = _enum([
|
|
44826
|
-
"view",
|
|
44827
|
-
"create",
|
|
44828
|
-
"delete"
|
|
44829
|
-
]);
|
|
44830
|
-
/**
|
|
44831
|
-
* A single scope grant. Three forms — checked in matcher with OR
|
|
44832
|
-
* semantics; the first match decides whether the call passes:
|
|
44833
|
-
*
|
|
44834
|
-
* - `category` — broadest. `target: 'device' | 'system'` selects every
|
|
44835
|
-
* cap with the matching `scope` declaration. New caps inherit grants
|
|
44836
|
-
* automatically — adding a device cap to the codebase makes it
|
|
44837
|
-
* reachable to every user with `category:device [...]` without a
|
|
44838
|
-
* re-grant. Use this for "family viewer" / "operator" tiers.
|
|
44839
|
-
*
|
|
44840
|
-
* - `addon` — every cap that ships inside a given addon id. Niche;
|
|
44841
|
-
* useful when an integration needs to interact with one specific
|
|
44842
|
-
* addon's surface regardless of how many caps it exports.
|
|
44843
|
-
*
|
|
44844
|
-
* - `capability` — the most precise form. Single cap name. Use for
|
|
44845
|
-
* integration tokens where you want to grant `addons.installPackage`
|
|
44846
|
-
* and nothing else.
|
|
44847
|
-
*
|
|
44848
|
-
* `access` is REQUIRED with min 1 element. `admin` bypass is the
|
|
44849
|
-
* "give me everything" escape; there is no wildcard scope.
|
|
44850
|
-
*/
|
|
44851
|
-
var AllowedProviderSchema = union([literal("*"), array(string())]);
|
|
44852
|
-
var AllowedDevicesSchema = record(string(), union([literal("*"), array(string())]));
|
|
44853
|
-
var CapScopeSchema = _enum(["device", "system"]);
|
|
44854
|
-
/**
|
|
44855
|
-
* DeviceSelector (scope model v3 — 2026-08-12).
|
|
44856
|
-
*
|
|
44857
|
-
* A `device` grant no longer carries a frozen list of deviceIds. It carries
|
|
44858
|
-
* a SELECTOR the matcher resolves against the live fleet, so the grant can be
|
|
44859
|
-
* DYNAMIC: a `types:['camera']` selector automatically covers a camera added
|
|
44860
|
-
* AFTER the grant was minted — no re-grant, no re-login.
|
|
44861
|
-
*
|
|
44862
|
-
* - `all` — every device in the deployment. The broad viewer/operator
|
|
44863
|
-
* lever without a `category` grant (a `category` grant also covers device
|
|
44864
|
-
* caps that carry no deviceId; `all` is specifically the device set).
|
|
44865
|
-
* - `ids` — an explicit deviceId list. This is what a v2 `device:[…]`
|
|
44866
|
-
* grant migrates to (see {@link TokenScopeSchema}); STATIC — a new camera
|
|
44867
|
-
* is NOT covered until the grant is edited.
|
|
44868
|
-
* - `types` — every device of a `DeviceType` (e.g. every `camera`).
|
|
44869
|
-
* DYNAMIC. A device that changes type, or a new device of the type,
|
|
44870
|
-
* re-resolves on the next request.
|
|
44871
|
-
* - `locations` — every device whose operator-assigned `location` label is
|
|
44872
|
-
* in the set (e.g. "Garden", "Front door"). DYNAMIC. A device with a
|
|
44873
|
-
* null/unset location matches NO `locations` selector.
|
|
44874
|
-
*/
|
|
44875
|
-
var DeviceSelectorSchema = discriminatedUnion("kind", [
|
|
44876
|
-
object({ kind: literal("all") }),
|
|
44877
|
-
object({
|
|
44878
|
-
kind: literal("ids"),
|
|
44879
|
-
ids: array(number().int()).min(1)
|
|
44880
|
-
}),
|
|
44881
|
-
object({
|
|
44882
|
-
kind: literal("types"),
|
|
44883
|
-
types: array(_enum(DeviceType)).min(1)
|
|
44884
|
-
}),
|
|
44885
|
-
object({
|
|
44886
|
-
kind: literal("locations"),
|
|
44887
|
-
locations: array(string().min(1)).min(1)
|
|
44888
|
-
})
|
|
44889
|
-
]);
|
|
44890
|
-
var DeviceTokenScopeSchema = object({
|
|
44891
|
-
type: literal("device"),
|
|
44892
|
-
/** The device SET this grant covers — resolved against the live fleet. */
|
|
44893
|
-
selector: DeviceSelectorSchema,
|
|
44894
|
-
access: array(MethodAccessSchema).min(1),
|
|
44895
|
-
/**
|
|
44896
|
-
* Whether a grant on a PARENT device transparently covers its accessory
|
|
44897
|
-
* CHILDREN (siren / floodlight / PIR) via the persisted-parentage walk.
|
|
44898
|
-
* Direction is parent → children ONLY.
|
|
44899
|
-
*
|
|
44900
|
-
* Absent → the matcher DERIVES it from the access flavour: `view`
|
|
44901
|
-
* inherits (a camera viewer sees the camera's accessories), `create` /
|
|
44902
|
-
* `delete` do NOT (actuating/removing a child is an explicit act the
|
|
44903
|
-
* operator must grant on the child, not inherit from the parent). Set it
|
|
44904
|
-
* explicitly to override that default per grant.
|
|
44905
|
-
*/
|
|
44906
|
-
includeLinked: boolean().optional()
|
|
44907
|
-
});
|
|
44908
|
-
/**
|
|
44909
|
-
* v2 → v3 lazy migration. A pre-v3 `device` grant carried
|
|
44910
|
-
* `targets: string[]` (stringified deviceIds); it rewrites to the equivalent
|
|
44911
|
-
* `selector: {kind:'ids', ids}`. Applied as a `preprocess` so it runs on
|
|
44912
|
-
* EVERY parse path — stored records AND the JWT-carried scope arrays
|
|
44913
|
-
* normalised at the request boundary ({@link normalizeTokenScopes} in
|
|
44914
|
-
* `device-selector.ts`). Chosen over a one-time DB migration because a
|
|
44915
|
-
* migration cannot reach a JWT already in a client's hands; parse-time
|
|
44916
|
-
* migration covers both without a flag day. No cast — the raw object is read
|
|
44917
|
-
* through `Reflect.get` (its static type is `unknown`).
|
|
44918
|
-
*/
|
|
44919
|
-
function migrateLegacyTokenScope(raw) {
|
|
44920
|
-
if (raw === null || typeof raw !== "object" || Array.isArray(raw)) return raw;
|
|
44921
|
-
if (Reflect.get(raw, "type") !== "device") return raw;
|
|
44922
|
-
if (Reflect.get(raw, "selector") !== void 0) return raw;
|
|
44923
|
-
const targets = Reflect.get(raw, "targets");
|
|
44924
|
-
if (!Array.isArray(targets)) return raw;
|
|
44925
|
-
return {
|
|
44926
|
-
type: "device",
|
|
44927
|
-
selector: {
|
|
44928
|
-
kind: "ids",
|
|
44929
|
-
ids: targets.map((t) => typeof t === "string" ? Number(t) : t).filter((n) => typeof n === "number" && Number.isInteger(n))
|
|
44930
|
-
},
|
|
44931
|
-
access: Reflect.get(raw, "access")
|
|
44932
|
-
};
|
|
44933
|
-
}
|
|
44934
|
-
var TokenScopeSchema = preprocess(migrateLegacyTokenScope, discriminatedUnion("type", [
|
|
44935
|
-
object({
|
|
44936
|
-
type: literal("category"),
|
|
44937
|
-
target: CapScopeSchema,
|
|
44938
|
-
access: array(MethodAccessSchema).min(1)
|
|
44939
|
-
}),
|
|
44940
|
-
object({
|
|
44941
|
-
type: literal("capability"),
|
|
44942
|
-
target: string(),
|
|
44943
|
-
access: array(MethodAccessSchema).min(1)
|
|
44944
|
-
}),
|
|
44945
|
-
object({
|
|
44946
|
-
type: literal("addon"),
|
|
44947
|
-
target: string(),
|
|
44948
|
-
access: array(MethodAccessSchema).min(1)
|
|
44949
|
-
}),
|
|
44950
|
-
DeviceTokenScopeSchema
|
|
44951
|
-
]));
|
|
44952
|
-
object({
|
|
44953
|
-
id: string(),
|
|
44954
|
-
username: string(),
|
|
44955
|
-
passwordHash: string(),
|
|
44956
|
-
/**
|
|
44957
|
-
* Admin bypass. When true, the middleware skips the scope-access
|
|
44958
|
-
* check entirely. There is no other axis of privilege; the legacy
|
|
44959
|
-
* role enum collapsed onto this boolean in v2.
|
|
44960
|
-
*/
|
|
44961
|
-
isAdmin: boolean().default(false),
|
|
44962
|
-
allowedProviders: AllowedProviderSchema,
|
|
44963
|
-
allowedDevices: AllowedDevicesSchema,
|
|
44964
|
-
/**
|
|
44965
|
-
* Scopes granted to this user. Admins bypass; their `scopes` is
|
|
44966
|
-
* ignored. Non-admins without scopes are locked out of every
|
|
44967
|
-
* protected call.
|
|
44968
|
-
*/
|
|
44969
|
-
scopes: array(TokenScopeSchema).default([]),
|
|
44970
|
-
createdAt: number(),
|
|
44971
|
-
updatedAt: number()
|
|
44972
|
-
});
|
|
44973
|
-
object({
|
|
44974
|
-
id: string(),
|
|
44975
|
-
label: string(),
|
|
44976
|
-
isAdmin: boolean().default(false),
|
|
44977
|
-
allowedProviders: AllowedProviderSchema,
|
|
44978
|
-
allowedDevices: AllowedDevicesSchema,
|
|
44979
|
-
tokenHash: string(),
|
|
44980
|
-
tokenPrefix: string(),
|
|
44981
|
-
createdAt: number(),
|
|
44982
|
-
lastUsedAt: number().optional()
|
|
44983
|
-
});
|
|
44984
|
-
object({
|
|
44985
|
-
id: string(),
|
|
44986
|
-
userId: string(),
|
|
44987
|
-
name: string(),
|
|
44988
|
-
tokenHash: string(),
|
|
44989
|
-
tokenPrefix: string(),
|
|
44990
|
-
scopes: array(TokenScopeSchema),
|
|
44991
|
-
expiresAt: number().nullish(),
|
|
44992
|
-
lastUsedAt: number().nullish(),
|
|
44993
|
-
createdAt: number()
|
|
44994
|
-
});
|
|
44995
|
-
/**
|
|
44996
45029
|
* `oauth-integration` — a collection cap by which an addon declares
|
|
44997
45030
|
* itself a linkable OAuth client of the hub's core `/oauth2/*` server.
|
|
44998
45031
|
* Each provider returns a static descriptor; the core enumerates them
|
|
@@ -7929,6 +7929,12 @@ function normalizeAddonInitResult(result) {
|
|
|
7929
7929
|
if (Array.isArray(result)) return { providers: result };
|
|
7930
7930
|
return result;
|
|
7931
7931
|
}
|
|
7932
|
+
/**
|
|
7933
|
+
* The share-view scope kinds a `csv_*` share token can carry. The hub mints
|
|
7934
|
+
* and validates them (`share-token.service.ts` builds its enum from this
|
|
7935
|
+
* list); a data plane names the kinds it ACCEPTS in `share`.
|
|
7936
|
+
*/
|
|
7937
|
+
var SHARE_VIEW_KINDS = ["grid-view", "events-view"];
|
|
7932
7938
|
/** The wire shape of {@link PeerBytesTicket} — see the type for what it is. */
|
|
7933
7939
|
var PeerBytesTicketSchema = object({
|
|
7934
7940
|
/** `http://127.0.0.1:<port>/<token>`. One `GET` takes it. */
|
|
@@ -12997,6 +13003,229 @@ var ConvertResultSchema = object({
|
|
|
12997
13003
|
files: array(string()).readonly()
|
|
12998
13004
|
})).readonly()
|
|
12999
13005
|
});
|
|
13006
|
+
/**
|
|
13007
|
+
* Zod schemas for persisted record types.
|
|
13008
|
+
*
|
|
13009
|
+
* These schemas serve as the single source of truth for types that are
|
|
13010
|
+
* stored in the settings-store backend and retrieved via tRPC. They
|
|
13011
|
+
* replace the manual TypeScript interfaces with schema-derived types,
|
|
13012
|
+
* enabling runtime validation when reading from the backend.
|
|
13013
|
+
*
|
|
13014
|
+
* Convention: each schema is named `<Type>Schema`, the inferred TS type
|
|
13015
|
+
* keeps the original name for backward compatibility.
|
|
13016
|
+
*/
|
|
13017
|
+
/**
|
|
13018
|
+
* Auth model (v2 — 2026-05-12 caps-only):
|
|
13019
|
+
*
|
|
13020
|
+
* Two principals:
|
|
13021
|
+
* - `isAdmin: true` — full bypass. Admin scope set is ignored.
|
|
13022
|
+
* - `isAdmin: false` — every call gated by `scopes` (see TokenScope).
|
|
13023
|
+
*
|
|
13024
|
+
* No role enum. There used to be `viewer / agent / scoped` and earlier
|
|
13025
|
+
* `super_admin` — collapsed onto the single boolean because every
|
|
13026
|
+
* non-admin caller is governed by the same scope-check rules; the
|
|
13027
|
+
* distinction was only ever used to route role-specific procedures
|
|
13028
|
+
* which we no longer have. CLI / webhook integrations are `cst_*` tokens
|
|
13029
|
+
* with `isAdmin: false` + an explicit scope list.
|
|
13030
|
+
*/
|
|
13031
|
+
/** Per-method access flavour. Materialised on every cap method via codegen. */
|
|
13032
|
+
var MethodAccessSchema = _enum([
|
|
13033
|
+
"view",
|
|
13034
|
+
"create",
|
|
13035
|
+
"delete"
|
|
13036
|
+
]);
|
|
13037
|
+
/**
|
|
13038
|
+
* A single scope grant. Three forms — checked in matcher with OR
|
|
13039
|
+
* semantics; the first match decides whether the call passes:
|
|
13040
|
+
*
|
|
13041
|
+
* - `category` — broadest. `target: 'device' | 'system'` selects every
|
|
13042
|
+
* cap with the matching `scope` declaration. New caps inherit grants
|
|
13043
|
+
* automatically — adding a device cap to the codebase makes it
|
|
13044
|
+
* reachable to every user with `category:device [...]` without a
|
|
13045
|
+
* re-grant. Use this for "family viewer" / "operator" tiers.
|
|
13046
|
+
*
|
|
13047
|
+
* - `addon` — every cap that ships inside a given addon id. Niche;
|
|
13048
|
+
* useful when an integration needs to interact with one specific
|
|
13049
|
+
* addon's surface regardless of how many caps it exports.
|
|
13050
|
+
*
|
|
13051
|
+
* - `capability` — the most precise form. Single cap name. Use for
|
|
13052
|
+
* integration tokens where you want to grant `addons.installPackage`
|
|
13053
|
+
* and nothing else.
|
|
13054
|
+
*
|
|
13055
|
+
* `access` is REQUIRED with min 1 element. `admin` bypass is the
|
|
13056
|
+
* "give me everything" escape; there is no wildcard scope.
|
|
13057
|
+
*/
|
|
13058
|
+
var AllowedProviderSchema = union([literal("*"), array(string())]);
|
|
13059
|
+
var AllowedDevicesSchema = record(string(), union([literal("*"), array(string())]));
|
|
13060
|
+
var CapScopeSchema = _enum(["device", "system"]);
|
|
13061
|
+
/**
|
|
13062
|
+
* DeviceSelector (scope model v3 — 2026-08-12).
|
|
13063
|
+
*
|
|
13064
|
+
* A `device` grant no longer carries a frozen list of deviceIds. It carries
|
|
13065
|
+
* a SELECTOR the matcher resolves against the live fleet, so the grant can be
|
|
13066
|
+
* DYNAMIC: a `types:['camera']` selector automatically covers a camera added
|
|
13067
|
+
* AFTER the grant was minted — no re-grant, no re-login.
|
|
13068
|
+
*
|
|
13069
|
+
* - `all` — every device in the deployment. The broad viewer/operator
|
|
13070
|
+
* lever without a `category` grant (a `category` grant also covers device
|
|
13071
|
+
* caps that carry no deviceId; `all` is specifically the device set).
|
|
13072
|
+
* - `ids` — an explicit deviceId list. This is what a v2 `device:[…]`
|
|
13073
|
+
* grant migrates to (see {@link TokenScopeSchema}); STATIC — a new camera
|
|
13074
|
+
* is NOT covered until the grant is edited.
|
|
13075
|
+
* - `types` — every device of a `DeviceType` (e.g. every `camera`).
|
|
13076
|
+
* DYNAMIC. A device that changes type, or a new device of the type,
|
|
13077
|
+
* re-resolves on the next request.
|
|
13078
|
+
* - `locations` — every device whose operator-assigned `location` label is
|
|
13079
|
+
* in the set (e.g. "Garden", "Front door"). DYNAMIC. A device with a
|
|
13080
|
+
* null/unset location matches NO `locations` selector.
|
|
13081
|
+
*/
|
|
13082
|
+
var DeviceSelectorSchema = discriminatedUnion("kind", [
|
|
13083
|
+
object({ kind: literal("all") }),
|
|
13084
|
+
object({
|
|
13085
|
+
kind: literal("ids"),
|
|
13086
|
+
ids: array(number().int()).min(1)
|
|
13087
|
+
}),
|
|
13088
|
+
object({
|
|
13089
|
+
kind: literal("types"),
|
|
13090
|
+
types: array(_enum(DeviceType)).min(1)
|
|
13091
|
+
}),
|
|
13092
|
+
object({
|
|
13093
|
+
kind: literal("locations"),
|
|
13094
|
+
locations: array(string().min(1)).min(1)
|
|
13095
|
+
})
|
|
13096
|
+
]);
|
|
13097
|
+
var DeviceTokenScopeSchema = object({
|
|
13098
|
+
type: literal("device"),
|
|
13099
|
+
/** The device SET this grant covers — resolved against the live fleet. */
|
|
13100
|
+
selector: DeviceSelectorSchema,
|
|
13101
|
+
access: array(MethodAccessSchema).min(1),
|
|
13102
|
+
/**
|
|
13103
|
+
* Whether a grant on a PARENT device transparently covers its accessory
|
|
13104
|
+
* CHILDREN (siren / floodlight / PIR) via the persisted-parentage walk.
|
|
13105
|
+
* Direction is parent → children ONLY.
|
|
13106
|
+
*
|
|
13107
|
+
* Absent → the matcher DERIVES it from the access flavour: `view`
|
|
13108
|
+
* inherits (a camera viewer sees the camera's accessories), `create` /
|
|
13109
|
+
* `delete` do NOT (actuating/removing a child is an explicit act the
|
|
13110
|
+
* operator must grant on the child, not inherit from the parent). Set it
|
|
13111
|
+
* explicitly to override that default per grant.
|
|
13112
|
+
*/
|
|
13113
|
+
includeLinked: boolean().optional()
|
|
13114
|
+
});
|
|
13115
|
+
/**
|
|
13116
|
+
* v2 → v3 lazy migration. A pre-v3 `device` grant carried
|
|
13117
|
+
* `targets: string[]` (stringified deviceIds); it rewrites to the equivalent
|
|
13118
|
+
* `selector: {kind:'ids', ids}`. Applied as a `preprocess` so it runs on
|
|
13119
|
+
* EVERY parse path — stored records AND the JWT-carried scope arrays
|
|
13120
|
+
* normalised at the request boundary ({@link normalizeTokenScopes} in
|
|
13121
|
+
* `device-selector.ts`). Chosen over a one-time DB migration because a
|
|
13122
|
+
* migration cannot reach a JWT already in a client's hands; parse-time
|
|
13123
|
+
* migration covers both without a flag day. No cast — the raw object is read
|
|
13124
|
+
* through `Reflect.get` (its static type is `unknown`).
|
|
13125
|
+
*/
|
|
13126
|
+
function migrateLegacyTokenScope(raw) {
|
|
13127
|
+
if (raw === null || typeof raw !== "object" || Array.isArray(raw)) return raw;
|
|
13128
|
+
if (Reflect.get(raw, "type") !== "device") return raw;
|
|
13129
|
+
if (Reflect.get(raw, "selector") !== void 0) return raw;
|
|
13130
|
+
const targets = Reflect.get(raw, "targets");
|
|
13131
|
+
if (!Array.isArray(targets)) return raw;
|
|
13132
|
+
return {
|
|
13133
|
+
type: "device",
|
|
13134
|
+
selector: {
|
|
13135
|
+
kind: "ids",
|
|
13136
|
+
ids: targets.map((t) => typeof t === "string" ? Number(t) : t).filter((n) => typeof n === "number" && Number.isInteger(n))
|
|
13137
|
+
},
|
|
13138
|
+
access: Reflect.get(raw, "access")
|
|
13139
|
+
};
|
|
13140
|
+
}
|
|
13141
|
+
var TokenScopeSchema = preprocess(migrateLegacyTokenScope, discriminatedUnion("type", [
|
|
13142
|
+
object({
|
|
13143
|
+
type: literal("category"),
|
|
13144
|
+
target: CapScopeSchema,
|
|
13145
|
+
access: array(MethodAccessSchema).min(1)
|
|
13146
|
+
}),
|
|
13147
|
+
object({
|
|
13148
|
+
type: literal("capability"),
|
|
13149
|
+
target: string(),
|
|
13150
|
+
access: array(MethodAccessSchema).min(1)
|
|
13151
|
+
}),
|
|
13152
|
+
object({
|
|
13153
|
+
type: literal("addon"),
|
|
13154
|
+
target: string(),
|
|
13155
|
+
access: array(MethodAccessSchema).min(1)
|
|
13156
|
+
}),
|
|
13157
|
+
DeviceTokenScopeSchema
|
|
13158
|
+
]));
|
|
13159
|
+
object({
|
|
13160
|
+
id: string(),
|
|
13161
|
+
username: string(),
|
|
13162
|
+
passwordHash: string(),
|
|
13163
|
+
/**
|
|
13164
|
+
* Admin bypass. When true, the middleware skips the scope-access
|
|
13165
|
+
* check entirely. There is no other axis of privilege; the legacy
|
|
13166
|
+
* role enum collapsed onto this boolean in v2.
|
|
13167
|
+
*/
|
|
13168
|
+
isAdmin: boolean().default(false),
|
|
13169
|
+
allowedProviders: AllowedProviderSchema,
|
|
13170
|
+
allowedDevices: AllowedDevicesSchema,
|
|
13171
|
+
/**
|
|
13172
|
+
* Scopes granted to this user. Admins bypass; their `scopes` is
|
|
13173
|
+
* ignored. Non-admins without scopes are locked out of every
|
|
13174
|
+
* protected call.
|
|
13175
|
+
*/
|
|
13176
|
+
scopes: array(TokenScopeSchema).default([]),
|
|
13177
|
+
createdAt: number(),
|
|
13178
|
+
updatedAt: number()
|
|
13179
|
+
});
|
|
13180
|
+
object({
|
|
13181
|
+
id: string(),
|
|
13182
|
+
label: string(),
|
|
13183
|
+
isAdmin: boolean().default(false),
|
|
13184
|
+
allowedProviders: AllowedProviderSchema,
|
|
13185
|
+
allowedDevices: AllowedDevicesSchema,
|
|
13186
|
+
tokenHash: string(),
|
|
13187
|
+
tokenPrefix: string(),
|
|
13188
|
+
createdAt: number(),
|
|
13189
|
+
lastUsedAt: number().optional()
|
|
13190
|
+
});
|
|
13191
|
+
object({
|
|
13192
|
+
id: string(),
|
|
13193
|
+
userId: string(),
|
|
13194
|
+
name: string(),
|
|
13195
|
+
tokenHash: string(),
|
|
13196
|
+
tokenPrefix: string(),
|
|
13197
|
+
scopes: array(TokenScopeSchema),
|
|
13198
|
+
expiresAt: number().nullish(),
|
|
13199
|
+
lastUsedAt: number().nullish(),
|
|
13200
|
+
createdAt: number()
|
|
13201
|
+
});
|
|
13202
|
+
/** What a share-view grant lets its holder see. */
|
|
13203
|
+
var ShareViewGrantSchema = object({
|
|
13204
|
+
kind: _enum(SHARE_VIEW_KINDS),
|
|
13205
|
+
deviceIds: array(number().int().nonnegative()).min(1).max(64),
|
|
13206
|
+
/** Talk-back, opt-in at mint time; absent means off. */
|
|
13207
|
+
talk: boolean().optional()
|
|
13208
|
+
});
|
|
13209
|
+
var ShareViewScopeSchema = object({
|
|
13210
|
+
type: literal("share-view"),
|
|
13211
|
+
grant: ShareViewGrantSchema
|
|
13212
|
+
});
|
|
13213
|
+
var AddonRoutesScopeSchema = object({
|
|
13214
|
+
type: literal("addon-routes"),
|
|
13215
|
+
access: array(MethodAccessSchema).min(1)
|
|
13216
|
+
});
|
|
13217
|
+
var CredentialScopeSchema = union([
|
|
13218
|
+
literal("*"),
|
|
13219
|
+
ShareViewScopeSchema,
|
|
13220
|
+
AddonRoutesScopeSchema,
|
|
13221
|
+
TokenScopeSchema
|
|
13222
|
+
]);
|
|
13223
|
+
object({
|
|
13224
|
+
kind: literal("credential"),
|
|
13225
|
+
sub: string().min(1),
|
|
13226
|
+
jti: string().min(16),
|
|
13227
|
+
scopes: array(CredentialScopeSchema).min(1)
|
|
13228
|
+
});
|
|
13000
13229
|
_enum(["new-session", "step-up"]);
|
|
13001
13230
|
/** The languages the hub's app landing pages are written in (D858). */
|
|
13002
13231
|
var AppPageLangSchema = _enum(["en", "it"]);
|
|
@@ -44798,202 +45027,6 @@ method(object({}), object({ rules: array(NcRuleSchema) }), { auth: "admin" }), m
|
|
|
44798
45027
|
auth: "admin"
|
|
44799
45028
|
}), method(NcAlarmSensorsInputSchema, NcAlarmSensorsSchema, { auth: "admin" });
|
|
44800
45029
|
/**
|
|
44801
|
-
* Zod schemas for persisted record types.
|
|
44802
|
-
*
|
|
44803
|
-
* These schemas serve as the single source of truth for types that are
|
|
44804
|
-
* stored in the settings-store backend and retrieved via tRPC. They
|
|
44805
|
-
* replace the manual TypeScript interfaces with schema-derived types,
|
|
44806
|
-
* enabling runtime validation when reading from the backend.
|
|
44807
|
-
*
|
|
44808
|
-
* Convention: each schema is named `<Type>Schema`, the inferred TS type
|
|
44809
|
-
* keeps the original name for backward compatibility.
|
|
44810
|
-
*/
|
|
44811
|
-
/**
|
|
44812
|
-
* Auth model (v2 — 2026-05-12 caps-only):
|
|
44813
|
-
*
|
|
44814
|
-
* Two principals:
|
|
44815
|
-
* - `isAdmin: true` — full bypass. Admin scope set is ignored.
|
|
44816
|
-
* - `isAdmin: false` — every call gated by `scopes` (see TokenScope).
|
|
44817
|
-
*
|
|
44818
|
-
* No role enum. There used to be `viewer / agent / scoped` and earlier
|
|
44819
|
-
* `super_admin` — collapsed onto the single boolean because every
|
|
44820
|
-
* non-admin caller is governed by the same scope-check rules; the
|
|
44821
|
-
* distinction was only ever used to route role-specific procedures
|
|
44822
|
-
* which we no longer have. CLI / webhook integrations are `cst_*` tokens
|
|
44823
|
-
* with `isAdmin: false` + an explicit scope list.
|
|
44824
|
-
*/
|
|
44825
|
-
/** Per-method access flavour. Materialised on every cap method via codegen. */
|
|
44826
|
-
var MethodAccessSchema = _enum([
|
|
44827
|
-
"view",
|
|
44828
|
-
"create",
|
|
44829
|
-
"delete"
|
|
44830
|
-
]);
|
|
44831
|
-
/**
|
|
44832
|
-
* A single scope grant. Three forms — checked in matcher with OR
|
|
44833
|
-
* semantics; the first match decides whether the call passes:
|
|
44834
|
-
*
|
|
44835
|
-
* - `category` — broadest. `target: 'device' | 'system'` selects every
|
|
44836
|
-
* cap with the matching `scope` declaration. New caps inherit grants
|
|
44837
|
-
* automatically — adding a device cap to the codebase makes it
|
|
44838
|
-
* reachable to every user with `category:device [...]` without a
|
|
44839
|
-
* re-grant. Use this for "family viewer" / "operator" tiers.
|
|
44840
|
-
*
|
|
44841
|
-
* - `addon` — every cap that ships inside a given addon id. Niche;
|
|
44842
|
-
* useful when an integration needs to interact with one specific
|
|
44843
|
-
* addon's surface regardless of how many caps it exports.
|
|
44844
|
-
*
|
|
44845
|
-
* - `capability` — the most precise form. Single cap name. Use for
|
|
44846
|
-
* integration tokens where you want to grant `addons.installPackage`
|
|
44847
|
-
* and nothing else.
|
|
44848
|
-
*
|
|
44849
|
-
* `access` is REQUIRED with min 1 element. `admin` bypass is the
|
|
44850
|
-
* "give me everything" escape; there is no wildcard scope.
|
|
44851
|
-
*/
|
|
44852
|
-
var AllowedProviderSchema = union([literal("*"), array(string())]);
|
|
44853
|
-
var AllowedDevicesSchema = record(string(), union([literal("*"), array(string())]));
|
|
44854
|
-
var CapScopeSchema = _enum(["device", "system"]);
|
|
44855
|
-
/**
|
|
44856
|
-
* DeviceSelector (scope model v3 — 2026-08-12).
|
|
44857
|
-
*
|
|
44858
|
-
* A `device` grant no longer carries a frozen list of deviceIds. It carries
|
|
44859
|
-
* a SELECTOR the matcher resolves against the live fleet, so the grant can be
|
|
44860
|
-
* DYNAMIC: a `types:['camera']` selector automatically covers a camera added
|
|
44861
|
-
* AFTER the grant was minted — no re-grant, no re-login.
|
|
44862
|
-
*
|
|
44863
|
-
* - `all` — every device in the deployment. The broad viewer/operator
|
|
44864
|
-
* lever without a `category` grant (a `category` grant also covers device
|
|
44865
|
-
* caps that carry no deviceId; `all` is specifically the device set).
|
|
44866
|
-
* - `ids` — an explicit deviceId list. This is what a v2 `device:[…]`
|
|
44867
|
-
* grant migrates to (see {@link TokenScopeSchema}); STATIC — a new camera
|
|
44868
|
-
* is NOT covered until the grant is edited.
|
|
44869
|
-
* - `types` — every device of a `DeviceType` (e.g. every `camera`).
|
|
44870
|
-
* DYNAMIC. A device that changes type, or a new device of the type,
|
|
44871
|
-
* re-resolves on the next request.
|
|
44872
|
-
* - `locations` — every device whose operator-assigned `location` label is
|
|
44873
|
-
* in the set (e.g. "Garden", "Front door"). DYNAMIC. A device with a
|
|
44874
|
-
* null/unset location matches NO `locations` selector.
|
|
44875
|
-
*/
|
|
44876
|
-
var DeviceSelectorSchema = discriminatedUnion("kind", [
|
|
44877
|
-
object({ kind: literal("all") }),
|
|
44878
|
-
object({
|
|
44879
|
-
kind: literal("ids"),
|
|
44880
|
-
ids: array(number().int()).min(1)
|
|
44881
|
-
}),
|
|
44882
|
-
object({
|
|
44883
|
-
kind: literal("types"),
|
|
44884
|
-
types: array(_enum(DeviceType)).min(1)
|
|
44885
|
-
}),
|
|
44886
|
-
object({
|
|
44887
|
-
kind: literal("locations"),
|
|
44888
|
-
locations: array(string().min(1)).min(1)
|
|
44889
|
-
})
|
|
44890
|
-
]);
|
|
44891
|
-
var DeviceTokenScopeSchema = object({
|
|
44892
|
-
type: literal("device"),
|
|
44893
|
-
/** The device SET this grant covers — resolved against the live fleet. */
|
|
44894
|
-
selector: DeviceSelectorSchema,
|
|
44895
|
-
access: array(MethodAccessSchema).min(1),
|
|
44896
|
-
/**
|
|
44897
|
-
* Whether a grant on a PARENT device transparently covers its accessory
|
|
44898
|
-
* CHILDREN (siren / floodlight / PIR) via the persisted-parentage walk.
|
|
44899
|
-
* Direction is parent → children ONLY.
|
|
44900
|
-
*
|
|
44901
|
-
* Absent → the matcher DERIVES it from the access flavour: `view`
|
|
44902
|
-
* inherits (a camera viewer sees the camera's accessories), `create` /
|
|
44903
|
-
* `delete` do NOT (actuating/removing a child is an explicit act the
|
|
44904
|
-
* operator must grant on the child, not inherit from the parent). Set it
|
|
44905
|
-
* explicitly to override that default per grant.
|
|
44906
|
-
*/
|
|
44907
|
-
includeLinked: boolean().optional()
|
|
44908
|
-
});
|
|
44909
|
-
/**
|
|
44910
|
-
* v2 → v3 lazy migration. A pre-v3 `device` grant carried
|
|
44911
|
-
* `targets: string[]` (stringified deviceIds); it rewrites to the equivalent
|
|
44912
|
-
* `selector: {kind:'ids', ids}`. Applied as a `preprocess` so it runs on
|
|
44913
|
-
* EVERY parse path — stored records AND the JWT-carried scope arrays
|
|
44914
|
-
* normalised at the request boundary ({@link normalizeTokenScopes} in
|
|
44915
|
-
* `device-selector.ts`). Chosen over a one-time DB migration because a
|
|
44916
|
-
* migration cannot reach a JWT already in a client's hands; parse-time
|
|
44917
|
-
* migration covers both without a flag day. No cast — the raw object is read
|
|
44918
|
-
* through `Reflect.get` (its static type is `unknown`).
|
|
44919
|
-
*/
|
|
44920
|
-
function migrateLegacyTokenScope(raw) {
|
|
44921
|
-
if (raw === null || typeof raw !== "object" || Array.isArray(raw)) return raw;
|
|
44922
|
-
if (Reflect.get(raw, "type") !== "device") return raw;
|
|
44923
|
-
if (Reflect.get(raw, "selector") !== void 0) return raw;
|
|
44924
|
-
const targets = Reflect.get(raw, "targets");
|
|
44925
|
-
if (!Array.isArray(targets)) return raw;
|
|
44926
|
-
return {
|
|
44927
|
-
type: "device",
|
|
44928
|
-
selector: {
|
|
44929
|
-
kind: "ids",
|
|
44930
|
-
ids: targets.map((t) => typeof t === "string" ? Number(t) : t).filter((n) => typeof n === "number" && Number.isInteger(n))
|
|
44931
|
-
},
|
|
44932
|
-
access: Reflect.get(raw, "access")
|
|
44933
|
-
};
|
|
44934
|
-
}
|
|
44935
|
-
var TokenScopeSchema = preprocess(migrateLegacyTokenScope, discriminatedUnion("type", [
|
|
44936
|
-
object({
|
|
44937
|
-
type: literal("category"),
|
|
44938
|
-
target: CapScopeSchema,
|
|
44939
|
-
access: array(MethodAccessSchema).min(1)
|
|
44940
|
-
}),
|
|
44941
|
-
object({
|
|
44942
|
-
type: literal("capability"),
|
|
44943
|
-
target: string(),
|
|
44944
|
-
access: array(MethodAccessSchema).min(1)
|
|
44945
|
-
}),
|
|
44946
|
-
object({
|
|
44947
|
-
type: literal("addon"),
|
|
44948
|
-
target: string(),
|
|
44949
|
-
access: array(MethodAccessSchema).min(1)
|
|
44950
|
-
}),
|
|
44951
|
-
DeviceTokenScopeSchema
|
|
44952
|
-
]));
|
|
44953
|
-
object({
|
|
44954
|
-
id: string(),
|
|
44955
|
-
username: string(),
|
|
44956
|
-
passwordHash: string(),
|
|
44957
|
-
/**
|
|
44958
|
-
* Admin bypass. When true, the middleware skips the scope-access
|
|
44959
|
-
* check entirely. There is no other axis of privilege; the legacy
|
|
44960
|
-
* role enum collapsed onto this boolean in v2.
|
|
44961
|
-
*/
|
|
44962
|
-
isAdmin: boolean().default(false),
|
|
44963
|
-
allowedProviders: AllowedProviderSchema,
|
|
44964
|
-
allowedDevices: AllowedDevicesSchema,
|
|
44965
|
-
/**
|
|
44966
|
-
* Scopes granted to this user. Admins bypass; their `scopes` is
|
|
44967
|
-
* ignored. Non-admins without scopes are locked out of every
|
|
44968
|
-
* protected call.
|
|
44969
|
-
*/
|
|
44970
|
-
scopes: array(TokenScopeSchema).default([]),
|
|
44971
|
-
createdAt: number(),
|
|
44972
|
-
updatedAt: number()
|
|
44973
|
-
});
|
|
44974
|
-
object({
|
|
44975
|
-
id: string(),
|
|
44976
|
-
label: string(),
|
|
44977
|
-
isAdmin: boolean().default(false),
|
|
44978
|
-
allowedProviders: AllowedProviderSchema,
|
|
44979
|
-
allowedDevices: AllowedDevicesSchema,
|
|
44980
|
-
tokenHash: string(),
|
|
44981
|
-
tokenPrefix: string(),
|
|
44982
|
-
createdAt: number(),
|
|
44983
|
-
lastUsedAt: number().optional()
|
|
44984
|
-
});
|
|
44985
|
-
object({
|
|
44986
|
-
id: string(),
|
|
44987
|
-
userId: string(),
|
|
44988
|
-
name: string(),
|
|
44989
|
-
tokenHash: string(),
|
|
44990
|
-
tokenPrefix: string(),
|
|
44991
|
-
scopes: array(TokenScopeSchema),
|
|
44992
|
-
expiresAt: number().nullish(),
|
|
44993
|
-
lastUsedAt: number().nullish(),
|
|
44994
|
-
createdAt: number()
|
|
44995
|
-
});
|
|
44996
|
-
/**
|
|
44997
45030
|
* `oauth-integration` — a collection cap by which an addon declares
|
|
44998
45031
|
* itself a linkable OAuth client of the hub's core `/oauth2/*` server.
|
|
44999
45032
|
* Each provider returns a static descriptor; the core enumerates them
|
|
@@ -24,7 +24,7 @@ var __toESM = (mod, isNodeMode, target) => (target = mod != null ? __create(__ge
|
|
|
24
24
|
enumerable: true
|
|
25
25
|
}) : target, mod));
|
|
26
26
|
//#endregion
|
|
27
|
-
const require_dist = require("../dist-
|
|
27
|
+
const require_dist = require("../dist-DWBNf9hd.js");
|
|
28
28
|
let node_crypto = require("node:crypto");
|
|
29
29
|
require("node:zlib");
|
|
30
30
|
let node_fs = require("node:fs");
|
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import { $ as oauthIntegrationCapability, Bt as EventCategory, C as buildAddonRouteProvider, Et as nodePin, I as deviceExportCapability, It as string, a as COCO_TO_MACRO, bt as BaseAddon, c as FanDirectionSchema, i as CAMERA_SWITCH_ORDER, l as HvacModeSchema, o as CameraSwitchIdSchema, p as addonRoutesCapability, t as AlarmArmModeSchema, u as MediaPlayerRepeatSchema } from "../dist-
|
|
1
|
+
import { $ as oauthIntegrationCapability, Bt as EventCategory, C as buildAddonRouteProvider, Et as nodePin, I as deviceExportCapability, It as string, a as COCO_TO_MACRO, bt as BaseAddon, c as FanDirectionSchema, i as CAMERA_SWITCH_ORDER, l as HvacModeSchema, o as CameraSwitchIdSchema, p as addonRoutesCapability, t as AlarmArmModeSchema, u as MediaPlayerRepeatSchema } from "../dist-DV_2NKnd.mjs";
|
|
2
2
|
import { createHmac, timingSafeEqual } from "node:crypto";
|
|
3
3
|
import "node:zlib";
|
|
4
4
|
import "node:fs";
|