Skip to content

v1.2.1

Choose a tag to compare

@AJAYMYTH AJAYMYTH released this 03 Jun 14:18
· 36 commits to main since this release

This patch release resolves several critical issues in the SDK (including ES module resolution, JWT
authentication handling, and WebSocket bridge framing) and introduces the new TcpClient wrapper in
@afterlink/core with full TypeScript typings.

### 🛠️ Bug Fixes                                                                                                   

* **Connection Auth Validation (`require` ➡️ `import`):** Replaced synchronous `require('jose')` with `await       

import('jose')inConnection._validateAuth. josev6 is ESM-only; the previous synchronous require crashed withERR_REQUIRE_ESMon Node 18+ andReferenceError: TextEncoder is not definedon older runtimes (affects both TCP and WebSockets). * **Handshake Authentication Flow:** UpdatedConnection._handleHandshaketo be async and await_validateAuth. Previously, the JWT verification promise resolved *after* the session was constructed, resulting in session.user always being null and allowing invalid tokens to pass unchecked. * **Session User Context:** Decoded JWT payloads are now stored inthis._jwtPayloadand populated insession.
userduring theHELLOhandshake. All route handlers and middleware now receive the correct user context via req.session.user. * **WebSocket Bridge JWT Auth:** Updated handleWsHandshaketo be async to properly verify theauthfield from theHELLOpayload usingjwtVerify. WebSocket sessions now populate session.useridentically to TCP sessions. * **WebSocket Frame Coalescing:** Fixed silent frame loss occurring when bothHELLOandREQUESTarrived in the same TCP packet. Buffer bytes following theHELLOframe are now preserved and processed immediately. * **CORS Behavior on WebSocket Bridge:** Connections without anOriginheader are now permitted whencors.
originsis empty (default). Node.js test clients will no longer receive a403 Forbidden` error in local
development.

### ✨ New Features & Enhancements                                                                                 

* **`TcpClient` in `@afterlink/core`:** Added a wrapper class for TCP connections wrapping `net.Socket` with       

native AfterLink framing. Features Promise-based connect(helloData) and request(route, body), and handles
HELLO_ACK, PING/PONG, and SERVER_CLOSING automatically.
* TypeScript Typings: Added complete typings for TcpClient, TcpClientOptions, and HelloData interfaces
in packages/core/types/index.d.ts.

Full Changelog: https://github.com/AJAYMYTH/AfterLink/commits/v1.2.1