velocious 1.0.358 → 1.0.359

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
@@ -1305,6 +1305,30 @@ socket.addEventListener("message", (event) => {
1305
1305
  })
1306
1306
  ```
1307
1307
 
1308
+ ## Attach WebSocket metadata
1309
+
1310
+ Clients can send session metadata over the shared WebSocket. Metadata is exposed to WebSocket-borne controller requests and frontend-model subscription authorization through `request.metadata(...)`; it is not merged into HTTP headers.
1311
+
1312
+ ```js
1313
+ socket.addEventListener("open", () => {
1314
+ socket.send(JSON.stringify({
1315
+ data: {locale: "da", sessionToken: "abc"},
1316
+ type: "metadata"
1317
+ }))
1318
+
1319
+ socket.send(JSON.stringify({
1320
+ id: "req-2",
1321
+ method: "POST",
1322
+ path: "/api/version",
1323
+ type: "request"
1324
+ }))
1325
+ })
1326
+ ```
1327
+
1328
+ ```js
1329
+ const sessionToken = this.getRequest().metadata("sessionToken")
1330
+ ```
1331
+
1308
1332
  # Logging
1309
1333
 
1310
1334
  Velocious includes a lightweight logger that can write to both console and file and is environment-aware.
@@ -321,7 +321,7 @@ export default class FrontendModelBase {
321
321
  static dropWebsocket(): Promise<void>;
322
322
  /**
323
323
  * Sets global metadata on the WebSocket connection. Sent to the server immediately
324
- * over WebSocket and included with every HTTP request as headers.
324
+ * over WebSocket and exposed to WebSocket-borne requests as request metadata.
325
325
  * @param {string} key - Metadata key.
326
326
  * @param {any} value - Metadata value (null to clear).
327
327
  * @returns {void}