@electerm/electerm-react 3.15.166 → 3.15.167
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/client/store/sync.js
CHANGED
|
@@ -18,6 +18,32 @@ const {
|
|
|
18
18
|
version: packVer
|
|
19
19
|
} = packInfo
|
|
20
20
|
|
|
21
|
+
// Server-managed config keys that must never be overwritten by an
|
|
22
|
+
// imported/synced config, because they are specific to the running
|
|
23
|
+
// server instance. Overwriting tokenElecterm in particular breaks
|
|
24
|
+
// every subsequent WebSocket connection (terminals, sftp, transfers)
|
|
25
|
+
// because the token no longer matches the server's JWT secret, causing
|
|
26
|
+
// connections to silently fail verification — the terminal appears to
|
|
27
|
+
// connect but input never works until the app is restarted.
|
|
28
|
+
const serverManagedConfigKeys = [
|
|
29
|
+
'tokenElecterm',
|
|
30
|
+
'host',
|
|
31
|
+
'port',
|
|
32
|
+
'server',
|
|
33
|
+
'wsHost',
|
|
34
|
+
'wsPort',
|
|
35
|
+
'useSystemTitleBar'
|
|
36
|
+
]
|
|
37
|
+
|
|
38
|
+
function stripServerManagedKeys (conf) {
|
|
39
|
+
if (!conf || typeof conf !== 'object') return conf
|
|
40
|
+
const safe = { ...conf }
|
|
41
|
+
for (const k of serverManagedConfigKeys) {
|
|
42
|
+
delete safe[k]
|
|
43
|
+
}
|
|
44
|
+
return safe
|
|
45
|
+
}
|
|
46
|
+
|
|
21
47
|
function isJSON (str = '') {
|
|
22
48
|
return str.startsWith('[')
|
|
23
49
|
}
|
|
@@ -515,7 +541,7 @@ export default (Store) => {
|
|
|
515
541
|
get(gist, 'files["userConfig.json"].content')
|
|
516
542
|
)
|
|
517
543
|
if (userConfig) {
|
|
518
|
-
store.setConfig(userConfig)
|
|
544
|
+
store.setConfig(stripServerManagedKeys(userConfig))
|
|
519
545
|
}
|
|
520
546
|
if (userConfig && userConfig.theme) {
|
|
521
547
|
store.setTheme(userConfig.theme)
|
|
@@ -582,7 +608,7 @@ export default (Store) => {
|
|
|
582
608
|
get(gist, 'files["userConfig.json"].content')
|
|
583
609
|
)
|
|
584
610
|
if (userConfig) {
|
|
585
|
-
store.setConfig(userConfig)
|
|
611
|
+
store.setConfig(stripServerManagedKeys(userConfig))
|
|
586
612
|
}
|
|
587
613
|
if (userConfig && userConfig.theme) {
|
|
588
614
|
store.setTheme(userConfig.theme)
|
|
@@ -677,8 +703,10 @@ export default (Store) => {
|
|
|
677
703
|
}
|
|
678
704
|
store.setItems(n, objs[n])
|
|
679
705
|
}
|
|
680
|
-
store.updateConfig(objs.config)
|
|
681
|
-
|
|
706
|
+
store.updateConfig(stripServerManagedKeys(objs.config))
|
|
707
|
+
if (objs.config?.theme) {
|
|
708
|
+
store.setTheme(objs.config.theme)
|
|
709
|
+
}
|
|
682
710
|
}
|
|
683
711
|
|
|
684
712
|
Store.prototype.handleAutoSync = function (v) {
|