@mega-yfue/eufy-sdk 0.2.0-beta.14 → 0.2.0-beta.16

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.
@@ -5,6 +5,14 @@ import type { RegionShard } from "../transport/http/mega-client.js";
5
5
  */
6
6
  export interface PersistedSession {
7
7
  userId: string;
8
+ /**
9
+ * The eufy account's own `user_id` — the id the `gtoken` header is hashed from, which is not always the
10
+ * `ap_cloud_user_id` that `userId` prefers.
11
+ *
12
+ * Always written, equal to `userId` when the login reply carried only the one id. Absent therefore means a
13
+ * record from before this was tracked, which {@link isSessionValid} refuses rather than restore.
14
+ */
15
+ accountUserId?: string;
8
16
  authToken: string;
9
17
  geoKey?: string;
10
18
  region: RegionShard;
@@ -50,5 +58,14 @@ export declare class FileSessionStore<T = PersistedSession> implements SessionSt
50
58
  * (e.g. Solix) whose session shape differs but whose freshness rule is identical.
51
59
  */
52
60
  export declare function tokenNotExpired(tokenExpiresAt: number | undefined, skewSec?: number): boolean;
53
- /** A persisted session is usable if it has a token that isn't (near-)expired. */
61
+ /**
62
+ * A persisted session is usable if it carries a complete credential — token, bound ECDH key, and the account
63
+ * id the `gtoken` header is hashed from — whose token isn't (near-)expired.
64
+ *
65
+ * `accountUserId` is part of the credential, not an optional extra: a record without it was written before
66
+ * that id was tracked, so it can only be restored as the other id, which is what the gateway rejects the
67
+ * header on. Nothing in a restored session can recover it either — the id arrives with a login reply. So such
68
+ * a record is refused and one login re-establishes it, rather than reinstating a session whose every
69
+ * authenticated call fails identically.
70
+ */
54
71
  export declare function isSessionValid(s: PersistedSession | null, skewSec?: number): boolean;