tmex-cli 0.4.4 → 0.4.5
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/dist/runtime/server.js +44 -1
- package/package.json +1 -1
package/dist/runtime/server.js
CHANGED
|
@@ -53616,6 +53616,16 @@ function resolvePrivateKeyFromConfig(identityFiles, deps) {
|
|
|
53616
53616
|
}
|
|
53617
53617
|
return;
|
|
53618
53618
|
}
|
|
53619
|
+
function resolvePrivateKeysFromConfig(identityFiles, deps) {
|
|
53620
|
+
const privateKeys = [];
|
|
53621
|
+
for (const identityFile of identityFiles) {
|
|
53622
|
+
if (!deps.fileExists(identityFile)) {
|
|
53623
|
+
continue;
|
|
53624
|
+
}
|
|
53625
|
+
privateKeys.push(deps.readTextFile(identityFile));
|
|
53626
|
+
}
|
|
53627
|
+
return privateKeys;
|
|
53628
|
+
}
|
|
53619
53629
|
function resolveSshConfigRef(device, deps) {
|
|
53620
53630
|
const ref = device.sshConfigRef?.trim();
|
|
53621
53631
|
if (!ref) {
|
|
@@ -53628,6 +53638,21 @@ function resolveSshConfigRef(device, deps) {
|
|
|
53628
53638
|
}
|
|
53629
53639
|
return parseSshConfigOutput(result.stdout, deps.env);
|
|
53630
53640
|
}
|
|
53641
|
+
function resolveImplicitIdentityFilesForAgentAuth(device, host, port, username, deps) {
|
|
53642
|
+
if (device.authMode !== "agent" || device.sshConfigRef?.trim()) {
|
|
53643
|
+
return [];
|
|
53644
|
+
}
|
|
53645
|
+
const target = username ? `${username}@${host}` : host;
|
|
53646
|
+
try {
|
|
53647
|
+
const result = deps.runSync(["ssh", "-G", "-p", String(port), target]);
|
|
53648
|
+
if (result.exitCode !== 0) {
|
|
53649
|
+
return [];
|
|
53650
|
+
}
|
|
53651
|
+
return parseSshConfigOutput(result.stdout, deps.env).identityFiles;
|
|
53652
|
+
} catch {
|
|
53653
|
+
return [];
|
|
53654
|
+
}
|
|
53655
|
+
}
|
|
53631
53656
|
async function resolveSshConnectConfig(device, decrypt2, inputDeps = {}) {
|
|
53632
53657
|
const deps = {
|
|
53633
53658
|
env: inputDeps.env ?? process.env,
|
|
@@ -53651,6 +53676,7 @@ async function resolveSshConnectConfig(device, decrypt2, inputDeps = {}) {
|
|
|
53651
53676
|
const configAgent = resolveAgentFromConfig(resolvedConfig?.identityAgent, deps);
|
|
53652
53677
|
const envAgent = resolveSshAgentSocket("auto", sshEnv);
|
|
53653
53678
|
const configPrivateKey = resolvePrivateKeyFromConfig(resolvedConfig?.identityFiles ?? [], deps);
|
|
53679
|
+
const implicitAgentFallbackPrivateKeys = resolvePrivateKeysFromConfig(resolveImplicitIdentityFilesForAgentAuth(device, host, port, username, deps), deps);
|
|
53654
53680
|
switch (device.authMode) {
|
|
53655
53681
|
case "password": {
|
|
53656
53682
|
if (!device.passwordEnc) {
|
|
@@ -53682,7 +53708,24 @@ async function resolveSshConnectConfig(device, decrypt2, inputDeps = {}) {
|
|
|
53682
53708
|
break;
|
|
53683
53709
|
}
|
|
53684
53710
|
case "agent": {
|
|
53685
|
-
|
|
53711
|
+
const agent = configAgent ?? resolveSshAgentSocket("agent", sshEnv);
|
|
53712
|
+
authConfig.agent = agent;
|
|
53713
|
+
if (implicitAgentFallbackPrivateKeys.length > 0) {
|
|
53714
|
+
const publicKeyFallbacks = implicitAgentFallbackPrivateKeys.map((key) => ({
|
|
53715
|
+
type: "publickey",
|
|
53716
|
+
username,
|
|
53717
|
+
key
|
|
53718
|
+
}));
|
|
53719
|
+
const authHandler = [
|
|
53720
|
+
{
|
|
53721
|
+
type: "agent",
|
|
53722
|
+
username,
|
|
53723
|
+
agent
|
|
53724
|
+
},
|
|
53725
|
+
...publicKeyFallbacks
|
|
53726
|
+
];
|
|
53727
|
+
authConfig.authHandler = authHandler;
|
|
53728
|
+
}
|
|
53686
53729
|
break;
|
|
53687
53730
|
}
|
|
53688
53731
|
case "configRef": {
|