@theholocron/holocron-plugin-1password 5.0.0-alpha.28 → 5.0.0-alpha.281
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 +1 -1
- package/dist/index.d.mts +35 -33
- package/dist/index.mjs +24 -11
- package/package.json +16 -16
package/README.md
CHANGED
|
@@ -145,7 +145,7 @@ convention):
|
|
|
145
145
|
`ensureProject` / `ensureEnvironment` — 1Password's data model
|
|
146
146
|
doesn't have projects with sub-configs the way Doppler / Infisical
|
|
147
147
|
do. The vault + item hierarchy is created via the 1P UI or `op item
|
|
148
|
-
create`, not via `holocron setup`. The methods are omitted;
|
|
148
|
+
create`, not via `holocron repo setup`. The methods are omitted;
|
|
149
149
|
`runSetup` skips them cleanly (see the [`Vault`
|
|
150
150
|
interface](../cli/src/capabilities/index.ts)).
|
|
151
151
|
|
package/dist/index.d.mts
CHANGED
|
@@ -1,18 +1,19 @@
|
|
|
1
|
+
import { Vault, VerifyTokenFailure, VerifyTokenResult, VerifyTokenResult as VerifyTokenResult$1, VerifyTokenSuccess } from "@theholocron/cli";
|
|
1
2
|
import { spawnSync } from "node:child_process";
|
|
2
|
-
|
|
3
|
-
|
|
4
|
-
|
|
3
|
+
/** Thrown when the 1Password `op` CLI is missing or does not run. */
|
|
4
|
+
export declare class AuthError extends Error {
|
|
5
|
+
/** Error name; always `"AuthError"`. */
|
|
5
6
|
name: string;
|
|
6
7
|
}
|
|
7
|
-
|
|
8
|
+
/** Inputs for checking that the `op` binary is installed. */
|
|
9
|
+
export interface VerifyInput {
|
|
8
10
|
/** Override the spawn function in tests. */
|
|
9
11
|
spawn?: typeof spawnSync;
|
|
10
12
|
/** Path to the op binary. Defaults to "op". */
|
|
11
13
|
binary?: string;
|
|
12
14
|
}
|
|
13
|
-
|
|
14
|
-
|
|
15
|
-
//#region src/shell.d.ts
|
|
15
|
+
/** Runs `op --version` and throws `AuthError` when the binary is not found or exits non-zero. */
|
|
16
|
+
export declare function verifyOpInstalled(input?: VerifyInput): void;
|
|
16
17
|
interface OpResult {
|
|
17
18
|
ok: boolean;
|
|
18
19
|
stdout: string;
|
|
@@ -30,9 +31,12 @@ interface RunOptions {
|
|
|
30
31
|
/** Skip `--account` injection for commands that operate above the account level (e.g., `account list`). */
|
|
31
32
|
skipAccount?: boolean;
|
|
32
33
|
}
|
|
33
|
-
|
|
34
|
+
/** Thin wrapper around `spawnSync` that runs the `op` CLI and returns a uniform result. */
|
|
35
|
+
export declare class OpShell {
|
|
34
36
|
private readonly spawnImpl;
|
|
37
|
+
/** The `op` binary this wrapper runs; defaults to `"op"`. */
|
|
35
38
|
readonly binary: string;
|
|
39
|
+
/** The 1Password account UUID passed as `--account` on each call, when one is set. */
|
|
36
40
|
readonly account?: string;
|
|
37
41
|
constructor(opts?: OpShellOptions);
|
|
38
42
|
/** Run `op <args>`, returning a uniform result. */
|
|
@@ -40,15 +44,16 @@ declare class OpShell {
|
|
|
40
44
|
/** Run + throw if non-zero. Mirrors REST clients' `request<T>` ergonomic. */
|
|
41
45
|
runOrThrow(args: string[], context: string, opts?: RunOptions): string;
|
|
42
46
|
}
|
|
43
|
-
//#endregion
|
|
44
|
-
//#region src/capabilities/vault.d.ts
|
|
45
47
|
interface OpVaultOptions {
|
|
46
48
|
/** 1P vault name items live in. Required — list/write default here. */
|
|
47
49
|
vault: string;
|
|
48
50
|
}
|
|
49
|
-
|
|
51
|
+
/** `vault` capability for 1Password, implemented by shelling out to the `op` CLI against one vault. */
|
|
52
|
+
export declare class OpVault implements Vault {
|
|
50
53
|
private readonly shell;
|
|
54
|
+
/** Capability key; always `"vault"`. */
|
|
51
55
|
readonly key: "vault";
|
|
56
|
+
/** Provider name; always `"1password"`. */
|
|
52
57
|
readonly providerName = "1password";
|
|
53
58
|
private readonly vaultName;
|
|
54
59
|
constructor(shell: OpShell, opts: OpVaultOptions);
|
|
@@ -58,38 +63,36 @@ declare class OpVault implements Vault {
|
|
|
58
63
|
environments(): Promise<string[]>;
|
|
59
64
|
readEnvironment(environmentId: string): Promise<Record<string, string>>;
|
|
60
65
|
}
|
|
61
|
-
//#endregion
|
|
62
|
-
//#region src/verify-token.d.ts
|
|
63
|
-
interface VerifyTokenSuccess {
|
|
64
|
-
ok: true;
|
|
65
|
-
subject: string;
|
|
66
|
-
}
|
|
67
|
-
interface VerifyTokenFailure {
|
|
68
|
-
ok: false;
|
|
69
|
-
message: string;
|
|
70
|
-
}
|
|
71
|
-
type VerifyTokenResult = VerifyTokenSuccess | VerifyTokenFailure;
|
|
72
66
|
interface VerifyTokenOptions {
|
|
73
67
|
spawn?: typeof spawnSync;
|
|
74
68
|
binary?: string;
|
|
75
69
|
}
|
|
76
|
-
|
|
77
|
-
|
|
78
|
-
|
|
79
|
-
interface OpPluginOptions extends VerifyInput {
|
|
70
|
+
/** Checks that `op` is installed and signed in by running `op whoami`; the token argument is unused. */
|
|
71
|
+
export declare function verifyToken(_token: string, opts?: VerifyTokenOptions): Promise<VerifyTokenResult$1>;
|
|
72
|
+
/** Options for the 1Password plugin: the vault and account to use plus the `op` binary overrides. */
|
|
73
|
+
export interface OpPluginOptions extends VerifyInput {
|
|
80
74
|
/** 1P vault name items live in. Required. */
|
|
81
75
|
vault: string;
|
|
82
76
|
/** Optional 1P account UUID; passed as `--account` on every op call. */
|
|
83
77
|
account?: string;
|
|
84
78
|
}
|
|
85
|
-
|
|
79
|
+
/** Shared state for one 1Password plugin instance: its options and the `op` shell wrapper. */
|
|
80
|
+
export interface PluginContext {
|
|
81
|
+
/** The options the plugin was created with. */
|
|
86
82
|
options: OpPluginOptions;
|
|
83
|
+
/** The wrapper that runs `op` commands. */
|
|
87
84
|
shell: OpShell;
|
|
88
85
|
}
|
|
89
|
-
|
|
90
|
-
declare function
|
|
91
|
-
|
|
86
|
+
/** Builds the plugin context; throws when `vault` is missing or the `op` binary is not installed. */
|
|
87
|
+
export declare function createContext(options: OpPluginOptions): PluginContext;
|
|
88
|
+
/** Builds the `vault` capability for the configured vault. */
|
|
89
|
+
export declare function vault(ctx: PluginContext): Vault;
|
|
90
|
+
/** Creates the 1Password plugin: its `connection` probe and the `vault` capability. */
|
|
91
|
+
export declare function createPlugin(options: OpPluginOptions): {
|
|
92
92
|
name: string;
|
|
93
|
+
probes: {
|
|
94
|
+
connection: import("@theholocron/cli").Probe;
|
|
95
|
+
};
|
|
93
96
|
capabilities: {
|
|
94
97
|
vault: () => Vault;
|
|
95
98
|
};
|
|
@@ -99,6 +102,5 @@ declare function createPlugin(options: OpPluginOptions): {
|
|
|
99
102
|
* store a token in the holocron keyring; the `op` CLI manages its own
|
|
100
103
|
* auth. Directs the operator to the two paths that actually work.
|
|
101
104
|
*/
|
|
102
|
-
declare const AUTH_HINT: string;
|
|
103
|
-
|
|
104
|
-
export { AUTH_HINT, AuthError, OpPluginOptions, OpShell, OpVault, PluginContext, VerifyInput, type VerifyTokenFailure, type VerifyTokenResult, type VerifyTokenSuccess, createContext, createPlugin, vault, verifyOpInstalled, verifyToken };
|
|
105
|
+
export declare const AUTH_HINT: string;
|
|
106
|
+
export type { VerifyTokenFailure, VerifyTokenResult, VerifyTokenSuccess };
|
package/dist/index.mjs
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
|
+
import { ProviderApiError, connectionProbe } from "@theholocron/cli";
|
|
1
2
|
import { spawnSync } from "node:child_process";
|
|
2
|
-
|
|
3
|
-
//#region src/auth.ts
|
|
3
|
+
// src/auth.ts
|
|
4
4
|
/**
|
|
5
5
|
* 1Password plugin "auth" is just verifying the `op` binary is on
|
|
6
6
|
* PATH — the CLI handles its own auth (keychain biometric unlock for
|
|
@@ -11,9 +11,12 @@ import { ProviderApiError } from "@theholocron/cli";
|
|
|
11
11
|
* a missing binary fails fast and clearly, not as a mystery error when
|
|
12
12
|
* the first `vault.read()` happens later.
|
|
13
13
|
*/
|
|
14
|
+
/** Thrown when the 1Password `op` CLI is missing or does not run. */
|
|
14
15
|
var AuthError = class extends Error {
|
|
16
|
+
/** Error name; always `"AuthError"`. */
|
|
15
17
|
name = "AuthError";
|
|
16
18
|
};
|
|
19
|
+
/** Runs `op --version` and throws `AuthError` when the binary is not found or exits non-zero. */
|
|
17
20
|
function verifyOpInstalled(input = {}) {
|
|
18
21
|
const spawnImpl = input.spawn ?? spawnSync;
|
|
19
22
|
const binary = input.binary ?? "op";
|
|
@@ -28,11 +31,13 @@ function verifyOpInstalled(input = {}) {
|
|
|
28
31
|
if (result.error) throw new AuthError(`1Password CLI (\`${binary}\`) not found on PATH. Install via \`brew install 1password-cli\` or see https://developer.1password.com/docs/cli/get-started.`);
|
|
29
32
|
if (result.status !== 0) throw new AuthError(`\`${binary} --version\` failed: ${(result.stderr ?? "").trim() || `exit ${result.status ?? "?"}`}`);
|
|
30
33
|
}
|
|
31
|
-
|
|
32
|
-
|
|
34
|
+
// src/capabilities/vault.ts
|
|
35
|
+
/** `vault` capability for 1Password, implemented by shelling out to the `op` CLI against one vault. */
|
|
33
36
|
var OpVault = class {
|
|
34
37
|
shell;
|
|
38
|
+
/** Capability key; always `"vault"`. */
|
|
35
39
|
key = "vault";
|
|
40
|
+
/** Provider name; always `"1password"`. */
|
|
36
41
|
providerName = "1password";
|
|
37
42
|
vaultName;
|
|
38
43
|
constructor(shell, opts) {
|
|
@@ -136,8 +141,7 @@ function parseEnvironmentDump(stdout) {
|
|
|
136
141
|
}
|
|
137
142
|
return out;
|
|
138
143
|
}
|
|
139
|
-
|
|
140
|
-
//#region src/shell.ts
|
|
144
|
+
// src/shell.ts
|
|
141
145
|
/**
|
|
142
146
|
* Thin wrapper around `spawnSync` for `op` CLI shell-outs.
|
|
143
147
|
*
|
|
@@ -156,9 +160,12 @@ function parseEnvironmentDump(stdout) {
|
|
|
156
160
|
* token). Default spawnSync stdio of `['pipe','pipe','pipe']` would
|
|
157
161
|
* suppress biometric unlock and return "not signed in" instead.
|
|
158
162
|
*/
|
|
163
|
+
/** Thin wrapper around `spawnSync` that runs the `op` CLI and returns a uniform result. */
|
|
159
164
|
var OpShell = class {
|
|
160
165
|
spawnImpl;
|
|
166
|
+
/** The `op` binary this wrapper runs; defaults to `"op"`. */
|
|
161
167
|
binary;
|
|
168
|
+
/** The 1Password account UUID passed as `--account` on each call, when one is set. */
|
|
162
169
|
account;
|
|
163
170
|
constructor(opts = {}) {
|
|
164
171
|
this.spawnImpl = opts.spawn ?? spawnSync;
|
|
@@ -198,8 +205,7 @@ var OpShell = class {
|
|
|
198
205
|
return result.stdout;
|
|
199
206
|
}
|
|
200
207
|
};
|
|
201
|
-
|
|
202
|
-
//#region src/verify-token.ts
|
|
208
|
+
// src/verify-token.ts
|
|
203
209
|
/**
|
|
204
210
|
* `verifyToken` — plugin-level export used by `holocron auth check`.
|
|
205
211
|
*
|
|
@@ -213,6 +219,7 @@ var OpShell = class {
|
|
|
213
219
|
* will be stored in the keyring but never read by this plugin — the
|
|
214
220
|
* `AUTH_HINT` below explains that up front.
|
|
215
221
|
*/
|
|
222
|
+
/** Checks that `op` is installed and signed in by running `op whoami`; the token argument is unused. */
|
|
216
223
|
async function verifyToken(_token, opts = {}) {
|
|
217
224
|
const spawnImpl = opts.spawn ?? spawnSync;
|
|
218
225
|
const binary = opts.binary ?? "op";
|
|
@@ -245,8 +252,8 @@ async function verifyToken(_token, opts = {}) {
|
|
|
245
252
|
};
|
|
246
253
|
}
|
|
247
254
|
}
|
|
248
|
-
|
|
249
|
-
|
|
255
|
+
// src/index.ts
|
|
256
|
+
/** Builds the plugin context; throws when `vault` is missing or the `op` binary is not installed. */
|
|
250
257
|
function createContext(options) {
|
|
251
258
|
if (!options.vault) throw new Error("@theholocron/holocron-plugin-1password requires `vault` in options");
|
|
252
259
|
const verifyOpts = {};
|
|
@@ -262,13 +269,20 @@ function createContext(options) {
|
|
|
262
269
|
shell: new OpShell(shellOpts)
|
|
263
270
|
};
|
|
264
271
|
}
|
|
272
|
+
/** Builds the `vault` capability for the configured vault. */
|
|
265
273
|
function vault(ctx) {
|
|
266
274
|
return new OpVault(ctx.shell, { vault: ctx.options.vault });
|
|
267
275
|
}
|
|
276
|
+
/** Creates the 1Password plugin: its `connection` probe and the `vault` capability. */
|
|
268
277
|
function createPlugin(options) {
|
|
269
278
|
const ctx = createContext(options);
|
|
270
279
|
return {
|
|
271
280
|
name: "@theholocron/holocron-plugin-1password",
|
|
281
|
+
probes: { connection: connectionProbe({
|
|
282
|
+
provider: "1Password",
|
|
283
|
+
token: () => "",
|
|
284
|
+
verify: (token) => verifyToken(token, { spawn: options.spawn })
|
|
285
|
+
}) },
|
|
272
286
|
capabilities: { vault: () => vault(ctx) }
|
|
273
287
|
};
|
|
274
288
|
}
|
|
@@ -278,5 +292,4 @@ function createPlugin(options) {
|
|
|
278
292
|
* auth. Directs the operator to the two paths that actually work.
|
|
279
293
|
*/
|
|
280
294
|
const AUTH_HINT = "1Password uses the `op` CLI for auth — no bearer token to store. On laptop: `op signin` (or the desktop app's biometric flow). In CI: set `OP_SERVICE_ACCOUNT_TOKEN` in the workflow env.";
|
|
281
|
-
//#endregion
|
|
282
295
|
export { AUTH_HINT, AuthError, OpShell, OpVault, createContext, createPlugin, vault, verifyOpInstalled, verifyToken };
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@theholocron/holocron-plugin-1password",
|
|
3
|
-
"version": "5.0.0-alpha.
|
|
3
|
+
"version": "5.0.0-alpha.281",
|
|
4
4
|
"description": "Holocron plugin for 1Password. Implements the vault capability via shell-out to the `op` CLI (https://developer.1password.com/docs/cli).",
|
|
5
5
|
"keywords": [
|
|
6
6
|
"1password",
|
|
@@ -8,12 +8,12 @@
|
|
|
8
8
|
"plugin",
|
|
9
9
|
"vault"
|
|
10
10
|
],
|
|
11
|
-
"homepage": "https://
|
|
11
|
+
"homepage": "https://docs.theholocron.dev/holocron/plugins/1password/",
|
|
12
12
|
"bugs": "https://github.com/theholocron/holocron/issues",
|
|
13
13
|
"repository": {
|
|
14
14
|
"type": "git",
|
|
15
15
|
"url": "git+https://github.com/theholocron/holocron.git",
|
|
16
|
-
"directory": "
|
|
16
|
+
"directory": "plugins/holocron-plugin-1password"
|
|
17
17
|
},
|
|
18
18
|
"license": "MIT",
|
|
19
19
|
"author": "Newton Koumantzelis",
|
|
@@ -30,24 +30,24 @@
|
|
|
30
30
|
"dist"
|
|
31
31
|
],
|
|
32
32
|
"devDependencies": {
|
|
33
|
-
"@theholocron/eslint-config": "^8.0.0",
|
|
34
|
-
"@theholocron/tsconfig": "^8.0.0",
|
|
35
|
-
"@theholocron/tsdown-config": "^8.0.0",
|
|
36
|
-
"@theholocron/vitest-config": "^8.0.0",
|
|
37
33
|
"@types/node": "^26",
|
|
38
|
-
"@vitest/coverage-v8": "^
|
|
34
|
+
"@vitest/coverage-v8": "^5.0.5",
|
|
39
35
|
"@vitest/eslint-plugin": "^1.6.27",
|
|
40
36
|
"eslint": "^10.8.1",
|
|
41
37
|
"eslint-plugin-n": "^18.3.0",
|
|
42
38
|
"globals": "^17.11.0",
|
|
43
|
-
"tsdown": "^0.
|
|
44
|
-
"tsx": "4.23.
|
|
39
|
+
"tsdown": "^0.23.3",
|
|
40
|
+
"tsx": "4.23.15",
|
|
45
41
|
"typescript": "^5.9.3",
|
|
46
|
-
"vitest": "^
|
|
47
|
-
"@theholocron/cli": "5.0.0-alpha.
|
|
42
|
+
"vitest": "^5.0.5",
|
|
43
|
+
"@theholocron/cli": "5.0.0-alpha.281",
|
|
44
|
+
"@theholocron/eslint-config": "^8.9.0-alpha.5",
|
|
45
|
+
"@theholocron/tsconfig": "^8.9.0-alpha.5",
|
|
46
|
+
"@theholocron/tsdown-config": "^8.9.0-alpha.5",
|
|
47
|
+
"@theholocron/vitest-config": "^8.9.0-alpha.5"
|
|
48
48
|
},
|
|
49
49
|
"peerDependencies": {
|
|
50
|
-
"@theholocron/cli": "5.0.0-alpha.
|
|
50
|
+
"@theholocron/cli": "5.0.0-alpha.281"
|
|
51
51
|
},
|
|
52
52
|
"engines": {
|
|
53
53
|
"node": ">=22"
|
|
@@ -57,10 +57,10 @@
|
|
|
57
57
|
},
|
|
58
58
|
"scripts": {
|
|
59
59
|
"delivery.build": "tsdown",
|
|
60
|
-
"sourceQuality.staticAnalysis": "
|
|
60
|
+
"sourceQuality.staticAnalysis": "eslint .",
|
|
61
61
|
"test:watch": "vitest",
|
|
62
62
|
"validate": "tsx scripts/validate.mjs",
|
|
63
|
-
"verification.typeSafety": "
|
|
64
|
-
"verification.unitTests": "
|
|
63
|
+
"verification.typeSafety": "tsc --noEmit",
|
|
64
|
+
"verification.unitTests": "vitest run"
|
|
65
65
|
}
|
|
66
66
|
}
|