@mega-yfue/eufy-sdk 0.4.0-beta.2 → 0.4.0-beta.4
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/client/eufy-mega.d.ts +4 -1
- package/dist/index.js +27 -8
- package/dist/index.js.map +2 -2
- package/dist/transport/p2p/p2p-session.d.ts +11 -2
- package/package.json +1 -1
|
@@ -871,7 +871,10 @@ export declare class EufyMega extends EventEmitter {
|
|
|
871
871
|
* one — so this never overwrites a channel a later login already brought up.
|
|
872
872
|
*/
|
|
873
873
|
private startPush;
|
|
874
|
-
/**
|
|
874
|
+
/**
|
|
875
|
+
* Admit only exact, account-known devices with resolved snapshot evidence into the passive store; a
|
|
876
|
+
* station-only candidate is admitted under the event's device serial.
|
|
877
|
+
*/
|
|
875
878
|
private observeStoredImage;
|
|
876
879
|
/**
|
|
877
880
|
* Tear down every realtime channel: close the secure-MQTT transport, all P2P sessions, and the FCM
|
package/dist/index.js
CHANGED
|
@@ -15253,7 +15253,10 @@ var P2PSession = class _P2PSession extends EventEmitter2 {
|
|
|
15253
15253
|
cloudLookup;
|
|
15254
15254
|
/** Local outbound IPv4 reported inside LOOKUP_WITH_KEY requests. */
|
|
15255
15255
|
selfHost;
|
|
15256
|
-
/**
|
|
15256
|
+
/**
|
|
15257
|
+
* In-flight multi-datagram frame per data channel (see reassemble): the payload gathered so far under its
|
|
15258
|
+
* parsed header, or, without a header, the start of a frame header cut by the datagram boundary.
|
|
15259
|
+
*/
|
|
15257
15260
|
pendingByDataType = /* @__PURE__ */ new Map();
|
|
15258
15261
|
/** Last delivered datagram sequence number per data type. */
|
|
15259
15262
|
lastSeqByType = /* @__PURE__ */ new Map();
|
|
@@ -16628,7 +16631,13 @@ var P2PSession = class _P2PSession extends EventEmitter2 {
|
|
|
16628
16631
|
clearTimeout(reorder.timer);
|
|
16629
16632
|
reorder.timer = void 0;
|
|
16630
16633
|
}
|
|
16631
|
-
/**
|
|
16634
|
+
/**
|
|
16635
|
+
* Reassemble one in-sequence datagram body into logical frames.
|
|
16636
|
+
*
|
|
16637
|
+
* Frames are packed back to back, so a frame header can itself be cut by a datagram boundary. The start
|
|
16638
|
+
* of a header left at the end of a datagram is carried into the next one rather than discarded; dropping
|
|
16639
|
+
* it would lose that frame and every frame after it until a datagram happened to begin on a header.
|
|
16640
|
+
*/
|
|
16632
16641
|
reassemble(dataType, datagramBody) {
|
|
16633
16642
|
const pending = this.pendingByDataType.get(dataType);
|
|
16634
16643
|
let body = pending ? Buffer.concat([pending.buf, datagramBody]) : datagramBody;
|
|
@@ -16652,6 +16661,9 @@ var P2PSession = class _P2PSession extends EventEmitter2 {
|
|
|
16652
16661
|
this.handleFrame(header, payload.subarray(0, header.bytesToRead), dataType);
|
|
16653
16662
|
body = body.subarray(P2P_DATA_HEADER_BYTES + header.bytesToRead);
|
|
16654
16663
|
}
|
|
16664
|
+
if (body.length > 0 && body.length < P2P_DATA_HEADER_BYTES && MAGIC_WORD.startsWith(body.subarray(0, 4).toString())) {
|
|
16665
|
+
this.pendingByDataType.set(dataType, { buf: body });
|
|
16666
|
+
}
|
|
16655
16667
|
}
|
|
16656
16668
|
/**
|
|
16657
16669
|
* Forget where each data type's sequence numbering had reached, and drop any half-reassembled frame.
|
|
@@ -26839,7 +26851,7 @@ var EufyMega = class extends EventEmitter9 {
|
|
|
26839
26851
|
if (ev.eventName === void 0 && ev.eventType != null)
|
|
26840
26852
|
ev.eventName = detectionName(ev.eventType);
|
|
26841
26853
|
if (ev.thumbnailCandidate)
|
|
26842
|
-
void this.observeStoredImage(ev.thumbnailCandidate);
|
|
26854
|
+
void this.observeStoredImage(ev.thumbnailCandidate, ev.deviceSn);
|
|
26843
26855
|
this.emit("push", ev);
|
|
26844
26856
|
const signal2 = {
|
|
26845
26857
|
source: "push",
|
|
@@ -26888,9 +26900,16 @@ var EufyMega = class extends EventEmitter9 {
|
|
|
26888
26900
|
client.on("error", (e) => this.reportError(e));
|
|
26889
26901
|
return client;
|
|
26890
26902
|
}
|
|
26891
|
-
/**
|
|
26892
|
-
|
|
26893
|
-
|
|
26903
|
+
/**
|
|
26904
|
+
* Admit only exact, account-known devices with resolved snapshot evidence into the passive store; a
|
|
26905
|
+
* station-only candidate is admitted under the event's device serial.
|
|
26906
|
+
*/
|
|
26907
|
+
async observeStoredImage(candidate, eventDeviceSn) {
|
|
26908
|
+
if (!this.storedImages)
|
|
26909
|
+
return;
|
|
26910
|
+
const { attribution } = candidate;
|
|
26911
|
+
const deviceSn = attribution.kind === "device" ? attribution.deviceSn : attribution.kind === "station" ? eventDeviceSn : void 0;
|
|
26912
|
+
if (!deviceSn)
|
|
26894
26913
|
return;
|
|
26895
26914
|
const account = this.mega.auth?.userId;
|
|
26896
26915
|
if (!account)
|
|
@@ -26900,9 +26919,9 @@ var EufyMega = class extends EventEmitter9 {
|
|
|
26900
26919
|
await this.registry.getDevices();
|
|
26901
26920
|
if (this.mega.auth?.userId !== account)
|
|
26902
26921
|
return;
|
|
26903
|
-
const caps = this.registry.capabilitiesForDevice(
|
|
26922
|
+
const caps = this.registry.capabilitiesForDevice(deviceSn);
|
|
26904
26923
|
if (caps && hasProvidedAction(caps, "snapshotStored")) {
|
|
26905
|
-
this.storedImages.observe(
|
|
26924
|
+
this.storedImages.observe(deviceSn, candidate.url);
|
|
26906
26925
|
}
|
|
26907
26926
|
} catch (e) {
|
|
26908
26927
|
this.reportError(e);
|