@mega-yfue/eufy-sdk 0.5.0-beta.32 → 0.5.0-beta.34
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 +20 -13
- package/dist/index.js.map +4 -4
- package/dist/transport/p2p/fmp4.d.ts +6 -1
- package/dist/transport/token-echo.d.ts +8 -0
- package/package.json +1 -1
package/dist/index.js
CHANGED
|
@@ -196,6 +196,11 @@ var ConsoleLogger = class {
|
|
|
196
196
|
}
|
|
197
197
|
};
|
|
198
198
|
|
|
199
|
+
// dist/transport/token-echo.js
|
|
200
|
+
function withoutTokenEcho(text2) {
|
|
201
|
+
return text2.replace(/token\s*[=:]\s*"?[A-Za-z0-9._-]{8,}"?/gi, "token = <redacted>");
|
|
202
|
+
}
|
|
203
|
+
|
|
199
204
|
// dist/transport/http/media-download.js
|
|
200
205
|
import { lookup } from "node:dns/promises";
|
|
201
206
|
import { BlockList, isIP } from "node:net";
|
|
@@ -1557,9 +1562,6 @@ var CONTENDED_SESSION_HINT = "the token was rejected again soon after it was las
|
|
|
1557
1562
|
function tokenRejected(code, msg) {
|
|
1558
1563
|
return code === EufyCloudErrorCode.SESSION_KICKED || /user_id is empty|invalid[^,]*\btoken\b|\btoken\b[^,]*(expired|error|not exist)|kicked|(?:\btoken\b|\bsession\b)[^,]*does not exist|unauthor/i.test(msg ?? "");
|
|
1559
1564
|
}
|
|
1560
|
-
function withoutTokenEcho(text2) {
|
|
1561
|
-
return text2.replace(/token\s*[=:]\s*"?[A-Za-z0-9._-]{8,}"?/gi, "token = <redacted>");
|
|
1562
|
-
}
|
|
1563
1565
|
var MegaHttpClient = class {
|
|
1564
1566
|
cfg;
|
|
1565
1567
|
region;
|
|
@@ -20417,7 +20419,8 @@ var Fmp4Muxer = class {
|
|
|
20417
20419
|
fragTicks = 0;
|
|
20418
20420
|
// ticks accumulated in the open fragment
|
|
20419
20421
|
samples = [];
|
|
20420
|
-
|
|
20422
|
+
/** Ticks from the first video sample's start to the newest sample's end, at its provisional duration. */
|
|
20423
|
+
videoTicks = 0;
|
|
20421
20424
|
audioRequested;
|
|
20422
20425
|
audioCodec;
|
|
20423
20426
|
/** Decoder config of an AAC-ELD track, taken from its frames; absent for AAC-LC, whose `esds` config is fixed. */
|
|
@@ -20441,6 +20444,10 @@ var Fmp4Muxer = class {
|
|
|
20441
20444
|
* Push one access unit. Returns any completed segments: the `init` on the first keyframe, and/or a
|
|
20442
20445
|
* media fragment when this frame closed the open one. Returns `undefined` if nothing is emitted yet
|
|
20443
20446
|
* (e.g. delta frames before the first keyframe).
|
|
20447
|
+
*
|
|
20448
|
+
* A sample lasts until the next frame's `timestampMs`, measured from the first keyframe's, so the video
|
|
20449
|
+
* timeline follows the arrival clock; a frame that shares the previous one's timestamp leaves that
|
|
20450
|
+
* sample one tick long, and the next frame's duration absorbs the difference.
|
|
20444
20451
|
*/
|
|
20445
20452
|
push(frame, timestampMs = now()) {
|
|
20446
20453
|
if (frame.codec === "av1")
|
|
@@ -20459,15 +20466,14 @@ var Fmp4Muxer = class {
|
|
|
20459
20466
|
this.height = declared?.height ?? frame.height;
|
|
20460
20467
|
this.firstVideoTimestampMs = timestampMs;
|
|
20461
20468
|
}
|
|
20462
|
-
if (this.
|
|
20463
|
-
const
|
|
20464
|
-
|
|
20465
|
-
|
|
20466
|
-
|
|
20467
|
-
|
|
20468
|
-
|
|
20469
|
+
if (this.firstVideoTimestampMs !== void 0 && this.samples.length) {
|
|
20470
|
+
const previous = this.samples[this.samples.length - 1];
|
|
20471
|
+
const arrival = Math.round((timestampMs - this.firstVideoTimestampMs) * (TIMESCALE / 1e3));
|
|
20472
|
+
const duration = Math.max(1, arrival - (this.videoTicks - previous.duration));
|
|
20473
|
+
this.fragTicks += duration - previous.duration;
|
|
20474
|
+
this.videoTicks += duration - previous.duration;
|
|
20475
|
+
previous.duration = duration;
|
|
20469
20476
|
}
|
|
20470
|
-
this.lastVideoTimestampMs = timestampMs;
|
|
20471
20477
|
let fragment;
|
|
20472
20478
|
if (frame.keyframe && this.samples.length > 0 && this.fragTicks >= this.fragmentTicks) {
|
|
20473
20479
|
if (!this.initSent) {
|
|
@@ -20479,6 +20485,7 @@ var Fmp4Muxer = class {
|
|
|
20479
20485
|
}
|
|
20480
20486
|
this.samples.push({ data: annexbToAvcc(frame.data), duration: this.firstDuration, keyframe: frame.keyframe });
|
|
20481
20487
|
this.fragTicks += this.firstDuration;
|
|
20488
|
+
this.videoTicks += this.firstDuration;
|
|
20482
20489
|
if (!this.initSent && (!this.audioRequested || this.audioCodec || this.audioDisabled)) {
|
|
20483
20490
|
init = this.buildInit();
|
|
20484
20491
|
this.initSent = true;
|
|
@@ -23505,7 +23512,7 @@ var RtcSignalingClient = class extends EventEmitter9 {
|
|
|
23505
23512
|
});
|
|
23506
23513
|
const body = await res.json().catch(() => ({})) ?? {};
|
|
23507
23514
|
if (!res.ok || body.code !== 0 || !body.data) {
|
|
23508
|
-
throw new Error(`RTC sign for ${this.opts.stationSn} refused: HTTP ${res.status} code ${body.code ?? "?"} ${body.msg ?? ""}`.trim());
|
|
23515
|
+
throw new Error(`RTC sign for ${this.opts.stationSn} refused: HTTP ${res.status} code ${body.code ?? "?"} ${withoutTokenEcho(body.msg ?? "")}`.trim());
|
|
23509
23516
|
}
|
|
23510
23517
|
this.sign = body.data;
|
|
23511
23518
|
return body.data;
|