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