@theholocron/holocron-plugin-1password 5.0.0-alpha.277 → 5.0.0-alpha.279

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/index.d.mts CHANGED
@@ -1,14 +1,18 @@
1
1
  import { Vault, VerifyTokenFailure, VerifyTokenResult, VerifyTokenResult as VerifyTokenResult$1, VerifyTokenSuccess } from "@theholocron/cli";
2
2
  import { spawnSync } from "node:child_process";
3
+ /** Thrown when the 1Password `op` CLI is missing or does not run. */
3
4
  export declare class AuthError extends Error {
5
+ /** Error name; always `"AuthError"`. */
4
6
  name: string;
5
7
  }
8
+ /** Inputs for checking that the `op` binary is installed. */
6
9
  export interface VerifyInput {
7
10
  /** Override the spawn function in tests. */
8
11
  spawn?: typeof spawnSync;
9
12
  /** Path to the op binary. Defaults to "op". */
10
13
  binary?: string;
11
14
  }
15
+ /** Runs `op --version` and throws `AuthError` when the binary is not found or exits non-zero. */
12
16
  export declare function verifyOpInstalled(input?: VerifyInput): void;
13
17
  interface OpResult {
14
18
  ok: boolean;
@@ -27,9 +31,12 @@ interface RunOptions {
27
31
  /** Skip `--account` injection for commands that operate above the account level (e.g., `account list`). */
28
32
  skipAccount?: boolean;
29
33
  }
34
+ /** Thin wrapper around `spawnSync` that runs the `op` CLI and returns a uniform result. */
30
35
  export declare class OpShell {
31
36
  private readonly spawnImpl;
37
+ /** The `op` binary this wrapper runs; defaults to `"op"`. */
32
38
  readonly binary: string;
39
+ /** The 1Password account UUID passed as `--account` on each call, when one is set. */
33
40
  readonly account?: string;
34
41
  constructor(opts?: OpShellOptions);
35
42
  /** Run `op <args>`, returning a uniform result. */
@@ -41,9 +48,12 @@ interface OpVaultOptions {
41
48
  /** 1P vault name items live in. Required — list/write default here. */
42
49
  vault: string;
43
50
  }
51
+ /** `vault` capability for 1Password, implemented by shelling out to the `op` CLI against one vault. */
44
52
  export declare class OpVault implements Vault {
45
53
  private readonly shell;
54
+ /** Capability key; always `"vault"`. */
46
55
  readonly key: "vault";
56
+ /** Provider name; always `"1password"`. */
47
57
  readonly providerName = "1password";
48
58
  private readonly vaultName;
49
59
  constructor(shell: OpShell, opts: OpVaultOptions);
@@ -57,19 +67,27 @@ interface VerifyTokenOptions {
57
67
  spawn?: typeof spawnSync;
58
68
  binary?: string;
59
69
  }
70
+ /** Checks that `op` is installed and signed in by running `op whoami`; the token argument is unused. */
60
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. */
61
73
  export interface OpPluginOptions extends VerifyInput {
62
74
  /** 1P vault name items live in. Required. */
63
75
  vault: string;
64
76
  /** Optional 1P account UUID; passed as `--account` on every op call. */
65
77
  account?: string;
66
78
  }
79
+ /** Shared state for one 1Password plugin instance: its options and the `op` shell wrapper. */
67
80
  export interface PluginContext {
81
+ /** The options the plugin was created with. */
68
82
  options: OpPluginOptions;
83
+ /** The wrapper that runs `op` commands. */
69
84
  shell: OpShell;
70
85
  }
86
+ /** Builds the plugin context; throws when `vault` is missing or the `op` binary is not installed. */
71
87
  export declare function createContext(options: OpPluginOptions): PluginContext;
88
+ /** Builds the `vault` capability for the configured vault. */
72
89
  export declare function vault(ctx: PluginContext): Vault;
90
+ /** Creates the 1Password plugin: its `connection` probe and the `vault` capability. */
73
91
  export declare function createPlugin(options: OpPluginOptions): {
74
92
  name: string;
75
93
  probes: {
package/dist/index.mjs CHANGED
@@ -11,9 +11,12 @@ import { spawnSync } from "node:child_process";
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";
@@ -29,9 +32,12 @@ function verifyOpInstalled(input = {}) {
29
32
  if (result.status !== 0) throw new AuthError(`\`${binary} --version\` failed: ${(result.stderr ?? "").trim() || `exit ${result.status ?? "?"}`}`);
30
33
  }
31
34
  // src/capabilities/vault.ts
35
+ /** `vault` capability for 1Password, implemented by shelling out to the `op` CLI against one vault. */
32
36
  var OpVault = class {
33
37
  shell;
38
+ /** Capability key; always `"vault"`. */
34
39
  key = "vault";
40
+ /** Provider name; always `"1password"`. */
35
41
  providerName = "1password";
36
42
  vaultName;
37
43
  constructor(shell, opts) {
@@ -154,9 +160,12 @@ function parseEnvironmentDump(stdout) {
154
160
  * token). Default spawnSync stdio of `['pipe','pipe','pipe']` would
155
161
  * suppress biometric unlock and return "not signed in" instead.
156
162
  */
163
+ /** Thin wrapper around `spawnSync` that runs the `op` CLI and returns a uniform result. */
157
164
  var OpShell = class {
158
165
  spawnImpl;
166
+ /** The `op` binary this wrapper runs; defaults to `"op"`. */
159
167
  binary;
168
+ /** The 1Password account UUID passed as `--account` on each call, when one is set. */
160
169
  account;
161
170
  constructor(opts = {}) {
162
171
  this.spawnImpl = opts.spawn ?? spawnSync;
@@ -210,6 +219,7 @@ var OpShell = class {
210
219
  * will be stored in the keyring but never read by this plugin — the
211
220
  * `AUTH_HINT` below explains that up front.
212
221
  */
222
+ /** Checks that `op` is installed and signed in by running `op whoami`; the token argument is unused. */
213
223
  async function verifyToken(_token, opts = {}) {
214
224
  const spawnImpl = opts.spawn ?? spawnSync;
215
225
  const binary = opts.binary ?? "op";
@@ -243,6 +253,7 @@ async function verifyToken(_token, opts = {}) {
243
253
  }
244
254
  }
245
255
  // src/index.ts
256
+ /** Builds the plugin context; throws when `vault` is missing or the `op` binary is not installed. */
246
257
  function createContext(options) {
247
258
  if (!options.vault) throw new Error("@theholocron/holocron-plugin-1password requires `vault` in options");
248
259
  const verifyOpts = {};
@@ -258,9 +269,11 @@ function createContext(options) {
258
269
  shell: new OpShell(shellOpts)
259
270
  };
260
271
  }
272
+ /** Builds the `vault` capability for the configured vault. */
261
273
  function vault(ctx) {
262
274
  return new OpVault(ctx.shell, { vault: ctx.options.vault });
263
275
  }
276
+ /** Creates the 1Password plugin: its `connection` probe and the `vault` capability. */
264
277
  function createPlugin(options) {
265
278
  const ctx = createContext(options);
266
279
  return {
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@theholocron/holocron-plugin-1password",
3
- "version": "5.0.0-alpha.277",
3
+ "version": "5.0.0-alpha.279",
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",
@@ -40,14 +40,14 @@
40
40
  "tsx": "4.23.15",
41
41
  "typescript": "^5.9.3",
42
42
  "vitest": "^5.0.5",
43
- "@theholocron/cli": "5.0.0-alpha.277",
44
- "@theholocron/tsconfig": "^8.9.0-alpha.3",
45
- "@theholocron/tsdown-config": "^8.9.0-alpha.3",
46
- "@theholocron/eslint-config": "^8.9.0-alpha.3",
47
- "@theholocron/vitest-config": "^8.9.0-alpha.3"
43
+ "@theholocron/cli": "5.0.0-alpha.279",
44
+ "@theholocron/tsconfig": "^8.9.0-alpha.4",
45
+ "@theholocron/eslint-config": "^8.9.0-alpha.4",
46
+ "@theholocron/vitest-config": "^8.9.0-alpha.4",
47
+ "@theholocron/tsdown-config": "^8.9.0-alpha.4"
48
48
  },
49
49
  "peerDependencies": {
50
- "@theholocron/cli": "5.0.0-alpha.277"
50
+ "@theholocron/cli": "5.0.0-alpha.279"
51
51
  },
52
52
  "engines": {
53
53
  "node": ">=22"