@electerm/electerm-react 3.15.163 → 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.
@@ -2,6 +2,9 @@
2
2
  * safe parse json
3
3
  */
4
4
  export default str => {
5
+ if (str === '' || str == null) {
6
+ return str
7
+ }
5
8
  try {
6
9
  return JSON.parse(str)
7
10
  } catch (e) {
@@ -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
- store.setTheme(objs.config.theme)
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) {
@@ -333,7 +333,7 @@ export default Store => {
333
333
  !newTab.host &&
334
334
  !window.store.hasNodePty
335
335
  ) {
336
- if (window.et.isWebApp) {
336
+ if (window.et.isWebApp || window.et.hideLocalTerminal) {
337
337
  return
338
338
  }
339
339
  return message.warning(
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@electerm/electerm-react",
3
- "version": "3.15.163",
3
+ "version": "3.15.167",
4
4
  "description": "react components src for electerm",
5
5
  "main": "./client/components/main/main.jsx",
6
6
  "license": "MIT",