peer-term 1.1.3 → 1.1.5
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 +1 -1
- package/src/index.js +20 -0
package/package.json
CHANGED
package/src/index.js
CHANGED
|
@@ -205,6 +205,24 @@ class Session {
|
|
|
205
205
|
logger.debug(`${prefix} ${msg}`);
|
|
206
206
|
}
|
|
207
207
|
|
|
208
|
+
async _sendSessionConfig() {
|
|
209
|
+
if (!this.sharedKey || !this.ws || this.ws.readyState !== WebSocket.OPEN) return;
|
|
210
|
+
|
|
211
|
+
const config = JSON.stringify({
|
|
212
|
+
type: 'session-config',
|
|
213
|
+
readonly: this.readOnly,
|
|
214
|
+
version: '1.1.5',
|
|
215
|
+
shell: this.shell,
|
|
216
|
+
startPath: this.startPath,
|
|
217
|
+
});
|
|
218
|
+
try {
|
|
219
|
+
const payload = await encrypt(this.sharedKey, config);
|
|
220
|
+
this.ws.send(JSON.stringify({ type: 'data', payload }));
|
|
221
|
+
} catch (err) {
|
|
222
|
+
this.log(`Failed to send session config: ${err.message}`);
|
|
223
|
+
}
|
|
224
|
+
}
|
|
225
|
+
|
|
208
226
|
// ─── Start the session ──────────────────────────────────────────────
|
|
209
227
|
async start() {
|
|
210
228
|
for (let i = 0; i < RELAY_URLS.length; i++) {
|
|
@@ -284,6 +302,7 @@ class Session {
|
|
|
284
302
|
const peerPublicKey = await importPublicKey(msg.publicKey);
|
|
285
303
|
this.sharedKey = await deriveSharedKey(this.keyPair.privateKey, peerPublicKey);
|
|
286
304
|
this.log('Encrypted tunnel active');
|
|
305
|
+
await this._sendSessionConfig();
|
|
287
306
|
|
|
288
307
|
this.startHeartbeat();
|
|
289
308
|
|
|
@@ -712,6 +731,7 @@ class Session {
|
|
|
712
731
|
const peerPublicKey = await importPublicKey(msg.publicKey);
|
|
713
732
|
this.sharedKey = await deriveSharedKey(this.keyPair.privateKey, peerPublicKey);
|
|
714
733
|
this.log('Encrypted tunnel active');
|
|
734
|
+
await this._sendSessionConfig();
|
|
715
735
|
|
|
716
736
|
this.startHeartbeat();
|
|
717
737
|
|