@mega-yfue/eufy-sdk 0.6.0-beta.31 → 0.6.0-beta.32

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.
@@ -212,6 +212,8 @@ export declare class MegaHttpClient {
212
212
  private region;
213
213
  /** The host `estimate_domain` answered, persisted with the session. */
214
214
  private estimatedDomain;
215
+ /** The in-flight (then settled, so cached) RTC-sign shard request from {@link portalShard}. */
216
+ private portalShardInFlight?;
215
217
  private bootstrapDomain?;
216
218
  private sessionKey?;
217
219
  /** Per-host ECDH session keys for non-mega gateways (e.g. eufylife) keyed by host. */
@@ -283,11 +285,19 @@ export declare class MegaHttpClient {
283
285
  /** The active region shard (e.g. `"eu-pr"`, `"us-pr"`), set after {@link login} or a region override. */
284
286
  get regionShard(): RegionShard;
285
287
  /**
286
- * The shard the RTC signalling signs on: the regional prefix of the estimated domain
287
- * (`…-ie-…`/`…-ie.` → `ie-pr`), else {@link regionShard}. The eu/us classification cannot name shards
288
- * like `ie-pr`, whose accounts need the IE sign host and cluster.
288
+ * The shard the estimated domain names (`…-ie-…`/`…-ie.` → `ie-pr`), else {@link regionShard}. The
289
+ * eu/us classification cannot name shards like `ie-pr`.
289
290
  */
290
291
  get rtcShard(): string;
292
+ /**
293
+ * The shard the RTC signalling signs on, from `estimate_domain` asked with the portal's WEB identity
294
+ * (`Model-Type: WEB`, `App-Name: eufy_mega`) — the identity the sign itself is sent with, which can name
295
+ * a different shard than the PHONE identity does for one account. The in-flight request is shared by
296
+ * concurrent first callers, and once it settles to a shard the resolved promise is the cache; a call
297
+ * that fails or names no shard answers {@link rtcShard}, clears the field and is asked again next time.
298
+ */
299
+ portalShard(): Promise<string>;
300
+ private fetchPortalShard;
291
301
  /**
292
302
  * The credentials the RTC signalling needs; `undefined` while logged out. The sign is refused
293
303
  * ("gtoken not equal userid") unless its gtoken is the one every authed HTTP call carries.
@@ -334,6 +344,8 @@ export declare class MegaHttpClient {
334
344
  * raw text. Never throws on HTTP status (the callers classify the envelope themselves). 20s timeout.
335
345
  */
336
346
  private httpPost;
347
+ /** POST `estimate_domain` with the given identity headers. */
348
+ private estimateDomainRequest;
337
349
  /** Step 1: discover the account's region shard (and the bootstrap host). */
338
350
  estimateDomain(): Promise<void>;
339
351
  /**
@@ -61,8 +61,8 @@ export interface RtcLiveRoute extends RtcRoute {
61
61
  export interface RtcCommandRouterDeps {
62
62
  /** The logged-in session's credentials; `undefined` while logged out. */
63
63
  identity: () => RtcIdentity | undefined;
64
- /** The mega shard the account signs on (`"ie-pr"`, `"eu-pr"`, `"us-pr"`); picks the smart host. */
65
- shard: () => string;
64
+ /** The signing shard for the route (`"ie-pr"`, `"eu-pr"`, `"us-pr"`); picks the smart host. */
65
+ shard: (route: RtcRoute) => string | Promise<string>;
66
66
  /** ISO country sent on the sign request (default `US`). */
67
67
  country?: string;
68
68
  logger?: Logger;
@@ -78,6 +78,8 @@ export declare class RtcCommandRouter {
78
78
  private readonly warm;
79
79
  private readonly callSources;
80
80
  private lastTransaction;
81
+ /** The latest shard each `call` source resolved, read by its `makeStream` (see {@link callMediaProviderFor}). */
82
+ private readonly callShards;
81
83
  constructor(deps: RtcCommandRouterDeps);
82
84
  dispatchCommand(route: RtcRoute, cmd: Command): Promise<void>;
83
85
  /**
@@ -132,7 +134,13 @@ export declare class RtcCommandRouter {
132
134
  trackMediaProviderFor(route: RtcRoute): MediaProvider;
133
135
  /** NVR media uses a dedicated call per camera, independent of station commands. */
134
136
  nvrMediaProviderFor(route: RtcLiveRoute, views: readonly number[]): MediaProvider;
135
- /** Share a dedicated-call source and its consumer operations under one route key. */
137
+ /**
138
+ * Share a dedicated-call source and its consumer operations under one route key.
139
+ *
140
+ * `SharedLiveSource` calls `makeStream` synchronously, so the shard cannot be awaited inside it. Each
141
+ * async entry point resolves the shard and records it in {@link callShards} before touching the source;
142
+ * `makeStream` reads the latest recorded value.
143
+ */
136
144
  private callMediaProviderFor;
137
145
  /**
138
146
  * Tear down every station session (logout / shutdown). Each live source is disposed before its session
@@ -174,6 +182,14 @@ export declare class RtcCommandRouter {
174
182
  */
175
183
  private sendAwaitAck;
176
184
  private newSession;
185
+ /** A connected session for `sn` to reuse, or undefined (dropping a dead one). */
186
+ private reusable;
187
+ /**
188
+ * Get or open the station's session. A connected session is reused before the shard is awaited, so a
189
+ * command on an already-connected station never waits on the unauthenticated `estimate_domain` round
190
+ * trip — only the create path awaits it. After the await the map is re-checked, with no `await` between
191
+ * the lookup and `this.sessions.set`, so concurrent creators still share one session.
192
+ */
177
193
  private stationSession;
178
194
  /**
179
195
  * One bounded bring-up: the session is up when its command channel opens, and it fails, with the
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@mega-yfue/eufy-sdk",
3
- "version": "0.6.0-beta.31",
3
+ "version": "0.6.0-beta.32",
4
4
  "description": "One typed TypeScript client for the Anker eufy v6 cloud — capability-driven devices, realtime events over P2P/MQTT/push, and live media",
5
5
  "license": "Apache-2.0",
6
6
  "author": "mega-yfue",