@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/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@ateam-ai-mobile/core",
3
- "version": "0.1.18",
3
+ "version": "0.1.20",
4
4
  "description": "Headless ADAS SDK core — auth bridge, API client, chat/job streaming, MCP calls, theme tokens. No UI, no Expo dependencies.",
5
5
  "main": "dist/index.js",
6
6
  "types": "dist/index.d.ts",
@@ -39,13 +39,22 @@ export interface PushRegistration {
39
39
  * the session clears the JWT). Returns once the token is forgotten locally.
40
40
  */
41
41
  unregister(): Promise<void>;
42
+ /**
43
+ * Bumped by every unregister() (sign-out). A push start notes it when it
44
+ * begins and checks it again before adopting a token or routing a tap: the
45
+ * host's sign-out unregisters BEFORE its UI stops push, so a token that
46
+ * arrives in between belongs to a user who already left.
47
+ */
48
+ generation(): number;
42
49
  }
43
50
 
44
51
  export function createPushRegistration(backend: PushBackend): PushRegistration {
45
52
  let token: string | null = null;
53
+ let generation = 0;
46
54
 
47
55
  return {
48
56
  getToken: () => token,
57
+ generation: () => generation,
49
58
 
50
59
  async setToken(next) {
51
60
  if (!next) { token = null; return; }
@@ -55,11 +64,14 @@ export function createPushRegistration(backend: PushBackend): PushRegistration {
55
64
  await backend.registerDevice(next);
56
65
  } catch (e: any) {
57
66
  console.warn('[adas/push] registerDevice failed:', e?.message || e);
67
+ // Not registered — forget it, so the next attempt with this token registers.
68
+ if (token === next) token = null;
58
69
  }
59
70
  },
60
71
 
61
72
  async unregister() {
62
73
  const t = token;
74
+ generation += 1;
63
75
  token = null; // forget locally immediately — a slow network must not block sign-out
64
76
  if (t) {
65
77
  backend.unregisterDevice(t).catch((e: any) =>