@aurabase/realtime 0.6.2 → 0.7.1
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 +13 -8
- package/dist/index.js +13 -8
- package/package.json +2 -2
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
|
|
1260
|
+
"Realtime: WebSocket connection closed unexpectedly.",
|
|
1261
1261
|
{ code: evt?.code, reason: evt?.reason }
|
|
1262
1262
|
) : new RealtimeConnectionError(
|
|
1263
1263
|
"handshake",
|
|
1264
|
-
"Realtime
|
|
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
|
|
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
|
|
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
|
|
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:
|
|
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:
|
|
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]
|
|
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
|
|
1258
|
+
"Realtime: WebSocket connection closed unexpectedly.",
|
|
1259
1259
|
{ code: evt?.code, reason: evt?.reason }
|
|
1260
1260
|
) : new RealtimeConnectionError(
|
|
1261
1261
|
"handshake",
|
|
1262
|
-
"Realtime
|
|
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
|
|
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
|
|
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
|
|
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:
|
|
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:
|
|
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]
|
|
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.
|
|
3
|
+
"version": "0.7.1",
|
|
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.
|
|
48
|
+
"@aurabase/core": "0.7.1"
|
|
49
49
|
},
|
|
50
50
|
"devDependencies": {
|
|
51
51
|
"@types/node": "20.14.15",
|