@aurabase/realtime 0.6.2 → 0.7.0

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.cjs CHANGED
@@ -1257,11 +1257,11 @@ var RealtimeService = class _RealtimeService {
1257
1257
  this._emitError(
1258
1258
  opened ? new RealtimeConnectionError(
1259
1259
  "connection",
1260
- "Realtime : connexion WebSocket ferm\xE9e de fa\xE7on inattendue.",
1260
+ "Realtime: WebSocket connection closed unexpectedly.",
1261
1261
  { code: evt?.code, reason: evt?.reason }
1262
1262
  ) : new RealtimeConnectionError(
1263
1263
  "handshake",
1264
- "Realtime : \xE9chec du handshake WebSocket (ferm\xE9 avant ouverture). Causes possibles, par ordre de fr\xE9quence : authentification refus\xE9e (HTTP 401/403 \u2014 token JWT absent, expir\xE9 ou invalide, apikey rejet\xE9e), quota de connexions atteint (HTTP 429), ou serveur injoignable / en red\xE9marrage / bloqu\xE9 par un proxy ou TLS. La sp\xE9cification WebSocket n'expose pas le statut HTTP du handshake au client : le SDK ne peut pas trancher entre ces causes.",
1264
+ "Realtime: WebSocket handshake failed (closed before opening). Possible causes, in order of likelihood: authentication refused (HTTP 401/403: JWT missing, expired or invalid, apikey rejected), connection quota reached (HTTP 429), or server unreachable / restarting / blocked by a proxy or TLS. The WebSocket specification does not expose the handshake HTTP status to the client: the SDK cannot tell these causes apart.",
1265
1265
  { code: evt?.code ?? 1006, reason: evt?.reason }
1266
1266
  )
1267
1267
  );
@@ -1309,7 +1309,7 @@ var RealtimeService = class _RealtimeService {
1309
1309
  const silence = Date.now() - this._lastServerMessageAt;
1310
1310
  if (silence < LIVENESS_MAX_SILENCE_MS) return;
1311
1311
  this._handleDeadConnection(
1312
- `Realtime : aucun message du serveur depuis ${Math.round(silence / 1e3)} s alors qu'il en pousse un toutes les 30 s \u2014 connexion consid\xE9r\xE9e morte. Reconnexion.`
1312
+ `Realtime: no message from the server for ${Math.round(silence / 1e3)} s although it pushes one every 30 s: the connection is considered dead. Reconnecting.`
1313
1313
  );
1314
1314
  }, LIVENESS_GUARD_INTERVAL_MS);
1315
1315
  if (isUnrefable2(this._livenessGuard)) {
@@ -1364,13 +1364,13 @@ var RealtimeService = class _RealtimeService {
1364
1364
  if (ws !== this._ws) return;
1365
1365
  if (ws.readyState !== WebSocket.OPEN) {
1366
1366
  this._handleDeadConnection(
1367
- "Realtime : la connexion WebSocket n\u2019est plus ouverte mais aucun \xE9v\xE9nement de fermeture n\u2019est arriv\xE9 (socket fig\xE9). Reconnexion."
1367
+ "Realtime: the WebSocket connection is no longer open but no close event arrived (stuck socket). Reconnecting."
1368
1368
  );
1369
1369
  return;
1370
1370
  }
1371
1371
  if (this._awaitingPong) {
1372
1372
  this._handleDeadConnection(
1373
- `Realtime : connexion inactive \u2014 aucune r\xE9ponse du serveur dans les ${HEARTBEAT_INTERVAL_MS} ms suivant un ping (connexion probablement morte). Reconnexion.`
1373
+ `Realtime: idle connection, no server response within ${HEARTBEAT_INTERVAL_MS} ms after a ping (connection probably dead). Reconnecting.`
1374
1374
  );
1375
1375
  return;
1376
1376
  }
@@ -1524,7 +1524,7 @@ var RealtimeService = class _RealtimeService {
1524
1524
  error: new core.AuraError(0, {
1525
1525
  error: {
1526
1526
  code: "realtime_payload_event_reserved",
1527
- message: "httpBroadcast: le payload contient une cl\xE9 `event`, r\xE9serv\xE9e au nom de l'\xE9v\xE9nement (elle \xE9craserait celui-ci chez les abonn\xE9s). Renommez-la (`eventName`, `kind`\u2026)."
1527
+ message: "httpBroadcast: the payload contains an `event` key, which is reserved for the event name (it would overwrite it for subscribers). Rename it (`eventName`, `kind`\u2026)."
1528
1528
  }
1529
1529
  })
1530
1530
  });
@@ -1545,7 +1545,7 @@ var RealtimeService = class _RealtimeService {
1545
1545
  error: new core.AuraError(0, {
1546
1546
  error: {
1547
1547
  code: "realtime_channel_non_qualifie",
1548
- message: `httpBroadcast: le canal "${channel}" n'est pas qualifi\xE9 et aucune session n'est ouverte \u2014 le SDK n'a donc aucun \`project_id\` \xE0 lui pr\xE9fixer, alors que le serveur l'EXIGE (403 \xAB Le canal n'appartient pas \xE0 ce projet \xBB). Passez le canal sous la forme "<project_id>:` + channel + `" ou sp\xE9cifiez l'option { projectId: "<uuid>" } \u2014 c'est la forme attendue c\xF4t\xE9 serveur/edge, o\xF9 il n'y a pas de session utilisateur.`
1548
+ message: `httpBroadcast: the channel "${channel}" is not qualified and no session is open, so the SDK has no \`project_id\` to prefix it with, while the server REQUIRES it (403 "The channel does not belong to this project"). Pass the channel as "<project_id>:` + channel + '" or specify the option { projectId: "<uuid>" }, which is the expected form server-side/edge, where there is no user session.'
1549
1549
  }
1550
1550
  })
1551
1551
  });
@@ -1711,7 +1711,7 @@ var RealtimeService = class _RealtimeService {
1711
1711
  if (msg.type === "error") {
1712
1712
  if (typeof console !== "undefined") {
1713
1713
  console.warn(
1714
- "[aura-realtime] Erreur serveur pour un canal inconnu de ce client \u2014 ignor\xE9e (aucun canal local concern\xE9) :",
1714
+ "[aura-realtime] Server error for a channel unknown to this client: ignored (no local channel concerned):",
1715
1715
  { channel: channelFull, message: msg.message }
1716
1716
  );
1717
1717
  }
@@ -1748,6 +1748,11 @@ var RealtimeService = class _RealtimeService {
1748
1748
  for (const ch of this._channels.values()) {
1749
1749
  ch._onMessage(msg);
1750
1750
  }
1751
+ const text = msg.message ?? "";
1752
+ if (text.startsWith("SESSION_REVOKED") && !this._customAuthToken) {
1753
+ this._reconnectAttempts = this._maxReconnectAttempts;
1754
+ this.client.authStore.clear();
1755
+ }
1751
1756
  }
1752
1757
  }
1753
1758
  };
package/dist/index.js CHANGED
@@ -1255,11 +1255,11 @@ var RealtimeService = class _RealtimeService {
1255
1255
  this._emitError(
1256
1256
  opened ? new RealtimeConnectionError(
1257
1257
  "connection",
1258
- "Realtime : connexion WebSocket ferm\xE9e de fa\xE7on inattendue.",
1258
+ "Realtime: WebSocket connection closed unexpectedly.",
1259
1259
  { code: evt?.code, reason: evt?.reason }
1260
1260
  ) : new RealtimeConnectionError(
1261
1261
  "handshake",
1262
- "Realtime : \xE9chec du handshake WebSocket (ferm\xE9 avant ouverture). Causes possibles, par ordre de fr\xE9quence : authentification refus\xE9e (HTTP 401/403 \u2014 token JWT absent, expir\xE9 ou invalide, apikey rejet\xE9e), quota de connexions atteint (HTTP 429), ou serveur injoignable / en red\xE9marrage / bloqu\xE9 par un proxy ou TLS. La sp\xE9cification WebSocket n'expose pas le statut HTTP du handshake au client : le SDK ne peut pas trancher entre ces causes.",
1262
+ "Realtime: WebSocket handshake failed (closed before opening). Possible causes, in order of likelihood: authentication refused (HTTP 401/403: JWT missing, expired or invalid, apikey rejected), connection quota reached (HTTP 429), or server unreachable / restarting / blocked by a proxy or TLS. The WebSocket specification does not expose the handshake HTTP status to the client: the SDK cannot tell these causes apart.",
1263
1263
  { code: evt?.code ?? 1006, reason: evt?.reason }
1264
1264
  )
1265
1265
  );
@@ -1307,7 +1307,7 @@ var RealtimeService = class _RealtimeService {
1307
1307
  const silence = Date.now() - this._lastServerMessageAt;
1308
1308
  if (silence < LIVENESS_MAX_SILENCE_MS) return;
1309
1309
  this._handleDeadConnection(
1310
- `Realtime : aucun message du serveur depuis ${Math.round(silence / 1e3)} s alors qu'il en pousse un toutes les 30 s \u2014 connexion consid\xE9r\xE9e morte. Reconnexion.`
1310
+ `Realtime: no message from the server for ${Math.round(silence / 1e3)} s although it pushes one every 30 s: the connection is considered dead. Reconnecting.`
1311
1311
  );
1312
1312
  }, LIVENESS_GUARD_INTERVAL_MS);
1313
1313
  if (isUnrefable2(this._livenessGuard)) {
@@ -1362,13 +1362,13 @@ var RealtimeService = class _RealtimeService {
1362
1362
  if (ws !== this._ws) return;
1363
1363
  if (ws.readyState !== WebSocket.OPEN) {
1364
1364
  this._handleDeadConnection(
1365
- "Realtime : la connexion WebSocket n\u2019est plus ouverte mais aucun \xE9v\xE9nement de fermeture n\u2019est arriv\xE9 (socket fig\xE9). Reconnexion."
1365
+ "Realtime: the WebSocket connection is no longer open but no close event arrived (stuck socket). Reconnecting."
1366
1366
  );
1367
1367
  return;
1368
1368
  }
1369
1369
  if (this._awaitingPong) {
1370
1370
  this._handleDeadConnection(
1371
- `Realtime : connexion inactive \u2014 aucune r\xE9ponse du serveur dans les ${HEARTBEAT_INTERVAL_MS} ms suivant un ping (connexion probablement morte). Reconnexion.`
1371
+ `Realtime: idle connection, no server response within ${HEARTBEAT_INTERVAL_MS} ms after a ping (connection probably dead). Reconnecting.`
1372
1372
  );
1373
1373
  return;
1374
1374
  }
@@ -1522,7 +1522,7 @@ var RealtimeService = class _RealtimeService {
1522
1522
  error: new AuraError(0, {
1523
1523
  error: {
1524
1524
  code: "realtime_payload_event_reserved",
1525
- message: "httpBroadcast: le payload contient une cl\xE9 `event`, r\xE9serv\xE9e au nom de l'\xE9v\xE9nement (elle \xE9craserait celui-ci chez les abonn\xE9s). Renommez-la (`eventName`, `kind`\u2026)."
1525
+ message: "httpBroadcast: the payload contains an `event` key, which is reserved for the event name (it would overwrite it for subscribers). Rename it (`eventName`, `kind`\u2026)."
1526
1526
  }
1527
1527
  })
1528
1528
  });
@@ -1543,7 +1543,7 @@ var RealtimeService = class _RealtimeService {
1543
1543
  error: new AuraError(0, {
1544
1544
  error: {
1545
1545
  code: "realtime_channel_non_qualifie",
1546
- message: `httpBroadcast: le canal "${channel}" n'est pas qualifi\xE9 et aucune session n'est ouverte \u2014 le SDK n'a donc aucun \`project_id\` \xE0 lui pr\xE9fixer, alors que le serveur l'EXIGE (403 \xAB Le canal n'appartient pas \xE0 ce projet \xBB). Passez le canal sous la forme "<project_id>:` + channel + `" ou sp\xE9cifiez l'option { projectId: "<uuid>" } \u2014 c'est la forme attendue c\xF4t\xE9 serveur/edge, o\xF9 il n'y a pas de session utilisateur.`
1546
+ message: `httpBroadcast: the channel "${channel}" is not qualified and no session is open, so the SDK has no \`project_id\` to prefix it with, while the server REQUIRES it (403 "The channel does not belong to this project"). Pass the channel as "<project_id>:` + channel + '" or specify the option { projectId: "<uuid>" }, which is the expected form server-side/edge, where there is no user session.'
1547
1547
  }
1548
1548
  })
1549
1549
  });
@@ -1709,7 +1709,7 @@ var RealtimeService = class _RealtimeService {
1709
1709
  if (msg.type === "error") {
1710
1710
  if (typeof console !== "undefined") {
1711
1711
  console.warn(
1712
- "[aura-realtime] Erreur serveur pour un canal inconnu de ce client \u2014 ignor\xE9e (aucun canal local concern\xE9) :",
1712
+ "[aura-realtime] Server error for a channel unknown to this client: ignored (no local channel concerned):",
1713
1713
  { channel: channelFull, message: msg.message }
1714
1714
  );
1715
1715
  }
@@ -1746,6 +1746,11 @@ var RealtimeService = class _RealtimeService {
1746
1746
  for (const ch of this._channels.values()) {
1747
1747
  ch._onMessage(msg);
1748
1748
  }
1749
+ const text = msg.message ?? "";
1750
+ if (text.startsWith("SESSION_REVOKED") && !this._customAuthToken) {
1751
+ this._reconnectAttempts = this._maxReconnectAttempts;
1752
+ this.client.authStore.clear();
1753
+ }
1749
1754
  }
1750
1755
  }
1751
1756
  };
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@aurabase/realtime",
3
- "version": "0.6.2",
3
+ "version": "0.7.0",
4
4
  "description": "Service temps réel du SDK Aurabase (postgres_changes, broadcast, presence)",
5
5
  "type": "module",
6
6
  "main": "dist/index.cjs",
@@ -45,7 +45,7 @@
45
45
  "realtime"
46
46
  ],
47
47
  "dependencies": {
48
- "@aurabase/core": "0.6.2"
48
+ "@aurabase/core": "0.7.0"
49
49
  },
50
50
  "devDependencies": {
51
51
  "@types/node": "20.14.15",