@co0ontty/wand 1.31.2 → 1.32.0
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/dist/auth.d.ts +20 -0
- package/dist/auth.js +31 -0
- package/dist/cert.d.ts +17 -2
- package/dist/cert.js +124 -68
- package/dist/config.js +12 -0
- package/dist/server.js +60 -51
- package/dist/tui/commands.js +51 -5
- package/dist/types.d.ts +9 -0
- package/dist/web-ui/content/scripts.js +271 -279
- package/dist/web-ui/content/styles.css +291 -308
- package/dist/ws-broadcast.d.ts +2 -2
- package/dist/ws-broadcast.js +5 -10
- package/package.json +1 -1
package/dist/ws-broadcast.d.ts
CHANGED
|
@@ -12,7 +12,8 @@ export declare class WsBroadcastManager {
|
|
|
12
12
|
private eventEmitter;
|
|
13
13
|
private heartbeatTimer?;
|
|
14
14
|
private getCardDefaults;
|
|
15
|
-
|
|
15
|
+
private useHttps;
|
|
16
|
+
constructor(wss: WebSocketServer, getCardDefaults?: () => CardExpandDefaults, useHttps?: boolean);
|
|
16
17
|
/** Set up connection handling. Should be called once during server startup. */
|
|
17
18
|
setup(getSession: (id: string) => SessionSnapshot | null): void;
|
|
18
19
|
/**
|
|
@@ -36,5 +37,4 @@ export declare class WsBroadcastManager {
|
|
|
36
37
|
private sendInit;
|
|
37
38
|
private broadcast;
|
|
38
39
|
private processWsQueue;
|
|
39
|
-
private readSessionCookie;
|
|
40
40
|
}
|
package/dist/ws-broadcast.js
CHANGED
|
@@ -4,7 +4,7 @@
|
|
|
4
4
|
*/
|
|
5
5
|
import { WebSocket } from "ws";
|
|
6
6
|
import { EventEmitter } from "node:events";
|
|
7
|
-
import { validateSession } from "./auth.js";
|
|
7
|
+
import { readSessionCookie, validateSession } from "./auth.js";
|
|
8
8
|
import { truncateMessagesForTransport } from "./message-truncator.js";
|
|
9
9
|
// ── Constants ──
|
|
10
10
|
const MAX_QUEUE_SIZE = 500;
|
|
@@ -28,14 +28,16 @@ export class WsBroadcastManager {
|
|
|
28
28
|
eventEmitter = new EventEmitter();
|
|
29
29
|
heartbeatTimer;
|
|
30
30
|
getCardDefaults;
|
|
31
|
-
|
|
31
|
+
useHttps;
|
|
32
|
+
constructor(wss, getCardDefaults, useHttps = false) {
|
|
32
33
|
this.wss = wss;
|
|
33
34
|
this.getCardDefaults = getCardDefaults ?? (() => ({}));
|
|
35
|
+
this.useHttps = useHttps;
|
|
34
36
|
}
|
|
35
37
|
/** Set up connection handling. Should be called once during server startup. */
|
|
36
38
|
setup(getSession) {
|
|
37
39
|
this.wss.on("connection", (ws, req) => {
|
|
38
|
-
const sessionToken =
|
|
40
|
+
const sessionToken = readSessionCookie(req, this.useHttps);
|
|
39
41
|
if (!sessionToken || !validateSession(sessionToken)) {
|
|
40
42
|
ws.close(1008, "Unauthorized");
|
|
41
43
|
return;
|
|
@@ -308,11 +310,4 @@ export class WsBroadcastManager {
|
|
|
308
310
|
});
|
|
309
311
|
}
|
|
310
312
|
}
|
|
311
|
-
readSessionCookie(req) {
|
|
312
|
-
const cookie = req.headers.cookie;
|
|
313
|
-
if (!cookie)
|
|
314
|
-
return undefined;
|
|
315
|
-
const match = cookie.split(";").map((part) => part.trim()).find((part) => part.startsWith("wand_session="));
|
|
316
|
-
return match?.slice("wand_session=".length);
|
|
317
|
-
}
|
|
318
313
|
}
|