@camstack/types 1.2.575 → 1.2.576

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.
Files changed (34) hide show
  1. package/CHANGELOG.md +12 -0
  2. package/dist/addon.js +1 -1
  3. package/dist/addon.mjs +1 -1
  4. package/dist/automation/action.d.ts +2 -0
  5. package/dist/automation/scheduler.d.ts +2 -0
  6. package/dist/capabilities/action-source.cap.d.ts +1 -0
  7. package/dist/capabilities/actions.cap.d.ts +7 -0
  8. package/dist/capabilities/core-blocks.cap.d.ts +20 -0
  9. package/dist/capabilities/device-manager.cap.d.ts +18 -0
  10. package/dist/capabilities/index.d.ts +3 -1
  11. package/dist/capabilities/schedulers.cap.d.ts +8 -0
  12. package/dist/capabilities/tags.cap.d.ts +123 -0
  13. package/dist/capabilities/template.cap.d.ts +8 -0
  14. package/dist/client.js +685 -678
  15. package/dist/client.mjs +685 -678
  16. package/dist/device/device-management.d.ts +4 -0
  17. package/dist/device-template-catalogue.d.ts +67 -0
  18. package/dist/device-template-catalogue.js +361 -0
  19. package/dist/device-template-catalogue.mjs +346 -0
  20. package/dist/expression/device-template.d.ts +5 -6
  21. package/dist/generated/addon-api.d.ts +43 -0
  22. package/dist/generated/cap-vocabulary.d.ts +1 -1
  23. package/dist/generated/capability-router-map.d.ts +5 -2
  24. package/dist/generated/device-proxy.d.ts +1 -1
  25. package/dist/generated/method-access-map.d.ts +1 -1
  26. package/dist/generated/method-device-selectors.d.ts +2 -2
  27. package/dist/generated/system-proxy.d.ts +2 -0
  28. package/dist/index.d.ts +4 -0
  29. package/dist/index.js +4108 -3872
  30. package/dist/index.mjs +4077 -3873
  31. package/dist/{sleep-CsIzA4m_.js → sleep-BURDyp_n.js} +7 -1
  32. package/dist/{sleep-CLDVTB5R.mjs → sleep-C9EWTQr9.mjs} +7 -1
  33. package/dist/tags/tag.d.ts +56 -0
  34. package/package.json +6 -1
package/dist/client.mjs CHANGED
@@ -1121,512 +1121,6 @@ z.object({
1121
1121
  resolution: CamStreamResolutionSchema.optional()
1122
1122
  });
1123
1123
  //#endregion
1124
- //#region src/device/device-type.ts
1125
- var DeviceType = /* @__PURE__ */ function(DeviceType) {
1126
- DeviceType["Camera"] = "camera";
1127
- DeviceType["Light"] = "light";
1128
- DeviceType["Siren"] = "siren";
1129
- DeviceType["Switch"] = "switch";
1130
- DeviceType["Sensor"] = "sensor";
1131
- /** Every climate device: an air conditioner, a room thermostat, a radiator
1132
- * valve, a floor-heating zone, a heat-pump circuit. They share one set of
1133
- * controls (`climate-control`), so they are one type; WHICH kind of climate
1134
- * device it is is its {@link DeviceRole} (`climate-*`), which the UI and the
1135
- * exports branch on. The retired `thermostat` type is read as this one
1136
- * (`canonicalStoredDeviceType`). */
1137
- DeviceType["Climate"] = "climate";
1138
- DeviceType["Button"] = "button";
1139
- /** Generic stateless event emitter — carries a device's EXACT declared
1140
- * event vocabulary verbatim (no normalization). Installed with the
1141
- * `event-emitter` cap. Sources: HA `event.*` entities (structured) and
1142
- * HA bus events (e.g. `zha_event`, generic). */
1143
- DeviceType["EventEmitter"] = "event-emitter";
1144
- /** Firmware/software update entity — current vs available version,
1145
- * updatable flag, update state, and an install action. Installed with
1146
- * the `update` cap. Sources: Homematic firmware-update channels (and
1147
- * reusable by other providers, e.g. HA `update.*` entities). */
1148
- DeviceType["Update"] = "update";
1149
- DeviceType["Generic"] = "generic";
1150
- /** Generic notification delivery target (HA `notify.<service>`, future
1151
- * Telegram / Discord / ntfy / SMTP, …). One device per delivery
1152
- * endpoint; the `notifier` cap defines the send surface. */
1153
- DeviceType["Notifier"] = "notifier";
1154
- /** Pre-recorded action sequence with optional parameters
1155
- * (HA `script.*`). Runnable via `script-runner` cap. */
1156
- DeviceType["Script"] = "script";
1157
- /** Automation rule (HA `automation.*`) — enable/disable + manual
1158
- * trigger surface exposed via `automation-control` cap. */
1159
- DeviceType["Automation"] = "automation";
1160
- /** Door / smart lock device (HA `lock.*`). `lock-control` cap. */
1161
- DeviceType["Lock"] = "lock";
1162
- /** Window covering, blinds, garage door, valve, etc. (HA `cover.*`,
1163
- * `valve.*`). `cover` cap with sub-roles for variant. */
1164
- DeviceType["Cover"] = "cover";
1165
- /** Pipe / water / gas valve with open/close/stop and optional
1166
- * position (HA `valve.*`). `valve` cap — a cover-sibling actuator
1167
- * modelled on the same open/closed lifecycle. */
1168
- DeviceType["Valve"] = "valve";
1169
- /** Humidifier / dehumidifier with on/off + target humidity + mode
1170
- * (HA `humidifier.*`). `humidifier` cap — a climate-family actuator
1171
- * modelled on the same target / mode lifecycle. */
1172
- DeviceType["Humidifier"] = "humidifier";
1173
- /** Water heater / boiler with target temperature + operation mode +
1174
- * away mode (HA `water_heater.*`). `water-heater` cap — a
1175
- * climate-family actuator. */
1176
- DeviceType["WaterHeater"] = "water-heater";
1177
- /** Ceiling / standing / exhaust fan (HA `fan.*`). `fan-control` cap. */
1178
- DeviceType["Fan"] = "fan";
1179
- /** Audio / video playback endpoint (HA `media_player.*`). Disjoint from
1180
- * the camera surface — those use `Camera`. `media-player` cap. */
1181
- DeviceType["MediaPlayer"] = "media-player";
1182
- /** Security panel / alarm system (HA `alarm_control_panel.*`).
1183
- * `alarm-panel` cap. */
1184
- DeviceType["AlarmPanel"] = "alarm-panel";
1185
- /** Generic user-settable input (HA `number` / `input_number` / `select`
1186
- * / `input_select` / `text` / `input_text` / `input_datetime`).
1187
- * Sub-type via `DeviceRole`: NumericControl / SelectControl /
1188
- * TextControl / DateTimeControl. */
1189
- DeviceType["Control"] = "control";
1190
- /** Person / device-tracker presence (HA `person.*`, `device_tracker.*`).
1191
- * `presence` cap. */
1192
- DeviceType["Presence"] = "presence";
1193
- /** Weather provider (HA `weather.*`). Tier-3, low MVP priority.
1194
- * `weather` cap. */
1195
- DeviceType["Weather"] = "weather";
1196
- /** A physical weather station (Ecowitt outdoor array). `weather-station`
1197
- * cap. Distinct from {@link Weather}, which is a forecast provider. */
1198
- DeviceType["WeatherStation"] = "weather-station";
1199
- /** Robot vacuum (HA `vacuum.*`). Tier-3. `vacuum-control` cap. */
1200
- DeviceType["Vacuum"] = "vacuum";
1201
- /** Robotic lawn mower (HA `lawn_mower.*`). Tier-3.
1202
- * `lawn-mower-control` cap. */
1203
- DeviceType["LawnMower"] = "lawn-mower";
1204
- /** Physical HA device group — parent container for entity-children
1205
- * adopted from a single HA device entry. Not renderable as a
1206
- * standalone device; exists only to anchor child entities. */
1207
- DeviceType["Container"] = "container";
1208
- /** Single still-image entity (HA `image.*`). Read-only display of an
1209
- * `entity_picture` signed URL the browser loads directly. `image` cap. */
1210
- DeviceType["Image"] = "image";
1211
- /** Smart pet feeder — cloud-connected food dispenser with a bowl food
1212
- * level, battery, desiccant life, feeding state and manual-feed /
1213
- * call-pet / maintenance actions. Installed with the `pet-feeder` cap;
1214
- * dual-hopper models (D4S/D4SH) expose per-hopper portions. Sources:
1215
- * native PetKit (`nodepetkit` `FeederDevice`), reusable by other feeder
1216
- * integrations sharing the same food/desiccant/hopper surface. */
1217
- DeviceType["PetFeeder"] = "pet-feeder";
1218
- /** Pet water fountain — tank level, water drunk, pump and its duty cycle.
1219
- * Installed with the `pet-fountain` cap. Reaches CamStack as loose entities
1220
- * of a container and is BUILT as a composed device (D967). */
1221
- DeviceType["PetFountain"] = "pet-fountain";
1222
- /** Built-in dishwasher — program lifecycle, door / remote-start gates,
1223
- * salt and rinse-aid levels. Installed with the `dishwasher` cap.
1224
- * Sources: native Bosch Home Connect, reusable by similar integrations.
1225
- * A plug-built dishwasher carries running-state and power instead. */
1226
- DeviceType["Dishwasher"] = "dishwasher";
1227
- /** Washing machine. A plug-built one is running while its power stays
1228
- * above a threshold. No program cap — that surface is the dishwasher's. */
1229
- DeviceType["Washer"] = "washer";
1230
- /** Tumble dryer. Same plug-built running surface as {@link Washer}. */
1231
- DeviceType["Dryer"] = "dryer";
1232
- /** The physical bridge box of a vendor ecosystem (Velux KLF-200, and later
1233
- * other radio-to-IP bridges). It carries the box's own facts (firmware,
1234
- * address, connection state) and the actions the box really supports
1235
- * (`reboot`, `device-admin-link`). Products are NOT its children — they are
1236
- * adopted beside it — and its connection settings stay on the integration. */
1237
- DeviceType["Gateway"] = "gateway";
1238
- /** A heat pump (any vendor): the compressor unit with its circuits (heating, hot
1239
- * water, cooling, solar), its system modes and its power. One main read-only
1240
- * `heat-pump-status` cap carries all of it; `heat-pump-control` sets it (D1026). */
1241
- DeviceType["HeatPump"] = "heat-pump";
1242
- /** A home energy installation (any vendor): solar, grid, house, a metered heat pump
1243
- * and the storage as branches of one bus. One read-only `energy-system` cap carries
1244
- * every value; the storage is a field of it, never the `battery` cap (#513, #522). */
1245
- DeviceType["EnergySystem"] = "energy-system";
1246
- return DeviceType;
1247
- }({});
1248
- /**
1249
- * Semantic role a device plays within its parent. Populated by driver
1250
- * addons when creating accessory devices (Reolink siren/floodlight/
1251
- * PIR/chime/autotrack/doorbell, ONVIF relay outputs, …). Used by the
1252
- * admin UI to pick icons, labels, and widgets — a `Switch` with
1253
- * `role: Floodlight` renders as a bulb with a brightness slider,
1254
- * whereas a `Switch` with `role: Siren` renders as a klaxon.
1255
- *
1256
- * Undefined for top-level devices (cameras, NVRs, hubs). Persisted in
1257
- * sqlite as a nullable TEXT column — old rows keep working unchanged.
1258
- */
1259
- var DeviceRole = /* @__PURE__ */ function(DeviceRole) {
1260
- DeviceRole["Siren"] = "siren";
1261
- DeviceRole["Floodlight"] = "floodlight";
1262
- DeviceRole["Spotlight"] = "spotlight";
1263
- DeviceRole["PirSensor"] = "pir-sensor";
1264
- DeviceRole["Chime"] = "chime";
1265
- DeviceRole["Autotrack"] = "autotrack";
1266
- DeviceRole["Nightvision"] = "nightvision";
1267
- DeviceRole["PrivacyMask"] = "privacy-mask";
1268
- DeviceRole["Doorbell"] = "doorbell";
1269
- /** Interior blind / shade / roller blind. HA `device_class: blind|shade`. */
1270
- DeviceRole["CoverBlind"] = "cover-blind";
1271
- /** Exterior roller shutter. HA `device_class: shutter`; Homematic BROLL. */
1272
- DeviceRole["CoverShutter"] = "cover-shutter";
1273
- /** Exterior awning. HA `device_class: awning`. */
1274
- DeviceRole["CoverAwning"] = "cover-awning";
1275
- /** Curtain / drape. HA `device_class: curtain`. */
1276
- DeviceRole["CoverCurtain"] = "cover-curtain";
1277
- /** Garage door. HA `device_class: garage`. A security actuator: exports gate it. */
1278
- DeviceRole["CoverGarage"] = "cover-garage";
1279
- /** Gate. HA `device_class: gate`. A security actuator: exports gate it. */
1280
- DeviceRole["CoverGate"] = "cover-gate";
1281
- /** Door. HA `device_class: door`. A security actuator: exports gate it. */
1282
- DeviceRole["CoverDoor"] = "cover-door";
1283
- /** Window. HA `device_class: window`. */
1284
- DeviceRole["CoverWindow"] = "cover-window";
1285
- /** Virtual HA toggle (input_boolean.*) — distinguishable from a
1286
- * real Switch device for UI rendering / export adapters. */
1287
- DeviceRole["BinaryHelper"] = "binary-helper";
1288
- /** A smart plug: a `switch` whose source says it is an outlet (HA
1289
- * `device_class: outlet`). The Alexa export shows it as a SMARTPLUG. */
1290
- DeviceRole["Outlet"] = "outlet";
1291
- /** A dumb plug-in stove or heater behind a switch: it runs only while the
1292
- * switch is on. Offered `timed-run`, which switches it off again after a
1293
- * chosen time. */
1294
- DeviceRole["SwitchHeater"] = "switch-heater";
1295
- /** A plain fan behind a switch (a smart plug powering it): drawn as a fan,
1296
- * with the switch's on/off only. Speed or oscillation appear only when the
1297
- * device also has a fan cap (D1033). */
1298
- DeviceRole["SwitchFan"] = "switch-fan";
1299
- /** A relay driving an on/off-only lamp: drawn as a light (bulb and glow, no
1300
- * slider), presented to the exports as a light with power only. Not a
1301
- * `light` type: the provider owns the type, and a light implies brightness
1302
- * or colour this relay lacks. */
1303
- DeviceRole["SwitchLight"] = "switch-light";
1304
- /** Air conditioner / split unit: cooling, fan speed, louvres. */
1305
- DeviceRole["ClimateAc"] = "climate-ac";
1306
- /** Room thermostat: a setpoint and a room temperature. The default. */
1307
- DeviceRole["ClimateThermostat"] = "climate-thermostat";
1308
- /** Floor-heating zone actuator. */
1309
- DeviceRole["ClimateFloor"] = "climate-floor";
1310
- /** Radiator valve (thermostatic radiator head). */
1311
- DeviceRole["ClimateRadiator"] = "climate-radiator";
1312
- /** A heater with its own thermostat (stove, convector). */
1313
- DeviceRole["ClimateHeater"] = "climate-heater";
1314
- /** One heating/cooling circuit of a heat pump: a water loop with comfort /
1315
- * eco setpoints and a heat/cool mode, no room sensor. */
1316
- DeviceRole["ClimateHeatPumpCircuit"] = "climate-heat-pump-circuit";
1317
- /** Generic motion / occupancy / moving event source. Distinct from
1318
- * the camera accessory PirSensor role: that one is a camera child;
1319
- * this is a standalone HA / 3rd-party motion sensor. */
1320
- DeviceRole["MotionSensor"] = "motion-sensor";
1321
- DeviceRole["ContactSensor"] = "contact-sensor";
1322
- DeviceRole["LeakSensor"] = "leak-sensor";
1323
- DeviceRole["SmokeSensor"] = "smoke-sensor";
1324
- DeviceRole["COSensor"] = "co-sensor";
1325
- DeviceRole["GasSensor"] = "gas-sensor";
1326
- DeviceRole["TamperSensor"] = "tamper-sensor";
1327
- DeviceRole["VibrationSensor"] = "vibration-sensor";
1328
- DeviceRole["ConnectivitySensor"] = "connectivity-sensor";
1329
- DeviceRole["SoundSensor"] = "sound-sensor";
1330
- /** Fallback for `binary_sensor` without a known `device_class`. */
1331
- DeviceRole["BinarySensor"] = "binary-sensor";
1332
- DeviceRole["TemperatureSensor"] = "temperature-sensor";
1333
- DeviceRole["HumiditySensor"] = "humidity-sensor";
1334
- DeviceRole["AmbientLightSensor"] = "ambient-light-sensor";
1335
- DeviceRole["PressureSensor"] = "pressure-sensor";
1336
- /** Wind speed or direction (weather-station `wind-sensor` cap). */
1337
- DeviceRole["WindSensor"] = "wind-sensor";
1338
- /** Rain accumulation or rate (weather-station `rain-sensor` cap). */
1339
- DeviceRole["RainSensor"] = "rain-sensor";
1340
- /** UV index (weather-station `uv-sensor` cap). */
1341
- DeviceRole["UvSensor"] = "uv-sensor";
1342
- /** Solar irradiance W/m² (weather-station `solar-radiation-sensor` cap).
1343
- * Distinct from AmbientLightSensor (lux). */
1344
- DeviceRole["SolarRadiationSensor"] = "solar-radiation-sensor";
1345
- /** Soil moisture % (garden/weather `soil-moisture-sensor` cap). */
1346
- DeviceRole["SoilMoistureSensor"] = "soil-moisture-sensor";
1347
- DeviceRole["PowerSensor"] = "power-sensor";
1348
- DeviceRole["EnergySensor"] = "energy-sensor";
1349
- DeviceRole["VoltageSensor"] = "voltage-sensor";
1350
- DeviceRole["CurrentSensor"] = "current-sensor";
1351
- DeviceRole["AirQualitySensor"] = "air-quality-sensor";
1352
- /** Battery level (numeric % via `sensor` OR low-bool via
1353
- * `binary_sensor` — the cap distinguishes via the value type). */
1354
- DeviceRole["BatterySensor"] = "battery-sensor";
1355
- /** Fallback for `sensor` numeric without a known `device_class`. */
1356
- DeviceRole["NumericSensor"] = "numeric-sensor";
1357
- /** String / enum state (HA `sensor` with `state_class: enum` or
1358
- * `attributes.options`). */
1359
- DeviceRole["EnumSensor"] = "enum-sensor";
1360
- /** Date / timestamp state (HA `sensor` with `device_class: timestamp`
1361
- * or `date`). The slice carries the raw ISO string verbatim (hosted on
1362
- * the `enum-sensor` cap); the UI renders it locale-formatted. */
1363
- DeviceRole["DateTimeSensor"] = "datetime-sensor";
1364
- /** Last-resort fallback when nothing else matches. */
1365
- DeviceRole["GenericSensor"] = "generic-sensor";
1366
- DeviceRole["NumericControl"] = "numeric-control";
1367
- DeviceRole["SelectControl"] = "select-control";
1368
- DeviceRole["TextControl"] = "text-control";
1369
- DeviceRole["DateTimeControl"] = "datetime-control";
1370
- /** Mobile push notifier (HA `notify.mobile_app_*`) — supports
1371
- * rich features (image, priority, channel routing). */
1372
- DeviceRole["MobilePushNotifier"] = "mobile-push-notifier";
1373
- /** Chat / messaging service (HA `notify.telegram_*`,
1374
- * `notify.discord_*`, etc.). */
1375
- DeviceRole["MessagingNotifier"] = "messaging-notifier";
1376
- /** Email-based delivery (HA `notify.smtp`, etc.). */
1377
- DeviceRole["EmailNotifier"] = "email-notifier";
1378
- /** Fallback when the notifier service name doesn't match a known
1379
- * pattern. */
1380
- DeviceRole["GenericNotifier"] = "generic-notifier";
1381
- /** Emits a pulse train (infrared or RF) on request — the `ir-transmitter`
1382
- * cap. A `DeviceType.Generic` device. */
1383
- DeviceRole["IrTransmitter"] = "ir-transmitter";
1384
- return DeviceRole;
1385
- }({});
1386
- z.enum(["new-session", "step-up"]);
1387
- z.enum(["en", "it"]);
1388
- /** How a native app starts one login method (D858), as `auth.listLoginMethods` reports it. */
1389
- var AppLoginPathSchema = z.discriminatedUnion("kind", [z.object({ kind: z.literal("native") }), z.object({
1390
- kind: z.literal("browser"),
1391
- startPath: z.string().startsWith("/")
1392
- })]);
1393
- //#endregion
1394
- //#region src/auth/device-certificate.ts
1395
- /**
1396
- * Device certificates (D855) — the wire contract shared by the hub, the admin
1397
- * UI and the native viewer.
1398
- *
1399
- * A device (a phone) generates its OWN P-256 key pair in hardware (Secure
1400
- * Enclave / Android Keystore / a non-extractable WebCrypto key). The private
1401
- * key never travels. The hub signs the PUBLIC key into an X.509 leaf under a
1402
- * dedicated device CA; the device later proves possession of the key by
1403
- * signing a hub-issued nonce, and the hub answers with the same session a
1404
- * password login opens.
1405
- *
1406
- * Everything on the wire is a small string (a PEM, a base64url signature):
1407
- * D613 is about bulk bytes, and a certificate is ~600 bytes.
1408
- */
1409
- /** Signature algorithm of every device credential: ECDSA, curve P-256, SHA-256. */
1410
- var DEVICE_CERT_SIGNATURE = "ecdsa-p256-sha256";
1411
- /** First line of every signed message; a change of format bumps the version. */
1412
- var DEVICE_SIGNATURE_MESSAGE_VERSION = "camstack-device-cert-v1";
1413
- z.enum([
1414
- "login",
1415
- "renew",
1416
- "revoke"
1417
- ]);
1418
- var DEVICE_CERT_RENEW_WINDOW_DAYS = 30;
1419
- /**
1420
- * The exact bytes a device signs (UTF-8, `\n` separators, no trailing newline):
1421
- *
1422
- * camstack-device-cert-v1
1423
- * <login|renew>
1424
- * <origin> the hub origin returned by `getDeviceChallenge`
1425
- * <nonce>
1426
- *
1427
- * The origin is part of the message so a signature collected by a look-alike
1428
- * hub is worthless on the real one; the hub additionally binds the nonce to
1429
- * the origin it issued it for and refuses any other.
1430
- */
1431
- function buildDeviceSignatureMessage(input) {
1432
- return [
1433
- DEVICE_SIGNATURE_MESSAGE_VERSION,
1434
- input.purpose,
1435
- input.origin,
1436
- input.nonce
1437
- ].join("\n");
1438
- }
1439
- /** The deep link a QR carries: `camstack://enroll?hub=<origin>&code=<code>`. */
1440
- function buildDeviceEnrollmentLink(input) {
1441
- const query = new URLSearchParams();
1442
- if (input.hub !== void 0) query.set("hub", input.hub);
1443
- query.set("code", input.code);
1444
- return `${input.scheme ?? "camstack"}://enroll?${query.toString()}`;
1445
- }
1446
- /** Parse an enrollment deep link; `null` when it is not one. `hub` is absent when the link names none. */
1447
- function parseDeviceEnrollmentLink(raw) {
1448
- let url;
1449
- try {
1450
- url = new URL(raw);
1451
- } catch {
1452
- return null;
1453
- }
1454
- if (url.protocol !== "camstack:" && url.protocol !== "camstack.dev:") return null;
1455
- if (url.hostname !== "enroll") return null;
1456
- const code = url.searchParams.get("code");
1457
- if (code === null || code === "") return null;
1458
- const hub = url.searchParams.get("hub");
1459
- return {
1460
- hub: hub === null || hub === "" ? null : hub,
1461
- code
1462
- };
1463
- }
1464
- var DevicePlatformSchema = z.enum([
1465
- "ios",
1466
- "android",
1467
- "web",
1468
- "other"
1469
- ]);
1470
- var Base64UrlSchema = z.string().min(1).max(4096).regex(/^[A-Za-z0-9_-]+$/);
1471
- var PemSchema = z.string().min(1).max(16384);
1472
- /**
1473
- * Why a device-certificate endpoint said no. Distinct from a transport / 5xx
1474
- * failure: those carry no reason and mean "try again", never "the credential is
1475
- * dead". The viewer switches on this exhaustively.
1476
- */
1477
- var DeviceRefusalReasonSchema = z.enum([
1478
- "revoked",
1479
- "unknown-credential",
1480
- "expired",
1481
- "bad-signature",
1482
- "nonce-invalid",
1483
- "rate-limited",
1484
- "invalid-certificate",
1485
- "superseded",
1486
- "user-gone",
1487
- "unavailable",
1488
- "code-invalid",
1489
- "self-enrollment-disabled",
1490
- "step-up-required",
1491
- "bad-public-key"
1492
- ]);
1493
- /** The only answers after which the app may count towards deleting its credential. */
1494
- var DEFINITIVE_DEVICE_REFUSALS = [
1495
- "revoked",
1496
- "unknown-credential",
1497
- "user-gone"
1498
- ];
1499
- /** Consecutive DEFINITIVE answers before the app deletes its key and certificate. */
1500
- var DEVICE_DEFINITIVE_REFUSALS_BEFORE_DELETE = 3;
1501
- function isDefinitiveDeviceRefusal(reason) {
1502
- return DEFINITIVE_DEVICE_REFUSALS.includes(reason);
1503
- }
1504
- var DeviceRefusalSchema = z.object({
1505
- ok: z.literal(false),
1506
- reason: DeviceRefusalReasonSchema,
1507
- definitive: z.boolean(),
1508
- retryAfterSeconds: z.number().optional()
1509
- });
1510
- /**
1511
- * A credential-bound session that can no longer refresh answers
1512
- * `auth.refreshSession` with UNAUTHORIZED whose message is this prefix + the
1513
- * reason; {@link deviceRefusalFromMessage} reads it back.
1514
- */
1515
- var DEVICE_REFRESH_REFUSAL_PREFIX = "device-credential:";
1516
- function deviceRefusalFromMessage(message) {
1517
- if (!message.startsWith("device-credential:")) return null;
1518
- const parsed = DeviceRefusalReasonSchema.safeParse(message.slice(18));
1519
- return parsed.success ? parsed.data : null;
1520
- }
1521
- z.object({
1522
- code: z.string().min(1).max(256),
1523
- /** SubjectPublicKeyInfo DER of the device's P-256 public key, base64url. */
1524
- publicKeySpki: Base64UrlSchema,
1525
- deviceName: z.string().min(1).max(80).optional(),
1526
- platform: DevicePlatformSchema
1527
- });
1528
- var CompleteEnrollmentOutputSchema = z.object({
1529
- credentialId: z.string(),
1530
- certPem: PemSchema,
1531
- /** The device CA certificate the leaf chains to. */
1532
- chainPem: PemSchema,
1533
- notAfter: z.number(),
1534
- user: z.object({
1535
- id: z.string(),
1536
- username: z.string()
1537
- })
1538
- });
1539
- z.discriminatedUnion("ok", [CompleteEnrollmentOutputSchema.extend({ ok: z.literal(true) }), DeviceRefusalSchema]);
1540
- z.object({
1541
- /** The single-use step-up proof (`auth.deviceEnrollProofFrom…`). */
1542
- proof: z.string().min(1).max(512),
1543
- publicKeySpki: Base64UrlSchema,
1544
- deviceName: z.string().min(1).max(80),
1545
- platform: DevicePlatformSchema
1546
- });
1547
- z.object({
1548
- proof: z.string(),
1549
- expiresAt: z.number()
1550
- });
1551
- var DeviceChallengeSchema = z.object({
1552
- nonce: z.string(),
1553
- /** The origin to put in the signed message. The app compares it to the hub it dialled. */
1554
- origin: z.string(),
1555
- expiresAt: z.number(),
1556
- signature: z.literal(DEVICE_CERT_SIGNATURE)
1557
- });
1558
- z.discriminatedUnion("ok", [DeviceChallengeSchema.extend({ ok: z.literal(true) }), DeviceRefusalSchema]);
1559
- z.object({
1560
- certPem: PemSchema,
1561
- nonce: z.string().min(1).max(256),
1562
- /** ECDSA P-256 SHA-256 over {@link buildDeviceSignatureMessage}; raw r||s or DER, base64url. */
1563
- signature: Base64UrlSchema
1564
- });
1565
- var RenewDeviceCertificateOutputSchema = z.object({
1566
- credentialId: z.string(),
1567
- certPem: PemSchema,
1568
- chainPem: PemSchema,
1569
- notAfter: z.number()
1570
- });
1571
- z.discriminatedUnion("ok", [RenewDeviceCertificateOutputSchema.extend({ ok: z.literal(true) }), DeviceRefusalSchema]);
1572
- z.discriminatedUnion("ok", [z.object({
1573
- ok: z.literal(true),
1574
- credentialId: z.string(),
1575
- sessionsEnded: z.number().int()
1576
- }), DeviceRefusalSchema]);
1577
- var DeviceCredentialStatusSchema = z.enum([
1578
- "active",
1579
- "expired",
1580
- "revoked"
1581
- ]);
1582
- z.object({
1583
- id: z.string(),
1584
- userId: z.string(),
1585
- username: z.string().nullable(),
1586
- deviceName: z.string(),
1587
- platform: DevicePlatformSchema,
1588
- enrolledVia: z.enum(["qr", "self"]),
1589
- /** SHA-256 of the leaf certificate DER, colon-hex. */
1590
- fingerprint: z.string(),
1591
- issuedAt: z.number(),
1592
- expiresAt: z.number(),
1593
- lastUsedAt: z.number().nullable(),
1594
- lastUsedFrom: z.string().nullable(),
1595
- revokedAt: z.number().nullable(),
1596
- /** `admin:<userId>` | `user:<userId>` | `device` | `user-deleted`. */
1597
- revokedBy: z.string().nullable(),
1598
- status: DeviceCredentialStatusSchema
1599
- });
1600
- z.object({
1601
- /** Shown once; only its hash is kept. */
1602
- code: z.string(),
1603
- expiresAt: z.number(),
1604
- /** `camstack://enroll?hub=…&code=…` — what the QR encodes. */
1605
- enrollUrl: z.string(),
1606
- /** The hub origin in the link, or `null` when the hub could not name one (the link then has no `hub`). */
1607
- hubOrigin: z.string().nullable(),
1608
- /** Every origin the apps may try (role `appConnections`). */
1609
- hubOrigins: z.array(z.string())
1610
- });
1611
- z.object({
1612
- kind: z.literal("device-certificate"),
1613
- id: z.literal("device-certificate"),
1614
- label: z.string(),
1615
- stage: z.literal("primary"),
1616
- /** tRPC paths under the hub's `auth` router, so a client names no literal. */
1617
- challengePath: z.literal("auth.getDeviceChallenge"),
1618
- revokePath: z.literal("auth.revokeOwnDeviceCertificate"),
1619
- enrollSelfPath: z.literal("auth.enrollSelf"),
1620
- loginPath: z.literal("auth.loginWithDeviceCertificate"),
1621
- renewPath: z.literal("auth.renewDeviceCertificate"),
1622
- signature: z.literal(DEVICE_CERT_SIGNATURE),
1623
- messageVersion: z.literal(DEVICE_SIGNATURE_MESSAGE_VERSION),
1624
- /** Which clients can execute it: a native app silently, a browser with a non-extractable WebCrypto key. */
1625
- clients: z.array(z.enum(["native", "web"])),
1626
- /** The app executes it itself, silently (D858). */
1627
- app: AppLoginPathSchema.nullable()
1628
- });
1629
- //#endregion
1630
1124
  //#region src/device/icon-catalog.generated.ts
1631
1125
  /** Lucide category ids, alphabetical. `ICON_META` indexes into this. */
1632
1126
  var ICON_CATEGORY_IDS = [
@@ -21448,197 +20942,703 @@ var ICON_SYNONYMS = {
21448
20942
  ]
21449
20943
  };
21450
20944
  /**
21451
- * Spellings an operator may already have PERSISTED that no lucide package
21452
- * accepts any more, and the catalog key they draw. They resolve
21453
- * (`canonicalIconKey`) but are never offered. `gauge2` was this repo's own
21454
- * pre-catalog spelling of `gauge`.
20945
+ * Spellings an operator may already have PERSISTED that no lucide package
20946
+ * accepts any more, and the catalog key they draw. They resolve
20947
+ * (`canonicalIconKey`) but are never offered. `gauge2` was this repo's own
20948
+ * pre-catalog spelling of `gauge`.
20949
+ */
20950
+ var LEGACY_ICON_ALIASES = { gauge2: "gauge" };
20951
+ //#endregion
20952
+ //#region src/device/icon-catalog.ts
20953
+ /**
20954
+ * icon-catalog — THE icon vocabulary (D854).
20955
+ *
20956
+ * Every place that picks or stores an icon — a device's display override, a
20957
+ * location, a site zone, a viewer accessory, an `icon` settings field — names
20958
+ * it by a key of this catalog and nothing else. There is no curated subset and
20959
+ * no second list: the catalog is every lucide icon that both surfaces can draw
20960
+ * (the admin UI's `lucide-react` and the viewer's `lucide-react-native`), the
20961
+ * intersection computed by `scripts/generate-icon-catalog.ts` into the
20962
+ * committed `icon-catalog.generated.ts`.
20963
+ *
20964
+ * Like the vocabularies it replaces, this module holds STRINGS only — no React,
20965
+ * no lucide import, no glyph. Each surface owns its glyph table (the web one
20966
+ * lives in `ui-library`, loaded lazily), and a test on each side pins that it
20967
+ * covers {@link ICON_KEYS}.
20968
+ *
20969
+ * ## What is persisted
20970
+ *
20971
+ * The canonical kebab-case lucide id ({@link IconKey}). Spellings that a lucide
20972
+ * package still accepts (`home` for `house`) and this repo's own legacy ones
20973
+ * (`gauge2`) RESOLVE ({@link canonicalIconKey}) so a stored value never goes
20974
+ * stale, but they are never OFFERED by search.
20975
+ *
20976
+ * ## Search
20977
+ *
20978
+ * Over the key, the Italian/English overlay in `icon-synonyms.ts`, any words
20979
+ * the caller adds, and lucide's English tags — in that order of weight.
20980
+ */
20981
+ var KEY_SET$1 = new Set(ICON_KEYS);
20982
+ var ALIAS_TO_KEY = new Map([...Object.entries(ICON_ALIASES), ...Object.entries(LEGACY_ICON_ALIASES)]);
20983
+ /** Is this a canonical key of the catalog? (An alias is not — see {@link canonicalIconKey}.) */
20984
+ function isIconKey(value) {
20985
+ return typeof value === "string" && KEY_SET$1.has(value);
20986
+ }
20987
+ /**
20988
+ * A stored value as a catalog key: the key itself, the key a still-accepted or
20989
+ * legacy spelling stands for, or `undefined` — never a guess.
20990
+ */
20991
+ function canonicalIconKey(value) {
20992
+ if (typeof value !== "string") return void 0;
20993
+ if (isIconKey(value)) return value;
20994
+ return ALIAS_TO_KEY.get(value);
20995
+ }
20996
+ /**
20997
+ * A stored icon value as a catalog key: its canonical key when it is (or
20998
+ * aliases) one, `fallback` otherwise. For an `icon` settings field whose stored
20999
+ * value may predate the catalog (a free-text lucide name) — the field's default
21000
+ * is drawn rather than nothing.
21001
+ */
21002
+ function resolveIconKey(value, fallback) {
21003
+ return canonicalIconKey(value) ?? fallback;
21004
+ }
21005
+ /**
21006
+ * Wire/storage schema for one icon key.
21007
+ *
21008
+ * Deliberately NOT a `z.enum` of the catalog: ~1,700 literals would be inlined
21009
+ * into every cap router, type and API-reference row that carries an icon. The
21010
+ * check is membership in the catalog and the type is {@link IconKey}.
21011
+ */
21012
+ var IconKeySchema = z.custom(isIconKey, "Not an icon of the catalog");
21013
+ var ENTRIES = ICON_KEYS.map((key, index) => {
21014
+ const [categoryIndexes, tags] = ICON_META[index] ?? [[], []];
21015
+ const categories = categoryIndexes.flatMap((i) => {
21016
+ const id = ICON_CATEGORY_IDS[i];
21017
+ return id === void 0 ? [] : [id];
21018
+ });
21019
+ return {
21020
+ key,
21021
+ categories,
21022
+ primaryCategory: categories[0] ?? ICON_CATEGORY_IDS[0],
21023
+ tags,
21024
+ synonyms: ICON_SYNONYMS[key] ?? []
21025
+ };
21026
+ });
21027
+ var ENTRY_BY_KEY = new Map(ENTRIES.map((e) => [e.key, e]));
21028
+ /** The entry for a canonical key, or `undefined`. */
21029
+ function iconEntry(key) {
21030
+ return ENTRY_BY_KEY.get(key);
21031
+ }
21032
+ /** Every entry, in key order. */
21033
+ var ICON_ENTRIES = ENTRIES;
21034
+ /** Categories a picker offers first: the ones this product's icons mostly live in. */
21035
+ var LEADING_CATEGORIES = [
21036
+ "devices",
21037
+ "home",
21038
+ "security",
21039
+ "buildings",
21040
+ "connectivity",
21041
+ "multimedia",
21042
+ "nature",
21043
+ "weather",
21044
+ "transportation",
21045
+ "animals"
21046
+ ];
21047
+ var PRIMARY_CATEGORIES = new Set(ENTRIES.map((e) => e.primaryCategory));
21048
+ /**
21049
+ * The categories a picker files icons under, in picker order: the leading ones,
21050
+ * then the rest alphabetically. Only categories that are some icon's PRIMARY
21051
+ * one — a category lucide lists only as a secondary has no section of its own.
21455
21052
  */
21456
- var LEGACY_ICON_ALIASES = { gauge2: "gauge" };
21053
+ var ICON_CATEGORIES = [...LEADING_CATEGORIES, ...ICON_CATEGORY_IDS.filter((c) => !LEADING_CATEGORIES.includes(c))].filter((c) => PRIMARY_CATEGORIES.has(c));
21054
+ /** The icons filed under a category as their PRIMARY one, in key order. */
21055
+ function iconsInCategory(category) {
21056
+ return ENTRIES.filter((e) => e.primaryCategory === category);
21057
+ }
21058
+ function normalise(text) {
21059
+ return text.normalize("NFD").replace(/\p{Diacritic}/gu, "").toLowerCase().replace(/[_-]+/g, " ").trim();
21060
+ }
21061
+ /** Does `needle` appear in `haystack` in order, though not adjacently? */
21062
+ function isSubsequence(needle, haystack) {
21063
+ let i = 0;
21064
+ for (const ch of haystack) {
21065
+ if (ch === needle[i]) i += 1;
21066
+ if (i === needle.length) return true;
21067
+ }
21068
+ return needle.length === 0;
21069
+ }
21070
+ /**
21071
+ * How well one word answers the query. 0 = not at all. An exact word beats a
21072
+ * prefix, a prefix beats a word STARTING inside the phrase, and a loose
21073
+ * subsequence comes last because it matches almost anything.
21074
+ */
21075
+ function scoreWord(query, word, loose) {
21076
+ if (word === query) return 100;
21077
+ if (word.startsWith(query)) return 80;
21078
+ if (word.split(" ").some((w) => w.startsWith(query))) return 60;
21079
+ if (word.includes(query)) return 40;
21080
+ if (loose && isSubsequence(query, word)) return 15;
21081
+ return 0;
21082
+ }
21083
+ var WORDS_CACHE = /* @__PURE__ */ new Map();
21084
+ /** Normalised once per entry — search runs on every keystroke over ~1,700 entries. */
21085
+ function wordsOf(entry) {
21086
+ const cached = WORDS_CACHE.get(entry.key);
21087
+ if (cached !== void 0) return cached;
21088
+ const built = {
21089
+ key: normalise(entry.key),
21090
+ synonyms: entry.synonyms.map(normalise),
21091
+ tags: entry.tags.map(normalise)
21092
+ };
21093
+ WORDS_CACHE.set(entry.key, built);
21094
+ return built;
21095
+ }
21096
+ /**
21097
+ * Rank the catalog against a free-text query.
21098
+ *
21099
+ * An empty query returns the WHOLE catalog in key order, because a picker's
21100
+ * resting state is the full list. `extraWords` lets a caller add the words IT
21101
+ * can translate without this module knowing what a locale is; they score like a
21102
+ * synonym. The key outranks a synonym, a synonym outranks a lucide tag, and
21103
+ * ties keep key order so the list does not reshuffle between keystrokes.
21104
+ */
21105
+ function searchIcons(query, extraWords) {
21106
+ const q = normalise(query);
21107
+ if (q.length === 0) return ENTRIES.map((entry) => ({
21108
+ entry,
21109
+ score: 0
21110
+ }));
21111
+ const hits = [];
21112
+ for (const entry of ENTRIES) {
21113
+ const words = wordsOf(entry);
21114
+ const keyScore = scoreWord(q, words.key, true);
21115
+ let best = keyScore > 0 ? keyScore + 2 : 0;
21116
+ for (const word of [...words.synonyms, ...(extraWords?.get(entry.key) ?? []).map(normalise)]) {
21117
+ const score = scoreWord(q, word, true);
21118
+ if (score > 0 && score + 1 > best) best = score + 1;
21119
+ }
21120
+ for (const word of words.tags) {
21121
+ const score = scoreWord(q, word, false);
21122
+ if (score > best) best = score;
21123
+ }
21124
+ if (best > 0) hits.push({
21125
+ entry,
21126
+ score: best
21127
+ });
21128
+ }
21129
+ return hits.toSorted((a, b) => b.score - a.score);
21130
+ }
21131
+ /** A readable label derived from a lucide category id (`food-beverage` → `Food beverage`). */
21132
+ function iconCategoryLabel(category) {
21133
+ const spaced = category.replace(/-/g, " ");
21134
+ return spaced.charAt(0).toUpperCase() + spaced.slice(1);
21135
+ }
21136
+ //#endregion
21137
+ //#region src/device/device-type.ts
21138
+ var DeviceType = /* @__PURE__ */ function(DeviceType) {
21139
+ DeviceType["Camera"] = "camera";
21140
+ DeviceType["Light"] = "light";
21141
+ DeviceType["Siren"] = "siren";
21142
+ DeviceType["Switch"] = "switch";
21143
+ DeviceType["Sensor"] = "sensor";
21144
+ /** Every climate device: an air conditioner, a room thermostat, a radiator
21145
+ * valve, a floor-heating zone, a heat-pump circuit. They share one set of
21146
+ * controls (`climate-control`), so they are one type; WHICH kind of climate
21147
+ * device it is is its {@link DeviceRole} (`climate-*`), which the UI and the
21148
+ * exports branch on. The retired `thermostat` type is read as this one
21149
+ * (`canonicalStoredDeviceType`). */
21150
+ DeviceType["Climate"] = "climate";
21151
+ DeviceType["Button"] = "button";
21152
+ /** Generic stateless event emitter — carries a device's EXACT declared
21153
+ * event vocabulary verbatim (no normalization). Installed with the
21154
+ * `event-emitter` cap. Sources: HA `event.*` entities (structured) and
21155
+ * HA bus events (e.g. `zha_event`, generic). */
21156
+ DeviceType["EventEmitter"] = "event-emitter";
21157
+ /** Firmware/software update entity — current vs available version,
21158
+ * updatable flag, update state, and an install action. Installed with
21159
+ * the `update` cap. Sources: Homematic firmware-update channels (and
21160
+ * reusable by other providers, e.g. HA `update.*` entities). */
21161
+ DeviceType["Update"] = "update";
21162
+ DeviceType["Generic"] = "generic";
21163
+ /** Generic notification delivery target (HA `notify.<service>`, future
21164
+ * Telegram / Discord / ntfy / SMTP, …). One device per delivery
21165
+ * endpoint; the `notifier` cap defines the send surface. */
21166
+ DeviceType["Notifier"] = "notifier";
21167
+ /** Pre-recorded action sequence with optional parameters
21168
+ * (HA `script.*`). Runnable via `script-runner` cap. */
21169
+ DeviceType["Script"] = "script";
21170
+ /** Automation rule (HA `automation.*`) — enable/disable + manual
21171
+ * trigger surface exposed via `automation-control` cap. */
21172
+ DeviceType["Automation"] = "automation";
21173
+ /** Door / smart lock device (HA `lock.*`). `lock-control` cap. */
21174
+ DeviceType["Lock"] = "lock";
21175
+ /** Window covering, blinds, garage door, valve, etc. (HA `cover.*`,
21176
+ * `valve.*`). `cover` cap with sub-roles for variant. */
21177
+ DeviceType["Cover"] = "cover";
21178
+ /** Pipe / water / gas valve with open/close/stop and optional
21179
+ * position (HA `valve.*`). `valve` cap — a cover-sibling actuator
21180
+ * modelled on the same open/closed lifecycle. */
21181
+ DeviceType["Valve"] = "valve";
21182
+ /** Humidifier / dehumidifier with on/off + target humidity + mode
21183
+ * (HA `humidifier.*`). `humidifier` cap — a climate-family actuator
21184
+ * modelled on the same target / mode lifecycle. */
21185
+ DeviceType["Humidifier"] = "humidifier";
21186
+ /** Water heater / boiler with target temperature + operation mode +
21187
+ * away mode (HA `water_heater.*`). `water-heater` cap — a
21188
+ * climate-family actuator. */
21189
+ DeviceType["WaterHeater"] = "water-heater";
21190
+ /** Ceiling / standing / exhaust fan (HA `fan.*`). `fan-control` cap. */
21191
+ DeviceType["Fan"] = "fan";
21192
+ /** Audio / video playback endpoint (HA `media_player.*`). Disjoint from
21193
+ * the camera surface — those use `Camera`. `media-player` cap. */
21194
+ DeviceType["MediaPlayer"] = "media-player";
21195
+ /** Security panel / alarm system (HA `alarm_control_panel.*`).
21196
+ * `alarm-panel` cap. */
21197
+ DeviceType["AlarmPanel"] = "alarm-panel";
21198
+ /** Generic user-settable input (HA `number` / `input_number` / `select`
21199
+ * / `input_select` / `text` / `input_text` / `input_datetime`).
21200
+ * Sub-type via `DeviceRole`: NumericControl / SelectControl /
21201
+ * TextControl / DateTimeControl. */
21202
+ DeviceType["Control"] = "control";
21203
+ /** Person / device-tracker presence (HA `person.*`, `device_tracker.*`).
21204
+ * `presence` cap. */
21205
+ DeviceType["Presence"] = "presence";
21206
+ /** Weather provider (HA `weather.*`). Tier-3, low MVP priority.
21207
+ * `weather` cap. */
21208
+ DeviceType["Weather"] = "weather";
21209
+ /** A physical weather station (Ecowitt outdoor array). `weather-station`
21210
+ * cap. Distinct from {@link Weather}, which is a forecast provider. */
21211
+ DeviceType["WeatherStation"] = "weather-station";
21212
+ /** Robot vacuum (HA `vacuum.*`). Tier-3. `vacuum-control` cap. */
21213
+ DeviceType["Vacuum"] = "vacuum";
21214
+ /** Robotic lawn mower (HA `lawn_mower.*`). Tier-3.
21215
+ * `lawn-mower-control` cap. */
21216
+ DeviceType["LawnMower"] = "lawn-mower";
21217
+ /** Physical HA device group — parent container for entity-children
21218
+ * adopted from a single HA device entry. Not renderable as a
21219
+ * standalone device; exists only to anchor child entities. */
21220
+ DeviceType["Container"] = "container";
21221
+ /** Single still-image entity (HA `image.*`). Read-only display of an
21222
+ * `entity_picture` signed URL the browser loads directly. `image` cap. */
21223
+ DeviceType["Image"] = "image";
21224
+ /** Smart pet feeder — cloud-connected food dispenser with a bowl food
21225
+ * level, battery, desiccant life, feeding state and manual-feed /
21226
+ * call-pet / maintenance actions. Installed with the `pet-feeder` cap;
21227
+ * dual-hopper models (D4S/D4SH) expose per-hopper portions. Sources:
21228
+ * native PetKit (`nodepetkit` `FeederDevice`), reusable by other feeder
21229
+ * integrations sharing the same food/desiccant/hopper surface. */
21230
+ DeviceType["PetFeeder"] = "pet-feeder";
21231
+ /** Pet water fountain — tank level, water drunk, pump and its duty cycle.
21232
+ * Installed with the `pet-fountain` cap. Reaches CamStack as loose entities
21233
+ * of a container and is BUILT as a composed device (D967). */
21234
+ DeviceType["PetFountain"] = "pet-fountain";
21235
+ /** Built-in dishwasher — program lifecycle, door / remote-start gates,
21236
+ * salt and rinse-aid levels. Installed with the `dishwasher` cap.
21237
+ * Sources: native Bosch Home Connect, reusable by similar integrations.
21238
+ * A plug-built dishwasher carries running-state and power instead. */
21239
+ DeviceType["Dishwasher"] = "dishwasher";
21240
+ /** Washing machine. A plug-built one is running while its power stays
21241
+ * above a threshold. No program cap — that surface is the dishwasher's. */
21242
+ DeviceType["Washer"] = "washer";
21243
+ /** Tumble dryer. Same plug-built running surface as {@link Washer}. */
21244
+ DeviceType["Dryer"] = "dryer";
21245
+ /** The physical bridge box of a vendor ecosystem (Velux KLF-200, and later
21246
+ * other radio-to-IP bridges). It carries the box's own facts (firmware,
21247
+ * address, connection state) and the actions the box really supports
21248
+ * (`reboot`, `device-admin-link`). Products are NOT its children — they are
21249
+ * adopted beside it — and its connection settings stay on the integration. */
21250
+ DeviceType["Gateway"] = "gateway";
21251
+ /** A heat pump (any vendor): the compressor unit with its circuits (heating, hot
21252
+ * water, cooling, solar), its system modes and its power. One main read-only
21253
+ * `heat-pump-status` cap carries all of it; `heat-pump-control` sets it (D1026). */
21254
+ DeviceType["HeatPump"] = "heat-pump";
21255
+ /** A home energy installation (any vendor): solar, grid, house, a metered heat pump
21256
+ * and the storage as branches of one bus. One read-only `energy-system` cap carries
21257
+ * every value; the storage is a field of it, never the `battery` cap (#513, #522). */
21258
+ DeviceType["EnergySystem"] = "energy-system";
21259
+ return DeviceType;
21260
+ }({});
21261
+ /**
21262
+ * Semantic role a device plays within its parent. Populated by driver
21263
+ * addons when creating accessory devices (Reolink siren/floodlight/
21264
+ * PIR/chime/autotrack/doorbell, ONVIF relay outputs, …). Used by the
21265
+ * admin UI to pick icons, labels, and widgets — a `Switch` with
21266
+ * `role: Floodlight` renders as a bulb with a brightness slider,
21267
+ * whereas a `Switch` with `role: Siren` renders as a klaxon.
21268
+ *
21269
+ * Undefined for top-level devices (cameras, NVRs, hubs). Persisted in
21270
+ * sqlite as a nullable TEXT column — old rows keep working unchanged.
21271
+ */
21272
+ var DeviceRole = /* @__PURE__ */ function(DeviceRole) {
21273
+ DeviceRole["Siren"] = "siren";
21274
+ DeviceRole["Floodlight"] = "floodlight";
21275
+ DeviceRole["Spotlight"] = "spotlight";
21276
+ DeviceRole["PirSensor"] = "pir-sensor";
21277
+ DeviceRole["Chime"] = "chime";
21278
+ DeviceRole["Autotrack"] = "autotrack";
21279
+ DeviceRole["Nightvision"] = "nightvision";
21280
+ DeviceRole["PrivacyMask"] = "privacy-mask";
21281
+ DeviceRole["Doorbell"] = "doorbell";
21282
+ /** Interior blind / shade / roller blind. HA `device_class: blind|shade`. */
21283
+ DeviceRole["CoverBlind"] = "cover-blind";
21284
+ /** Exterior roller shutter. HA `device_class: shutter`; Homematic BROLL. */
21285
+ DeviceRole["CoverShutter"] = "cover-shutter";
21286
+ /** Exterior awning. HA `device_class: awning`. */
21287
+ DeviceRole["CoverAwning"] = "cover-awning";
21288
+ /** Curtain / drape. HA `device_class: curtain`. */
21289
+ DeviceRole["CoverCurtain"] = "cover-curtain";
21290
+ /** Garage door. HA `device_class: garage`. A security actuator: exports gate it. */
21291
+ DeviceRole["CoverGarage"] = "cover-garage";
21292
+ /** Gate. HA `device_class: gate`. A security actuator: exports gate it. */
21293
+ DeviceRole["CoverGate"] = "cover-gate";
21294
+ /** Door. HA `device_class: door`. A security actuator: exports gate it. */
21295
+ DeviceRole["CoverDoor"] = "cover-door";
21296
+ /** Window. HA `device_class: window`. */
21297
+ DeviceRole["CoverWindow"] = "cover-window";
21298
+ /** Virtual HA toggle (input_boolean.*) — distinguishable from a
21299
+ * real Switch device for UI rendering / export adapters. */
21300
+ DeviceRole["BinaryHelper"] = "binary-helper";
21301
+ /** A smart plug: a `switch` whose source says it is an outlet (HA
21302
+ * `device_class: outlet`). The Alexa export shows it as a SMARTPLUG. */
21303
+ DeviceRole["Outlet"] = "outlet";
21304
+ /** A dumb plug-in stove or heater behind a switch: it runs only while the
21305
+ * switch is on. Offered `timed-run`, which switches it off again after a
21306
+ * chosen time. */
21307
+ DeviceRole["SwitchHeater"] = "switch-heater";
21308
+ /** A plain fan behind a switch (a smart plug powering it): drawn as a fan,
21309
+ * with the switch's on/off only. Speed or oscillation appear only when the
21310
+ * device also has a fan cap (D1033). */
21311
+ DeviceRole["SwitchFan"] = "switch-fan";
21312
+ /** A relay driving an on/off-only lamp: drawn as a light (bulb and glow, no
21313
+ * slider), presented to the exports as a light with power only. Not a
21314
+ * `light` type: the provider owns the type, and a light implies brightness
21315
+ * or colour this relay lacks. */
21316
+ DeviceRole["SwitchLight"] = "switch-light";
21317
+ /** Air conditioner / split unit: cooling, fan speed, louvres. */
21318
+ DeviceRole["ClimateAc"] = "climate-ac";
21319
+ /** Room thermostat: a setpoint and a room temperature. The default. */
21320
+ DeviceRole["ClimateThermostat"] = "climate-thermostat";
21321
+ /** Floor-heating zone actuator. */
21322
+ DeviceRole["ClimateFloor"] = "climate-floor";
21323
+ /** Radiator valve (thermostatic radiator head). */
21324
+ DeviceRole["ClimateRadiator"] = "climate-radiator";
21325
+ /** A heater with its own thermostat (stove, convector). */
21326
+ DeviceRole["ClimateHeater"] = "climate-heater";
21327
+ /** One heating/cooling circuit of a heat pump: a water loop with comfort /
21328
+ * eco setpoints and a heat/cool mode, no room sensor. */
21329
+ DeviceRole["ClimateHeatPumpCircuit"] = "climate-heat-pump-circuit";
21330
+ /** Generic motion / occupancy / moving event source. Distinct from
21331
+ * the camera accessory PirSensor role: that one is a camera child;
21332
+ * this is a standalone HA / 3rd-party motion sensor. */
21333
+ DeviceRole["MotionSensor"] = "motion-sensor";
21334
+ DeviceRole["ContactSensor"] = "contact-sensor";
21335
+ DeviceRole["LeakSensor"] = "leak-sensor";
21336
+ DeviceRole["SmokeSensor"] = "smoke-sensor";
21337
+ DeviceRole["COSensor"] = "co-sensor";
21338
+ DeviceRole["GasSensor"] = "gas-sensor";
21339
+ DeviceRole["TamperSensor"] = "tamper-sensor";
21340
+ DeviceRole["VibrationSensor"] = "vibration-sensor";
21341
+ DeviceRole["ConnectivitySensor"] = "connectivity-sensor";
21342
+ DeviceRole["SoundSensor"] = "sound-sensor";
21343
+ /** Fallback for `binary_sensor` without a known `device_class`. */
21344
+ DeviceRole["BinarySensor"] = "binary-sensor";
21345
+ DeviceRole["TemperatureSensor"] = "temperature-sensor";
21346
+ DeviceRole["HumiditySensor"] = "humidity-sensor";
21347
+ DeviceRole["AmbientLightSensor"] = "ambient-light-sensor";
21348
+ DeviceRole["PressureSensor"] = "pressure-sensor";
21349
+ /** Wind speed or direction (weather-station `wind-sensor` cap). */
21350
+ DeviceRole["WindSensor"] = "wind-sensor";
21351
+ /** Rain accumulation or rate (weather-station `rain-sensor` cap). */
21352
+ DeviceRole["RainSensor"] = "rain-sensor";
21353
+ /** UV index (weather-station `uv-sensor` cap). */
21354
+ DeviceRole["UvSensor"] = "uv-sensor";
21355
+ /** Solar irradiance W/m² (weather-station `solar-radiation-sensor` cap).
21356
+ * Distinct from AmbientLightSensor (lux). */
21357
+ DeviceRole["SolarRadiationSensor"] = "solar-radiation-sensor";
21358
+ /** Soil moisture % (garden/weather `soil-moisture-sensor` cap). */
21359
+ DeviceRole["SoilMoistureSensor"] = "soil-moisture-sensor";
21360
+ DeviceRole["PowerSensor"] = "power-sensor";
21361
+ DeviceRole["EnergySensor"] = "energy-sensor";
21362
+ DeviceRole["VoltageSensor"] = "voltage-sensor";
21363
+ DeviceRole["CurrentSensor"] = "current-sensor";
21364
+ DeviceRole["AirQualitySensor"] = "air-quality-sensor";
21365
+ /** Battery level (numeric % via `sensor` OR low-bool via
21366
+ * `binary_sensor` — the cap distinguishes via the value type). */
21367
+ DeviceRole["BatterySensor"] = "battery-sensor";
21368
+ /** Fallback for `sensor` numeric without a known `device_class`. */
21369
+ DeviceRole["NumericSensor"] = "numeric-sensor";
21370
+ /** String / enum state (HA `sensor` with `state_class: enum` or
21371
+ * `attributes.options`). */
21372
+ DeviceRole["EnumSensor"] = "enum-sensor";
21373
+ /** Date / timestamp state (HA `sensor` with `device_class: timestamp`
21374
+ * or `date`). The slice carries the raw ISO string verbatim (hosted on
21375
+ * the `enum-sensor` cap); the UI renders it locale-formatted. */
21376
+ DeviceRole["DateTimeSensor"] = "datetime-sensor";
21377
+ /** Last-resort fallback when nothing else matches. */
21378
+ DeviceRole["GenericSensor"] = "generic-sensor";
21379
+ DeviceRole["NumericControl"] = "numeric-control";
21380
+ DeviceRole["SelectControl"] = "select-control";
21381
+ DeviceRole["TextControl"] = "text-control";
21382
+ DeviceRole["DateTimeControl"] = "datetime-control";
21383
+ /** Mobile push notifier (HA `notify.mobile_app_*`) — supports
21384
+ * rich features (image, priority, channel routing). */
21385
+ DeviceRole["MobilePushNotifier"] = "mobile-push-notifier";
21386
+ /** Chat / messaging service (HA `notify.telegram_*`,
21387
+ * `notify.discord_*`, etc.). */
21388
+ DeviceRole["MessagingNotifier"] = "messaging-notifier";
21389
+ /** Email-based delivery (HA `notify.smtp`, etc.). */
21390
+ DeviceRole["EmailNotifier"] = "email-notifier";
21391
+ /** Fallback when the notifier service name doesn't match a known
21392
+ * pattern. */
21393
+ DeviceRole["GenericNotifier"] = "generic-notifier";
21394
+ /** Emits a pulse train (infrared or RF) on request — the `ir-transmitter`
21395
+ * cap. A `DeviceType.Generic` device. */
21396
+ DeviceRole["IrTransmitter"] = "ir-transmitter";
21397
+ return DeviceRole;
21398
+ }({});
21399
+ z.enum(["new-session", "step-up"]);
21400
+ z.enum(["en", "it"]);
21401
+ /** How a native app starts one login method (D858), as `auth.listLoginMethods` reports it. */
21402
+ var AppLoginPathSchema = z.discriminatedUnion("kind", [z.object({ kind: z.literal("native") }), z.object({
21403
+ kind: z.literal("browser"),
21404
+ startPath: z.string().startsWith("/")
21405
+ })]);
21457
21406
  //#endregion
21458
- //#region src/device/icon-catalog.ts
21407
+ //#region src/auth/device-certificate.ts
21459
21408
  /**
21460
- * icon-catalog — THE icon vocabulary (D854).
21461
- *
21462
- * Every place that picks or stores an icon — a device's display override, a
21463
- * location, a site zone, a viewer accessory, an `icon` settings field — names
21464
- * it by a key of this catalog and nothing else. There is no curated subset and
21465
- * no second list: the catalog is every lucide icon that both surfaces can draw
21466
- * (the admin UI's `lucide-react` and the viewer's `lucide-react-native`), the
21467
- * intersection computed by `scripts/generate-icon-catalog.ts` into the
21468
- * committed `icon-catalog.generated.ts`.
21469
- *
21470
- * Like the vocabularies it replaces, this module holds STRINGS only — no React,
21471
- * no lucide import, no glyph. Each surface owns its glyph table (the web one
21472
- * lives in `ui-library`, loaded lazily), and a test on each side pins that it
21473
- * covers {@link ICON_KEYS}.
21474
- *
21475
- * ## What is persisted
21476
- *
21477
- * The canonical kebab-case lucide id ({@link IconKey}). Spellings that a lucide
21478
- * package still accepts (`home` for `house`) and this repo's own legacy ones
21479
- * (`gauge2`) RESOLVE ({@link canonicalIconKey}) so a stored value never goes
21480
- * stale, but they are never OFFERED by search.
21409
+ * Device certificates (D855) — the wire contract shared by the hub, the admin
21410
+ * UI and the native viewer.
21481
21411
  *
21482
- * ## Search
21412
+ * A device (a phone) generates its OWN P-256 key pair in hardware (Secure
21413
+ * Enclave / Android Keystore / a non-extractable WebCrypto key). The private
21414
+ * key never travels. The hub signs the PUBLIC key into an X.509 leaf under a
21415
+ * dedicated device CA; the device later proves possession of the key by
21416
+ * signing a hub-issued nonce, and the hub answers with the same session a
21417
+ * password login opens.
21483
21418
  *
21484
- * Over the key, the Italian/English overlay in `icon-synonyms.ts`, any words
21485
- * the caller adds, and lucide's English tags — in that order of weight.
21486
- */
21487
- var KEY_SET$1 = new Set(ICON_KEYS);
21488
- var ALIAS_TO_KEY = new Map([...Object.entries(ICON_ALIASES), ...Object.entries(LEGACY_ICON_ALIASES)]);
21489
- /** Is this a canonical key of the catalog? (An alias is not — see {@link canonicalIconKey}.) */
21490
- function isIconKey(value) {
21491
- return typeof value === "string" && KEY_SET$1.has(value);
21492
- }
21493
- /**
21494
- * A stored value as a catalog key: the key itself, the key a still-accepted or
21495
- * legacy spelling stands for, or `undefined` — never a guess.
21496
- */
21497
- function canonicalIconKey(value) {
21498
- if (typeof value !== "string") return void 0;
21499
- if (isIconKey(value)) return value;
21500
- return ALIAS_TO_KEY.get(value);
21501
- }
21502
- /**
21503
- * A stored icon value as a catalog key: its canonical key when it is (or
21504
- * aliases) one, `fallback` otherwise. For an `icon` settings field whose stored
21505
- * value may predate the catalog (a free-text lucide name) — the field's default
21506
- * is drawn rather than nothing.
21419
+ * Everything on the wire is a small string (a PEM, a base64url signature):
21420
+ * D613 is about bulk bytes, and a certificate is ~600 bytes.
21507
21421
  */
21508
- function resolveIconKey(value, fallback) {
21509
- return canonicalIconKey(value) ?? fallback;
21510
- }
21422
+ /** Signature algorithm of every device credential: ECDSA, curve P-256, SHA-256. */
21423
+ var DEVICE_CERT_SIGNATURE = "ecdsa-p256-sha256";
21424
+ /** First line of every signed message; a change of format bumps the version. */
21425
+ var DEVICE_SIGNATURE_MESSAGE_VERSION = "camstack-device-cert-v1";
21426
+ z.enum([
21427
+ "login",
21428
+ "renew",
21429
+ "revoke"
21430
+ ]);
21431
+ var DEVICE_CERT_RENEW_WINDOW_DAYS = 30;
21511
21432
  /**
21512
- * Wire/storage schema for one icon key.
21433
+ * The exact bytes a device signs (UTF-8, `\n` separators, no trailing newline):
21513
21434
  *
21514
- * Deliberately NOT a `z.enum` of the catalog: ~1,700 literals would be inlined
21515
- * into every cap router, type and API-reference row that carries an icon. The
21516
- * check is membership in the catalog and the type is {@link IconKey}.
21517
- */
21518
- var IconKeySchema = z.custom(isIconKey, "Not an icon of the catalog");
21519
- var ENTRIES = ICON_KEYS.map((key, index) => {
21520
- const [categoryIndexes, tags] = ICON_META[index] ?? [[], []];
21521
- const categories = categoryIndexes.flatMap((i) => {
21522
- const id = ICON_CATEGORY_IDS[i];
21523
- return id === void 0 ? [] : [id];
21524
- });
21525
- return {
21526
- key,
21527
- categories,
21528
- primaryCategory: categories[0] ?? ICON_CATEGORY_IDS[0],
21529
- tags,
21530
- synonyms: ICON_SYNONYMS[key] ?? []
21531
- };
21532
- });
21533
- var ENTRY_BY_KEY = new Map(ENTRIES.map((e) => [e.key, e]));
21534
- /** The entry for a canonical key, or `undefined`. */
21535
- function iconEntry(key) {
21536
- return ENTRY_BY_KEY.get(key);
21537
- }
21538
- /** Every entry, in key order. */
21539
- var ICON_ENTRIES = ENTRIES;
21540
- /** Categories a picker offers first: the ones this product's icons mostly live in. */
21541
- var LEADING_CATEGORIES = [
21542
- "devices",
21543
- "home",
21544
- "security",
21545
- "buildings",
21546
- "connectivity",
21547
- "multimedia",
21548
- "nature",
21549
- "weather",
21550
- "transportation",
21551
- "animals"
21552
- ];
21553
- var PRIMARY_CATEGORIES = new Set(ENTRIES.map((e) => e.primaryCategory));
21554
- /**
21555
- * The categories a picker files icons under, in picker order: the leading ones,
21556
- * then the rest alphabetically. Only categories that are some icon's PRIMARY
21557
- * one — a category lucide lists only as a secondary has no section of its own.
21435
+ * camstack-device-cert-v1
21436
+ * <login|renew>
21437
+ * <origin> the hub origin returned by `getDeviceChallenge`
21438
+ * <nonce>
21439
+ *
21440
+ * The origin is part of the message so a signature collected by a look-alike
21441
+ * hub is worthless on the real one; the hub additionally binds the nonce to
21442
+ * the origin it issued it for and refuses any other.
21558
21443
  */
21559
- var ICON_CATEGORIES = [...LEADING_CATEGORIES, ...ICON_CATEGORY_IDS.filter((c) => !LEADING_CATEGORIES.includes(c))].filter((c) => PRIMARY_CATEGORIES.has(c));
21560
- /** The icons filed under a category as their PRIMARY one, in key order. */
21561
- function iconsInCategory(category) {
21562
- return ENTRIES.filter((e) => e.primaryCategory === category);
21444
+ function buildDeviceSignatureMessage(input) {
21445
+ return [
21446
+ DEVICE_SIGNATURE_MESSAGE_VERSION,
21447
+ input.purpose,
21448
+ input.origin,
21449
+ input.nonce
21450
+ ].join("\n");
21563
21451
  }
21564
- function normalise(text) {
21565
- return text.normalize("NFD").replace(/\p{Diacritic}/gu, "").toLowerCase().replace(/[_-]+/g, " ").trim();
21452
+ /** The deep link a QR carries: `camstack://enroll?hub=<origin>&code=<code>`. */
21453
+ function buildDeviceEnrollmentLink(input) {
21454
+ const query = new URLSearchParams();
21455
+ if (input.hub !== void 0) query.set("hub", input.hub);
21456
+ query.set("code", input.code);
21457
+ return `${input.scheme ?? "camstack"}://enroll?${query.toString()}`;
21566
21458
  }
21567
- /** Does `needle` appear in `haystack` in order, though not adjacently? */
21568
- function isSubsequence(needle, haystack) {
21569
- let i = 0;
21570
- for (const ch of haystack) {
21571
- if (ch === needle[i]) i += 1;
21572
- if (i === needle.length) return true;
21459
+ /** Parse an enrollment deep link; `null` when it is not one. `hub` is absent when the link names none. */
21460
+ function parseDeviceEnrollmentLink(raw) {
21461
+ let url;
21462
+ try {
21463
+ url = new URL(raw);
21464
+ } catch {
21465
+ return null;
21573
21466
  }
21574
- return needle.length === 0;
21467
+ if (url.protocol !== "camstack:" && url.protocol !== "camstack.dev:") return null;
21468
+ if (url.hostname !== "enroll") return null;
21469
+ const code = url.searchParams.get("code");
21470
+ if (code === null || code === "") return null;
21471
+ const hub = url.searchParams.get("hub");
21472
+ return {
21473
+ hub: hub === null || hub === "" ? null : hub,
21474
+ code
21475
+ };
21575
21476
  }
21477
+ var DevicePlatformSchema = z.enum([
21478
+ "ios",
21479
+ "android",
21480
+ "web",
21481
+ "other"
21482
+ ]);
21483
+ var Base64UrlSchema = z.string().min(1).max(4096).regex(/^[A-Za-z0-9_-]+$/);
21484
+ var PemSchema = z.string().min(1).max(16384);
21576
21485
  /**
21577
- * How well one word answers the query. 0 = not at all. An exact word beats a
21578
- * prefix, a prefix beats a word STARTING inside the phrase, and a loose
21579
- * subsequence comes last because it matches almost anything.
21486
+ * Why a device-certificate endpoint said no. Distinct from a transport / 5xx
21487
+ * failure: those carry no reason and mean "try again", never "the credential is
21488
+ * dead". The viewer switches on this exhaustively.
21580
21489
  */
21581
- function scoreWord(query, word, loose) {
21582
- if (word === query) return 100;
21583
- if (word.startsWith(query)) return 80;
21584
- if (word.split(" ").some((w) => w.startsWith(query))) return 60;
21585
- if (word.includes(query)) return 40;
21586
- if (loose && isSubsequence(query, word)) return 15;
21587
- return 0;
21588
- }
21589
- var WORDS_CACHE = /* @__PURE__ */ new Map();
21590
- /** Normalised once per entry — search runs on every keystroke over ~1,700 entries. */
21591
- function wordsOf(entry) {
21592
- const cached = WORDS_CACHE.get(entry.key);
21593
- if (cached !== void 0) return cached;
21594
- const built = {
21595
- key: normalise(entry.key),
21596
- synonyms: entry.synonyms.map(normalise),
21597
- tags: entry.tags.map(normalise)
21598
- };
21599
- WORDS_CACHE.set(entry.key, built);
21600
- return built;
21490
+ var DeviceRefusalReasonSchema = z.enum([
21491
+ "revoked",
21492
+ "unknown-credential",
21493
+ "expired",
21494
+ "bad-signature",
21495
+ "nonce-invalid",
21496
+ "rate-limited",
21497
+ "invalid-certificate",
21498
+ "superseded",
21499
+ "user-gone",
21500
+ "unavailable",
21501
+ "code-invalid",
21502
+ "self-enrollment-disabled",
21503
+ "step-up-required",
21504
+ "bad-public-key"
21505
+ ]);
21506
+ /** The only answers after which the app may count towards deleting its credential. */
21507
+ var DEFINITIVE_DEVICE_REFUSALS = [
21508
+ "revoked",
21509
+ "unknown-credential",
21510
+ "user-gone"
21511
+ ];
21512
+ /** Consecutive DEFINITIVE answers before the app deletes its key and certificate. */
21513
+ var DEVICE_DEFINITIVE_REFUSALS_BEFORE_DELETE = 3;
21514
+ function isDefinitiveDeviceRefusal(reason) {
21515
+ return DEFINITIVE_DEVICE_REFUSALS.includes(reason);
21601
21516
  }
21517
+ var DeviceRefusalSchema = z.object({
21518
+ ok: z.literal(false),
21519
+ reason: DeviceRefusalReasonSchema,
21520
+ definitive: z.boolean(),
21521
+ retryAfterSeconds: z.number().optional()
21522
+ });
21602
21523
  /**
21603
- * Rank the catalog against a free-text query.
21604
- *
21605
- * An empty query returns the WHOLE catalog in key order, because a picker's
21606
- * resting state is the full list. `extraWords` lets a caller add the words IT
21607
- * can translate without this module knowing what a locale is; they score like a
21608
- * synonym. The key outranks a synonym, a synonym outranks a lucide tag, and
21609
- * ties keep key order so the list does not reshuffle between keystrokes.
21524
+ * A credential-bound session that can no longer refresh answers
21525
+ * `auth.refreshSession` with UNAUTHORIZED whose message is this prefix + the
21526
+ * reason; {@link deviceRefusalFromMessage} reads it back.
21610
21527
  */
21611
- function searchIcons(query, extraWords) {
21612
- const q = normalise(query);
21613
- if (q.length === 0) return ENTRIES.map((entry) => ({
21614
- entry,
21615
- score: 0
21616
- }));
21617
- const hits = [];
21618
- for (const entry of ENTRIES) {
21619
- const words = wordsOf(entry);
21620
- const keyScore = scoreWord(q, words.key, true);
21621
- let best = keyScore > 0 ? keyScore + 2 : 0;
21622
- for (const word of [...words.synonyms, ...(extraWords?.get(entry.key) ?? []).map(normalise)]) {
21623
- const score = scoreWord(q, word, true);
21624
- if (score > 0 && score + 1 > best) best = score + 1;
21625
- }
21626
- for (const word of words.tags) {
21627
- const score = scoreWord(q, word, false);
21628
- if (score > best) best = score;
21629
- }
21630
- if (best > 0) hits.push({
21631
- entry,
21632
- score: best
21633
- });
21634
- }
21635
- return hits.toSorted((a, b) => b.score - a.score);
21636
- }
21637
- /** A readable label derived from a lucide category id (`food-beverage` → `Food beverage`). */
21638
- function iconCategoryLabel(category) {
21639
- const spaced = category.replace(/-/g, " ");
21640
- return spaced.charAt(0).toUpperCase() + spaced.slice(1);
21528
+ var DEVICE_REFRESH_REFUSAL_PREFIX = "device-credential:";
21529
+ function deviceRefusalFromMessage(message) {
21530
+ if (!message.startsWith("device-credential:")) return null;
21531
+ const parsed = DeviceRefusalReasonSchema.safeParse(message.slice(18));
21532
+ return parsed.success ? parsed.data : null;
21641
21533
  }
21534
+ z.object({
21535
+ code: z.string().min(1).max(256),
21536
+ /** SubjectPublicKeyInfo DER of the device's P-256 public key, base64url. */
21537
+ publicKeySpki: Base64UrlSchema,
21538
+ deviceName: z.string().min(1).max(80).optional(),
21539
+ platform: DevicePlatformSchema
21540
+ });
21541
+ var CompleteEnrollmentOutputSchema = z.object({
21542
+ credentialId: z.string(),
21543
+ certPem: PemSchema,
21544
+ /** The device CA certificate the leaf chains to. */
21545
+ chainPem: PemSchema,
21546
+ notAfter: z.number(),
21547
+ user: z.object({
21548
+ id: z.string(),
21549
+ username: z.string()
21550
+ })
21551
+ });
21552
+ z.discriminatedUnion("ok", [CompleteEnrollmentOutputSchema.extend({ ok: z.literal(true) }), DeviceRefusalSchema]);
21553
+ z.object({
21554
+ /** The single-use step-up proof (`auth.deviceEnrollProofFrom…`). */
21555
+ proof: z.string().min(1).max(512),
21556
+ publicKeySpki: Base64UrlSchema,
21557
+ deviceName: z.string().min(1).max(80),
21558
+ platform: DevicePlatformSchema
21559
+ });
21560
+ z.object({
21561
+ proof: z.string(),
21562
+ expiresAt: z.number()
21563
+ });
21564
+ var DeviceChallengeSchema = z.object({
21565
+ nonce: z.string(),
21566
+ /** The origin to put in the signed message. The app compares it to the hub it dialled. */
21567
+ origin: z.string(),
21568
+ expiresAt: z.number(),
21569
+ signature: z.literal(DEVICE_CERT_SIGNATURE)
21570
+ });
21571
+ z.discriminatedUnion("ok", [DeviceChallengeSchema.extend({ ok: z.literal(true) }), DeviceRefusalSchema]);
21572
+ z.object({
21573
+ certPem: PemSchema,
21574
+ nonce: z.string().min(1).max(256),
21575
+ /** ECDSA P-256 SHA-256 over {@link buildDeviceSignatureMessage}; raw r||s or DER, base64url. */
21576
+ signature: Base64UrlSchema
21577
+ });
21578
+ var RenewDeviceCertificateOutputSchema = z.object({
21579
+ credentialId: z.string(),
21580
+ certPem: PemSchema,
21581
+ chainPem: PemSchema,
21582
+ notAfter: z.number()
21583
+ });
21584
+ z.discriminatedUnion("ok", [RenewDeviceCertificateOutputSchema.extend({ ok: z.literal(true) }), DeviceRefusalSchema]);
21585
+ z.discriminatedUnion("ok", [z.object({
21586
+ ok: z.literal(true),
21587
+ credentialId: z.string(),
21588
+ sessionsEnded: z.number().int()
21589
+ }), DeviceRefusalSchema]);
21590
+ var DeviceCredentialStatusSchema = z.enum([
21591
+ "active",
21592
+ "expired",
21593
+ "revoked"
21594
+ ]);
21595
+ z.object({
21596
+ id: z.string(),
21597
+ userId: z.string(),
21598
+ username: z.string().nullable(),
21599
+ deviceName: z.string(),
21600
+ platform: DevicePlatformSchema,
21601
+ enrolledVia: z.enum(["qr", "self"]),
21602
+ /** SHA-256 of the leaf certificate DER, colon-hex. */
21603
+ fingerprint: z.string(),
21604
+ issuedAt: z.number(),
21605
+ expiresAt: z.number(),
21606
+ lastUsedAt: z.number().nullable(),
21607
+ lastUsedFrom: z.string().nullable(),
21608
+ revokedAt: z.number().nullable(),
21609
+ /** `admin:<userId>` | `user:<userId>` | `device` | `user-deleted`. */
21610
+ revokedBy: z.string().nullable(),
21611
+ status: DeviceCredentialStatusSchema
21612
+ });
21613
+ z.object({
21614
+ /** Shown once; only its hash is kept. */
21615
+ code: z.string(),
21616
+ expiresAt: z.number(),
21617
+ /** `camstack://enroll?hub=…&code=…` — what the QR encodes. */
21618
+ enrollUrl: z.string(),
21619
+ /** The hub origin in the link, or `null` when the hub could not name one (the link then has no `hub`). */
21620
+ hubOrigin: z.string().nullable(),
21621
+ /** Every origin the apps may try (role `appConnections`). */
21622
+ hubOrigins: z.array(z.string())
21623
+ });
21624
+ z.object({
21625
+ kind: z.literal("device-certificate"),
21626
+ id: z.literal("device-certificate"),
21627
+ label: z.string(),
21628
+ stage: z.literal("primary"),
21629
+ /** tRPC paths under the hub's `auth` router, so a client names no literal. */
21630
+ challengePath: z.literal("auth.getDeviceChallenge"),
21631
+ revokePath: z.literal("auth.revokeOwnDeviceCertificate"),
21632
+ enrollSelfPath: z.literal("auth.enrollSelf"),
21633
+ loginPath: z.literal("auth.loginWithDeviceCertificate"),
21634
+ renewPath: z.literal("auth.renewDeviceCertificate"),
21635
+ signature: z.literal(DEVICE_CERT_SIGNATURE),
21636
+ messageVersion: z.literal(DEVICE_SIGNATURE_MESSAGE_VERSION),
21637
+ /** Which clients can execute it: a native app silently, a browser with a non-extractable WebCrypto key. */
21638
+ clients: z.array(z.enum(["native", "web"])),
21639
+ /** The app executes it itself, silently (D858). */
21640
+ app: AppLoginPathSchema.nullable()
21641
+ });
21642
21642
  //#endregion
21643
21643
  //#region src/device/location-icon.ts
21644
21644
  /**
@@ -28154,6 +28154,7 @@ function createDeviceProxy(api, binding, opts) {
28154
28154
  setName: (input) => dispatchSystem("deviceManager", "setName", "mutation", input),
28155
28155
  setAlias: (input) => dispatchSystem("deviceManager", "setAlias", "mutation", input),
28156
28156
  setLocation: (input) => dispatchSystem("deviceManager", "setLocation", "mutation", input),
28157
+ setTags: (input) => dispatchSystem("deviceManager", "setTags", "mutation", input),
28157
28158
  setType: (input) => dispatchSystem("deviceManager", "setType", "mutation", input),
28158
28159
  setIntegrationId: (input) => dispatchSystem("deviceManager", "setIntegrationId", "mutation", input),
28159
28160
  setLinkDeviceId: (input) => dispatchSystem("deviceManager", "setLinkDeviceId", "mutation", input),
@@ -29963,6 +29964,12 @@ function createSystemProxy(api) {
29963
29964
  setLoggingSettings: (input) => dispatch("system", "setLoggingSettings", "mutation", input),
29964
29965
  debugWatch: (input) => dispatch("system", "debugWatch", "mutation", input)
29965
29966
  },
29967
+ tags: {
29968
+ list: (input) => dispatch("tags", "list", "query", input),
29969
+ setStyle: (input) => dispatch("tags", "setStyle", "mutation", input),
29970
+ rename: (input) => dispatch("tags", "rename", "mutation", input),
29971
+ remove: (input) => dispatch("tags", "remove", "mutation", input)
29972
+ },
29966
29973
  template: {
29967
29974
  list: (input) => dispatch("template", "list", "query", input),
29968
29975
  get: (input) => dispatch("template", "get", "query", input),