lunel-cli 0.1.92 → 0.1.94
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/index.js +1 -4
- package/dist/transport/v2.d.ts +2 -1
- package/dist/transport/v2.js +15 -1
- package/package.json +1 -1
package/dist/index.js
CHANGED
|
@@ -2836,15 +2836,12 @@ async function connectWebSocketV2() {
|
|
|
2836
2836
|
if (!currentSessionPassword) {
|
|
2837
2837
|
throw new Error("missing password for websocket connect");
|
|
2838
2838
|
}
|
|
2839
|
-
if (!currentSessionCode) {
|
|
2840
|
-
throw new Error("missing session code for secure transport");
|
|
2841
|
-
}
|
|
2842
2839
|
console.log(`Connecting to gateway ${gatewayUrl}...`);
|
|
2843
2840
|
activeGatewayUrl = gatewayUrl;
|
|
2844
2841
|
const transport = new V2SessionTransport({
|
|
2845
2842
|
gatewayUrl,
|
|
2846
2843
|
password: currentSessionPassword,
|
|
2847
|
-
|
|
2844
|
+
sessionSecret: currentSessionPassword,
|
|
2848
2845
|
role: "cli",
|
|
2849
2846
|
debugLog: DEBUG_MODE ? debugLog : undefined,
|
|
2850
2847
|
handlers: {
|
package/dist/transport/v2.d.ts
CHANGED
|
@@ -9,7 +9,7 @@ export interface V2TransportHandlers {
|
|
|
9
9
|
export interface V2TransportOptions {
|
|
10
10
|
gatewayUrl: string;
|
|
11
11
|
password: string;
|
|
12
|
-
|
|
12
|
+
sessionSecret: string;
|
|
13
13
|
role: "cli" | "app";
|
|
14
14
|
handlers: V2TransportHandlers;
|
|
15
15
|
debugLog?: (message: string, ...args: unknown[]) => void;
|
|
@@ -37,6 +37,7 @@ export declare class V2SessionTransport {
|
|
|
37
37
|
private handleHandshakeFrame;
|
|
38
38
|
private encryptEnvelope;
|
|
39
39
|
private ensureKeyPair;
|
|
40
|
+
private resetPeerSession;
|
|
40
41
|
private computeHandshakeAuth;
|
|
41
42
|
private sendJsonFrame;
|
|
42
43
|
private sendBinaryFrame;
|
package/dist/transport/v2.js
CHANGED
|
@@ -124,8 +124,12 @@ export class V2SessionTransport {
|
|
|
124
124
|
if ("type" in raw) {
|
|
125
125
|
await this.options.handlers.onSystemMessage(raw);
|
|
126
126
|
if (raw.type === "peer_connected") {
|
|
127
|
+
this.resetPeerSession();
|
|
127
128
|
await this.maybeStartHandshake();
|
|
128
129
|
}
|
|
130
|
+
else if (raw.type === "peer_disconnected" || raw.type === "app_disconnected") {
|
|
131
|
+
this.resetPeerSession();
|
|
132
|
+
}
|
|
129
133
|
return;
|
|
130
134
|
}
|
|
131
135
|
if (isV2HandshakeFrame(raw)) {
|
|
@@ -290,8 +294,18 @@ export class V2SessionTransport {
|
|
|
290
294
|
};
|
|
291
295
|
return this.keyPair;
|
|
292
296
|
}
|
|
297
|
+
resetPeerSession() {
|
|
298
|
+
this.remotePublicKey = null;
|
|
299
|
+
this.sessionKeys = null;
|
|
300
|
+
if (this.ws?.readyState === WebSocket.OPEN) {
|
|
301
|
+
this.state = "open";
|
|
302
|
+
}
|
|
303
|
+
else {
|
|
304
|
+
this.state = "idle";
|
|
305
|
+
}
|
|
306
|
+
}
|
|
293
307
|
computeHandshakeAuth(phase, senderRole, peerPubkeyB64, nonce, boxed) {
|
|
294
|
-
const authKey = sodium.crypto_generichash(sodium.crypto_auth_KEYBYTES, encodeUtf8(this.options.
|
|
308
|
+
const authKey = sodium.crypto_generichash(sodium.crypto_auth_KEYBYTES, encodeUtf8(this.options.sessionSecret), undefined);
|
|
295
309
|
const parts = [
|
|
296
310
|
phase,
|
|
297
311
|
senderRole,
|