@theholocron/holocron-plugin-1password 5.0.0-alpha.42 → 5.0.0-alpha.420
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 +11 -9
- package/dist/index.d.mts +100 -41
- package/dist/index.mjs +411 -47
- package/package.json +25 -22
package/README.md
CHANGED
|
@@ -1,3 +1,5 @@
|
|
|
1
|
+
<!-- alex disable fire -->
|
|
2
|
+
|
|
1
3
|
<!-- editorconfig-checker-disable-file -->
|
|
2
4
|
|
|
3
5
|
# `@theholocron/holocron-plugin-1password`
|
|
@@ -116,7 +118,7 @@ holocron.
|
|
|
116
118
|
|
|
117
119
|
```
|
|
118
120
|
|
|
119
|
-
- `vault` (
|
|
121
|
+
- `vault` (optional) — the 1Password vault name items live in. `list()` needs it, or an `environment` (see below) (`read` and `write` take the vault from the `op://` reference), and Environments are not in a vault, so a project that only reads an Environment can leave it out.
|
|
120
122
|
- `account` (optional) — 1P account UUID. Passes `--account <UUID>`
|
|
121
123
|
on every `op` call so the integration targets a specific account
|
|
122
124
|
even when the developer has multiple signed in (e.g., work +
|
|
@@ -124,13 +126,13 @@ holocron.
|
|
|
124
126
|
|
|
125
127
|
## What's implemented
|
|
126
128
|
|
|
127
|
-
| Method
|
|
128
|
-
|
|
|
129
|
-
| `read(reference)`
|
|
130
|
-
| `write(reference, v)`
|
|
131
|
-
| `list()`
|
|
132
|
-
| `
|
|
133
|
-
| `readEnvironment(id)` | `op environment
|
|
129
|
+
| Method | What it does |
|
|
130
|
+
| ----------------------------- | --------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------- |
|
|
131
|
+
| `read(reference)` | `op read <reference>` — resolves `op://Vault/Item/field`. `--no-newline`. |
|
|
132
|
+
| `write(reference, v)` | Probe + `op item edit` if exists, else `op item create --category=API Credential`. |
|
|
133
|
+
| `list()` | `op item list --vault=<vault> --format=json` — names of items in the vault; with only an `environment` set, the variable names of that Environment (`repo setup` calls it). Neither is an error. |
|
|
134
|
+
| `readSecret(name)` | Reads one variable of the Environment named by the `environment` option, through the same `op environment secret list`; refuses without that option. Lets a caller (the `comlink deliver` probe) ask for a secret by its bare name. |
|
|
135
|
+
| `readEnvironment(name or id)` | `op environment secret list <name or id> --reveal --format=dotenv` — parses the variables into a record (a multi-line PEM key, which `op` prints unquoted, is read whole). `op environment read` takes only an id, so this reads through `secret list`, which takes either. |
|
|
134
136
|
|
|
135
137
|
Plugin-level exports (not capability methods, per the auth-bootstrap
|
|
136
138
|
convention):
|
|
@@ -145,7 +147,7 @@ convention):
|
|
|
145
147
|
`ensureProject` / `ensureEnvironment` — 1Password's data model
|
|
146
148
|
doesn't have projects with sub-configs the way Doppler / Infisical
|
|
147
149
|
do. The vault + item hierarchy is created via the 1P UI or `op item
|
|
148
|
-
create`, not via `holocron setup`. The methods are omitted;
|
|
150
|
+
create`, not via `holocron repo setup`. The methods are omitted;
|
|
149
151
|
`runSetup` skips them cleanly (see the [`Vault`
|
|
150
152
|
interface](../cli/src/capabilities/index.ts)).
|
|
151
153
|
|
package/dist/index.d.mts
CHANGED
|
@@ -1,18 +1,19 @@
|
|
|
1
|
+
import { Credentials, CredentialsInspection, EnvironmentEntry, 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;
|
|
@@ -29,10 +30,15 @@ interface OpShellOptions {
|
|
|
29
30
|
interface RunOptions {
|
|
30
31
|
/** Skip `--account` injection for commands that operate above the account level (e.g., `account list`). */
|
|
31
32
|
skipAccount?: boolean;
|
|
33
|
+
/** Stop waiting for `op` after this many milliseconds. `op` can wait on the desktop app (a Touch ID prompt) without end. */
|
|
34
|
+
timeoutMs?: number;
|
|
32
35
|
}
|
|
33
|
-
|
|
36
|
+
/** Thin wrapper around `spawnSync` that runs the `op` CLI and returns a uniform result. */
|
|
37
|
+
export declare class OpShell {
|
|
34
38
|
private readonly spawnImpl;
|
|
39
|
+
/** The `op` binary this wrapper runs; defaults to `"op"`. */
|
|
35
40
|
readonly binary: string;
|
|
41
|
+
/** The 1Password account UUID passed as `--account` on each call, when one is set. */
|
|
36
42
|
readonly account?: string;
|
|
37
43
|
constructor(opts?: OpShellOptions);
|
|
38
44
|
/** Run `op <args>`, returning a uniform result. */
|
|
@@ -40,58 +46,112 @@ declare class OpShell {
|
|
|
40
46
|
/** Run + throw if non-zero. Mirrors REST clients' `request<T>` ergonomic. */
|
|
41
47
|
runOrThrow(args: string[], context: string, opts?: RunOptions): string;
|
|
42
48
|
}
|
|
43
|
-
|
|
44
|
-
|
|
49
|
+
/** `credentials` capability for 1Password, implemented by shelling out to `op environment secret list`. */
|
|
50
|
+
export declare class OpCredentials implements Credentials {
|
|
51
|
+
private readonly shell;
|
|
52
|
+
/** Capability key; always `"credentials"`. */
|
|
53
|
+
readonly key: "credentials";
|
|
54
|
+
/** Provider name; always `"1password"`. */
|
|
55
|
+
readonly providerName = "1password";
|
|
56
|
+
constructor(shell: OpShell);
|
|
57
|
+
/**
|
|
58
|
+
* Every variable of the Environment, with values. Tries {@link spellings} of the name until `op` finds one;
|
|
59
|
+
* any other failure (not signed in, a prompt that timed out) is thrown at once.
|
|
60
|
+
*/
|
|
61
|
+
read(environment: string): Promise<Record<string, string>>;
|
|
62
|
+
/**
|
|
63
|
+
* The Environment as `op` spells it and the names of its variables, asked without `--reveal` so no value is
|
|
64
|
+
* printed or kept: `op` shows a placeholder for each value, which is not read. Tries the same spellings as `read`.
|
|
65
|
+
*/
|
|
66
|
+
inspect(environment: string): Promise<CredentialsInspection>;
|
|
67
|
+
private list;
|
|
68
|
+
}
|
|
45
69
|
interface OpVaultOptions {
|
|
46
|
-
/**
|
|
47
|
-
|
|
70
|
+
/**
|
|
71
|
+
* 1P vault name items live in. `list()` needs it; `read` and `write` take it from the `op://` reference, and
|
|
72
|
+
* Environments are not in a vault, so a project that only reads an Environment can leave it out.
|
|
73
|
+
*/
|
|
74
|
+
vault?: string;
|
|
75
|
+
/**
|
|
76
|
+
* The 1Password Environment `readSecret` looks a variable up in. An app keeps its secrets in one Environment, so
|
|
77
|
+
* its config names it here and a caller can ask for a variable by its bare name.
|
|
78
|
+
*/
|
|
79
|
+
environment?: string;
|
|
48
80
|
}
|
|
49
|
-
|
|
81
|
+
/** `vault` capability for 1Password, implemented by shelling out to the `op` CLI against one vault. */
|
|
82
|
+
export declare class OpVault implements Vault {
|
|
50
83
|
private readonly shell;
|
|
84
|
+
/** Capability key; always `"vault"`. */
|
|
51
85
|
readonly key: "vault";
|
|
86
|
+
/** Provider name; always `"1password"`. */
|
|
52
87
|
readonly providerName = "1password";
|
|
53
88
|
private readonly vaultName;
|
|
54
|
-
|
|
89
|
+
private readonly environmentName;
|
|
90
|
+
constructor(shell: OpShell, opts?: OpVaultOptions);
|
|
55
91
|
read(reference: string): Promise<string>;
|
|
56
92
|
write(reference: string, value: string): Promise<void>;
|
|
93
|
+
/**
|
|
94
|
+
* The names this vault holds: the item titles of its `vault`, or, when only an `environment` is set (an Environment
|
|
95
|
+
* is not in a vault), that Environment's variable names. Values are read in memory and never returned.
|
|
96
|
+
*/
|
|
57
97
|
list(): Promise<string[]>;
|
|
58
|
-
|
|
59
|
-
|
|
98
|
+
/**
|
|
99
|
+
* Every variable of a 1Password Environment, by its name or id. `op environment read` takes only an id, while
|
|
100
|
+
* `op environment secret list` takes either, so this reads through the latter with the values revealed. There is
|
|
101
|
+
* no `op` command that lists Environments, so this vault has no `environments()`.
|
|
102
|
+
*/
|
|
103
|
+
readEnvironment(environment: string): Promise<Record<string, string>>;
|
|
104
|
+
/**
|
|
105
|
+
* Every variable of an Environment with its `concealed` flag, from `--format=json`. The values are returned for an
|
|
106
|
+
* in-memory comparison and nothing here prints or logs them.
|
|
107
|
+
*/
|
|
108
|
+
readEnvironmentEntries(environment: string): Promise<EnvironmentEntry[]>;
|
|
109
|
+
/** One variable of the Environment this vault was set up with, by its bare name. */
|
|
110
|
+
readSecret(name: string): Promise<string>;
|
|
60
111
|
}
|
|
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
112
|
interface VerifyTokenOptions {
|
|
73
113
|
spawn?: typeof spawnSync;
|
|
74
114
|
binary?: string;
|
|
75
115
|
}
|
|
76
|
-
|
|
77
|
-
|
|
78
|
-
|
|
79
|
-
interface OpPluginOptions extends VerifyInput {
|
|
80
|
-
/**
|
|
81
|
-
|
|
82
|
-
|
|
116
|
+
/** Checks that `op` is installed and signed in by running `op whoami`; the token argument is unused. */
|
|
117
|
+
export declare function verifyToken(_token: string, opts?: VerifyTokenOptions): Promise<VerifyTokenResult$1>;
|
|
118
|
+
/** Options for the 1Password plugin: the vault and account to use plus the `op` binary overrides. */
|
|
119
|
+
export interface OpPluginOptions extends VerifyInput {
|
|
120
|
+
/**
|
|
121
|
+
* 1P vault name items live in. Only listing a vault's items needs it; Environments are not in a vault, so a
|
|
122
|
+
* project that only reads an Environment can leave it out.
|
|
123
|
+
*/
|
|
124
|
+
vault?: string;
|
|
125
|
+
/** The Environment `readSecret` reads a variable from by its bare name; the one an app keeps its secrets in. */
|
|
126
|
+
environment?: string;
|
|
127
|
+
/** Optional 1P account UUID; passed as `--account` on every op call. Useful when several accounts are signed in. */
|
|
83
128
|
account?: string;
|
|
129
|
+
/** The repository root, handed in by the CLI: where `export-environment` writes `.credentials` and finds a layer word's remote. */
|
|
130
|
+
repoRoot?: string;
|
|
84
131
|
}
|
|
85
|
-
|
|
132
|
+
/** Shared state for one 1Password plugin instance: its options and the `op` shell wrapper. */
|
|
133
|
+
export interface PluginContext {
|
|
134
|
+
/** The options the plugin was created with. */
|
|
86
135
|
options: OpPluginOptions;
|
|
136
|
+
/** The wrapper that runs `op` commands. */
|
|
87
137
|
shell: OpShell;
|
|
88
138
|
}
|
|
89
|
-
|
|
90
|
-
declare function
|
|
91
|
-
|
|
139
|
+
/** Builds the plugin context; throws when the `op` binary is not installed. */
|
|
140
|
+
export declare function createContext(options: OpPluginOptions): PluginContext;
|
|
141
|
+
/** Builds the `vault` capability for the configured vault. */
|
|
142
|
+
export declare function vault(ctx: PluginContext): Vault;
|
|
143
|
+
/** Builds the `credentials` capability: the variables of a 1Password Environment, read for the token resolvers. */
|
|
144
|
+
export declare function credentials(ctx: PluginContext): Credentials;
|
|
145
|
+
/** Creates the 1Password plugin: its `connection` and `export-environment` probes and the `vault` and `credentials` capabilities. */
|
|
146
|
+
export declare function createPlugin(options?: OpPluginOptions): {
|
|
92
147
|
name: string;
|
|
148
|
+
probes: {
|
|
149
|
+
connection: import("@theholocron/cli").Probe;
|
|
150
|
+
"export-environment": import("@theholocron/cli").Probe;
|
|
151
|
+
};
|
|
93
152
|
capabilities: {
|
|
94
153
|
vault: () => Vault;
|
|
154
|
+
credentials: () => Credentials;
|
|
95
155
|
};
|
|
96
156
|
};
|
|
97
157
|
/**
|
|
@@ -99,6 +159,5 @@ declare function createPlugin(options: OpPluginOptions): {
|
|
|
99
159
|
* store a token in the holocron keyring; the `op` CLI manages its own
|
|
100
160
|
* auth. Directs the operator to the two paths that actually work.
|
|
101
161
|
*/
|
|
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 };
|
|
162
|
+
export declare const AUTH_HINT: string;
|
|
163
|
+
export type { VerifyTokenFailure, VerifyTokenResult, VerifyTokenSuccess };
|
package/dist/index.mjs
CHANGED
|
@@ -1,6 +1,7 @@
|
|
|
1
|
+
import { ProviderApiError, connectionProbe, ignoreAdvice, resolveCredentialsFile, resolveEnvironmentId, stdoutKind } from "@theholocron/cli";
|
|
1
2
|
import { spawnSync } from "node:child_process";
|
|
2
|
-
import {
|
|
3
|
-
|
|
3
|
+
import { copyToClipboard, dotenvLine, finishCredentialsFile, isGitIgnored, shredFile, writeCredentialsFile } from "@theholocron/kyber/secrets";
|
|
4
|
+
// src/auth.ts
|
|
4
5
|
/**
|
|
5
6
|
* 1Password plugin "auth" is just verifying the `op` binary is on
|
|
6
7
|
* PATH — the CLI handles its own auth (keychain biometric unlock for
|
|
@@ -11,9 +12,12 @@ import { ProviderApiError } from "@theholocron/cli";
|
|
|
11
12
|
* a missing binary fails fast and clearly, not as a mystery error when
|
|
12
13
|
* the first `vault.read()` happens later.
|
|
13
14
|
*/
|
|
15
|
+
/** Thrown when the 1Password `op` CLI is missing or does not run. */
|
|
14
16
|
var AuthError = class extends Error {
|
|
17
|
+
/** Error name; always `"AuthError"`. */
|
|
15
18
|
name = "AuthError";
|
|
16
19
|
};
|
|
20
|
+
/** Runs `op --version` and throws `AuthError` when the binary is not found or exits non-zero. */
|
|
17
21
|
function verifyOpInstalled(input = {}) {
|
|
18
22
|
const spawnImpl = input.spawn ?? spawnSync;
|
|
19
23
|
const binary = input.binary ?? "op";
|
|
@@ -28,17 +32,187 @@ function verifyOpInstalled(input = {}) {
|
|
|
28
32
|
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
33
|
if (result.status !== 0) throw new AuthError(`\`${binary} --version\` failed: ${(result.stderr ?? "").trim() || `exit ${result.status ?? "?"}`}`);
|
|
30
34
|
}
|
|
31
|
-
|
|
32
|
-
|
|
35
|
+
// src/parse-dotenv.ts
|
|
36
|
+
/**
|
|
37
|
+
* Parse dotenv text (`op environment secret list --format=dotenv`) into a record.
|
|
38
|
+
*
|
|
39
|
+
* Blank lines and `# comment` lines are skipped, as is a line with no `=`. A leading `export ` is dropped. A value
|
|
40
|
+
* in double quotes has `\n`, `\r`, `\t`, `\"` and `\\` unescaped and may run over several lines; a value in single
|
|
41
|
+
* quotes is taken as written; an unquoted value that opens a PEM block (`-----BEGIN …-----`) runs to its `-----END …-----`
|
|
42
|
+
* line, because `op` prints a multi-line key that way; anything else is the rest of the line, trimmed. Inline `#`
|
|
43
|
+
* comments are not stripped, because a token may contain one.
|
|
44
|
+
*/
|
|
45
|
+
function parseDotenv(text) {
|
|
46
|
+
const out = {};
|
|
47
|
+
const lines = text.split(/\r?\n/);
|
|
48
|
+
for (let i = 0; i < lines.length; i++) {
|
|
49
|
+
const line = lines[i].trim();
|
|
50
|
+
if (!line || line.startsWith("#")) continue;
|
|
51
|
+
const eq = line.indexOf("=");
|
|
52
|
+
if (eq < 0) continue;
|
|
53
|
+
const key = line.slice(0, eq).trim().replace(/^export\s+/, "");
|
|
54
|
+
if (!key) continue;
|
|
55
|
+
const value = line.slice(eq + 1).trim();
|
|
56
|
+
if (value.startsWith("\"")) {
|
|
57
|
+
let body = value.slice(1);
|
|
58
|
+
while (!hasClosingQuote(body) && i + 1 < lines.length) body += `\n${lines[++i]}`;
|
|
59
|
+
out[key] = unescapeDouble(body.slice(0, closingQuoteAt(body)));
|
|
60
|
+
continue;
|
|
61
|
+
}
|
|
62
|
+
if (value.startsWith("'") && value.endsWith("'") && value.length >= 2) {
|
|
63
|
+
out[key] = value.slice(1, -1);
|
|
64
|
+
continue;
|
|
65
|
+
}
|
|
66
|
+
if (/^-----BEGIN [^-]+-----/.test(value)) {
|
|
67
|
+
let block = value;
|
|
68
|
+
while (!/-----END [^-]+-----\s*$/.test(block) && i + 1 < lines.length) block += `\n${lines[++i].trim()}`;
|
|
69
|
+
out[key] = block;
|
|
70
|
+
continue;
|
|
71
|
+
}
|
|
72
|
+
out[key] = value;
|
|
73
|
+
}
|
|
74
|
+
return out;
|
|
75
|
+
}
|
|
76
|
+
/** The index of the first `"` not preceded by a backslash, or the whole length when there is none. */
|
|
77
|
+
function closingQuoteAt(body) {
|
|
78
|
+
for (let i = 0; i < body.length; i++) if (body[i] === "\\") i++;
|
|
79
|
+
else if (body[i] === "\"") return i;
|
|
80
|
+
return body.length;
|
|
81
|
+
}
|
|
82
|
+
function hasClosingQuote(body) {
|
|
83
|
+
return closingQuoteAt(body) < body.length;
|
|
84
|
+
}
|
|
85
|
+
function unescapeDouble(inner) {
|
|
86
|
+
return inner.replace(/\\([nrt"\\])/g, (_, c) => ({
|
|
87
|
+
n: "\n",
|
|
88
|
+
r: "\r",
|
|
89
|
+
t: " ",
|
|
90
|
+
"\"": "\"",
|
|
91
|
+
"\\": "\\"
|
|
92
|
+
})[c]);
|
|
93
|
+
}
|
|
94
|
+
// src/capabilities/credentials.ts
|
|
95
|
+
/** How long to wait for `op` (a Touch ID prompt included) before giving up on the environment. */
|
|
96
|
+
const READ_TIMEOUT_MS = 6e4;
|
|
97
|
+
/** `op` words a missing Environment as "environment couldn't be found". */
|
|
98
|
+
const NOT_FOUND = /couldn.?t be found|could not be found|not found/i;
|
|
99
|
+
/**
|
|
100
|
+
* The spellings of an Environment name to try, in order: as written, lowercase, Title case, UPPERCASE. `op` finds an
|
|
101
|
+
* Environment by its exact name and has no command that lists them, so the real spelling cannot be looked up.
|
|
102
|
+
*/
|
|
103
|
+
function spellings(name) {
|
|
104
|
+
const title = name.charAt(0).toUpperCase() + name.slice(1).toLowerCase();
|
|
105
|
+
return [.../* @__PURE__ */ new Set([
|
|
106
|
+
name,
|
|
107
|
+
name.toLowerCase(),
|
|
108
|
+
title,
|
|
109
|
+
name.toUpperCase()
|
|
110
|
+
])];
|
|
111
|
+
}
|
|
112
|
+
/** `credentials` capability for 1Password, implemented by shelling out to `op environment secret list`. */
|
|
113
|
+
var OpCredentials = class {
|
|
114
|
+
shell;
|
|
115
|
+
/** Capability key; always `"credentials"`. */
|
|
116
|
+
key = "credentials";
|
|
117
|
+
/** Provider name; always `"1password"`. */
|
|
118
|
+
providerName = "1password";
|
|
119
|
+
constructor(shell) {
|
|
120
|
+
this.shell = shell;
|
|
121
|
+
}
|
|
122
|
+
/**
|
|
123
|
+
* Every variable of the Environment, with values. Tries {@link spellings} of the name until `op` finds one;
|
|
124
|
+
* any other failure (not signed in, a prompt that timed out) is thrown at once.
|
|
125
|
+
*/
|
|
126
|
+
async read(environment) {
|
|
127
|
+
return parseDotenv((await this.list(environment, ["--reveal"])).stdout);
|
|
128
|
+
}
|
|
129
|
+
/**
|
|
130
|
+
* The Environment as `op` spells it and the names of its variables, asked without `--reveal` so no value is
|
|
131
|
+
* printed or kept: `op` shows a placeholder for each value, which is not read. Tries the same spellings as `read`.
|
|
132
|
+
*/
|
|
133
|
+
async inspect(environment) {
|
|
134
|
+
const { name, stdout } = await this.list(environment, []);
|
|
135
|
+
return {
|
|
136
|
+
environment: name,
|
|
137
|
+
names: variableNames(stdout)
|
|
138
|
+
};
|
|
139
|
+
}
|
|
140
|
+
async list(environment, flags) {
|
|
141
|
+
const tried = spellings(environment);
|
|
142
|
+
for (const name of tried) {
|
|
143
|
+
const result = this.shell.run([
|
|
144
|
+
"environment",
|
|
145
|
+
"secret",
|
|
146
|
+
"list",
|
|
147
|
+
name,
|
|
148
|
+
...flags,
|
|
149
|
+
"--format=dotenv"
|
|
150
|
+
], { timeoutMs: READ_TIMEOUT_MS });
|
|
151
|
+
if (result.ok) return {
|
|
152
|
+
name,
|
|
153
|
+
stdout: result.stdout
|
|
154
|
+
};
|
|
155
|
+
if (!NOT_FOUND.test(result.stderr)) throw new ProviderApiError(`1Password environment secret list ${name} failed: ${result.stderr || "no stderr"}`, 0, result.stderr);
|
|
156
|
+
}
|
|
157
|
+
throw new ProviderApiError(`1Password has no Environment named "${environment}" (tried ${tried.map((n) => `"${n}"`).join(", ")}). Check the name, or use the Environment's id; names are matched exactly and \`op\` cannot list them.`, 404, void 0);
|
|
158
|
+
}
|
|
159
|
+
};
|
|
160
|
+
/** The variable names in dotenv text, taken from the start of each line so a value is never looked at. */
|
|
161
|
+
function variableNames(text) {
|
|
162
|
+
return text.split(/\r?\n/).map((line) => /^\s*(?:export\s+)?([A-Za-z_][A-Za-z0-9_.-]*)\s*=/.exec(line)?.[1]).filter((name) => name !== void 0);
|
|
163
|
+
}
|
|
164
|
+
// src/parse-environment-json.ts
|
|
165
|
+
/** The list in `op environment secret list --format=json`: a bare array, or an object that holds one. */
|
|
166
|
+
function entriesOf(parsed) {
|
|
167
|
+
if (Array.isArray(parsed)) return parsed;
|
|
168
|
+
if (parsed && typeof parsed === "object") {
|
|
169
|
+
const found = Object.values(parsed).find(Array.isArray);
|
|
170
|
+
if (found) return found;
|
|
171
|
+
}
|
|
172
|
+
throw new ProviderApiError("1Password returned an Environment listing in a shape this plugin does not know", 502, void 0);
|
|
173
|
+
}
|
|
174
|
+
/**
|
|
175
|
+
* Parse `op environment secret list --reveal --format=json` into entries that say whether each is concealed.
|
|
176
|
+
*
|
|
177
|
+
* Each entry carries a name (`name`, else `key`), a `value` and a boolean `concealed`. An entry with no name is
|
|
178
|
+
* skipped; a missing value is empty; a `concealed` that is not `false` counts as concealed, because the safe side
|
|
179
|
+
* of a comparison of secrets is to include it. The shape of `op`'s JSON is not documented here beyond those fields.
|
|
180
|
+
*/
|
|
181
|
+
function parseEnvironmentJson(text) {
|
|
182
|
+
let parsed;
|
|
183
|
+
try {
|
|
184
|
+
parsed = JSON.parse(text);
|
|
185
|
+
} catch {
|
|
186
|
+
throw new ProviderApiError("1Password returned an Environment listing that is not JSON", 502, void 0);
|
|
187
|
+
}
|
|
188
|
+
const out = [];
|
|
189
|
+
for (const raw of entriesOf(parsed)) {
|
|
190
|
+
if (!raw || typeof raw !== "object") continue;
|
|
191
|
+
const entry = raw;
|
|
192
|
+
const name = typeof entry.name === "string" ? entry.name : typeof entry.key === "string" ? entry.key : "";
|
|
193
|
+
if (!name) continue;
|
|
194
|
+
out.push({
|
|
195
|
+
name,
|
|
196
|
+
value: typeof entry.value === "string" ? entry.value : "",
|
|
197
|
+
concealed: entry.concealed !== false
|
|
198
|
+
});
|
|
199
|
+
}
|
|
200
|
+
return out;
|
|
201
|
+
}
|
|
202
|
+
// src/capabilities/vault.ts
|
|
203
|
+
/** `vault` capability for 1Password, implemented by shelling out to the `op` CLI against one vault. */
|
|
33
204
|
var OpVault = class {
|
|
34
205
|
shell;
|
|
206
|
+
/** Capability key; always `"vault"`. */
|
|
35
207
|
key = "vault";
|
|
208
|
+
/** Provider name; always `"1password"`. */
|
|
36
209
|
providerName = "1password";
|
|
37
210
|
vaultName;
|
|
38
|
-
|
|
211
|
+
environmentName;
|
|
212
|
+
constructor(shell, opts = {}) {
|
|
39
213
|
this.shell = shell;
|
|
40
|
-
|
|
41
|
-
this.
|
|
214
|
+
this.vaultName = opts.vault || void 0;
|
|
215
|
+
this.environmentName = opts.environment || void 0;
|
|
42
216
|
}
|
|
43
217
|
async read(reference) {
|
|
44
218
|
return this.shell.runOrThrow([
|
|
@@ -74,7 +248,13 @@ var OpVault = class {
|
|
|
74
248
|
`${parsed.field}=${value}`
|
|
75
249
|
], `item create ${parsed.item}`);
|
|
76
250
|
}
|
|
251
|
+
/**
|
|
252
|
+
* The names this vault holds: the item titles of its `vault`, or, when only an `environment` is set (an Environment
|
|
253
|
+
* is not in a vault), that Environment's variable names. Values are read in memory and never returned.
|
|
254
|
+
*/
|
|
77
255
|
async list() {
|
|
256
|
+
if (!this.vaultName && this.environmentName) return Object.keys(await this.readEnvironment(this.environmentName));
|
|
257
|
+
if (!this.vaultName) throw new ProviderApiError("1Password `list` needs a `vault` or an `environment` in the plugin options: it lists the items in one vault, or the variable names of one Environment", 400, void 0);
|
|
78
258
|
const stdout = this.shell.runOrThrow([
|
|
79
259
|
"item",
|
|
80
260
|
"list",
|
|
@@ -84,21 +264,41 @@ var OpVault = class {
|
|
|
84
264
|
if (!stdout) return [];
|
|
85
265
|
return JSON.parse(stdout).map((i) => i.title);
|
|
86
266
|
}
|
|
87
|
-
|
|
88
|
-
|
|
267
|
+
/**
|
|
268
|
+
* Every variable of a 1Password Environment, by its name or id. `op environment read` takes only an id, while
|
|
269
|
+
* `op environment secret list` takes either, so this reads through the latter with the values revealed. There is
|
|
270
|
+
* no `op` command that lists Environments, so this vault has no `environments()`.
|
|
271
|
+
*/
|
|
272
|
+
async readEnvironment(environment) {
|
|
273
|
+
return parseDotenv(this.shell.runOrThrow([
|
|
89
274
|
"environment",
|
|
275
|
+
"secret",
|
|
90
276
|
"list",
|
|
91
|
-
|
|
92
|
-
|
|
93
|
-
|
|
94
|
-
|
|
277
|
+
environment,
|
|
278
|
+
"--reveal",
|
|
279
|
+
"--format=dotenv"
|
|
280
|
+
], `environment secret list ${environment}`));
|
|
95
281
|
}
|
|
96
|
-
|
|
97
|
-
|
|
282
|
+
/**
|
|
283
|
+
* Every variable of an Environment with its `concealed` flag, from `--format=json`. The values are returned for an
|
|
284
|
+
* in-memory comparison and nothing here prints or logs them.
|
|
285
|
+
*/
|
|
286
|
+
async readEnvironmentEntries(environment) {
|
|
287
|
+
return parseEnvironmentJson(this.shell.runOrThrow([
|
|
98
288
|
"environment",
|
|
99
|
-
"
|
|
100
|
-
|
|
101
|
-
|
|
289
|
+
"secret",
|
|
290
|
+
"list",
|
|
291
|
+
environment,
|
|
292
|
+
"--reveal",
|
|
293
|
+
"--format=json"
|
|
294
|
+
], `environment secret list ${environment}`));
|
|
295
|
+
}
|
|
296
|
+
/** One variable of the Environment this vault was set up with, by its bare name. */
|
|
297
|
+
async readSecret(name) {
|
|
298
|
+
if (!this.environmentName) throw new ProviderApiError("1Password `readSecret` needs an `environment` in the plugin options: it reads one variable of that Environment", 400, void 0);
|
|
299
|
+
const value = (await this.readEnvironment(this.environmentName))[name];
|
|
300
|
+
if (value === void 0) throw new ProviderApiError(`1Password Environment ${this.environmentName} has no variable ${name}`, 404, void 0);
|
|
301
|
+
return value;
|
|
102
302
|
}
|
|
103
303
|
};
|
|
104
304
|
/**
|
|
@@ -117,27 +317,169 @@ function parseReference(reference) {
|
|
|
117
317
|
field: fieldParts.join("/")
|
|
118
318
|
};
|
|
119
319
|
}
|
|
320
|
+
// src/probes/parse-export-args.ts
|
|
321
|
+
const USAGE = "usage: holocron probe 1password export-environment <environment> [--only NAME]... [--copy]";
|
|
322
|
+
/** Reads the words after `export-environment`: one Environment, any number of `--only NAME`, and `--copy`. */
|
|
323
|
+
function parseExportArgs(args) {
|
|
324
|
+
const only = [];
|
|
325
|
+
const positional = [];
|
|
326
|
+
let copy = false;
|
|
327
|
+
for (let i = 0; i < args.length; i++) {
|
|
328
|
+
const arg = args[i];
|
|
329
|
+
if (arg === "--copy") copy = true;
|
|
330
|
+
else if (arg === "--only") {
|
|
331
|
+
const name = args[++i];
|
|
332
|
+
if (name === void 0) throw new Error(`--only needs a variable name. ${USAGE}`);
|
|
333
|
+
only.push(name);
|
|
334
|
+
} else if (arg.startsWith("--only=")) only.push(arg.slice(7));
|
|
335
|
+
else if (arg.startsWith("--")) throw new Error(`unknown option ${arg}. ${USAGE}`);
|
|
336
|
+
else positional.push(arg);
|
|
337
|
+
}
|
|
338
|
+
if (positional.length !== 1) throw new Error(`name one Environment. ${USAGE}`);
|
|
339
|
+
return {
|
|
340
|
+
environment: positional[0],
|
|
341
|
+
only,
|
|
342
|
+
copy
|
|
343
|
+
};
|
|
344
|
+
}
|
|
345
|
+
// src/probes/export-environment.ts
|
|
346
|
+
/** The name of the file the lines go to (in `.holocron/.private/`), for the messages. */
|
|
347
|
+
const FILE_NAME = ".credentials";
|
|
348
|
+
/** Plain code-unit order: the same on every machine, whatever its locale. The names it sorts are all different. */
|
|
349
|
+
const compare = (a, b) => a < b ? -1 : 1;
|
|
350
|
+
/** Where the lines may go. Throws (with no value in the message) when nowhere is safe. */
|
|
351
|
+
function chooseDestination(deps, copy) {
|
|
352
|
+
if (copy) return "clipboard";
|
|
353
|
+
const kind = deps.outKind();
|
|
354
|
+
if (kind === "pipe") return "stdout";
|
|
355
|
+
if (kind === "other") throw new Error("refusing to write secrets to a redirected file: it would leave them on disk with no protection. Run it on a terminal for the private, short-lived .credentials file, or pipe the output to a tool, or use --copy");
|
|
356
|
+
if (deps.platform === "win32") throw new Error("cannot make the file private on Windows: its mode bits are not enforced, so other users may read it. Use --copy, or pipe the output to a tool");
|
|
357
|
+
if (!deps.interactive) throw new Error("the .credentials file is deleted once you confirm the import, which needs a terminal to ask on. Pipe the output to a tool, or use --copy");
|
|
358
|
+
return "file";
|
|
359
|
+
}
|
|
360
|
+
/** Writes the lines to the private file, waits for the import and deletes it. Registers the deletion for a failure or Ctrl-C. */
|
|
361
|
+
async function writeToFile(probe, deps, text) {
|
|
362
|
+
const { path } = resolveCredentialsFile(deps.repoRoot, void 0, deps.makeDir);
|
|
363
|
+
const git = deps.isIgnored(path);
|
|
364
|
+
if (git === "tracked" || git === "unknown") throw new Error(`refusing to write secrets to ${path}: ${git === "tracked" ? "git does not ignore it, so it could be committed" : "git could not say whether it ignores it"}; ${ignoreAdvice(true, "")}`);
|
|
365
|
+
let identity;
|
|
366
|
+
try {
|
|
367
|
+
identity = deps.writeFile(path, text, false);
|
|
368
|
+
} catch (err) {
|
|
369
|
+
const reason = err instanceof Error ? err.message : "unknown error";
|
|
370
|
+
throw new Error(`could not write ${path}: ${reason}. An existing file is never overwritten: delete it first`, { cause: err });
|
|
371
|
+
}
|
|
372
|
+
probe.cleanup(`the ${FILE_NAME} file`, async () => {
|
|
373
|
+
deps.shred(path, identity);
|
|
374
|
+
});
|
|
375
|
+
if (!await finishCredentialsFile({
|
|
376
|
+
path,
|
|
377
|
+
identity,
|
|
378
|
+
print: (line) => probe.say({
|
|
379
|
+
status: "info",
|
|
380
|
+
label: line
|
|
381
|
+
}),
|
|
382
|
+
holds: "the Environment's secrets",
|
|
383
|
+
importHint: "import it in the 1Password app: Developer, View Environments, the target Environment, Import .env file",
|
|
384
|
+
interactive: deps.interactive,
|
|
385
|
+
shred: deps.shred,
|
|
386
|
+
waitForImport: deps.waitForImport
|
|
387
|
+
})) probe.say({
|
|
388
|
+
status: "fail",
|
|
389
|
+
label: `${path} is still on disk and holds secrets in plain text: delete it`
|
|
390
|
+
});
|
|
391
|
+
}
|
|
120
392
|
/**
|
|
121
|
-
*
|
|
122
|
-
*
|
|
123
|
-
*
|
|
124
|
-
* a literal newline, that's a problem for the underlying environment,
|
|
125
|
-
* not this parser.
|
|
393
|
+
* The `export-environment` probe: reads one 1Password Environment in memory and writes its variables as `NAME=value`
|
|
394
|
+
* to a private `.credentials` file (deleted once the import into another Environment is done), a pipe or the clipboard.
|
|
395
|
+
* Names and counts are all it ever reports; a value is only ever in the text handed to the destination.
|
|
126
396
|
*/
|
|
127
|
-
function
|
|
128
|
-
|
|
129
|
-
|
|
130
|
-
|
|
131
|
-
|
|
132
|
-
|
|
133
|
-
|
|
134
|
-
|
|
135
|
-
|
|
136
|
-
|
|
137
|
-
|
|
397
|
+
function exportEnvironmentProbe(deps) {
|
|
398
|
+
return {
|
|
399
|
+
summary: "Read one 1Password Environment in memory and write its variables as NAME=value to a private .credentials file (deleted after the import), a pipe or the clipboard.",
|
|
400
|
+
writes: true,
|
|
401
|
+
reportsTo: "stderr",
|
|
402
|
+
async run(probe) {
|
|
403
|
+
const args = parseExportArgs(probe.args ?? []);
|
|
404
|
+
const destination = chooseDestination(deps, args.copy);
|
|
405
|
+
const environment = await deps.resolveId(args.environment, deps.repoRoot);
|
|
406
|
+
const all = await deps.read(environment);
|
|
407
|
+
const present = Object.keys(all);
|
|
408
|
+
const unknown = args.only.filter((name) => !present.includes(name));
|
|
409
|
+
if (unknown.length > 0) throw new Error(`${environment} has no variable named ${unknown.join(", ")}`);
|
|
410
|
+
const names = (args.only.length > 0 ? [...new Set(args.only)] : present).sort(compare);
|
|
411
|
+
if (names.length === 0) {
|
|
412
|
+
probe.say({
|
|
413
|
+
status: "info",
|
|
414
|
+
label: environment,
|
|
415
|
+
detail: "has no variables, so there is nothing to export"
|
|
416
|
+
});
|
|
417
|
+
return;
|
|
418
|
+
}
|
|
419
|
+
const lines = [];
|
|
420
|
+
const exported = [];
|
|
421
|
+
for (const name of names) {
|
|
422
|
+
const value = all[name];
|
|
423
|
+
probe.secret(value);
|
|
424
|
+
const line = dotenvLine(name, value);
|
|
425
|
+
if (line === null) {
|
|
426
|
+
probe.say({
|
|
427
|
+
status: "fail",
|
|
428
|
+
label: name,
|
|
429
|
+
detail: "a value dotenv cannot carry unchanged, so add it by hand"
|
|
430
|
+
});
|
|
431
|
+
continue;
|
|
432
|
+
}
|
|
433
|
+
lines.push(line);
|
|
434
|
+
exported.push(name);
|
|
435
|
+
}
|
|
436
|
+
if (lines.length === 0) return;
|
|
437
|
+
const text = `${lines.join("\n")}\n`;
|
|
438
|
+
probe.say({
|
|
439
|
+
status: "heading",
|
|
440
|
+
label: `${environment}: ${exported.length} of ${names.length} variables`
|
|
441
|
+
});
|
|
442
|
+
for (const name of exported) probe.say({
|
|
443
|
+
status: "info",
|
|
444
|
+
label: name
|
|
445
|
+
});
|
|
446
|
+
const label = `write ${exported.length} variables to ${destination === "file" ? FILE_NAME : destination}`;
|
|
447
|
+
await probe.write(label, async () => {
|
|
448
|
+
if (destination === "clipboard") {
|
|
449
|
+
await deps.copy(text);
|
|
450
|
+
probe.say({
|
|
451
|
+
status: "ok",
|
|
452
|
+
label: "copied to the clipboard: paste it, then clear the clipboard"
|
|
453
|
+
});
|
|
454
|
+
} else if (destination === "stdout") {
|
|
455
|
+
deps.out(text);
|
|
456
|
+
probe.say({
|
|
457
|
+
status: "ok",
|
|
458
|
+
label: "wrote the variables to stdout"
|
|
459
|
+
});
|
|
460
|
+
} else await writeToFile(probe, deps, text);
|
|
461
|
+
});
|
|
462
|
+
}
|
|
463
|
+
};
|
|
464
|
+
}
|
|
465
|
+
// src/probes/export-environment-deps.ts
|
|
466
|
+
/** The real pieces `export-environment` runs on: the plugin's own reader, the repo root, this process's stdout and the shared secret-file helpers. */
|
|
467
|
+
function exportEnvironmentDeps(credentials, repoRoot) {
|
|
468
|
+
return {
|
|
469
|
+
read: (environment) => credentials.read(environment),
|
|
470
|
+
repoRoot,
|
|
471
|
+
resolveId: (id, root) => resolveEnvironmentId(id, { repoRoot: root }),
|
|
472
|
+
outKind: () => stdoutKind(process.stdout.isTTY === true),
|
|
473
|
+
out: (text) => void process.stdout.write(text),
|
|
474
|
+
copy: copyToClipboard,
|
|
475
|
+
writeFile: writeCredentialsFile,
|
|
476
|
+
shred: shredFile,
|
|
477
|
+
isIgnored: isGitIgnored,
|
|
478
|
+
platform: process.platform,
|
|
479
|
+
interactive: process.stdin.isTTY === true
|
|
480
|
+
};
|
|
138
481
|
}
|
|
139
|
-
|
|
140
|
-
//#region src/shell.ts
|
|
482
|
+
// src/shell.ts
|
|
141
483
|
/**
|
|
142
484
|
* Thin wrapper around `spawnSync` for `op` CLI shell-outs.
|
|
143
485
|
*
|
|
@@ -156,9 +498,12 @@ function parseEnvironmentDump(stdout) {
|
|
|
156
498
|
* token). Default spawnSync stdio of `['pipe','pipe','pipe']` would
|
|
157
499
|
* suppress biometric unlock and return "not signed in" instead.
|
|
158
500
|
*/
|
|
501
|
+
/** Thin wrapper around `spawnSync` that runs the `op` CLI and returns a uniform result. */
|
|
159
502
|
var OpShell = class {
|
|
160
503
|
spawnImpl;
|
|
504
|
+
/** The `op` binary this wrapper runs; defaults to `"op"`. */
|
|
161
505
|
binary;
|
|
506
|
+
/** The 1Password account UUID passed as `--account` on each call, when one is set. */
|
|
162
507
|
account;
|
|
163
508
|
constructor(opts = {}) {
|
|
164
509
|
this.spawnImpl = opts.spawn ?? spawnSync;
|
|
@@ -178,7 +523,8 @@ var OpShell = class {
|
|
|
178
523
|
"inherit",
|
|
179
524
|
"pipe",
|
|
180
525
|
"pipe"
|
|
181
|
-
]
|
|
526
|
+
],
|
|
527
|
+
...opts.timeoutMs !== void 0 ? { timeout: opts.timeoutMs } : {}
|
|
182
528
|
});
|
|
183
529
|
if (out.error) return {
|
|
184
530
|
ok: false,
|
|
@@ -198,8 +544,7 @@ var OpShell = class {
|
|
|
198
544
|
return result.stdout;
|
|
199
545
|
}
|
|
200
546
|
};
|
|
201
|
-
|
|
202
|
-
//#region src/verify-token.ts
|
|
547
|
+
// src/verify-token.ts
|
|
203
548
|
/**
|
|
204
549
|
* `verifyToken` — plugin-level export used by `holocron auth check`.
|
|
205
550
|
*
|
|
@@ -213,6 +558,7 @@ var OpShell = class {
|
|
|
213
558
|
* will be stored in the keyring but never read by this plugin — the
|
|
214
559
|
* `AUTH_HINT` below explains that up front.
|
|
215
560
|
*/
|
|
561
|
+
/** Checks that `op` is installed and signed in by running `op whoami`; the token argument is unused. */
|
|
216
562
|
async function verifyToken(_token, opts = {}) {
|
|
217
563
|
const spawnImpl = opts.spawn ?? spawnSync;
|
|
218
564
|
const binary = opts.binary ?? "op";
|
|
@@ -245,10 +591,9 @@ async function verifyToken(_token, opts = {}) {
|
|
|
245
591
|
};
|
|
246
592
|
}
|
|
247
593
|
}
|
|
248
|
-
|
|
249
|
-
|
|
594
|
+
// src/index.ts
|
|
595
|
+
/** Builds the plugin context; throws when the `op` binary is not installed. */
|
|
250
596
|
function createContext(options) {
|
|
251
|
-
if (!options.vault) throw new Error("@theholocron/holocron-plugin-1password requires `vault` in options");
|
|
252
597
|
const verifyOpts = {};
|
|
253
598
|
if (options.spawn !== void 0) verifyOpts.spawn = options.spawn;
|
|
254
599
|
if (options.binary !== void 0) verifyOpts.binary = options.binary;
|
|
@@ -262,14 +607,34 @@ function createContext(options) {
|
|
|
262
607
|
shell: new OpShell(shellOpts)
|
|
263
608
|
};
|
|
264
609
|
}
|
|
610
|
+
/** Builds the `vault` capability for the configured vault. */
|
|
265
611
|
function vault(ctx) {
|
|
266
|
-
return new OpVault(ctx.shell, {
|
|
612
|
+
return new OpVault(ctx.shell, {
|
|
613
|
+
...ctx.options.vault !== void 0 ? { vault: ctx.options.vault } : {},
|
|
614
|
+
...ctx.options.environment !== void 0 ? { environment: ctx.options.environment } : {}
|
|
615
|
+
});
|
|
267
616
|
}
|
|
268
|
-
|
|
617
|
+
/** Builds the `credentials` capability: the variables of a 1Password Environment, read for the token resolvers. */
|
|
618
|
+
function credentials(ctx) {
|
|
619
|
+
return new OpCredentials(ctx.shell);
|
|
620
|
+
}
|
|
621
|
+
/** Creates the 1Password plugin: its `connection` and `export-environment` probes and the `vault` and `credentials` capabilities. */
|
|
622
|
+
function createPlugin(options = {}) {
|
|
269
623
|
const ctx = createContext(options);
|
|
270
624
|
return {
|
|
271
625
|
name: "@theholocron/holocron-plugin-1password",
|
|
272
|
-
|
|
626
|
+
probes: {
|
|
627
|
+
connection: connectionProbe({
|
|
628
|
+
provider: "1Password",
|
|
629
|
+
token: () => "",
|
|
630
|
+
verify: (token) => verifyToken(token, { spawn: options.spawn })
|
|
631
|
+
}),
|
|
632
|
+
"export-environment": exportEnvironmentProbe(exportEnvironmentDeps(new OpCredentials(ctx.shell), options.repoRoot ?? process.cwd()))
|
|
633
|
+
},
|
|
634
|
+
capabilities: {
|
|
635
|
+
vault: () => vault(ctx),
|
|
636
|
+
credentials: () => credentials(ctx)
|
|
637
|
+
}
|
|
273
638
|
};
|
|
274
639
|
}
|
|
275
640
|
/**
|
|
@@ -278,5 +643,4 @@ function createPlugin(options) {
|
|
|
278
643
|
* auth. Directs the operator to the two paths that actually work.
|
|
279
644
|
*/
|
|
280
645
|
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
|
-
|
|
282
|
-
export { AUTH_HINT, AuthError, OpShell, OpVault, createContext, createPlugin, vault, verifyOpInstalled, verifyToken };
|
|
646
|
+
export { AUTH_HINT, AuthError, OpCredentials, OpShell, OpVault, createContext, createPlugin, credentials, 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.420",
|
|
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",
|
|
@@ -29,25 +29,28 @@
|
|
|
29
29
|
"files": [
|
|
30
30
|
"dist"
|
|
31
31
|
],
|
|
32
|
+
"dependencies": {
|
|
33
|
+
"@theholocron/kyber": "^5.0.0-alpha.420"
|
|
34
|
+
},
|
|
32
35
|
"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
36
|
"@types/node": "^26",
|
|
38
|
-
"@vitest/coverage-v8": "^
|
|
39
|
-
"@vitest/eslint-plugin": "^1.6.
|
|
40
|
-
"eslint": "^10.
|
|
41
|
-
"eslint-plugin-n": "^18.
|
|
42
|
-
"globals": "^17.
|
|
43
|
-
"tsdown": "^0.
|
|
44
|
-
"tsx": "4.23.
|
|
37
|
+
"@vitest/coverage-v8": "^5.1.0",
|
|
38
|
+
"@vitest/eslint-plugin": "^1.6.28",
|
|
39
|
+
"eslint": "^10.14.0",
|
|
40
|
+
"eslint-plugin-n": "^18.5.0",
|
|
41
|
+
"globals": "^17.14.0",
|
|
42
|
+
"tsdown": "^0.23.5",
|
|
43
|
+
"tsx": "4.23.15",
|
|
45
44
|
"typescript": "^5.9.3",
|
|
46
|
-
"vitest": "^
|
|
47
|
-
"@theholocron/cli": "5.0.0-alpha.
|
|
45
|
+
"vitest": "^5.1.0",
|
|
46
|
+
"@theholocron/cli": "5.0.0-alpha.420",
|
|
47
|
+
"@theholocron/eslint-config": "^8.9.0-alpha.16",
|
|
48
|
+
"@theholocron/tsconfig": "^8.9.0-alpha.16",
|
|
49
|
+
"@theholocron/tsdown-config": "^8.9.0-alpha.16",
|
|
50
|
+
"@theholocron/vitest-config": "^8.9.0-alpha.16"
|
|
48
51
|
},
|
|
49
52
|
"peerDependencies": {
|
|
50
|
-
"@theholocron/cli": "5.0.0-alpha.
|
|
53
|
+
"@theholocron/cli": "5.0.0-alpha.420"
|
|
51
54
|
},
|
|
52
55
|
"engines": {
|
|
53
56
|
"node": ">=22"
|
|
@@ -56,11 +59,11 @@
|
|
|
56
59
|
"access": "public"
|
|
57
60
|
},
|
|
58
61
|
"scripts": {
|
|
59
|
-
"
|
|
60
|
-
"
|
|
62
|
+
"build": "tsdown",
|
|
63
|
+
"lint:code": "eslint .",
|
|
64
|
+
"test:unit": "vitest run --coverage",
|
|
61
65
|
"test:watch": "vitest",
|
|
62
|
-
"
|
|
63
|
-
"
|
|
64
|
-
"verification.unitTests": "holocron run verification.unitTests --"
|
|
66
|
+
"typecheck": "tsc --noEmit",
|
|
67
|
+
"validate:plugin": "tsx scripts/validate.mjs"
|
|
65
68
|
}
|
|
66
69
|
}
|