lunel-cli 0.1.88 → 0.1.91

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.
@@ -74,5 +74,4 @@ export declare function decodeV2BinaryFrame(data: Uint8Array): {
74
74
  type: number;
75
75
  payload: Uint8Array;
76
76
  } | null;
77
- export declare function buildSessionV1WsUrl(gatewayUrl: string, role: "cli" | "app", channel: "control" | "data", password: string): string;
78
77
  export declare function buildSessionV2WsUrl(gatewayUrl: string, role: "cli" | "app", password: string): string;
@@ -66,14 +66,6 @@ export function decodeV2BinaryFrame(data) {
66
66
  payload: data.subarray(3),
67
67
  };
68
68
  }
69
- export function buildSessionV1WsUrl(gatewayUrl, role, channel, password) {
70
- const wsBase = gatewayUrl.replace(/^https:/, "wss:");
71
- if (!wsBase.startsWith("wss://")) {
72
- throw new Error("Gateway URL must use https://");
73
- }
74
- const query = new URLSearchParams({ password });
75
- return `${wsBase}/v1/ws/${role}/${channel}?${query.toString()}`;
76
- }
77
69
  export function buildSessionV2WsUrl(gatewayUrl, role, password) {
78
70
  const wsBase = gatewayUrl.replace(/^https:/, "wss:");
79
71
  if (!wsBase.startsWith("wss://")) {
@@ -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, isProtocolRequest, isProtocolResponse, isV2HandshakeFrame, } from "./protocol.js";
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
- if (this.state !== "secure") {
136
- throw new Error("received plaintext app message before secure transport");
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", frame.pubkey, nonce, boxed);
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",
@@ -256,10 +246,11 @@ export class V2SessionTransport {
256
246
  rx: sodium.from_base64(payload.c2s, sodium.base64_variants.URLSAFE_NO_PADDING),
257
247
  tx: sodium.from_base64(payload.s2c, sodium.base64_variants.URLSAFE_NO_PADDING),
258
248
  };
249
+ const auth = this.computeHandshakeAuth("server_ready", "cli", sodium.to_base64(keyPair.publicKey, sodium.base64_variants.URLSAFE_NO_PADDING));
259
250
  this.sendJsonFrame({
260
251
  t: "lunel_v2",
261
252
  kind: "server_ready",
262
- auth: this.computeHandshakeAuth("server_ready", "cli", sodium.to_base64(this.remotePublicKey, sodium.base64_variants.URLSAFE_NO_PADDING)),
253
+ auth,
263
254
  });
264
255
  this.markSecure();
265
256
  return;
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "lunel-cli",
3
- "version": "0.1.88",
3
+ "version": "0.1.91",
4
4
  "author": [
5
5
  {
6
6
  "name": "Soham Bharambe",