@mega-yfue/eufy-sdk 0.5.0-beta.55 → 0.5.0-beta.57
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 +15 -5
- package/dist/index.js.map +2 -2
- package/dist/transport/http/mega-client.d.ts +6 -1
- package/package.json +1 -1
package/dist/index.js
CHANGED
|
@@ -1605,6 +1605,8 @@ var MegaHttpClient = class {
|
|
|
1605
1605
|
/** True while a 2FA code is outstanding: `auth_` holds only the limited pre-verify token, so the
|
|
1606
1606
|
* restored-session short-circuit must NOT treat it as a usable session. Cleared on Ok/reset. */
|
|
1607
1607
|
pending2fa = false;
|
|
1608
|
+
/** An autonomous re-login answered captcha/2FA; see {@link canReauthenticate}. */
|
|
1609
|
+
reloginChallenged = false;
|
|
1608
1610
|
tokenExpiresAt = 0;
|
|
1609
1611
|
/**
|
|
1610
1612
|
* Stable per-install device id: `openudid` as configured, as restored from the session store, or as
|
|
@@ -1656,6 +1658,7 @@ var MegaHttpClient = class {
|
|
|
1656
1658
|
*
|
|
1657
1659
|
* Read at construction, and again when a rejection is being recovered from — a store SHARED with another
|
|
1658
1660
|
* client may already hold the session that client obtained, which is cheaper to adopt than to compete with.
|
|
1661
|
+
* An adopted session is a complete one, so it ends any 2FA or challenged re-login this client was left with.
|
|
1659
1662
|
*
|
|
1660
1663
|
* Note: the device identity (openudid + phone model + media UA) is NOT restored here — it is resolved once
|
|
1661
1664
|
* in the constructor, where an explicit config wins over the stored value, and must not be re-derived from a
|
|
@@ -1674,6 +1677,8 @@ var MegaHttpClient = class {
|
|
|
1674
1677
|
geoKey: saved.geoKey
|
|
1675
1678
|
};
|
|
1676
1679
|
this.tokenExpiresAt = saved.tokenExpiresAt;
|
|
1680
|
+
this.pending2fa = false;
|
|
1681
|
+
this.reloginChallenged = false;
|
|
1677
1682
|
this.sessionKey = {
|
|
1678
1683
|
keyIdent: saved.keyIdent,
|
|
1679
1684
|
shareKey: saved.shareKey,
|
|
@@ -2358,11 +2363,13 @@ ${this.auth_?.authToken ?? ""}`;
|
|
|
2358
2363
|
* Structural rather than a list of paths: a login round trip is itself an authenticated call while a limited
|
|
2359
2364
|
* token is held, so re-logging in from inside one would recurse — and a path list would have to be
|
|
2360
2365
|
* maintained alongside every request the login flow makes. A 2FA code already outstanding is a login a human
|
|
2361
|
-
* is part-way through, and restarting it silently would discard it.
|
|
2366
|
+
* is part-way through, and restarting it silently would discard it. A re-login that already came back needing
|
|
2367
|
+
* a captcha or a 2FA code would need the same again, and each attempt sends the account another code, so
|
|
2368
|
+
* none is tried until a login completes or a stored session is adopted. No credentials means nothing to try,
|
|
2362
2369
|
* so the rejection surfaces instead.
|
|
2363
2370
|
*/
|
|
2364
2371
|
canReauthenticate() {
|
|
2365
|
-
return !!this.cfg.email && !!this.cfg.password && !this.loggingIn && !this.pending2fa;
|
|
2372
|
+
return !!this.cfg.email && !!this.cfg.password && !this.loggingIn && !this.pending2fa && !this.reloginChallenged;
|
|
2366
2373
|
}
|
|
2367
2374
|
/**
|
|
2368
2375
|
* Replace a rejected token by running the login state machine again, at most once at a time.
|
|
@@ -2379,8 +2386,10 @@ ${this.auth_?.authToken ?? ""}`;
|
|
|
2379
2386
|
this.reauthAttempt ??= this.login().then((result) => {
|
|
2380
2387
|
if (result.status === LoginStatus.Ok)
|
|
2381
2388
|
this.logger.debug("[mega] token was rejected \u2014 logged in again");
|
|
2382
|
-
else
|
|
2389
|
+
else {
|
|
2390
|
+
this.reloginChallenged = true;
|
|
2383
2391
|
this.logger.warn(`[mega] token was rejected and the re-login needs ${result.status} \u2014 cannot recover`);
|
|
2392
|
+
}
|
|
2384
2393
|
return result.status === LoginStatus.Ok;
|
|
2385
2394
|
}).catch((e) => {
|
|
2386
2395
|
this.logger.warn(`[mega] re-login failed: ${e instanceof Error ? e.message : String(e)}`);
|
|
@@ -2457,6 +2466,7 @@ ${this.auth_?.authToken ?? ""}`;
|
|
|
2457
2466
|
}
|
|
2458
2467
|
this.pendingCaptchaId = void 0;
|
|
2459
2468
|
this.pending2fa = false;
|
|
2469
|
+
this.reloginChallenged = false;
|
|
2460
2470
|
this.auth_ = { userId, accountUserId, authToken, geoKey };
|
|
2461
2471
|
this.tokenExpiresAt = reply.tokenExpiresAt;
|
|
2462
2472
|
this.sessionKey = void 0;
|
|
@@ -4591,7 +4601,7 @@ function decodePowerSource(raw) {
|
|
|
4591
4601
|
function recordSetting(param, value, ctx) {
|
|
4592
4602
|
return setStationScalar(param, value, ctx.channel);
|
|
4593
4603
|
}
|
|
4594
|
-
var MAINS_CAMERA_MODELS = ["T8425", "T8419", "T8410", "T84A1", "T8423"];
|
|
4604
|
+
var MAINS_CAMERA_MODELS = ["T8425", "T8419", "T8410", "T84A1", "T8423", "T8E00", "T8P00"];
|
|
4595
4605
|
function cameraPowerTier(model, capabilities) {
|
|
4596
4606
|
return capabilities.has("battery") && notMainsCamera({ model }) ? "battery" : "wired";
|
|
4597
4607
|
}
|
|
@@ -17575,7 +17585,7 @@ var P2PSession = class _P2PSession extends EventEmitter2 {
|
|
|
17575
17585
|
} catch {
|
|
17576
17586
|
}
|
|
17577
17587
|
}
|
|
17578
|
-
if (header.commandId === CMD_GATEWAYINFO && header.signCode
|
|
17588
|
+
if (header.commandId === CMD_GATEWAYINFO && header.signCode <= 1 && !this.level2Key && !this.level2Negotiating && this.cfg.resolveCipherKey) {
|
|
17579
17589
|
this.negotiateLevel2Key(data);
|
|
17580
17590
|
}
|
|
17581
17591
|
if (header.commandId === CMD_DATABASE && header.signCode > 0) {
|