instar 0.7.37 → 0.7.38
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.
|
@@ -6,8 +6,9 @@
|
|
|
6
6
|
*
|
|
7
7
|
* Ported from Dawn's dawn-server equivalent for general Instar use.
|
|
8
8
|
*/
|
|
9
|
-
import {
|
|
9
|
+
import { execFileSync } from 'node:child_process';
|
|
10
10
|
import fs from 'node:fs';
|
|
11
|
+
import os from 'node:os';
|
|
11
12
|
import path from 'node:path';
|
|
12
13
|
const KEYCHAIN_SERVICE = 'Claude Code-credentials';
|
|
13
14
|
export class AccountSwitcher {
|
|
@@ -16,12 +17,7 @@ export class AccountSwitcher {
|
|
|
16
17
|
constructor(registryPath) {
|
|
17
18
|
this.registryPath = registryPath || path.join(process.env.HOME || '', '.dawn-server/account-registry.json');
|
|
18
19
|
// Get the macOS username for Keychain access
|
|
19
|
-
|
|
20
|
-
this.keychainAccount = execSync('whoami', { encoding: 'utf-8' }).trim();
|
|
21
|
-
}
|
|
22
|
-
catch {
|
|
23
|
-
this.keychainAccount = 'justin';
|
|
24
|
-
}
|
|
20
|
+
this.keychainAccount = os.userInfo().username;
|
|
25
21
|
}
|
|
26
22
|
/**
|
|
27
23
|
* Switch to a target account. Supports fuzzy matching:
|
|
@@ -160,13 +156,19 @@ export class AccountSwitcher {
|
|
|
160
156
|
return null;
|
|
161
157
|
}
|
|
162
158
|
readFromKeychain() {
|
|
163
|
-
const result =
|
|
159
|
+
const result = execFileSync('security', ['find-generic-password', '-s', KEYCHAIN_SERVICE, '-w'], { encoding: 'utf-8', timeout: 10000, stdio: ['pipe', 'pipe', 'pipe'] });
|
|
164
160
|
return JSON.parse(result.trim());
|
|
165
161
|
}
|
|
166
162
|
writeToKeychain(data) {
|
|
167
163
|
const jsonStr = JSON.stringify(data);
|
|
168
164
|
const hexStr = Buffer.from(jsonStr).toString('hex');
|
|
169
|
-
|
|
165
|
+
// Use execFileSync with stdin input instead of shell heredoc
|
|
166
|
+
execFileSync('security', ['-i'], {
|
|
167
|
+
input: `add-generic-password -U -a "${this.keychainAccount}" -s "${KEYCHAIN_SERVICE}" -X "${hexStr}"\n`,
|
|
168
|
+
encoding: 'utf-8',
|
|
169
|
+
timeout: 10000,
|
|
170
|
+
stdio: ['pipe', 'pipe', 'pipe'],
|
|
171
|
+
});
|
|
170
172
|
}
|
|
171
173
|
loadRegistry() {
|
|
172
174
|
try {
|