@mega-yfue/eufy-sdk 0.5.0-beta.43 → 0.5.0-beta.45

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
@@ -620,7 +620,8 @@ function scanEntropy(tail, subsampling, extraTables) {
620
620
  // dist/transport/http/decodeImageV2.js
621
621
  import { decode as jpegDecode } from "jpeg-js";
622
622
  var V2_PREFIX = "v2_eufysecurity:";
623
- var DC_CHROMA = Buffer.from([255, 196, 0, 31, 1]);
623
+ var DRI_SEGMENT = Buffer.from([255, 221, 0, 4]);
624
+ var SOS_HEADER = Buffer.from([255, 218, 0, 12, 3]);
624
625
  var ZIGZAG = [
625
626
  0,
626
627
  1,
@@ -821,6 +822,9 @@ var QUANT_CHROMA = [
821
822
  ];
822
823
  var DHT_DC_LUMA = Buffer.from("ffc4001f0000010501010101010100000000000000000102030405060708090a0b", "hex");
823
824
  var DHT_AC_LUMA = Buffer.from("ffc400b5100002010303020403050504040000017d01020300041105122131410613516107227114328191a1082342b1c11552d1f02433627282090a161718191a25262728292a3435363738393a434445464748494a535455565758595a636465666768696a737475767778797a838485868788898a92939495969798999aa2a3a4a5a6a7a8a9aab2b3b4b5b6b7b8b9bac2c3c4c5c6c7c8c9cad2d3d4d5d6d7d8d9dae1e2e3e4e5e6e7e8e9eaf1f2f3f4f5f6f7f8f9fa", "hex");
825
+ var DHT_DC_CHROMA = Buffer.from("ffc4001f0100030101010101010101010000000000000102030405060708090a0b", "hex");
826
+ var DC_CHROMA = DHT_DC_CHROMA.subarray(0, 5);
827
+ var DHT_AC_CHROMA = Buffer.from("ffc400b51100020102040403040705040400010277000102031104052131061241510761711322328108144291a1b1c109233352f0156272d10a162434e125f11718191a262728292a35363738393a434445464748494a535455565758595a636465666768696a737475767778797a82838485868788898a92939495969798999aa2a3a4a5a6a7a8a9aab2b3b4b5b6b7b8b9bac2c3c4c5c6c7c8c9cad2d3d4d5d6d7d8d9dae2e3e4e5e6e7e8e9eaf2f3f4f5f6f7f8f9fa", "hex");
824
828
  var SOI = Buffer.from([255, 216]);
825
829
  var APP0 = Buffer.from("ffe000104a46494600010100000100010000", "hex");
826
830
  var MCU = { 0: [8, 8], 1: [16, 8], 2: [16, 16] };
@@ -973,16 +977,31 @@ function findGeometry(tail) {
973
977
  }
974
978
  return best;
975
979
  }
980
+ function findScanCut(data) {
981
+ const sos = data.lastIndexOf(SOS_HEADER);
982
+ if (sos < 0)
983
+ return -1;
984
+ const dri = sos - DRI_SEGMENT.length - 2;
985
+ return dri >= 0 && data.subarray(dri, dri + DRI_SEGMENT.length).equals(DRI_SEGMENT) ? dri : -1;
986
+ }
987
+ function plaintextTail(data) {
988
+ const cut = data.indexOf(DC_CHROMA);
989
+ if (cut >= 0)
990
+ return data.subarray(cut);
991
+ const scan = findScanCut(data);
992
+ if (scan < 0)
993
+ return null;
994
+ return Buffer.concat([DHT_DC_CHROMA, DHT_AC_CHROMA, data.subarray(scan)]);
995
+ }
976
996
  function isV2Image(data) {
977
997
  return data.length >= V2_PREFIX.length && data.subarray(0, V2_PREFIX.length).toString("latin1") === V2_PREFIX;
978
998
  }
979
999
  function decodeImageV2(data) {
980
1000
  if (!isV2Image(data))
981
1001
  return null;
982
- const cut = data.indexOf(DC_CHROMA);
983
- if (cut < 0)
1002
+ const tail = plaintextTail(data);
1003
+ if (!tail)
984
1004
  return null;
985
- const tail = data.subarray(cut);
986
1005
  const geometry = findGeometry(tail);
987
1006
  if (!geometry)
988
1007
  return null;
@@ -7891,6 +7910,10 @@ var ARMING_MEMBERS = {
7891
7910
  };
7892
7911
  }, "Turn the push notification of the device on a channel on or off in a guard mode (home/away).", (ctx) => ctx.model === "T8010")
7893
7912
  };
7913
+ function decodeAlarmPhase(signal) {
7914
+ const type = signal.source === "push" ? signal.payload?.["type"] : void 0;
7915
+ return type === CusPushAlarmType.HUB_STOP_BY_APP ? { phase: "stopped" } : {};
7916
+ }
7894
7917
  var ARMING = {
7895
7918
  capability: "arming",
7896
7919
  description: "Station/device guard (arming) mode.",
@@ -7905,8 +7928,9 @@ var ARMING = {
7905
7928
  * generic `CusPushEvent` channel, so these ids are shared with other families and resolve by
7906
7929
  * capability (see the barrel's event index).
7907
7930
  *
7908
- * The alarm ids carry a static `phase` so one event name covers the whole lifecycle, the same shape
7909
- * `battery` uses for its threshold pushes. The mode-switch push is known to identify WHICH mode and
7931
+ * The alarm ids carry a `phase` so one event name covers the whole lifecycle: the countdown push a
7932
+ * static `"delayed"`, the alarm push a `"triggered"` or `"stopped"` read from its alarm type (see
7933
+ * {@link decodeAlarmPhase}). The mode-switch push is known to identify WHICH mode and
7910
7934
  * what triggered the change, but neither has been observed on the wire here, so this emits the bare
7911
7935
  * transition and refreshes the `mode` read rather than trusting a decoded field.
7912
7936
  */
@@ -7917,7 +7941,13 @@ var ARMING = {
7917
7941
  emit: "armingModeChanged",
7918
7942
  refresh: { member: "mode" }
7919
7943
  },
7920
- { source: "push", match: CusPushEvent.ALARM, emit: "alarm", payload: { phase: "triggered" } },
7944
+ {
7945
+ source: "push",
7946
+ match: CusPushEvent.ALARM,
7947
+ emit: "alarm",
7948
+ payload: { phase: "triggered" },
7949
+ derive: decodeAlarmPhase
7950
+ },
7921
7951
  { source: "push", match: CusPushEvent.ALARM_DELAY, emit: "alarm", payload: { phase: "delayed" } }
7922
7952
  ]
7923
7953
  };