@linxin666/dsh-ssh 0.1.3 → 0.1.7

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/lib/index.js CHANGED
@@ -1052,17 +1052,17 @@ function validateHostPayload(payload) {
1052
1052
  if (typeof auth !== "object" || auth === null) return "auth must be an object";
1053
1053
  if (auth.kind !== "key" && auth.kind !== "password") return "auth.kind must be key or password";
1054
1054
  if (auth.kind === "key" && (typeof auth.keyPath !== "string" || auth.keyPath.trim() === "")) return "auth.keyPath is required for key auth";
1055
- if (auth.kind === "password" && (typeof auth.password !== "string" || auth.password === "")) return "auth.password is required for password auth";
1055
+ if (auth.kind === "password" && auth.password !== void 0 && typeof auth.password !== "string") return "auth.password must be a string when provided";
1056
1056
  }
1057
1057
  if (p.port !== void 0 && (typeof p.port !== "number" || !Number.isInteger(p.port) || p.port < 1 || p.port > 65535)) return "port must be an integer in 1..65535";
1058
1058
  if (p.proxyJump !== void 0 && (!Array.isArray(p.proxyJump) || p.proxyJump.some((x) => typeof x !== "string" || x === ""))) return "proxyJump must be an array of alias strings";
1059
1059
  if (p.tags !== void 0 && (!Array.isArray(p.tags) || p.tags.some((x) => typeof x !== "string"))) return "tags must be an array of strings";
1060
1060
  }
1061
- /** The alias grammar (same as the scaffold rule: lowercase, digits, single hyphens). */
1062
- const ALIAS_RE = /^[a-z0-9]+(-[a-z0-9]+)*$/;
1061
+ /** Alias grammar: letters/digits plus dots, hyphens, underscores (IP/domain aliases included). */
1062
+ const ALIAS_RE = /^[a-zA-Z0-9][a-zA-Z0-9._-]*$/;
1063
1063
  /** Validate an alias for creation. */
1064
1064
  function validateAlias(alias) {
1065
- if (!ALIAS_RE.test(alias)) return "alias must be lowercase letters, digits and single hyphens";
1065
+ if (!ALIAS_RE.test(alias)) return "alias must be letters, digits, dots, hyphens or underscores";
1066
1066
  }
1067
1067
  /**
1068
1068
  * The host store. Pure file I/O — no cordis dependency, unit-testable.
@@ -1160,7 +1160,7 @@ var HostStore = class {
1160
1160
  const auth = patch.auth;
1161
1161
  if (auth.kind !== "key" && auth.kind !== "password") throw new Error("auth.kind must be key or password");
1162
1162
  if (auth.kind === "key" && (typeof auth.keyPath !== "string" || auth.keyPath.trim() === "")) throw new Error("auth.keyPath is required for key auth");
1163
- if (auth.kind === "password" && (typeof auth.password !== "string" || auth.password === "")) throw new Error("auth.password is required for password auth");
1163
+ if (auth.kind === "password" && auth.password !== void 0 && typeof auth.password !== "string") throw new Error("auth.password must be a string when provided");
1164
1164
  const keyChanged = auth.kind === "key" && auth.keyPath !== void 0 && expandHome(auth.keyPath.trim()) !== entry.auth.keyPath;
1165
1165
  entry.auth = {
1166
1166
  kind: auth.kind,
package/package.json CHANGED
@@ -1,7 +1,7 @@
1
1
  {
2
2
  "name": "@linxin666/dsh-ssh",
3
3
  "description": "Remote SSH operations for the dsh web GUI: host config store (~/.dsh/dsh-ssh.json, import from ~/.ssh/config), a persistent ssh2 connection pool with jump-host support, exec / PTY web terminal / SFTP transfer / local port-forward tunnels / cluster execution, plus agent tools (ssh_list, ssh_exec, ssh_upload, ssh_download, ssh_tunnel, ssh_cluster). Hot-pluggable — mounted via ~/.dsh/cordis.patch.yml + a profile node_modules symlink, no dsh source changes.",
4
- "version": "0.1.3",
4
+ "version": "0.1.7",
5
5
  "type": "module",
6
6
  "engines": {
7
7
  "node": "^22.19.0 || >=24.0.0"
@@ -92,25 +92,37 @@ export function mountSidebarEntry(controller: PanelController): () => void {
92
92
  let placed = false
93
93
 
94
94
  const tryPlace = (): void => {
95
- if (placed) return
96
95
  if (root !== undefined && !root.isConnected) {
97
- // The shell re-created the sidebar pane; re-query from scratch.
96
+ // The shell rebuilt the sidebar pane (whole-tree teardown); the root
97
+ // observer is gone with the old tree, so detach it and re-query from
98
+ // scratch. The new pane is later noticed by the body-level watcher.
98
99
  rootObserver.disconnect()
99
100
  root = undefined
101
+ placed = false
102
+ }
103
+ if (placed) {
104
+ // Cheap short-circuit: entry still lives in a mountable subtree.
105
+ if (document.body.contains(entry)) return
106
+ // Entry was torn down together with the old tree; reset and re-place.
107
+ rootObserver.disconnect()
108
+ root = undefined
109
+ placed = false
100
110
  }
101
111
  root ??= sidebarRoot()
102
112
  if (root === undefined) return
103
113
  placed = placeEntry(root, entry)
104
114
  if (placed) {
105
115
  rootObserver.observe(root, { childList: true, subtree: true })
106
- // Placement done; the root observer alone keeps the entry healed.
107
- // Disconnect the body-wide watcher so unrelated app mutations (e.g.
108
- // chat streaming) no longer churn every plugin's self-heal loop.
109
- waitObserver.disconnect()
110
116
  }
111
117
  }
112
118
 
113
- // The shell renders after boot settlement; watch for its arrival.
119
+ // Body-level watcher retained as the "whole rebuild" fallback: when the shell
120
+ // tears down the whole sidebar pane, the root observer is gone with it and
121
+ // only this body observation can notice the new pane mounting. It is no
122
+ // longer disconnected after placement; the placed-and-still-mounted case
123
+ // short-circuits through the cheap document.body.contains(entry) check, so
124
+ // unrelated app mutations (e.g. chat streaming) cost one contains check
125
+ // instead of churning the full re-query.
114
126
  const waitObserver = new MutationObserver(() => { tryPlace() })
115
127
  waitObserver.observe(document.body, { childList: true, subtree: true })
116
128
 
package/src/store.ts CHANGED
@@ -42,8 +42,8 @@ export function validateHostPayload(payload: unknown): string | undefined {
42
42
  if (auth.kind === 'key' && (typeof auth.keyPath !== 'string' || auth.keyPath.trim() === '')) {
43
43
  return 'auth.keyPath is required for key auth'
44
44
  }
45
- if (auth.kind === 'password' && (typeof auth.password !== 'string' || auth.password === '')) {
46
- return 'auth.password is required for password auth'
45
+ if (auth.kind === 'password' && auth.password !== undefined && typeof auth.password !== 'string') {
46
+ return 'auth.password must be a string when provided'
47
47
  }
48
48
  }
49
49
  if (p.port !== undefined && (typeof p.port !== 'number' || !Number.isInteger(p.port) || p.port < 1 || p.port > 65535)) {
@@ -58,12 +58,12 @@ export function validateHostPayload(payload: unknown): string | undefined {
58
58
  return undefined
59
59
  }
60
60
 
61
- /** The alias grammar (same as the scaffold rule: lowercase, digits, single hyphens). */
62
- const ALIAS_RE = /^[a-z0-9]+(-[a-z0-9]+)*$/
61
+ /** Alias grammar: letters/digits plus dots, hyphens, underscores (IP/domain aliases included). */
62
+ const ALIAS_RE = /^[a-zA-Z0-9][a-zA-Z0-9._-]*$/
63
63
 
64
64
  /** Validate an alias for creation. */
65
65
  export function validateAlias(alias: string): string | undefined {
66
- if (!ALIAS_RE.test(alias)) return 'alias must be lowercase letters, digits and single hyphens'
66
+ if (!ALIAS_RE.test(alias)) return 'alias must be letters, digits, dots, hyphens or underscores'
67
67
  return undefined
68
68
  }
69
69
 
@@ -188,8 +188,8 @@ export class HostStore {
188
188
  if (auth.kind === 'key' && (typeof auth.keyPath !== 'string' || auth.keyPath.trim() === '')) {
189
189
  throw new Error('auth.keyPath is required for key auth')
190
190
  }
191
- if (auth.kind === 'password' && (typeof auth.password !== 'string' || auth.password === '')) {
192
- throw new Error('auth.password is required for password auth')
191
+ if (auth.kind === 'password' && auth.password !== undefined && typeof auth.password !== 'string') {
192
+ throw new Error('auth.password must be a string when provided')
193
193
  }
194
194
  // A changed key path with no passphrase means the new key has none;
195
195
  // only keep the old passphrase when the key path is unchanged.