@antzsoft/chat-core 1.3.4 → 1.3.6
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/README.md +11 -1
- package/dist/index.cjs +27 -7
- package/dist/index.cjs.map +1 -1
- package/dist/index.js +27 -7
- package/dist/index.js.map +1 -1
- package/package.json +1 -1
package/README.md
CHANGED
|
@@ -2141,7 +2141,7 @@ import type { SocketStatus } from '@antzsoft/chat-core';
|
|
|
2141
2141
|
|---|---|---|
|
|
2142
2142
|
| `connectSocket` | `(config: ResolvedConfig, getToken: () => string \| null \| undefined) => Promise<Socket>` | Initialize and connect the Socket.IO client. No-ops if already connected. |
|
|
2143
2143
|
| `disconnectSocket` | `() => void` | Disconnect and clear the socket singleton. |
|
|
2144
|
-
| `reconnectSocket` | `(token: string) => void` | Update the auth token on the existing socket and reconnect. |
|
|
2144
|
+
| `reconnectSocket` | `(token: string) => void` | Update the auth token on the existing socket and reconnect. When transit encryption is enabled it re-runs the full `connectSocket()` handshake (re-establishing the transit session) rather than a bare auth swap, and dedupes concurrent calls. |
|
|
2145
2145
|
| `getSocketStatus` | `() => SocketStatus` | Synchronously read the current connection status. |
|
|
2146
2146
|
| `onSocketStatus` | `(listener: (status: SocketStatus) => void) => () => void` | Subscribe to status changes. Returns an unsubscribe function. |
|
|
2147
2147
|
|
|
@@ -3056,6 +3056,16 @@ document.querySelectorAll('[data-conv-id]').forEach((el) => {
|
|
|
3056
3056
|
|
|
3057
3057
|
## Changelog
|
|
3058
3058
|
|
|
3059
|
+
### v1.3.5
|
|
3060
|
+
|
|
3061
|
+
- **Fix: `reconnectSocket()` no longer drops the transit-encryption handshake** — when transit encryption is enabled, `reconnectSocket()` now delegates to the full `connectSocket()` flow instead of doing a bare `_socket.auth` swap. `reconnectSocket()` predates transit encryption and was never migrated: it overwrote `_socket.auth` with only `{ token, userId, tenantId }`, dropping the `transitSessionId` / `transitEphemeralPub` fields that `connectSocket()` sets during the handshake. Combined with the `'disconnect'` handler clearing the cached transit session, a reconnect after the socket had disconnected (e.g. app returning to foreground on iOS/Android, where backgrounding fully disconnects) went out with no transit auth and no cached session → the server rejected the handshake with **"Transit encryption required: missing transitEphemeralPub/transitAlgo in handshake auth"**. It was intermittent — fast devices whose cached transit session survived the reconnect were unaffected.
|
|
3062
|
+
|
|
3063
|
+
Now, when transit encryption is on, `reconnectSocket()` re-runs `connectSocket()`, which re-establishes/reuses the transit session and rebuilds the handshake auth. It also inherits `connectSocket()`'s in-flight dedupe (`_connectingPromise`), so multiple rapid reconnect calls (a token refresh can trigger several) collapse into a single connect. Non-transit deployments keep the original fast bare auth-swap path unchanged.
|
|
3064
|
+
|
|
3065
|
+
The transit path is gated on the resolved config flag (`transitEncryption`), not the runtime `isTransitEnabled()` — the latter is `false` immediately after a disconnect clears the session, which is exactly when the transit-aware reconnect is needed.
|
|
3066
|
+
|
|
3067
|
+
**No integration changes required** — `reconnectSocket(token, userId, tenantId)` keeps the same signature; the SDK now handles the transit handshake internally on reconnect.
|
|
3068
|
+
|
|
3059
3069
|
### v1.3.4
|
|
3060
3070
|
|
|
3061
3071
|
- **New: `deletedConversationIds` in `CrossConversationSyncResponse`** — `syncApi.pull(since)` now returns `deletedConversationIds: string[]`. Contains the IDs of conversations this user explicitly deleted from their list (via the delete-conversation action) since the `since` cursor. The client should remove these from local SQLite and the UI conversation list.
|
package/dist/index.cjs
CHANGED
|
@@ -1516,6 +1516,7 @@ var _statusListeners = /* @__PURE__ */ new Set();
|
|
|
1516
1516
|
var _getToken = null;
|
|
1517
1517
|
var _userId;
|
|
1518
1518
|
var _tenantId;
|
|
1519
|
+
var _config2 = null;
|
|
1519
1520
|
function setStatus(s) {
|
|
1520
1521
|
_status = s;
|
|
1521
1522
|
_statusListeners.forEach((l) => l(s));
|
|
@@ -1594,6 +1595,7 @@ async function _doConnect(config, getToken) {
|
|
|
1594
1595
|
_getToken = getToken;
|
|
1595
1596
|
_userId = config.userId;
|
|
1596
1597
|
_tenantId = config.tenantId;
|
|
1598
|
+
_config2 = config;
|
|
1597
1599
|
const token = getToken();
|
|
1598
1600
|
const socketHandshakeAuth = {
|
|
1599
1601
|
token: token ? `Bearer ${token}` : "",
|
|
@@ -1756,16 +1758,34 @@ function disconnectSocket() {
|
|
|
1756
1758
|
_getToken = null;
|
|
1757
1759
|
_userId = void 0;
|
|
1758
1760
|
_tenantId = void 0;
|
|
1761
|
+
_config2 = null;
|
|
1759
1762
|
}
|
|
1760
1763
|
function reconnectSocket(token, userId, tenantId) {
|
|
1761
|
-
if (_socket)
|
|
1762
|
-
|
|
1763
|
-
|
|
1764
|
-
|
|
1765
|
-
|
|
1766
|
-
|
|
1767
|
-
|
|
1764
|
+
if (!_socket) return;
|
|
1765
|
+
if (_config2?.transitEncryption) {
|
|
1766
|
+
const existing = getTransitSession();
|
|
1767
|
+
if (existing?.enabled && existing.sessionId) {
|
|
1768
|
+
_socket.auth = {
|
|
1769
|
+
token: `Bearer ${token}`,
|
|
1770
|
+
...userId && { userId },
|
|
1771
|
+
...tenantId && { tenantId },
|
|
1772
|
+
transitSessionId: existing.sessionId
|
|
1773
|
+
};
|
|
1774
|
+
_socket.connect();
|
|
1775
|
+
return;
|
|
1776
|
+
}
|
|
1777
|
+
if (_getToken) {
|
|
1778
|
+
if (!_socket.disconnected) _socket.disconnect();
|
|
1779
|
+
void connectSocket(_config2, _getToken);
|
|
1780
|
+
return;
|
|
1781
|
+
}
|
|
1768
1782
|
}
|
|
1783
|
+
_socket.auth = {
|
|
1784
|
+
token: `Bearer ${token}`,
|
|
1785
|
+
...userId && { userId },
|
|
1786
|
+
...tenantId && { tenantId }
|
|
1787
|
+
};
|
|
1788
|
+
_socket.connect();
|
|
1769
1789
|
}
|
|
1770
1790
|
function refreshSocketAuth() {
|
|
1771
1791
|
if (!_socket || !_getToken) return false;
|