axauth 1.6.0 → 1.7.0
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/cli.js +3 -2
- package/dist/commands/auth.d.ts +2 -1
- package/dist/commands/auth.js +49 -7
- package/package.json +1 -1
package/dist/cli.js
CHANGED
|
@@ -52,9 +52,10 @@ program
|
|
|
52
52
|
.action(handleAuthToken);
|
|
53
53
|
program
|
|
54
54
|
.command("export")
|
|
55
|
-
.description("Export credentials to encrypted file")
|
|
55
|
+
.description("Export credentials to encrypted file or clipboard")
|
|
56
56
|
.requiredOption("-a, --agent <agent>", `Agent to export credentials from (${AGENT_CLIS.join(", ")})`)
|
|
57
|
-
.
|
|
57
|
+
.option("--output <file>", "Output file path")
|
|
58
|
+
.option("-c, --clipboard", "Copy to clipboard instead of file")
|
|
58
59
|
.option("--no-password", "Use default password (no prompt)")
|
|
59
60
|
.action(handleAuthExport);
|
|
60
61
|
program
|
package/dist/commands/auth.d.ts
CHANGED
package/dist/commands/auth.js
CHANGED
|
@@ -1,6 +1,7 @@
|
|
|
1
1
|
/**
|
|
2
2
|
* Auth commands - manage agent credentials.
|
|
3
3
|
*/
|
|
4
|
+
import { execFileSync } from "node:child_process";
|
|
4
5
|
import { renameSync, writeFileSync } from "node:fs";
|
|
5
6
|
import promptPassword from "@inquirer/password";
|
|
6
7
|
import { checkAllAuth, extractRawCredentials, getAccessToken, removeCredentials, } from "../auth/registry.js";
|
|
@@ -43,6 +44,11 @@ async function handleAuthToken(options) {
|
|
|
43
44
|
}
|
|
44
45
|
/** Handle auth export command */
|
|
45
46
|
async function handleAuthExport(options) {
|
|
47
|
+
if (!options.output && !options.clipboard) {
|
|
48
|
+
console.error("Error: Either --output or --clipboard is required");
|
|
49
|
+
process.exitCode = 2;
|
|
50
|
+
return;
|
|
51
|
+
}
|
|
46
52
|
const agentId = validateAgent(options.agent);
|
|
47
53
|
if (!agentId)
|
|
48
54
|
return;
|
|
@@ -56,15 +62,51 @@ async function handleAuthExport(options) {
|
|
|
56
62
|
const userPassword = options.password
|
|
57
63
|
? await promptPassword({ message: "Encryption password" })
|
|
58
64
|
: DEFAULT_PASSWORD;
|
|
59
|
-
// Encrypt
|
|
65
|
+
// Encrypt credentials
|
|
60
66
|
const encrypted = encrypt(JSON.stringify(creds), userPassword);
|
|
61
67
|
const file = { version: 1, agent: agentId, ...toBase64(encrypted) };
|
|
62
|
-
const
|
|
63
|
-
|
|
64
|
-
|
|
65
|
-
|
|
66
|
-
|
|
67
|
-
|
|
68
|
+
const json = JSON.stringify(file, undefined, 2);
|
|
69
|
+
if (options.output) {
|
|
70
|
+
// Write atomically (write to temp, then rename)
|
|
71
|
+
const temporaryFile = `${options.output}.tmp.${Date.now()}`;
|
|
72
|
+
writeFileSync(temporaryFile, json, { mode: 0o600 });
|
|
73
|
+
renameSync(temporaryFile, options.output);
|
|
74
|
+
console.error(`Credentials exported to ${options.output}`);
|
|
75
|
+
}
|
|
76
|
+
if (options.clipboard) {
|
|
77
|
+
try {
|
|
78
|
+
copyToClipboard(json);
|
|
79
|
+
console.error(`Credentials copied to clipboard`);
|
|
80
|
+
}
|
|
81
|
+
catch (error) {
|
|
82
|
+
console.error(`Failed to copy to clipboard: ${error.message}`);
|
|
83
|
+
if (process.platform === "linux") {
|
|
84
|
+
console.error("Hint: Ensure 'xclip' is installed.");
|
|
85
|
+
}
|
|
86
|
+
process.exitCode = 1;
|
|
87
|
+
}
|
|
88
|
+
}
|
|
89
|
+
}
|
|
90
|
+
/** Copy text to system clipboard */
|
|
91
|
+
function copyToClipboard(text) {
|
|
92
|
+
switch (process.platform) {
|
|
93
|
+
case "darwin": {
|
|
94
|
+
execFileSync("pbcopy", [], { input: text });
|
|
95
|
+
break;
|
|
96
|
+
}
|
|
97
|
+
case "linux": {
|
|
98
|
+
execFileSync("xclip", ["-selection", "clipboard"], { input: text });
|
|
99
|
+
break;
|
|
100
|
+
}
|
|
101
|
+
case "win32": {
|
|
102
|
+
execFileSync("clip", [], { input: text });
|
|
103
|
+
break;
|
|
104
|
+
}
|
|
105
|
+
default: {
|
|
106
|
+
throw new Error(`Clipboard not supported on ${process.platform}. ` +
|
|
107
|
+
`Use --output to write to a file instead.`);
|
|
108
|
+
}
|
|
109
|
+
}
|
|
68
110
|
}
|
|
69
111
|
/** Print auth status as TSV table */
|
|
70
112
|
function printAuthTable(statuses) {
|