dc-ops-cli 1.0.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/README.md +310 -0
- package/dist/commands/copy.d.ts +23 -0
- package/dist/commands/copy.d.ts.map +1 -0
- package/dist/commands/copy.js +74 -0
- package/dist/commands/copy.js.map +1 -0
- package/dist/commands/export.d.ts +14 -0
- package/dist/commands/export.d.ts.map +1 -0
- package/dist/commands/export.js +111 -0
- package/dist/commands/export.js.map +1 -0
- package/dist/commands/get.d.ts +31 -0
- package/dist/commands/get.d.ts.map +1 -0
- package/dist/commands/get.js +142 -0
- package/dist/commands/get.js.map +1 -0
- package/dist/commands/import.d.ts +27 -0
- package/dist/commands/import.d.ts.map +1 -0
- package/dist/commands/import.js +129 -0
- package/dist/commands/import.js.map +1 -0
- package/dist/commands/inspect.d.ts +20 -0
- package/dist/commands/inspect.d.ts.map +1 -0
- package/dist/commands/inspect.js +73 -0
- package/dist/commands/inspect.js.map +1 -0
- package/dist/commands/list.d.ts +11 -0
- package/dist/commands/list.d.ts.map +1 -0
- package/dist/commands/list.js +90 -0
- package/dist/commands/list.js.map +1 -0
- package/dist/commands/resolve.d.ts +18 -0
- package/dist/commands/resolve.d.ts.map +1 -0
- package/dist/commands/resolve.js +143 -0
- package/dist/commands/resolve.js.map +1 -0
- package/dist/commands/run.d.ts +29 -0
- package/dist/commands/run.d.ts.map +1 -0
- package/dist/commands/run.js +127 -0
- package/dist/commands/run.js.map +1 -0
- package/dist/commands/set.d.ts +12 -0
- package/dist/commands/set.d.ts.map +1 -0
- package/dist/commands/set.js +86 -0
- package/dist/commands/set.js.map +1 -0
- package/dist/commands/vaults.d.ts +18 -0
- package/dist/commands/vaults.d.ts.map +1 -0
- package/dist/commands/vaults.js +54 -0
- package/dist/commands/vaults.js.map +1 -0
- package/dist/index.d.ts +3 -0
- package/dist/index.d.ts.map +1 -0
- package/dist/index.js +161 -0
- package/dist/index.js.map +1 -0
- package/dist/utils/cli.d.ts +8 -0
- package/dist/utils/cli.d.ts.map +1 -0
- package/dist/utils/cli.js +53 -0
- package/dist/utils/cli.js.map +1 -0
- package/dist/utils/io.d.ts +2 -0
- package/dist/utils/io.d.ts.map +1 -0
- package/dist/utils/io.js +8 -0
- package/dist/utils/io.js.map +1 -0
- package/dist/utils/op.d.ts +68 -0
- package/dist/utils/op.d.ts.map +1 -0
- package/dist/utils/op.js +358 -0
- package/dist/utils/op.js.map +1 -0
- package/dist/utils/types.d.ts +31 -0
- package/dist/utils/types.d.ts.map +1 -0
- package/dist/utils/types.js +9 -0
- package/dist/utils/types.js.map +1 -0
- package/package.json +52 -0
package/dist/index.js
ADDED
|
@@ -0,0 +1,161 @@
|
|
|
1
|
+
#!/usr/bin/env node
|
|
2
|
+
import { Command } from 'commander';
|
|
3
|
+
import { getCommand } from './commands/get.js';
|
|
4
|
+
import { listCommand } from './commands/list.js';
|
|
5
|
+
import { setCommand } from './commands/set.js';
|
|
6
|
+
import { exportCommand } from './commands/export.js';
|
|
7
|
+
import { copyCommand } from './commands/copy.js';
|
|
8
|
+
import { importCommand } from './commands/import.js';
|
|
9
|
+
import { resolveCommand } from './commands/resolve.js';
|
|
10
|
+
import { runCommand } from './commands/run.js';
|
|
11
|
+
import { inspectCommand } from './commands/inspect.js';
|
|
12
|
+
import { vaultsCommand } from './commands/vaults.js';
|
|
13
|
+
const program = new Command();
|
|
14
|
+
program
|
|
15
|
+
.name('ops')
|
|
16
|
+
.description('Easy secret retrieval from 1Password with smart fallbacks')
|
|
17
|
+
.version('1.0.0')
|
|
18
|
+
.addHelpCommand()
|
|
19
|
+
.showHelpAfterError()
|
|
20
|
+
.showSuggestionAfterError()
|
|
21
|
+
.action(() => {
|
|
22
|
+
// Show help when no command is provided (exit 0, not 1)
|
|
23
|
+
program.outputHelp();
|
|
24
|
+
});
|
|
25
|
+
program.enablePositionalOptions();
|
|
26
|
+
program
|
|
27
|
+
.command('get <name>')
|
|
28
|
+
.description('Get a secret from 1Password (with fallback prompt if not found)')
|
|
29
|
+
.option('-v, --vault <vault>', 'vault name (default: OPS_VAULT or Private)')
|
|
30
|
+
.option('-f, --field <field>', 'field name (default: OPS_FIELD or password)')
|
|
31
|
+
.option('-s, --silent', 'output only the secret value (alias for --plain)')
|
|
32
|
+
.option('--plain', 'output only the secret value')
|
|
33
|
+
.option('--json', 'output as JSON')
|
|
34
|
+
.option('--no-input', 'disable prompts (fail if input is required)')
|
|
35
|
+
.option('-q, --quiet', 'suppress non-essential output')
|
|
36
|
+
.option('--no-color', 'disable color output')
|
|
37
|
+
.action(getCommand);
|
|
38
|
+
program
|
|
39
|
+
.command('inspect <name>')
|
|
40
|
+
.description('Inspect an item to see available fields')
|
|
41
|
+
.option('-v, --vault <vault>', 'vault name (default: OPS_VAULT or Private)')
|
|
42
|
+
.option('-j, --json', 'output as JSON')
|
|
43
|
+
.option('-q, --quiet', 'suppress non-essential output')
|
|
44
|
+
.option('--no-color', 'disable color output')
|
|
45
|
+
.action(inspectCommand);
|
|
46
|
+
program
|
|
47
|
+
.command('set <name>')
|
|
48
|
+
.description('Store a secret in 1Password')
|
|
49
|
+
.option('-v, --vault <vault>', 'vault name (default: OPS_VAULT or Private)')
|
|
50
|
+
.option('-f, --field <field>', 'field name (default: OPS_FIELD or password)')
|
|
51
|
+
.option('--value <value>', 'secret value (use "-" to read from stdin)')
|
|
52
|
+
.option('--value-file <file>', 'read secret value from file (use "-" for stdin)')
|
|
53
|
+
.option('--force', 'overwrite without confirmation')
|
|
54
|
+
.option('--no-input', 'disable prompts (fail if input is required)')
|
|
55
|
+
.option('-q, --quiet', 'suppress non-essential output')
|
|
56
|
+
.option('--no-color', 'disable color output')
|
|
57
|
+
.action(setCommand);
|
|
58
|
+
program
|
|
59
|
+
.command('run')
|
|
60
|
+
.description('Run a command with secrets injected into the environment')
|
|
61
|
+
.argument('<command...>', 'command to run')
|
|
62
|
+
.passThroughOptions()
|
|
63
|
+
.allowUnknownOption(true)
|
|
64
|
+
.option('-v, --vault <vault>', 'vault name (default: OPS_VAULT or Private)')
|
|
65
|
+
.option('-f, --field <field>', 'field name (default: OPS_FIELD or password)')
|
|
66
|
+
.option('-e, --env <pair>', 'map env var to secret name (repeatable, e.g. --env API_KEY=MY_SECRET)', (value, previous = []) => [...previous, value], [])
|
|
67
|
+
.option('--env-file <file>', 'env mapping file (default: .env.ops)')
|
|
68
|
+
.option('--verbose', 'show which secrets are being injected')
|
|
69
|
+
.option('--no-color', 'disable color output')
|
|
70
|
+
.action(runCommand);
|
|
71
|
+
program
|
|
72
|
+
.command('copy <name>')
|
|
73
|
+
.description('Copy a secret to the clipboard and clear it after a delay')
|
|
74
|
+
.option('-v, --vault <vault>', 'vault name (default: OPS_VAULT or Private)')
|
|
75
|
+
.option('-f, --field <field>', 'field name (default: OPS_FIELD or password)')
|
|
76
|
+
.option('--ttl <seconds>', 'seconds before clipboard is cleared', (value) => Number(value), 30)
|
|
77
|
+
.option('-q, --quiet', 'suppress non-essential output')
|
|
78
|
+
.option('--no-color', 'disable color output')
|
|
79
|
+
.action(copyCommand);
|
|
80
|
+
program
|
|
81
|
+
.command('list')
|
|
82
|
+
.description('List all items in a vault')
|
|
83
|
+
.option('-v, --vault <vault>', 'vault name (default: OPS_VAULT or Private)')
|
|
84
|
+
.option('-s, --search <query>', 'search for items by title')
|
|
85
|
+
.option('-j, --json', 'output as JSON')
|
|
86
|
+
.option('--plain', 'output as tab-delimited text')
|
|
87
|
+
.option('--favorites', 'show only favorite items')
|
|
88
|
+
.option('-q, --quiet', 'suppress non-essential output')
|
|
89
|
+
.option('--no-color', 'disable color output')
|
|
90
|
+
.action(listCommand);
|
|
91
|
+
program
|
|
92
|
+
.command('search <query>')
|
|
93
|
+
.description('Search items by title in a vault')
|
|
94
|
+
.option('-v, --vault <vault>', 'vault name (default: OPS_VAULT or Private)')
|
|
95
|
+
.option('-j, --json', 'output as JSON')
|
|
96
|
+
.option('--plain', 'output as tab-delimited text')
|
|
97
|
+
.option('-q, --quiet', 'suppress non-essential output')
|
|
98
|
+
.option('--no-color', 'disable color output')
|
|
99
|
+
.action((query, options) => listCommand({
|
|
100
|
+
vault: options.vault,
|
|
101
|
+
json: options.json,
|
|
102
|
+
plain: options.plain,
|
|
103
|
+
search: query,
|
|
104
|
+
quiet: options.quiet,
|
|
105
|
+
color: options.color,
|
|
106
|
+
}));
|
|
107
|
+
program
|
|
108
|
+
.command('favorites')
|
|
109
|
+
.description('List favorite items in a vault')
|
|
110
|
+
.option('-v, --vault <vault>', 'vault name (default: OPS_VAULT or Private)')
|
|
111
|
+
.option('-j, --json', 'output as JSON')
|
|
112
|
+
.option('--plain', 'output as tab-delimited text')
|
|
113
|
+
.option('-q, --quiet', 'suppress non-essential output')
|
|
114
|
+
.option('--no-color', 'disable color output')
|
|
115
|
+
.action((options) => listCommand({
|
|
116
|
+
...options,
|
|
117
|
+
favorites: true,
|
|
118
|
+
}));
|
|
119
|
+
program
|
|
120
|
+
.command('vaults')
|
|
121
|
+
.description('List available vaults')
|
|
122
|
+
.option('-j, --json', 'output as JSON')
|
|
123
|
+
.option('-q, --quiet', 'suppress non-essential output')
|
|
124
|
+
.option('--no-color', 'disable color output')
|
|
125
|
+
.action(vaultsCommand);
|
|
126
|
+
program
|
|
127
|
+
.command('export')
|
|
128
|
+
.description('Export secrets as .env or JSON')
|
|
129
|
+
.option('-v, --vault <vault>', 'vault name (default: OPS_VAULT or Private)')
|
|
130
|
+
.option('-f, --format <format>', 'output format (env|json)')
|
|
131
|
+
.option('-j, --json', 'alias for --format json')
|
|
132
|
+
.option('-o, --output <file>', 'output file (default: stdout, use "-" for stdout)')
|
|
133
|
+
.option('-q, --quiet', 'suppress non-essential output')
|
|
134
|
+
.option('--no-color', 'disable color output')
|
|
135
|
+
.action(exportCommand);
|
|
136
|
+
program
|
|
137
|
+
.command('import <file>')
|
|
138
|
+
.description('Import secrets from a .env file into 1Password')
|
|
139
|
+
.option('-v, --vault <vault>', 'vault name (default: OPS_VAULT or Private)')
|
|
140
|
+
.option('--dry-run', 'preview what would be imported without modifying')
|
|
141
|
+
.option('-q, --quiet', 'suppress non-essential output')
|
|
142
|
+
.option('--no-color', 'disable color output')
|
|
143
|
+
.action(importCommand);
|
|
144
|
+
program
|
|
145
|
+
.command('resolve <shareLink>')
|
|
146
|
+
.description('Resolve a 1Password share link to ops references')
|
|
147
|
+
.option('-j, --json', 'output as JSON')
|
|
148
|
+
.option('-q, --quiet', 'suppress non-essential output')
|
|
149
|
+
.option('--no-color', 'disable color output')
|
|
150
|
+
.action(resolveCommand);
|
|
151
|
+
// Error handling
|
|
152
|
+
process.on('uncaughtException', (error) => {
|
|
153
|
+
console.error('Unexpected error:', error.message);
|
|
154
|
+
process.exit(1);
|
|
155
|
+
});
|
|
156
|
+
process.on('unhandledRejection', (error) => {
|
|
157
|
+
console.error('Unexpected error:', error.message);
|
|
158
|
+
process.exit(1);
|
|
159
|
+
});
|
|
160
|
+
program.parse();
|
|
161
|
+
//# sourceMappingURL=index.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"index.js","sourceRoot":"","sources":["../src/index.ts"],"names":[],"mappings":";AACA,OAAO,EAAE,OAAO,EAAE,MAAM,WAAW,CAAC;AACpC,OAAO,EAAE,UAAU,EAAE,MAAM,mBAAmB,CAAC;AAC/C,OAAO,EAAE,WAAW,EAAE,MAAM,oBAAoB,CAAC;AACjD,OAAO,EAAE,UAAU,EAAE,MAAM,mBAAmB,CAAC;AAC/C,OAAO,EAAE,aAAa,EAAE,MAAM,sBAAsB,CAAC;AACrD,OAAO,EAAE,WAAW,EAAE,MAAM,oBAAoB,CAAC;AACjD,OAAO,EAAE,aAAa,EAAE,MAAM,sBAAsB,CAAC;AACrD,OAAO,EAAE,cAAc,EAAE,MAAM,uBAAuB,CAAC;AACvD,OAAO,EAAE,UAAU,EAAE,MAAM,mBAAmB,CAAC;AAC/C,OAAO,EAAE,cAAc,EAAE,MAAM,uBAAuB,CAAC;AACvD,OAAO,EAAE,aAAa,EAA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AAM,CAAC,aAAa,EAAE,+BAA+B,CAAC;KACtD,MAAM,CAAC,YAAY,EAAE,sBAAsB,CAAC;KAC5C,MAAM,CAAC,aAAa,CAAC,CAAC;AAEzB,OAAO;KACJ,OAAO,CAAC,qBAAqB,CAAC;KAC9B,WAAW,CAAC,kDAAkD,CAAC;KAC/D,MAAM,CAAC,YAAY,EAAE,gBAAgB,CAAC;KACtC,MAAM,CAAC,aAAa,EAAE,+BAA+B,CAAC;KACtD,MAAM,CAAC,YAAY,EAAE,sBAAsB,CAAC;KAC5C,MAAM,CAAC,cAAc,CAAC,CAAC;AAE1B,iBAAiB;AACjB,OAAO,CAAC,EAAE,CAAC,mBAAmB,EAAE,CAAC,KAAY,EAAE,EAAE;IAC/C,OAAO,CAAC,KAAK,CAAC,mBAAmB,EAAE,KAAK,CAAC,OAAO,CAAC,CAAC;IAClD,OAAO,CAAC,IAAI,CAAC,CAAC,CAAC,CAAC;AAClB,CAAC,CAAC,CAAC;AAEH,OAAO,CAAC,EAAE,CAAC,oBAAoB,EAAE,CAAC,KAAY,EAAE,EAAE;IAChD,OAAO,CAAC,KAAK,CAAC,mBAAmB,EAAE,KAAK,CAAC,OAAO,CAAC,CAAC;IAClD,OAAO,CAAC,IAAI,CAAC,CAAC,CAAC,CAAC;AAClB,CAAC,CAAC,CAAC;AAEH,OAAO,CAAC,KAAK,EAAE,CAAC"}
|
|
@@ -0,0 +1,8 @@
|
|
|
1
|
+
export declare function resolveBooleanOption(value: boolean | undefined, envVar: string): boolean;
|
|
2
|
+
export declare function resolveVault(value?: string): string;
|
|
3
|
+
export declare function resolveField(value?: string): string;
|
|
4
|
+
export declare function resolveFormat(value?: string): 'env' | 'json';
|
|
5
|
+
export declare function applyColorConfig(noColor: boolean): void;
|
|
6
|
+
export declare function isInteractiveInput(): boolean;
|
|
7
|
+
export declare function createSpinner(text: string, quiet: boolean): import("ora").Ora;
|
|
8
|
+
//# sourceMappingURL=cli.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"cli.d.ts","sourceRoot":"","sources":["../../src/utils/cli.ts"],"names":[],"mappings":"AAMA,wBAAgB,oBAAoB,CAClC,KAAK,EAAE,OAAO,GAAG,SAAS,EAC1B,MAAM,EAAE,MAAM,GACb,OAAO,CAKT;AAED,wBAAgB,YAAY,CAAC,KAAK,CAAC,EAAE,MAAM,GAAG,MAAM,CAEnD;AAED,wBAAgB,YAAY,CAAC,KAAK,CAAC,EAAE,MAAM,GAAG,MAAM,CAEnD;AAED,wBAAgB,aAAa,CAAC,KAAK,CAAC,EAAE,MAAM,GAAG,KAAK,GAAG,MAAM,CAM5D;AAED,wBAAgB,gBAAgB,CAAC,OAAO,EAAE,OAAO,GAAG,IAAI,CAIvD;AAED,wBAAgB,kBAAkB,IAAI,OAAO,CAE5C;AAED,wBAAgB,aAAa,CAAC,IAAI,EAAE,MAAM,EAAE,KAAK,EAAE,OAAO,qBAmBzD"}
|
|
@@ -0,0 +1,53 @@
|
|
|
1
|
+
import chalk from 'chalk';
|
|
2
|
+
import ora from 'ora';
|
|
3
|
+
import { OpError } from './types.js';
|
|
4
|
+
const TRUE_VALUES = new Set(['1', 'true', 'yes', 'on']);
|
|
5
|
+
export function resolveBooleanOption(value, envVar) {
|
|
6
|
+
if (value !== undefined)
|
|
7
|
+
return value;
|
|
8
|
+
const envValue = process.env[envVar];
|
|
9
|
+
if (!envValue)
|
|
10
|
+
return false;
|
|
11
|
+
return TRUE_VALUES.has(envValue.toLowerCase());
|
|
12
|
+
}
|
|
13
|
+
export function resolveVault(value) {
|
|
14
|
+
return value || process.env.OPS_VAULT || 'Private';
|
|
15
|
+
}
|
|
16
|
+
export function resolveField(value) {
|
|
17
|
+
return value || process.env.OPS_FIELD || 'password';
|
|
18
|
+
}
|
|
19
|
+
export function resolveFormat(value) {
|
|
20
|
+
const format = (value || process.env.OPS_FORMAT || 'env').toLowerCase();
|
|
21
|
+
if (format !== 'env' && format !== 'json') {
|
|
22
|
+
throw new OpError(`Invalid format "${format}". Use "env" or "json".`, 2);
|
|
23
|
+
}
|
|
24
|
+
return format;
|
|
25
|
+
}
|
|
26
|
+
export function applyColorConfig(noColor) {
|
|
27
|
+
if (noColor || process.env.NO_COLOR || process.env.TERM === 'dumb') {
|
|
28
|
+
chalk.level = 0;
|
|
29
|
+
}
|
|
30
|
+
}
|
|
31
|
+
export function isInteractiveInput() {
|
|
32
|
+
return Boolean(process.stdin.isTTY);
|
|
33
|
+
}
|
|
34
|
+
export function createSpinner(text, quiet) {
|
|
35
|
+
// When quiet or non-TTY, return a no-op spinner that outputs nothing
|
|
36
|
+
if (quiet || !process.stderr.isTTY) {
|
|
37
|
+
return {
|
|
38
|
+
start: () => { },
|
|
39
|
+
stop: () => { },
|
|
40
|
+
succeed: () => { },
|
|
41
|
+
fail: () => { },
|
|
42
|
+
warn: () => { },
|
|
43
|
+
info: () => { },
|
|
44
|
+
text: '',
|
|
45
|
+
};
|
|
46
|
+
}
|
|
47
|
+
// Use stderr so spinner output doesn't pollute stdout (important for piping)
|
|
48
|
+
return ora({
|
|
49
|
+
text,
|
|
50
|
+
stream: process.stderr,
|
|
51
|
+
}).start();
|
|
52
|
+
}
|
|
53
|
+
//# sourceMappingURL=cli.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"cli.js","sourceRoot":"","sources":["../../src/utils/cli.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,MAAM,OAAO,CAAC;AAC1B,OAAO,GAAG,MAAM,KAAK,CAAC;AACtB,OAAO,EAAE,OAAO,EAAE,MAAM,YAAY,CAAC;AAErC,MAAM,WAAW,GAAG,IAAI,GAAG,CAAC,CAAC,GAAG,EAAE,MAAM,EAAE,KAAK,EAAE,IAAI,CAAC,CAAC,CAAC;AAExD,MAAM,UAAU,oBAAoB,CAClC,KAA0B,EAC1B,MAAc;IAEd,IAAI,KAAK,KAAK,SAAS;QAAE,OAAO,KAAK,CAAC;IACtC,MAAM,QAAQ,GAAG,OAAO,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,EAAE,GAAG,EAAE,GAAE,CAAC;YACf,IAAI,EAAE,GAAG,EAAE,GAAE,CAAC;YACd,OAAO,EAAE,GAAG,EAAE,GAAE,CAAC;YACjB,IAAI,EAAE,GAAG,EAAE,GAAE,CAAC;YACd,IAAI,EAAE,GAAG,EAAE,GAAE,CAAC;YACd,IAAI,EAAE,GAAG,EAAE,GAAE,CAAC;YACd,IAAI,EAAE,EAAE;SACiB,CAAC;IAC9B,CAAC;IAED,6EAA6E;IAC7E,OAAO,GAAG,CAAC;QACT,IAAI;QACJ,MAAM,EAAE,OAAO,CAAC,MAAM;KACvB,CAAC,CAAC,KAAK,EAAE,CAAC;AACb,CAAC"}
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"io.d.ts","sourceRoot":"","sources":["../../src/utils/io.ts"],"names":[],"mappings":"AAEA,wBAAgB,kBAAkB,CAAC,MAAM,EAAE,MAAM,GAAG,MAAM,CAMzD"}
|
package/dist/utils/io.js
ADDED
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"io.js","sourceRoot":"","sources":["../../src/utils/io.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,YAAY,EAAE,MAAM,IAAI,CAAC;AAElC,MAAM,UAAU,kBAAkB,CAAC,MAAc;IAC/C,IAAI,MAAM,KAAK,GAAG,EAAE,CAAC;QACnB,OAAO,YAAY,CAAC,CAAC,EAAE,OAAO,CAAC,CAAC,OAAO,EAAE,CAAC;IAC5C,CAAC;IAED,OAAO,YAAY,CAAC,MAAM,EAAE,OAAO,CAAC,CAAC,OAAO,EAAE,CAAC;AACjD,CAAC"}
|
|
@@ -0,0 +1,68 @@
|
|
|
1
|
+
import { execFileSync } from 'child_process';
|
|
2
|
+
import { OpItem } from './types.js';
|
|
3
|
+
interface ShareLinkResolverDeps {
|
|
4
|
+
execFileSync: typeof execFileSync;
|
|
5
|
+
getServiceAccountEnv: () => NodeJS.ProcessEnv;
|
|
6
|
+
getUserEnv: () => NodeJS.ProcessEnv;
|
|
7
|
+
}
|
|
8
|
+
export declare function createShareLinkResolver(overrides?: Partial<ShareLinkResolverDeps>): (shareLink: string) => OpItem;
|
|
9
|
+
/**
|
|
10
|
+
* Check if op CLI is installed and user is signed in
|
|
11
|
+
*/
|
|
12
|
+
export declare function checkOpCli(): void;
|
|
13
|
+
/**
|
|
14
|
+
* List items in a vault
|
|
15
|
+
*/
|
|
16
|
+
export declare function listItems(vault?: string): OpItem[];
|
|
17
|
+
/**
|
|
18
|
+
* Check if an item exists in the vault (regardless of field)
|
|
19
|
+
*/
|
|
20
|
+
export declare function itemExists(title: string, vault?: string): boolean;
|
|
21
|
+
/**
|
|
22
|
+
* Get a secret from 1Password
|
|
23
|
+
*/
|
|
24
|
+
export declare function getSecret(reference: string, vault?: string, field?: string): string | null;
|
|
25
|
+
/**
|
|
26
|
+
* Create or update a secret in 1Password
|
|
27
|
+
*/
|
|
28
|
+
export declare function setSecret(title: string, value: string, vault?: string, field?: string): void;
|
|
29
|
+
/**
|
|
30
|
+
* Create a secret item in 1Password
|
|
31
|
+
*/
|
|
32
|
+
export declare function createItem(title: string, value: string, vault?: string, field?: string): void;
|
|
33
|
+
/**
|
|
34
|
+
* Update a secret item in 1Password
|
|
35
|
+
*/
|
|
36
|
+
export declare function updateItem(title: string, value: string, vault?: string, field?: string): void;
|
|
37
|
+
/**
|
|
38
|
+
* Get item details including all fields
|
|
39
|
+
*/
|
|
40
|
+
export declare function getItem(title: string, vault?: string): OpItem | null;
|
|
41
|
+
/**
|
|
42
|
+
* Get available field labels for an item
|
|
43
|
+
*/
|
|
44
|
+
export declare function getItemFields(title: string, vault?: string): string[];
|
|
45
|
+
export declare function getItemFromShareLink(shareLink: string): OpItem;
|
|
46
|
+
/**
|
|
47
|
+
* List favorite items in a vault
|
|
48
|
+
*/
|
|
49
|
+
export declare function listFavorites(vault?: string): OpItem[];
|
|
50
|
+
/**
|
|
51
|
+
* Search for items by title
|
|
52
|
+
*/
|
|
53
|
+
export declare function searchItems(query: string, vault?: string): OpItem[];
|
|
54
|
+
/**
|
|
55
|
+
* Find similar item names using simple string matching
|
|
56
|
+
*/
|
|
57
|
+
export declare function findSimilarItems(query: string, vault?: string, maxResults?: number): string[];
|
|
58
|
+
export interface OpVault {
|
|
59
|
+
id: string;
|
|
60
|
+
name: string;
|
|
61
|
+
type: string;
|
|
62
|
+
}
|
|
63
|
+
/**
|
|
64
|
+
* List all vaults accessible to the user
|
|
65
|
+
*/
|
|
66
|
+
export declare function listVaults(): OpVault[];
|
|
67
|
+
export {};
|
|
68
|
+
//# sourceMappingURL=op.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"op.d.ts","sourceRoot":"","sources":["../../src/utils/op.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,YAAY,EAAY,MAAM,eAAe,CAAC;AAIvD,OAAO,EAAE,MAAM,EAAW,MAAM,YAAY,CAAC;AAgE7C,UAAU,qBAAqB;IAC7B,YAAY,EAAE,OAAO,YAAY,CAAC;IAClC,oBAAoB,EAAE,MAAM,MAAM,CAAC,UAAU,CAAC;IAC9C,UAAU,EAAE,MAAM,MAAM,CAAC,UAAU,CAAC;CACrC;AAyCD,wBAAgB,uBAAuB,CACrC,SAAS,GAAE,OAAO,CAAC,qBAAqB,CAAM,GAC7C,CAAC,SAAS,EAAE,MAAM,KAAK,MAAM,CAmD/B;AAED;;GAEG;AACH,wBAAgB,UAAU,IAAI,IAAI,CAoBjC;AAED;;GAEG;AACH,wBAAgB,SAAS,CAAC,KAAK,GAAE,MAAkB,GAAG,MAAM,EAAE,CAe7D;AAED;;GAEG;AACH,wBAAgB,UAAU,CACxB,KAAK,EAAE,MAAM,EACb,KAAK,GAAE,MAAkB,GACxB,OAAO,CAaT;AAED;;GAEG;AACH,wBAAgB,SAAS,CACvB,SAAS,EAAE,MAAM,EACjB,KAAK,GAAE,MAAkB,EACzB,KAAK,GAAE,MAAmB,GACzB,MAAM,GAAG,IAAI,CAyBf;AAED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