@jskit-ai/realtime 0.1.212 → 0.1.214
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/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@jskit-ai/realtime",
|
|
3
|
-
"version": "0.1.
|
|
3
|
+
"version": "0.1.214",
|
|
4
4
|
"type": "module",
|
|
5
5
|
"scripts": {
|
|
6
6
|
"test": "node --test"
|
|
@@ -20,8 +20,8 @@
|
|
|
20
20
|
"socket.io-client": "^4.8.3"
|
|
21
21
|
},
|
|
22
22
|
"peerDependencies": {
|
|
23
|
-
"@jskit-ai/kernel": "0.1.
|
|
24
|
-
"@jskit-ai/shell-web": "0.1.
|
|
23
|
+
"@jskit-ai/kernel": "0.1.217",
|
|
24
|
+
"@jskit-ai/shell-web": "0.1.221",
|
|
25
25
|
"vue": "^3.5.13"
|
|
26
26
|
},
|
|
27
27
|
"description": "Thin, generic realtime runtime wrappers for socket.io server and client.",
|
|
@@ -193,8 +193,14 @@ async function resolveSocketActor(authService, socket) {
|
|
|
193
193
|
const request = {
|
|
194
194
|
cookies: parseCookieHeader(handshakeHeaders.cookie || requestHeaders.cookie)
|
|
195
195
|
};
|
|
196
|
-
|
|
197
|
-
|
|
196
|
+
const headers = host ? { host } : {};
|
|
197
|
+
for (const name of ["origin", "x-forwarded-proto"]) {
|
|
198
|
+
const value = handshakeHeaders[name] ?? requestHeaders[name];
|
|
199
|
+
if (value !== undefined) headers[name] = value;
|
|
200
|
+
}
|
|
201
|
+
if (Object.keys(headers).length > 0) request.headers = headers;
|
|
202
|
+
request.socket = { encrypted: socket?.request?.socket?.encrypted === true };
|
|
203
|
+
if (remoteAddress) request.socket.remoteAddress = remoteAddress;
|
|
198
204
|
const result = await authService.authenticateRequest(request);
|
|
199
205
|
const id = result?.authenticated === true
|
|
200
206
|
? normalizeRecordId(result?.actor?.id, { fallback: null }) : null;
|
|
@@ -177,16 +177,21 @@ test("socket audience bootstrap authenticates explicitly and joins actor workspa
|
|
|
177
177
|
});
|
|
178
178
|
const joinedRooms = [];
|
|
179
179
|
const socket = {
|
|
180
|
-
handshake: { headers: {
|
|
181
|
-
|
|
180
|
+
handshake: { headers: {
|
|
181
|
+
cookie: "session=abc123; theme=dark", host: "127.0.0.1:3100",
|
|
182
|
+
origin: "https://127.0.0.1:3100", "x-forwarded-proto": "https"
|
|
183
|
+
} },
|
|
184
|
+
request: { headers: {}, socket: { remoteAddress: "127.0.0.1", encrypted: true } },
|
|
182
185
|
data: {},
|
|
183
186
|
join(room) { joinedRooms.push(room); }
|
|
184
187
|
};
|
|
185
188
|
await connectionHandler(socket);
|
|
186
189
|
assert.deepEqual(authenticateCalls, [{
|
|
187
190
|
cookies: { session: "abc123", theme: "dark" },
|
|
188
|
-
headers: {
|
|
189
|
-
|
|
191
|
+
headers: {
|
|
192
|
+
host: "127.0.0.1:3100", origin: "https://127.0.0.1:3100", "x-forwarded-proto": "https"
|
|
193
|
+
},
|
|
194
|
+
socket: { remoteAddress: "127.0.0.1", encrypted: true }
|
|
190
195
|
}]);
|
|
191
196
|
assert.equal(socket.data.actorId, "9");
|
|
192
197
|
assert.deepEqual(joinedRooms, [
|