eufy-security-client 4.1.0-dev.36 → 4.1.0-dev.38

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.
@@ -287,14 +287,30 @@ class EufySecurity extends tiny_typed_emitter_1.TypedEmitter {
287
287
  this.api.setSerialNumber(this.persistentData.serial_number);
288
288
  this.pushService = await service_1.PushNotificationService.initialize();
289
289
  this.pushService.on("connect", async (token) => {
290
- this.pushCloudRegistered = await this.api.registerPushToken(token);
291
- this.pushCloudChecked = await this.api.checkPushToken();
292
- const megaRegistered = await this.megaTransition.registerMegaPushToken(token);
293
- //TODO: Retry if failed with max retry to not lock account
294
- // Push is "connected" if registration succeeded on EITHER backend: on a migrated account the
295
- // legacy registration fails (no legacy session) but the v6 one carries the events.
296
- if ((this.pushCloudRegistered && this.pushCloudChecked) || megaRegistered) {
297
- logging_1.rootMainLogger.info("Push notification connection successfully established");
290
+ // Register the SAME FCM token on BOTH backends, INDEPENDENTLY. A migrated account is rejected
291
+ // by the legacy endpoint; a non-migrated one has no mega session. Whichever backend accepts the
292
+ // token delivers events — so one failing must never starve the other, and push counts as
293
+ // established if EITHER side accepted it.
294
+ let legacyOk = false;
295
+ try {
296
+ legacyOk = await this.api.registerPushToken(token);
297
+ legacyOk = legacyOk && (await this.api.checkPushToken());
298
+ }
299
+ catch (err) {
300
+ logging_1.rootMainLogger.warn("Legacy push token registration failed (v6 may still deliver)", {
301
+ error: (0, utils_1.getError)((0, error_1.ensureError)(err)),
302
+ });
303
+ }
304
+ this.pushCloudRegistered = legacyOk;
305
+ this.pushCloudChecked = legacyOk;
306
+ // Adjust this call to match your build: inline it's this.registerMegaPushToken(token);
307
+ // after the refactor it's likely this.megaTransition.registerMegaPushToken(token).
308
+ const megaOk = await this.megaTransition.registerMegaPushToken(token); // must return boolean, best-effort, never throws
309
+ if (legacyOk || megaOk) {
310
+ logging_1.rootMainLogger.info("Push notification connection successfully established", {
311
+ legacy: legacyOk,
312
+ eufyMega: megaOk,
313
+ });
298
314
  this.emit("push connect");
299
315
  }
300
316
  else {