@linxin666/dsh-ssh 0.1.6 → 0.1.8
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 +5 -5
- package/package.json +1 -1
- package/src/store.ts +7 -7
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" &&
|
|
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
|
-
/**
|
|
1062
|
-
const ALIAS_RE = /^[a-
|
|
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
|
|
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" &&
|
|
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.
|
|
4
|
+
"version": "0.1.8",
|
|
5
5
|
"type": "module",
|
|
6
6
|
"engines": {
|
|
7
7
|
"node": "^22.19.0 || >=24.0.0"
|
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' &&
|
|
46
|
-
return 'auth.password
|
|
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
|
-
/**
|
|
62
|
-
const ALIAS_RE = /^[a-
|
|
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
|
|
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' &&
|
|
192
|
-
throw new Error('auth.password
|
|
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.
|