@antzsoft/chat-core 1.3.5 → 1.3.7

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 CHANGED
@@ -3056,6 +3056,22 @@ document.querySelectorAll('[data-conv-id]').forEach((el) => {
3056
3056
 
3057
3057
  ## Changelog
3058
3058
 
3059
+ ### v1.3.7
3060
+
3061
+ - **Docs only — no code changes.** Brought the docs fully up to date: added the missing
3062
+ release notes to `docs/integration-guide.html` (its "What's New" section had stopped at
3063
+ v1.3.4) so both the README changelog and the HTML integration guide now cover v1.3.5,
3064
+ v1.3.6, and this v1.3.7 entry. No SDK behaviour changed in this version; upgrading from
3065
+ 1.3.6 is a no-op at runtime.
3066
+
3067
+ ### v1.3.6
3068
+
3069
+ - **Fix: `reconnectSocket` now PRESERVES the transit session instead of recreating it** — follow-up to the 1.3.5 reconnect fix. 1.3.5 fixed `"Transit encryption required"` by disconnecting and re-running the full `connectSocket()` handshake, but that also cleared the cached transit session (the `'disconnect'` handler calls `clearTransitSession()`) and established a brand-new one with a new session key. Server-broadcast events (e.g. `user_online`) are encrypted with the session the server still holds, so a fresh client key could not decrypt them → continuous `"Transit decryption failed for event: user_online"`.
3070
+
3071
+ `reconnectSocket` is a token-only refresh — the transit session is still valid on the server (stored in Redis by `sessionId`, re-linked to the new socket on reconnect). So it now carries the existing `transitSessionId` forward in the handshake auth and reconnects the **same** socket **without** disconnecting, keeping the client's session key intact. The server re-links the same session (`getBySessionId` + `linkSocket`), so both sides keep the same key and decryption continues to work. Falls back to the full `connectSocket()` flow only when there is no valid cached session to preserve.
3072
+
3073
+ Net: keeps 1.3.5's "no more `Transit encryption required` on reconnect" while removing the `user_online` decryption-failure regression. **No integration changes required.**
3074
+
3059
3075
  ### v1.3.5
3060
3076
 
3061
3077
  - **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.
package/dist/index.cjs CHANGED
@@ -1762,10 +1762,23 @@ function disconnectSocket() {
1762
1762
  }
1763
1763
  function reconnectSocket(token, userId, tenantId) {
1764
1764
  if (!_socket) return;
1765
- if (_config2?.transitEncryption && _getToken) {
1766
- if (!_socket.disconnected) _socket.disconnect();
1767
- void connectSocket(_config2, _getToken);
1768
- 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
+ }
1769
1782
  }
1770
1783
  _socket.auth = {
1771
1784
  token: `Bearer ${token}`,