lunel-cli 0.1.88 → 0.1.89
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/transport/v2.js +5 -15
- package/package.json +1 -1
package/dist/transport/v2.js
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
import { WebSocket } from "ws";
|
|
2
2
|
import { createRequire } from "module";
|
|
3
|
-
import { V2_FRAME_ENCRYPTED_MESSAGE, buildSessionV2WsUrl, decodeV2BinaryFrame, encodeV2EncryptedFrame, isEncryptedProtocolEnvelope,
|
|
3
|
+
import { V2_FRAME_ENCRYPTED_MESSAGE, buildSessionV2WsUrl, decodeV2BinaryFrame, encodeV2EncryptedFrame, isEncryptedProtocolEnvelope, isV2HandshakeFrame, } from "./protocol.js";
|
|
4
4
|
const encoder = new TextEncoder();
|
|
5
5
|
const decoder = new TextDecoder();
|
|
6
6
|
const require = createRequire(import.meta.url);
|
|
@@ -132,19 +132,9 @@ export class V2SessionTransport {
|
|
|
132
132
|
await this.handleHandshakeFrame(raw);
|
|
133
133
|
return;
|
|
134
134
|
}
|
|
135
|
-
|
|
136
|
-
|
|
137
|
-
|
|
138
|
-
if (isProtocolResponse(raw)) {
|
|
139
|
-
await this.options.handlers.onProtocolResponse?.(raw);
|
|
140
|
-
return;
|
|
141
|
-
}
|
|
142
|
-
if (isProtocolRequest(raw)) {
|
|
143
|
-
const response = await this.options.handlers.onProtocolRequest(raw);
|
|
144
|
-
await this.sendResponse(response);
|
|
145
|
-
return;
|
|
146
|
-
}
|
|
147
|
-
return;
|
|
135
|
+
throw new Error(this.state === "secure"
|
|
136
|
+
? "received plaintext app message after secure transport"
|
|
137
|
+
: "received plaintext app message before secure transport");
|
|
148
138
|
}
|
|
149
139
|
const bytes = toUint8Array(data);
|
|
150
140
|
const frame = decodeV2BinaryFrame(bytes);
|
|
@@ -225,7 +215,7 @@ export class V2SessionTransport {
|
|
|
225
215
|
s2c: sodium.to_base64(s2cKey, sodium.base64_variants.URLSAFE_NO_PADDING),
|
|
226
216
|
};
|
|
227
217
|
const boxed = sodium.crypto_box_easy(encodeUtf8(JSON.stringify(payload)), nonce, this.remotePublicKey, keyPair.privateKey);
|
|
228
|
-
const auth = this.computeHandshakeAuth("client_key", "app",
|
|
218
|
+
const auth = this.computeHandshakeAuth("client_key", "app", sodium.to_base64(keyPair.publicKey, sodium.base64_variants.URLSAFE_NO_PADDING), nonce, boxed);
|
|
229
219
|
this.sessionKeys = { rx: s2cKey, tx: c2sKey };
|
|
230
220
|
this.sendJsonFrame({
|
|
231
221
|
t: "lunel_v2",
|