@mega-yfue/eufy-sdk 0.5.0-beta.71 → 0.5.0-beta.73

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
package/dist/index.js CHANGED
@@ -4235,6 +4235,10 @@ function decodeAiDetectType(value) {
4235
4235
  pet: !!(value & AiDetectType.pet)
4236
4236
  };
4237
4237
  }
4238
+ function decodeAiDetectTypeParam(raw) {
4239
+ const value = typeof raw === "object" && raw !== null ? raw.ai_detect_type : raw;
4240
+ return typeof value === "number" && Number.isInteger(value) ? value : void 0;
4241
+ }
4238
4242
  function snoozePayload(seconds) {
4239
4243
  if (seconds <= 0)
4240
4244
  return { snooze_time: 0 };
@@ -4331,11 +4335,15 @@ var MOTION_MEMBERS = {
4331
4335
  * 1298 holds the detailed AI-type BITMASK (live-observed: `0x30000` enabled-base | type bits, e.g. a
4332
4336
  * T8425 reads `0x3000f`). Cams also report 1299 (`hbAiDetectType`) but that is a separate, simpler
4333
4337
  * value (1) — NOT this bitmask, so 1298 is the read/write id.
4338
+ *
4339
+ * The value arrives in two shapes, both read by the app's 1298 parser: a bare bitmask, or a JSON
4340
+ * object carrying the same bitmask as `ai_detect_type` (see {@link decodeAiDetectTypeParam}).
4334
4341
  */
4335
4342
  aiDetectType: {
4336
4343
  param: MOTION_CMD.AI_DETECT_TYPE,
4337
- type: "number",
4338
- kind: "bitfield",
4344
+ type: "string",
4345
+ decode: decodeAiDetectTypeParam,
4346
+ decodedKind: "bitfield",
4339
4347
  provenance: "verified",
4340
4348
  description: "AI detection type bitmask \u2014 which classes trigger detection. \u2705 Bits decoded live + confirmed vs the app: 0x30000 = enabled base, bit0 = human recognition, bit1 = human detection, bit2 = vehicle, bit3 = pet (see AiDetectType / encodeAiDetectType). \u2705 WRITE HW-verified live on T8124 (1350 SET_PAYLOAD, {ai_detect_type, channel}): each write landed byte-exact + read back (0x30003 \u2192 0x8 \u2192 0x3000b).",
4341
4349
  write: (v, ctx) => {
@@ -12336,10 +12344,13 @@ var SECURITY_PARAMS = {
12336
12344
  type: "string",
12337
12345
  provenance: "apk"
12338
12346
  },
12347
+ // A camera answers a bare bitmask; a camera behind an NVR-class hub answers a JSON object carrying
12348
+ // it as `ai_detect_type` beside `ai_switch`, `ai_notification`, `ai_use_global` and `channel`.
12339
12349
  1298: {
12340
12350
  name: "aiDetectType",
12341
- type: "number",
12342
- provenance: "apk"
12351
+ type: "string",
12352
+ provenance: "apk",
12353
+ encoding: "json"
12343
12354
  },
12344
12355
  // Cameras and a HomeBase 3 answer a bare number; a HomeBase S1 Pro (T9000) answers a JSON envelope
12345
12356
  // (`{"ai_switch":1,"smart_detection":…,"devlist":[…]}`).
@@ -13219,7 +13230,7 @@ var CLEAN_PARAMS = {
13219
13230
  },
13220
13231
  155: {
13221
13232
  name: "direction",
13222
- type: "enum",
13233
+ type: "string",
13223
13234
  provenance: "mega"
13224
13235
  },
13225
13236
  156: {
@@ -24553,6 +24564,10 @@ var RtcSession = class extends EventEmitter11 {
24553
24564
  * `connect()` still waiting for the signalling auth is rejected and its timer stopped.
24554
24565
  */
24555
24566
  close() {
24567
+ this.shutdown();
24568
+ }
24569
+ /** {@link RtcSession.close}, with the failure that ended the session handed to `close` when one did. */
24570
+ shutdown(err) {
24556
24571
  if (this.closed)
24557
24572
  return;
24558
24573
  this.closed = true;
@@ -24565,7 +24580,7 @@ var RtcSession = class extends EventEmitter11 {
24565
24580
  this.signaling.close();
24566
24581
  this.peer.close();
24567
24582
  this.settleAuth(new Error("RTC session closed while waiting for signalling auth"));
24568
- this.announceClose();
24583
+ this.announceClose(err);
24569
24584
  }
24570
24585
  /**
24571
24586
  * Trickle one local candidate, or the empty end-of-candidates. The native peer can report one after the
@@ -24577,11 +24592,11 @@ var RtcSession = class extends EventEmitter11 {
24577
24592
  return;
24578
24593
  this.signaling.sendInfoCandidate(candidate);
24579
24594
  }
24580
- announceClose() {
24595
+ announceClose(err) {
24581
24596
  if (this.closeAnnounced)
24582
24597
  return;
24583
24598
  this.closeAnnounced = true;
24584
- this.emit("close");
24599
+ this.emit("close", err);
24585
24600
  }
24586
24601
  waitForAuth() {
24587
24602
  if (this.authOk)
@@ -24641,7 +24656,14 @@ var RtcSession = class extends EventEmitter11 {
24641
24656
  const status = payload.status;
24642
24657
  if (status === 100 && payload.turn) {
24643
24658
  this.turn = payload.turn;
24644
- await this.peer.init(payload.turn);
24659
+ try {
24660
+ await this.peer.init(payload.turn);
24661
+ } catch (e) {
24662
+ const err = e instanceof Error ? e : new Error(String(e));
24663
+ this.emit("error", err);
24664
+ this.shutdown(err);
24665
+ return;
24666
+ }
24645
24667
  return;
24646
24668
  }
24647
24669
  if (status === 200) {
@@ -24977,9 +24999,9 @@ var RtcCommandRouter = class {
24977
24999
  }
24978
25000
  /**
24979
25001
  * One bounded bring-up: the session is up when its command channel opens, and it fails, with the
24980
- * session closed and every listener gone, when `connect()` throws, the session closes first, or
24981
- * {@link CONNECT_TIMEOUT_MS} passes. A single promise, so an early failure cannot leave a second one
24982
- * rejecting unheard.
25002
+ * session closed and every listener gone, when `connect()` throws, the session closes first (rejecting
25003
+ * with the failure that closed it, when it carries one), or {@link CONNECT_TIMEOUT_MS} passes. A single
25004
+ * promise, so an early failure cannot leave a second one rejecting unheard.
24983
25005
  */
24984
25006
  bringUp(sn, session) {
24985
25007
  return new Promise((resolve, reject) => {
@@ -25003,7 +25025,7 @@ var RtcCommandRouter = class {
25003
25025
  }
25004
25026
  };
25005
25027
  const onConnected = () => finish();
25006
- const onClose = () => finish(new Error(`rtc: ${sn} session closed before the command channel opened`));
25028
+ const onClose = (err) => finish(err ?? new Error(`rtc: ${sn} session closed before the command channel opened`));
25007
25029
  const timer = setTimeout(() => finish(new Error(`rtc: ${sn} did not come up within ${CONNECT_TIMEOUT_MS2}ms`)), CONNECT_TIMEOUT_MS2);
25008
25030
  session.once("connected", onConnected);
25009
25031
  session.once("close", onClose);