@ateam-ai-mobile/core 0.1.18 → 0.1.20

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.d.mts CHANGED
@@ -434,6 +434,13 @@ interface PushRegistration {
434
434
  * the session clears the JWT). Returns once the token is forgotten locally.
435
435
  */
436
436
  unregister(): Promise<void>;
437
+ /**
438
+ * Bumped by every unregister() (sign-out). A push start notes it when it
439
+ * begins and checks it again before adopting a token or routing a tap: the
440
+ * host's sign-out unregisters BEFORE its UI stops push, so a token that
441
+ * arrives in between belongs to a user who already left.
442
+ */
443
+ generation(): number;
437
444
  }
438
445
  declare function createPushRegistration(backend: PushBackend): PushRegistration;
439
446
 
package/dist/index.d.ts CHANGED
@@ -434,6 +434,13 @@ interface PushRegistration {
434
434
  * the session clears the JWT). Returns once the token is forgotten locally.
435
435
  */
436
436
  unregister(): Promise<void>;
437
+ /**
438
+ * Bumped by every unregister() (sign-out). A push start notes it when it
439
+ * begins and checks it again before adopting a token or routing a tap: the
440
+ * host's sign-out unregisters BEFORE its UI stops push, so a token that
441
+ * arrives in between belongs to a user who already left.
442
+ */
443
+ generation(): number;
437
444
  }
438
445
  declare function createPushRegistration(backend: PushBackend): PushRegistration;
439
446
 
package/dist/index.js CHANGED
@@ -548,8 +548,10 @@ function createAuthSession(deps) {
548
548
  // src/pushRegistration.ts
549
549
  function createPushRegistration(backend) {
550
550
  let token = null;
551
+ let generation = 0;
551
552
  return {
552
553
  getToken: () => token,
554
+ generation: () => generation,
553
555
  async setToken(next) {
554
556
  if (!next) {
555
557
  token = null;
@@ -561,10 +563,12 @@ function createPushRegistration(backend) {
561
563
  await backend.registerDevice(next);
562
564
  } catch (e) {
563
565
  console.warn("[adas/push] registerDevice failed:", e?.message || e);
566
+ if (token === next) token = null;
564
567
  }
565
568
  },
566
569
  async unregister() {
567
570
  const t = token;
571
+ generation += 1;
568
572
  token = null;
569
573
  if (t) {
570
574
  backend.unregisterDevice(t).catch(