@ralphkrauss/codex-account-switcher 0.1.1-beta.0 → 0.1.2
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/CHANGELOG.md +25 -0
- package/README.md +82 -1
- package/dist/accounts.d.ts +4 -1
- package/dist/accounts.js +1 -1
- package/dist/accounts.js.map +1 -1
- package/dist/cli.js +380 -7
- package/dist/cli.js.map +1 -1
- package/dist/hermes.d.ts +56 -0
- package/dist/hermes.js +638 -0
- package/dist/hermes.js.map +1 -0
- package/dist/index.d.ts +4 -0
- package/dist/index.js +2 -0
- package/dist/index.js.map +1 -1
- package/dist/remote.d.ts +85 -0
- package/dist/remote.js +468 -0
- package/dist/remote.js.map +1 -0
- package/package.json +1 -1
- package/src/accounts.ts +6 -2
- package/src/cli.ts +473 -6
- package/src/hermes.ts +794 -0
- package/src/index.ts +49 -0
- package/src/remote.ts +670 -0
package/dist/index.d.ts
CHANGED
|
@@ -1,2 +1,6 @@
|
|
|
1
1
|
export { ACCOUNT_NAME_PATTERN, AUTH_NON_EMPTY_BYTES, CxError, accountPathForName, authFileExists, authLooksNonEmpty, getCodexHome, getCodexPaths, inspectDoctor, listAccountNames, listAccounts, loginAccount, readCurrentMarker, removeAccount, renameAccount, resolveExecutable, runCodex, saveAccount, switchAndRunCodex, useAccount, validateAccountName, writebackCurrentAccount, } from './accounts.js';
|
|
2
|
+
export { HERMES_CODEX_BASE_URL, HERMES_OPENAI_CODEX_PROVIDER, getHermesPaths, inspectHermesStatus, syncHermesAccount, useHermesAccount, } from './hermes.js';
|
|
3
|
+
export { DEFAULT_ONEPASSWORD_ITEM_PREFIX, ONEPASSWORD_AUTH_FIELD, ONEPASSWORD_BACKEND, REMOTE_CONFIG_VERSION, configureOnePasswordRemote, getRemoteConfigPath, inspectRemoteStatus, inspectSyncStatus, readRemoteConfig, syncPullAccount, syncPushAccount, } from './remote.js';
|
|
2
4
|
export type { AccountEntry, AccountList, CodexPaths, CurrentMarker, DoctorReport, ForceOptions, OperationOptions, RemoveResult, RenameResult, SpawnCodexOptions, WritebackResult, } from './accounts.js';
|
|
5
|
+
export type { HermesPaths, HermesProfileOptions, HermesStatus, HermesSyncResult, HermesUseOptions, HermesUseResult, } from './hermes.js';
|
|
6
|
+
export type { ConfigureOnePasswordRemoteInput, ConfigureRemoteResult, OnePasswordRemoteConfig, RemoteBackend, RemoteCliOptions, RemoteConfig, RemoteForceOptions, RemotePathOptions, RemotePresence, RemoteStatus, SyncPullResult, SyncPushResult, SyncStatus, SyncStatusAccount, } from './remote.js';
|
package/dist/index.js
CHANGED
|
@@ -1,2 +1,4 @@
|
|
|
1
1
|
export { ACCOUNT_NAME_PATTERN, AUTH_NON_EMPTY_BYTES, CxError, accountPathForName, authFileExists, authLooksNonEmpty, getCodexHome, getCodexPaths, inspectDoctor, listAccountNames, listAccounts, loginAccount, readCurrentMarker, removeAccount, renameAccount, resolveExecutable, runCodex, saveAccount, switchAndRunCodex, useAccount, validateAccountName, writebackCurrentAccount, } from './accounts.js';
|
|
2
|
+
export { HERMES_CODEX_BASE_URL, HERMES_OPENAI_CODEX_PROVIDER, getHermesPaths, inspectHermesStatus, syncHermesAccount, useHermesAccount, } from './hermes.js';
|
|
3
|
+
export { DEFAULT_ONEPASSWORD_ITEM_PREFIX, ONEPASSWORD_AUTH_FIELD, ONEPASSWORD_BACKEND, REMOTE_CONFIG_VERSION, configureOnePasswordRemote, getRemoteConfigPath, inspectRemoteStatus, inspectSyncStatus, readRemoteConfig, syncPullAccount, syncPushAccount, } from './remote.js';
|
|
2
4
|
//# sourceMappingURL=index.js.map
|
package/dist/index.js.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"index.js","sourceRoot":"","sources":["../src/index.ts"],"names":[],"mappings":"AAAA,OAAO,EACL,oBAAoB,EACpB,oBAAoB,EACpB,OAAO,EACP,kBAAkB,EAClB,cAAc,EACd,iBAAiB,EACjB,YAAY,EACZ,aAAa,EACb,aAAa,EACb,gBAAgB,EAChB,YAAY,EACZ,YAAY,EACZ,iBAAiB,EACjB,aAAa,EACb,aAAa,EACb,iBAAiB,EACjB,QAAQ,EACR,WAAW,EACX,iBAAiB,EACjB,UAAU,EACV,mBAAmB,EACnB,uBAAuB,GACxB,MAAM,eAAe,CAAC"}
|
|
1
|
+
{"version":3,"file":"index.js","sourceRoot":"","sources":["../src/index.ts"],"names":[],"mappings":"AAAA,OAAO,EACL,oBAAoB,EACpB,oBAAoB,EACpB,OAAO,EACP,kBAAkB,EAClB,cAAc,EACd,iBAAiB,EACjB,YAAY,EACZ,aAAa,EACb,aAAa,EACb,gBAAgB,EAChB,YAAY,EACZ,YAAY,EACZ,iBAAiB,EACjB,aAAa,EACb,aAAa,EACb,iBAAiB,EACjB,QAAQ,EACR,WAAW,EACX,iBAAiB,EACjB,UAAU,EACV,mBAAmB,EACnB,uBAAuB,GACxB,MAAM,eAAe,CAAC;AAEvB,OAAO,EACL,qBAAqB,EACrB,4BAA4B,EAC5B,cAAc,EACd,mBAAmB,EACnB,iBAAiB,EACjB,gBAAgB,GACjB,MAAM,aAAa,CAAC;AAErB,OAAO,EACL,+BAA+B,EAC/B,sBAAsB,EACtB,mBAAmB,EACnB,qBAAqB,EACrB,0BAA0B,EAC1B,mBAAmB,EACnB,mBAAmB,EACnB,iBAAiB,EACjB,gBAAgB,EAChB,eAAe,EACf,eAAe,GAChB,MAAM,aAAa,CAAC"}
|
package/dist/remote.d.ts
ADDED
|
@@ -0,0 +1,85 @@
|
|
|
1
|
+
import { type CodexPaths } from './accounts.js';
|
|
2
|
+
export declare const REMOTE_CONFIG_VERSION = 1;
|
|
3
|
+
export declare const DEFAULT_ONEPASSWORD_ITEM_PREFIX = "cx-";
|
|
4
|
+
export declare const ONEPASSWORD_BACKEND = "1password";
|
|
5
|
+
export declare const ONEPASSWORD_AUTH_FIELD = "auth_json";
|
|
6
|
+
export type RemoteBackend = typeof ONEPASSWORD_BACKEND;
|
|
7
|
+
export type RemotePresence = 'present' | 'missing' | 'unknown';
|
|
8
|
+
export interface OnePasswordRemoteConfig {
|
|
9
|
+
readonly version: typeof REMOTE_CONFIG_VERSION;
|
|
10
|
+
readonly backend: typeof ONEPASSWORD_BACKEND;
|
|
11
|
+
readonly vault: string;
|
|
12
|
+
readonly itemPrefix: string;
|
|
13
|
+
}
|
|
14
|
+
export type RemoteConfig = OnePasswordRemoteConfig;
|
|
15
|
+
export interface ConfigureOnePasswordRemoteInput {
|
|
16
|
+
readonly vault: string;
|
|
17
|
+
readonly itemPrefix?: string;
|
|
18
|
+
}
|
|
19
|
+
export interface RemotePathOptions {
|
|
20
|
+
readonly paths?: CodexPaths;
|
|
21
|
+
}
|
|
22
|
+
export interface RemoteCliOptions extends RemotePathOptions {
|
|
23
|
+
readonly env?: NodeJS.ProcessEnv;
|
|
24
|
+
}
|
|
25
|
+
export interface RemoteForceOptions extends RemoteCliOptions {
|
|
26
|
+
readonly force?: boolean;
|
|
27
|
+
}
|
|
28
|
+
export interface ConfigureRemoteResult {
|
|
29
|
+
readonly configPath: string;
|
|
30
|
+
readonly config: RemoteConfig;
|
|
31
|
+
}
|
|
32
|
+
export interface RemoteStatus {
|
|
33
|
+
readonly configPath: string;
|
|
34
|
+
readonly configured: boolean;
|
|
35
|
+
readonly backend: RemoteBackend | null;
|
|
36
|
+
readonly vault: string | null;
|
|
37
|
+
readonly itemPrefix: string | null;
|
|
38
|
+
readonly opAvailable: boolean;
|
|
39
|
+
readonly opPath: string | null;
|
|
40
|
+
}
|
|
41
|
+
export interface SyncPushResult {
|
|
42
|
+
readonly account: string;
|
|
43
|
+
readonly accountFile: string;
|
|
44
|
+
readonly backend: RemoteBackend;
|
|
45
|
+
readonly vault: string;
|
|
46
|
+
readonly item: string;
|
|
47
|
+
readonly operation: 'created' | 'updated';
|
|
48
|
+
}
|
|
49
|
+
export interface SyncPullResult {
|
|
50
|
+
readonly account: string;
|
|
51
|
+
readonly accountFile: string;
|
|
52
|
+
readonly backend: RemoteBackend;
|
|
53
|
+
readonly vault: string;
|
|
54
|
+
readonly item: string;
|
|
55
|
+
readonly overwritten: boolean;
|
|
56
|
+
}
|
|
57
|
+
export interface SyncStatusAccount {
|
|
58
|
+
readonly account: string;
|
|
59
|
+
readonly item: string | null;
|
|
60
|
+
readonly local: {
|
|
61
|
+
readonly exists: boolean;
|
|
62
|
+
readonly file: string;
|
|
63
|
+
};
|
|
64
|
+
readonly remote: {
|
|
65
|
+
readonly presence: RemotePresence;
|
|
66
|
+
readonly error: string | null;
|
|
67
|
+
};
|
|
68
|
+
}
|
|
69
|
+
export interface SyncStatus {
|
|
70
|
+
readonly configPath: string;
|
|
71
|
+
readonly configured: boolean;
|
|
72
|
+
readonly backend: RemoteBackend | null;
|
|
73
|
+
readonly vault: string | null;
|
|
74
|
+
readonly itemPrefix: string | null;
|
|
75
|
+
readonly opAvailable: boolean;
|
|
76
|
+
readonly opPath: string | null;
|
|
77
|
+
readonly accounts: readonly SyncStatusAccount[];
|
|
78
|
+
}
|
|
79
|
+
export declare function getRemoteConfigPath(paths?: CodexPaths): string;
|
|
80
|
+
export declare function readRemoteConfig(options?: RemotePathOptions): Promise<RemoteConfig | null>;
|
|
81
|
+
export declare function configureOnePasswordRemote(input: ConfigureOnePasswordRemoteInput, options?: RemotePathOptions): Promise<ConfigureRemoteResult>;
|
|
82
|
+
export declare function inspectRemoteStatus(options?: RemoteCliOptions): Promise<RemoteStatus>;
|
|
83
|
+
export declare function syncPushAccount(account: string, options?: RemoteCliOptions): Promise<SyncPushResult>;
|
|
84
|
+
export declare function syncPullAccount(account: string, options?: RemoteForceOptions): Promise<SyncPullResult>;
|
|
85
|
+
export declare function inspectSyncStatus(account?: string, options?: RemoteCliOptions): Promise<SyncStatus>;
|
package/dist/remote.js
ADDED
|
@@ -0,0 +1,468 @@
|
|
|
1
|
+
import { spawn } from 'node:child_process';
|
|
2
|
+
import { randomBytes } from 'node:crypto';
|
|
3
|
+
import { constants as fsConstants } from 'node:fs';
|
|
4
|
+
import { access, chmod, mkdir, readFile, rename, rm, writeFile, } from 'node:fs/promises';
|
|
5
|
+
import { dirname, join } from 'node:path';
|
|
6
|
+
import { CxError, accountPathForName, getCodexPaths, listAccountNames, resolveExecutable, validateAccountName, } from './accounts.js';
|
|
7
|
+
export const REMOTE_CONFIG_VERSION = 1;
|
|
8
|
+
export const DEFAULT_ONEPASSWORD_ITEM_PREFIX = 'cx-';
|
|
9
|
+
export const ONEPASSWORD_BACKEND = '1password';
|
|
10
|
+
export const ONEPASSWORD_AUTH_FIELD = 'auth_json';
|
|
11
|
+
function isRecord(value) {
|
|
12
|
+
return typeof value === 'object' && value !== null && !Array.isArray(value);
|
|
13
|
+
}
|
|
14
|
+
function errorMessage(error) {
|
|
15
|
+
return error instanceof Error ? error.message : String(error);
|
|
16
|
+
}
|
|
17
|
+
function isNotFoundError(error) {
|
|
18
|
+
return typeof error === 'object'
|
|
19
|
+
&& error !== null
|
|
20
|
+
&& 'code' in error
|
|
21
|
+
&& error.code === 'ENOENT';
|
|
22
|
+
}
|
|
23
|
+
async function pathExists(path) {
|
|
24
|
+
try {
|
|
25
|
+
await access(path, fsConstants.F_OK);
|
|
26
|
+
return true;
|
|
27
|
+
}
|
|
28
|
+
catch (error) {
|
|
29
|
+
if (isNotFoundError(error)) {
|
|
30
|
+
return false;
|
|
31
|
+
}
|
|
32
|
+
throw error;
|
|
33
|
+
}
|
|
34
|
+
}
|
|
35
|
+
async function chmodIfPossible(path, mode) {
|
|
36
|
+
if (process.platform === 'win32') {
|
|
37
|
+
return;
|
|
38
|
+
}
|
|
39
|
+
try {
|
|
40
|
+
await chmod(path, mode);
|
|
41
|
+
}
|
|
42
|
+
catch (error) {
|
|
43
|
+
const code = typeof error === 'object' && error !== null && 'code' in error
|
|
44
|
+
? error.code
|
|
45
|
+
: undefined;
|
|
46
|
+
if (code === 'ENOSYS' || code === 'ENOTSUP' || code === 'EINVAL' || code === 'EPERM') {
|
|
47
|
+
return;
|
|
48
|
+
}
|
|
49
|
+
throw error;
|
|
50
|
+
}
|
|
51
|
+
}
|
|
52
|
+
async function ensurePrivateDir(path) {
|
|
53
|
+
const existed = await pathExists(path);
|
|
54
|
+
await mkdir(path, { recursive: true, mode: 0o700 });
|
|
55
|
+
if (!existed) {
|
|
56
|
+
await chmodIfPossible(path, 0o700);
|
|
57
|
+
}
|
|
58
|
+
}
|
|
59
|
+
async function writeFilePrivate(destination, contents) {
|
|
60
|
+
await ensurePrivateDir(dirname(destination));
|
|
61
|
+
const temp = join(dirname(destination), `.cx-${randomBytes(6).toString('hex')}.tmp`);
|
|
62
|
+
try {
|
|
63
|
+
await writeFile(temp, contents, { mode: 0o600 });
|
|
64
|
+
await chmodIfPossible(temp, 0o600);
|
|
65
|
+
await rename(temp, destination);
|
|
66
|
+
await chmodIfPossible(destination, 0o600);
|
|
67
|
+
}
|
|
68
|
+
catch (error) {
|
|
69
|
+
await rm(temp, { force: true }).catch(() => undefined);
|
|
70
|
+
throw error;
|
|
71
|
+
}
|
|
72
|
+
}
|
|
73
|
+
function remotePaths(options = {}) {
|
|
74
|
+
return options.paths ?? getCodexPaths(options.env ?? process.env);
|
|
75
|
+
}
|
|
76
|
+
export function getRemoteConfigPath(paths = getCodexPaths()) {
|
|
77
|
+
return join(paths.home, 'remote.json');
|
|
78
|
+
}
|
|
79
|
+
function nonEmptyConfigString(value, label, exitCode = 1) {
|
|
80
|
+
if (typeof value !== 'string') {
|
|
81
|
+
throw new CxError(`${label} must be a string`, exitCode);
|
|
82
|
+
}
|
|
83
|
+
const trimmed = value.trim();
|
|
84
|
+
if (trimmed.length === 0) {
|
|
85
|
+
throw new CxError(`${label} must not be empty`, exitCode);
|
|
86
|
+
}
|
|
87
|
+
if (/[\r\n]/u.test(trimmed)) {
|
|
88
|
+
throw new CxError(`${label} must not contain line breaks`, exitCode);
|
|
89
|
+
}
|
|
90
|
+
return trimmed;
|
|
91
|
+
}
|
|
92
|
+
function normalizeItemPrefix(value, exitCode = 1) {
|
|
93
|
+
if (value === undefined || value === null) {
|
|
94
|
+
return DEFAULT_ONEPASSWORD_ITEM_PREFIX;
|
|
95
|
+
}
|
|
96
|
+
return nonEmptyConfigString(value, '1Password item prefix', exitCode);
|
|
97
|
+
}
|
|
98
|
+
function parseRemoteConfig(parsed, configPath) {
|
|
99
|
+
if (!isRecord(parsed)) {
|
|
100
|
+
throw new CxError(`remote config at ${configPath} must be a JSON object`, 1);
|
|
101
|
+
}
|
|
102
|
+
if (parsed.version !== REMOTE_CONFIG_VERSION) {
|
|
103
|
+
throw new CxError(`unsupported remote config version at ${configPath}`, 1);
|
|
104
|
+
}
|
|
105
|
+
if (parsed.backend !== ONEPASSWORD_BACKEND) {
|
|
106
|
+
throw new CxError(`unsupported remote backend in ${configPath}`, 1);
|
|
107
|
+
}
|
|
108
|
+
return {
|
|
109
|
+
version: REMOTE_CONFIG_VERSION,
|
|
110
|
+
backend: ONEPASSWORD_BACKEND,
|
|
111
|
+
vault: nonEmptyConfigString(parsed.vault, '1Password vault'),
|
|
112
|
+
itemPrefix: normalizeItemPrefix(parsed.itemPrefix),
|
|
113
|
+
};
|
|
114
|
+
}
|
|
115
|
+
export async function readRemoteConfig(options = {}) {
|
|
116
|
+
const paths = remotePaths(options);
|
|
117
|
+
const configPath = getRemoteConfigPath(paths);
|
|
118
|
+
let raw;
|
|
119
|
+
try {
|
|
120
|
+
raw = await readFile(configPath, 'utf8');
|
|
121
|
+
}
|
|
122
|
+
catch (error) {
|
|
123
|
+
if (isNotFoundError(error)) {
|
|
124
|
+
return null;
|
|
125
|
+
}
|
|
126
|
+
throw error;
|
|
127
|
+
}
|
|
128
|
+
try {
|
|
129
|
+
return parseRemoteConfig(JSON.parse(raw), configPath);
|
|
130
|
+
}
|
|
131
|
+
catch (error) {
|
|
132
|
+
if (error instanceof CxError) {
|
|
133
|
+
throw error;
|
|
134
|
+
}
|
|
135
|
+
throw new CxError(`failed to parse remote config at ${configPath}: ${errorMessage(error)}`, 1);
|
|
136
|
+
}
|
|
137
|
+
}
|
|
138
|
+
async function requireRemoteConfig(options = {}) {
|
|
139
|
+
const paths = remotePaths(options);
|
|
140
|
+
const config = await readRemoteConfig({ paths });
|
|
141
|
+
if (!config) {
|
|
142
|
+
throw new CxError(`remote backend is not configured (run: cx remote configure 1password --vault <vault>)`, 1);
|
|
143
|
+
}
|
|
144
|
+
return config;
|
|
145
|
+
}
|
|
146
|
+
export async function configureOnePasswordRemote(input, options = {}) {
|
|
147
|
+
const paths = remotePaths(options);
|
|
148
|
+
const configPath = getRemoteConfigPath(paths);
|
|
149
|
+
const config = {
|
|
150
|
+
version: REMOTE_CONFIG_VERSION,
|
|
151
|
+
backend: ONEPASSWORD_BACKEND,
|
|
152
|
+
vault: nonEmptyConfigString(input.vault, '1Password vault', 2),
|
|
153
|
+
itemPrefix: normalizeItemPrefix(input.itemPrefix, 2),
|
|
154
|
+
};
|
|
155
|
+
await writeFilePrivate(configPath, `${JSON.stringify(config, null, 2)}\n`);
|
|
156
|
+
return { configPath, config };
|
|
157
|
+
}
|
|
158
|
+
export async function inspectRemoteStatus(options = {}) {
|
|
159
|
+
const paths = remotePaths(options);
|
|
160
|
+
const config = await readRemoteConfig({ paths });
|
|
161
|
+
const opPath = await resolveExecutable('op', options.env ?? process.env);
|
|
162
|
+
return {
|
|
163
|
+
configPath: getRemoteConfigPath(paths),
|
|
164
|
+
configured: config !== null,
|
|
165
|
+
backend: config?.backend ?? null,
|
|
166
|
+
vault: config?.vault ?? null,
|
|
167
|
+
itemPrefix: config?.itemPrefix ?? null,
|
|
168
|
+
opAvailable: opPath !== null,
|
|
169
|
+
opPath,
|
|
170
|
+
};
|
|
171
|
+
}
|
|
172
|
+
function missingOpError() {
|
|
173
|
+
return new CxError("1Password CLI ('op') was not found on PATH. Install 1Password CLI v2 and sign in with 'op signin' or set OP_SERVICE_ACCOUNT_TOKEN.", 1);
|
|
174
|
+
}
|
|
175
|
+
async function resolveOp(env) {
|
|
176
|
+
const opPath = await resolveExecutable('op', env);
|
|
177
|
+
if (!opPath) {
|
|
178
|
+
throw missingOpError();
|
|
179
|
+
}
|
|
180
|
+
return opPath;
|
|
181
|
+
}
|
|
182
|
+
function summarizeOutput(stdout, stderr) {
|
|
183
|
+
const combined = [stderr, stdout]
|
|
184
|
+
.map((part) => part.trim())
|
|
185
|
+
.filter((part) => part.length > 0)
|
|
186
|
+
.join('\n')
|
|
187
|
+
.replace(/auth_json(?:\[[^\]]+\])?=[\s\S]*/giu, 'auth_json=[redacted]')
|
|
188
|
+
.replaceAll('\r\n', '\n')
|
|
189
|
+
.split('\n')
|
|
190
|
+
.map((line) => line.trim())
|
|
191
|
+
.filter((line) => line.length > 0)
|
|
192
|
+
.join(' ');
|
|
193
|
+
if (combined.length > 500) {
|
|
194
|
+
return `${combined.slice(0, 500)}…`;
|
|
195
|
+
}
|
|
196
|
+
return combined;
|
|
197
|
+
}
|
|
198
|
+
function opAuthHint() {
|
|
199
|
+
return "Make sure 'op' is signed in (run 'op signin') or OP_SERVICE_ACCOUNT_TOKEN is set.";
|
|
200
|
+
}
|
|
201
|
+
function opFailureMessage(action, result, options = {}) {
|
|
202
|
+
const output = options.sensitive === true
|
|
203
|
+
? summarizeOutput('', result.stderr)
|
|
204
|
+
: summarizeOutput(result.stdout, result.stderr);
|
|
205
|
+
const detail = output ? `: ${output}` : ` (exit code ${result.exitCode})`;
|
|
206
|
+
return `1Password CLI command failed while ${action}${detail}. ${opAuthHint()}`;
|
|
207
|
+
}
|
|
208
|
+
function throwOpFailure(action, result, options = {}) {
|
|
209
|
+
throw new CxError(opFailureMessage(action, result, options), 1);
|
|
210
|
+
}
|
|
211
|
+
async function runOpRaw(args, env) {
|
|
212
|
+
const opPath = await resolveOp(env);
|
|
213
|
+
return await new Promise((resolvePromise, reject) => {
|
|
214
|
+
const child = spawn(opPath, [...args], {
|
|
215
|
+
env,
|
|
216
|
+
shell: false,
|
|
217
|
+
stdio: ['ignore', 'pipe', 'pipe'],
|
|
218
|
+
windowsHide: true,
|
|
219
|
+
});
|
|
220
|
+
let stdout = '';
|
|
221
|
+
let stderr = '';
|
|
222
|
+
child.stdout.setEncoding('utf8');
|
|
223
|
+
child.stderr.setEncoding('utf8');
|
|
224
|
+
child.stdout.on('data', (chunk) => {
|
|
225
|
+
stdout += chunk;
|
|
226
|
+
});
|
|
227
|
+
child.stderr.on('data', (chunk) => {
|
|
228
|
+
stderr += chunk;
|
|
229
|
+
});
|
|
230
|
+
child.on('error', (error) => {
|
|
231
|
+
if (isNotFoundError(error)) {
|
|
232
|
+
reject(missingOpError());
|
|
233
|
+
return;
|
|
234
|
+
}
|
|
235
|
+
reject(new CxError(`failed to run 1Password CLI ('op'): ${error.message}`, 1));
|
|
236
|
+
});
|
|
237
|
+
child.on('close', (code) => {
|
|
238
|
+
resolvePromise({ exitCode: code ?? 1, stdout, stderr });
|
|
239
|
+
});
|
|
240
|
+
});
|
|
241
|
+
}
|
|
242
|
+
async function runOp(args, env, action, options = {}) {
|
|
243
|
+
const result = await runOpRaw(args, env);
|
|
244
|
+
if (result.exitCode !== 0) {
|
|
245
|
+
throwOpFailure(action, result, options);
|
|
246
|
+
}
|
|
247
|
+
return result;
|
|
248
|
+
}
|
|
249
|
+
function looksLikeMissingItem(result) {
|
|
250
|
+
const text = `${result.stderr}\n${result.stdout}`;
|
|
251
|
+
return /(?:not found|could not be found|does not exist|doesn't exist|isn't an item|is not an item|no item)/iu.test(text);
|
|
252
|
+
}
|
|
253
|
+
function looksLikeMissingField(result) {
|
|
254
|
+
const text = `${result.stderr}\n${result.stdout}`;
|
|
255
|
+
return /(?:field.*not found|no field|does not have.*field|doesn't have.*field|unknown field)/iu.test(text);
|
|
256
|
+
}
|
|
257
|
+
function itemTitle(config, account) {
|
|
258
|
+
return `${config.itemPrefix}${account}`;
|
|
259
|
+
}
|
|
260
|
+
async function onePasswordItemExists(config, item, env) {
|
|
261
|
+
const result = await runOpRaw([
|
|
262
|
+
'item',
|
|
263
|
+
'get',
|
|
264
|
+
item,
|
|
265
|
+
'--vault',
|
|
266
|
+
config.vault,
|
|
267
|
+
'--format',
|
|
268
|
+
'json',
|
|
269
|
+
], env);
|
|
270
|
+
if (result.exitCode === 0) {
|
|
271
|
+
return true;
|
|
272
|
+
}
|
|
273
|
+
if (looksLikeMissingItem(result)) {
|
|
274
|
+
return false;
|
|
275
|
+
}
|
|
276
|
+
throwOpFailure(`checking 1Password item '${item}'`, result);
|
|
277
|
+
}
|
|
278
|
+
function authFieldAssignment(authJson) {
|
|
279
|
+
return `${ONEPASSWORD_AUTH_FIELD}[concealed]=${authJson}`;
|
|
280
|
+
}
|
|
281
|
+
async function upsertOnePasswordAuthJson(config, item, authJson, env) {
|
|
282
|
+
if (await onePasswordItemExists(config, item, env)) {
|
|
283
|
+
await runOp([
|
|
284
|
+
'item',
|
|
285
|
+
'edit',
|
|
286
|
+
item,
|
|
287
|
+
'--vault',
|
|
288
|
+
config.vault,
|
|
289
|
+
authFieldAssignment(authJson),
|
|
290
|
+
], env, `updating 1Password item '${item}'`, { sensitive: true });
|
|
291
|
+
return 'updated';
|
|
292
|
+
}
|
|
293
|
+
await runOp([
|
|
294
|
+
'item',
|
|
295
|
+
'create',
|
|
296
|
+
'--vault',
|
|
297
|
+
config.vault,
|
|
298
|
+
'--category',
|
|
299
|
+
'secure-note',
|
|
300
|
+
'--title',
|
|
301
|
+
item,
|
|
302
|
+
authFieldAssignment(authJson),
|
|
303
|
+
], env, `creating 1Password item '${item}'`, { sensitive: true });
|
|
304
|
+
return 'created';
|
|
305
|
+
}
|
|
306
|
+
function stripOneTrailingLineEnding(value) {
|
|
307
|
+
if (value.endsWith('\r\n')) {
|
|
308
|
+
return value.slice(0, -2);
|
|
309
|
+
}
|
|
310
|
+
if (value.endsWith('\n')) {
|
|
311
|
+
return value.slice(0, -1);
|
|
312
|
+
}
|
|
313
|
+
return value;
|
|
314
|
+
}
|
|
315
|
+
function parseAuthJsonString(raw, description) {
|
|
316
|
+
try {
|
|
317
|
+
JSON.parse(raw);
|
|
318
|
+
}
|
|
319
|
+
catch (error) {
|
|
320
|
+
throw new CxError(`${description} is not valid JSON: ${errorMessage(error)}`, 1);
|
|
321
|
+
}
|
|
322
|
+
}
|
|
323
|
+
function decodeAuthJsonField(stdout, item) {
|
|
324
|
+
const withoutOpLineEnding = stripOneTrailingLineEnding(stdout);
|
|
325
|
+
try {
|
|
326
|
+
parseAuthJsonString(withoutOpLineEnding, `auth_json field in 1Password item '${item}'`);
|
|
327
|
+
return withoutOpLineEnding;
|
|
328
|
+
}
|
|
329
|
+
catch {
|
|
330
|
+
parseAuthJsonString(stdout, `auth_json field in 1Password item '${item}'`);
|
|
331
|
+
return stdout;
|
|
332
|
+
}
|
|
333
|
+
}
|
|
334
|
+
async function readOnePasswordAuthJson(config, item, env) {
|
|
335
|
+
const result = await runOpRaw([
|
|
336
|
+
'item',
|
|
337
|
+
'get',
|
|
338
|
+
item,
|
|
339
|
+
'--vault',
|
|
340
|
+
config.vault,
|
|
341
|
+
'--fields',
|
|
342
|
+
`label=${ONEPASSWORD_AUTH_FIELD}`,
|
|
343
|
+
'--reveal',
|
|
344
|
+
], env);
|
|
345
|
+
if (result.exitCode === 0) {
|
|
346
|
+
return decodeAuthJsonField(result.stdout, item);
|
|
347
|
+
}
|
|
348
|
+
if (looksLikeMissingField(result)) {
|
|
349
|
+
throw new CxError(`1Password item '${item}' does not contain a revealable '${ONEPASSWORD_AUTH_FIELD}' field`, 1);
|
|
350
|
+
}
|
|
351
|
+
if (looksLikeMissingItem(result)) {
|
|
352
|
+
throw new CxError(`remote account item '${item}' was not found in 1Password vault '${config.vault}'`, 1);
|
|
353
|
+
}
|
|
354
|
+
throwOpFailure(`reading '${ONEPASSWORD_AUTH_FIELD}' from 1Password item '${item}'`, result);
|
|
355
|
+
}
|
|
356
|
+
async function readLocalAccountAuthJson(account, paths) {
|
|
357
|
+
const safeAccount = validateAccountName(account);
|
|
358
|
+
const accountFile = accountPathForName(paths, safeAccount);
|
|
359
|
+
let authJson;
|
|
360
|
+
try {
|
|
361
|
+
authJson = await readFile(accountFile, 'utf8');
|
|
362
|
+
}
|
|
363
|
+
catch (error) {
|
|
364
|
+
if (isNotFoundError(error)) {
|
|
365
|
+
throw new CxError(`no account '${safeAccount}'`, 1);
|
|
366
|
+
}
|
|
367
|
+
throw error;
|
|
368
|
+
}
|
|
369
|
+
parseAuthJsonString(authJson, `Codex account '${safeAccount}' at ${accountFile}`);
|
|
370
|
+
return { account: safeAccount, accountFile, authJson };
|
|
371
|
+
}
|
|
372
|
+
async function writeLocalAccountAuthJson(account, authJson, paths, force) {
|
|
373
|
+
const safeAccount = validateAccountName(account);
|
|
374
|
+
const accountFile = accountPathForName(paths, safeAccount);
|
|
375
|
+
const overwritten = await pathExists(accountFile);
|
|
376
|
+
if (overwritten && !force) {
|
|
377
|
+
throw new CxError(`account '${safeAccount}' already exists (use --force to overwrite)`, 1);
|
|
378
|
+
}
|
|
379
|
+
parseAuthJsonString(authJson, `remote account '${safeAccount}'`);
|
|
380
|
+
await writeFilePrivate(accountFile, authJson);
|
|
381
|
+
return { account: safeAccount, accountFile, overwritten };
|
|
382
|
+
}
|
|
383
|
+
export async function syncPushAccount(account, options = {}) {
|
|
384
|
+
const env = options.env ?? process.env;
|
|
385
|
+
const paths = remotePaths(options);
|
|
386
|
+
const [config, local] = await Promise.all([
|
|
387
|
+
requireRemoteConfig({ paths }),
|
|
388
|
+
readLocalAccountAuthJson(account, paths),
|
|
389
|
+
]);
|
|
390
|
+
const item = itemTitle(config, local.account);
|
|
391
|
+
const operation = await upsertOnePasswordAuthJson(config, item, local.authJson, env);
|
|
392
|
+
return {
|
|
393
|
+
account: local.account,
|
|
394
|
+
accountFile: local.accountFile,
|
|
395
|
+
backend: config.backend,
|
|
396
|
+
vault: config.vault,
|
|
397
|
+
item,
|
|
398
|
+
operation,
|
|
399
|
+
};
|
|
400
|
+
}
|
|
401
|
+
export async function syncPullAccount(account, options = {}) {
|
|
402
|
+
const env = options.env ?? process.env;
|
|
403
|
+
const paths = remotePaths(options);
|
|
404
|
+
const config = await requireRemoteConfig({ paths });
|
|
405
|
+
const safeAccount = validateAccountName(account);
|
|
406
|
+
const item = itemTitle(config, safeAccount);
|
|
407
|
+
const authJson = await readOnePasswordAuthJson(config, item, env);
|
|
408
|
+
const local = await writeLocalAccountAuthJson(safeAccount, authJson, paths, options.force === true);
|
|
409
|
+
return {
|
|
410
|
+
account: local.account,
|
|
411
|
+
accountFile: local.accountFile,
|
|
412
|
+
backend: config.backend,
|
|
413
|
+
vault: config.vault,
|
|
414
|
+
item,
|
|
415
|
+
overwritten: local.overwritten,
|
|
416
|
+
};
|
|
417
|
+
}
|
|
418
|
+
export async function inspectSyncStatus(account, options = {}) {
|
|
419
|
+
const env = options.env ?? process.env;
|
|
420
|
+
const paths = remotePaths(options);
|
|
421
|
+
const config = await readRemoteConfig({ paths });
|
|
422
|
+
const opPath = await resolveExecutable('op', env);
|
|
423
|
+
const accounts = account ? [validateAccountName(account)] : await listAccountNames(paths);
|
|
424
|
+
const statuses = [];
|
|
425
|
+
for (const accountName of accounts) {
|
|
426
|
+
const accountFile = accountPathForName(paths, accountName);
|
|
427
|
+
let presence = 'unknown';
|
|
428
|
+
let remoteError = null;
|
|
429
|
+
const remoteItem = config ? itemTitle(config, accountName) : null;
|
|
430
|
+
if (!config) {
|
|
431
|
+
remoteError = 'remote backend is not configured';
|
|
432
|
+
}
|
|
433
|
+
else if (!opPath) {
|
|
434
|
+
remoteError = missingOpError().message;
|
|
435
|
+
}
|
|
436
|
+
else {
|
|
437
|
+
try {
|
|
438
|
+
presence = await onePasswordItemExists(config, remoteItem ?? '', env) ? 'present' : 'missing';
|
|
439
|
+
}
|
|
440
|
+
catch (error) {
|
|
441
|
+
remoteError = errorMessage(error);
|
|
442
|
+
}
|
|
443
|
+
}
|
|
444
|
+
statuses.push({
|
|
445
|
+
account: accountName,
|
|
446
|
+
item: remoteItem,
|
|
447
|
+
local: {
|
|
448
|
+
exists: await pathExists(accountFile),
|
|
449
|
+
file: accountFile,
|
|
450
|
+
},
|
|
451
|
+
remote: {
|
|
452
|
+
presence,
|
|
453
|
+
error: remoteError,
|
|
454
|
+
},
|
|
455
|
+
});
|
|
456
|
+
}
|
|
457
|
+
return {
|
|
458
|
+
configPath: getRemoteConfigPath(paths),
|
|
459
|
+
configured: config !== null,
|
|
460
|
+
backend: config?.backend ?? null,
|
|
461
|
+
vault: config?.vault ?? null,
|
|
462
|
+
itemPrefix: config?.itemPrefix ?? null,
|
|
463
|
+
opAvailable: opPath !== null,
|
|
464
|
+
opPath,
|
|
465
|
+
accounts: statuses,
|
|
466
|
+
};
|
|
467
|
+
}
|
|
468
|
+
//# sourceMappingURL=remote.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"remote.js","sourceRoot":"","sources":["../src/remote.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,KAAK,EAAE,MAAM,oBAAoB,CAAC;AAC3C,OAAO,EAAE,WAAW,EAAE,MAAM,aAAa,CAAC;AAC1C,OAAO,EAAE,SAAS,IAAI,WAAW,EAAE,MAAM,SAAS,CAAC;AACnD,OAAO,EACL,MAAM,EACN,KAAK,EACL,KAAK,EACL,QAAQ,EACR,MAAM,EACN,EAAE,EACF,SAAS,GACV,MAAM,kBAAkB,CAAC;AAC1B,OAAO,EAAE,OAAO,EAAE,IAAI,EAAE,MAAM,WAAW,CAAC;AAC1C,OAAO,EACL,OAAO,EACP,kBAAkB,EAClB,aAAa,EACb,gBAAgB,EAChB,iBAAiB,EACjB,mBAAmB,GAEpB,MAAM,eAAe,CAAC;AAEvB,MAAM,CAAC,MAAM,qBAAqB,GAAG,CAAC,CAAC;AACvC,MAAM,CAAC,MAAM,+BAA+B,GAAG,KAAK,CAAC;AACrD,MAAM,CAAC,MAAM,mBAAmB,GAAG,WAAW,CAAC;AAC/C,MAAM,CAAC,MAAM,sBAAsB,GAAG,WAAW,CAAC;AAoGlD,SAAS,QAAQ,CAAC,KAAc;IAC9B,OAAO,OAAO,KAAK,KAAK,QAAQ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
|
|
49
49
|
|
|
50
|
+
export interface LoginAccountOptions extends ForceOptions, SpawnCodexOptions {
|
|
51
|
+
readonly loginArgs?: readonly string[];
|
|
52
|
+
}
|
|
53
|
+
|
|
50
54
|
export interface AccountEntry {
|
|
51
55
|
readonly name: string;
|
|
52
56
|
readonly file: string;
|
|
@@ -492,7 +496,7 @@ export async function runCodex(
|
|
|
492
496
|
|
|
493
497
|
export async function loginAccount(
|
|
494
498
|
name: string,
|
|
495
|
-
options:
|
|
499
|
+
options: LoginAccountOptions = {},
|
|
496
500
|
): Promise<WritebackResult> {
|
|
497
501
|
const paths = options.paths ?? getCodexPaths(options.env ?? process.env);
|
|
498
502
|
const safeName = validateAccountName(name);
|
|
@@ -505,7 +509,7 @@ export async function loginAccount(
|
|
|
505
509
|
const writeback = await writebackCurrentAccount({ paths });
|
|
506
510
|
const loginExitCode = await runCodex([], {
|
|
507
511
|
...options,
|
|
508
|
-
args: ['login'],
|
|
512
|
+
args: ['login', ...(options.loginArgs ?? [])],
|
|
509
513
|
});
|
|
510
514
|
|
|
511
515
|
if (loginExitCode !== 0) {
|