@theholocron/holocron-plugin-1password 5.0.0-alpha.419 → 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/dist/index.d.mts CHANGED
@@ -1,4 +1,4 @@
1
- import { Credentials, CredentialsInspection, Vault, VerifyTokenFailure, VerifyTokenResult, VerifyTokenResult as VerifyTokenResult$1, VerifyTokenSuccess } from "@theholocron/cli";
1
+ import { Credentials, CredentialsInspection, EnvironmentEntry, Vault, VerifyTokenFailure, VerifyTokenResult, VerifyTokenResult as VerifyTokenResult$1, VerifyTokenSuccess } from "@theholocron/cli";
2
2
  import { spawnSync } from "node:child_process";
3
3
  /** Thrown when the 1Password `op` CLI is missing or does not run. */
4
4
  export declare class AuthError extends Error {
@@ -101,6 +101,11 @@ export declare class OpVault implements Vault {
101
101
  * no `op` command that lists Environments, so this vault has no `environments()`.
102
102
  */
103
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[]>;
104
109
  /** One variable of the Environment this vault was set up with, by its bare name. */
105
110
  readSecret(name: string): Promise<string>;
106
111
  }
package/dist/index.mjs CHANGED
@@ -161,6 +161,44 @@ var OpCredentials = class {
161
161
  function variableNames(text) {
162
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
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
+ }
164
202
  // src/capabilities/vault.ts
165
203
  /** `vault` capability for 1Password, implemented by shelling out to the `op` CLI against one vault. */
166
204
  var OpVault = class {
@@ -241,6 +279,20 @@ var OpVault = class {
241
279
  "--format=dotenv"
242
280
  ], `environment secret list ${environment}`));
243
281
  }
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([
288
+ "environment",
289
+ "secret",
290
+ "list",
291
+ environment,
292
+ "--reveal",
293
+ "--format=json"
294
+ ], `environment secret list ${environment}`));
295
+ }
244
296
  /** One variable of the Environment this vault was set up with, by its bare name. */
245
297
  async readSecret(name) {
246
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);
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@theholocron/holocron-plugin-1password",
3
- "version": "5.0.0-alpha.419",
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",
@@ -30,7 +30,7 @@
30
30
  "dist"
31
31
  ],
32
32
  "dependencies": {
33
- "@theholocron/kyber": "^5.0.0-alpha.419"
33
+ "@theholocron/kyber": "^5.0.0-alpha.420"
34
34
  },
35
35
  "devDependencies": {
36
36
  "@types/node": "^26",
@@ -43,14 +43,14 @@
43
43
  "tsx": "4.23.15",
44
44
  "typescript": "^5.9.3",
45
45
  "vitest": "^5.1.0",
46
+ "@theholocron/cli": "5.0.0-alpha.420",
46
47
  "@theholocron/eslint-config": "^8.9.0-alpha.16",
47
- "@theholocron/vitest-config": "^8.9.0-alpha.16",
48
48
  "@theholocron/tsconfig": "^8.9.0-alpha.16",
49
49
  "@theholocron/tsdown-config": "^8.9.0-alpha.16",
50
- "@theholocron/cli": "5.0.0-alpha.419"
50
+ "@theholocron/vitest-config": "^8.9.0-alpha.16"
51
51
  },
52
52
  "peerDependencies": {
53
- "@theholocron/cli": "5.0.0-alpha.419"
53
+ "@theholocron/cli": "5.0.0-alpha.420"
54
54
  },
55
55
  "engines": {
56
56
  "node": ">=22"