peer-term 1.3.4 → 1.3.6
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 +19 -1
package/package.json
CHANGED
package/src/index.js
CHANGED
|
@@ -41,7 +41,7 @@ import {
|
|
|
41
41
|
decrypt,
|
|
42
42
|
} from './crypto.js';
|
|
43
43
|
import { HostWebRTC } from './webrtc.js';
|
|
44
|
-
import logger
|
|
44
|
+
import logger from './logger.js';
|
|
45
45
|
import { printBanner, printSessionBox, printHelp, printVersion } from './ui.js';
|
|
46
46
|
|
|
47
47
|
// ─── File paths ──────────────────────────────────────────────────────────────
|
|
@@ -613,6 +613,10 @@ class Session {
|
|
|
613
613
|
try {
|
|
614
614
|
const parsedMsg = JSON.parse(plaintext);
|
|
615
615
|
if (parsedMsg && typeof parsedMsg.type === 'string' && parsedMsg.type.startsWith('file-')) {
|
|
616
|
+
if (this.readOnly) {
|
|
617
|
+
this._sendFileError(parsedMsg.id, 'File uploads are disabled in read-only mode');
|
|
618
|
+
return;
|
|
619
|
+
}
|
|
616
620
|
this._handleFileMessage(parsedMsg);
|
|
617
621
|
return;
|
|
618
622
|
}
|
|
@@ -846,6 +850,12 @@ class Session {
|
|
|
846
850
|
* All file messages arrive over the DataChannel only.
|
|
847
851
|
*/
|
|
848
852
|
_handleFileMessage(msg) {
|
|
853
|
+
// Defense-in-depth: reject all file operations in read-only sessions
|
|
854
|
+
if (this.readOnly) {
|
|
855
|
+
this._sendFileError(msg.id, 'File uploads are disabled in read-only mode');
|
|
856
|
+
return;
|
|
857
|
+
}
|
|
858
|
+
|
|
849
859
|
switch (msg.type) {
|
|
850
860
|
case 'file-start': {
|
|
851
861
|
// Validate required fields
|
|
@@ -1370,6 +1380,10 @@ class Session {
|
|
|
1370
1380
|
try {
|
|
1371
1381
|
const parsedMsg = JSON.parse(plaintext);
|
|
1372
1382
|
if (parsedMsg && typeof parsedMsg.type === 'string' && parsedMsg.type.startsWith('file-')) {
|
|
1383
|
+
if (this.readOnly) {
|
|
1384
|
+
this._sendFileError(parsedMsg.id, 'File uploads are disabled in read-only mode');
|
|
1385
|
+
return;
|
|
1386
|
+
}
|
|
1373
1387
|
this._handleFileMessage(parsedMsg);
|
|
1374
1388
|
return;
|
|
1375
1389
|
}
|
|
@@ -1527,6 +1541,10 @@ class Session {
|
|
|
1527
1541
|
try {
|
|
1528
1542
|
const msg = JSON.parse(plaintext);
|
|
1529
1543
|
if (msg && typeof msg.type === 'string' && msg.type.startsWith('file-')) {
|
|
1544
|
+
if (this.readOnly) {
|
|
1545
|
+
this._sendFileError(msg.id, 'File uploads are disabled in read-only mode');
|
|
1546
|
+
return;
|
|
1547
|
+
}
|
|
1530
1548
|
this._handleFileMessage(msg);
|
|
1531
1549
|
return;
|
|
1532
1550
|
}
|