@theholocron/holocron-plugin-1password 5.0.0-alpha.434 → 5.0.0-alpha.436
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 +3 -2
- package/dist/index.mjs +47 -48
- package/package.json +6 -6
package/dist/index.d.mts
CHANGED
|
@@ -60,8 +60,9 @@ export declare class OpCredentials implements Credentials {
|
|
|
60
60
|
*/
|
|
61
61
|
read(environment: string): Promise<Record<string, string>>;
|
|
62
62
|
/**
|
|
63
|
-
* The Environment as `op` spells it
|
|
64
|
-
* printed or kept: `op` shows a placeholder for each value, which is not read
|
|
63
|
+
* The Environment as `op` spells it, the names of its variables and which of them are visible, asked without
|
|
64
|
+
* `--reveal` so no value is printed or kept: `op` shows a placeholder for each value, which is not read, and the
|
|
65
|
+
* `concealed` flag that says secret from variable. Tries the same spellings as `read`.
|
|
65
66
|
*/
|
|
66
67
|
inspect(environment: string): Promise<CredentialsInspection>;
|
|
67
68
|
private list;
|
package/dist/index.mjs
CHANGED
|
@@ -91,6 +91,44 @@ function unescapeDouble(inner) {
|
|
|
91
91
|
"\\": "\\"
|
|
92
92
|
})[c]);
|
|
93
93
|
}
|
|
94
|
+
// src/parse-environment-json.ts
|
|
95
|
+
/** The list in `op environment secret list --format=json`: a bare array, or an object that holds one. */
|
|
96
|
+
function entriesOf(parsed) {
|
|
97
|
+
if (Array.isArray(parsed)) return parsed;
|
|
98
|
+
if (parsed && typeof parsed === "object") {
|
|
99
|
+
const found = Object.values(parsed).find(Array.isArray);
|
|
100
|
+
if (found) return found;
|
|
101
|
+
}
|
|
102
|
+
throw new ProviderApiError("1Password returned an Environment listing in a shape this plugin does not know", 502, void 0);
|
|
103
|
+
}
|
|
104
|
+
/**
|
|
105
|
+
* Parse `op environment secret list --reveal --format=json` into entries that say whether each is concealed.
|
|
106
|
+
*
|
|
107
|
+
* Each entry carries a name (`name`, else `key`), a `value` and a boolean `concealed`. An entry with no name is
|
|
108
|
+
* skipped; a missing value is empty; a `concealed` that is not `false` counts as concealed, because the safe side
|
|
109
|
+
* of a comparison of secrets is to include it. The shape of `op`'s JSON is not documented here beyond those fields.
|
|
110
|
+
*/
|
|
111
|
+
function parseEnvironmentJson(text) {
|
|
112
|
+
let parsed;
|
|
113
|
+
try {
|
|
114
|
+
parsed = JSON.parse(text);
|
|
115
|
+
} catch {
|
|
116
|
+
throw new ProviderApiError("1Password returned an Environment listing that is not JSON", 502, void 0);
|
|
117
|
+
}
|
|
118
|
+
const out = [];
|
|
119
|
+
for (const raw of entriesOf(parsed)) {
|
|
120
|
+
if (!raw || typeof raw !== "object") continue;
|
|
121
|
+
const entry = raw;
|
|
122
|
+
const name = typeof entry.name === "string" ? entry.name : typeof entry.key === "string" ? entry.key : "";
|
|
123
|
+
if (!name) continue;
|
|
124
|
+
out.push({
|
|
125
|
+
name,
|
|
126
|
+
value: typeof entry.value === "string" ? entry.value : "",
|
|
127
|
+
concealed: entry.concealed !== false
|
|
128
|
+
});
|
|
129
|
+
}
|
|
130
|
+
return out;
|
|
131
|
+
}
|
|
94
132
|
// src/capabilities/credentials.ts
|
|
95
133
|
/** How long to wait for `op` (a Touch ID prompt included) before giving up on the environment. */
|
|
96
134
|
const READ_TIMEOUT_MS = 6e4;
|
|
@@ -127,17 +165,20 @@ var OpCredentials = class {
|
|
|
127
165
|
return parseDotenv((await this.list(environment, ["--reveal"])).stdout);
|
|
128
166
|
}
|
|
129
167
|
/**
|
|
130
|
-
* The Environment as `op` spells it
|
|
131
|
-
* printed or kept: `op` shows a placeholder for each value, which is not read
|
|
168
|
+
* The Environment as `op` spells it, the names of its variables and which of them are visible, asked without
|
|
169
|
+
* `--reveal` so no value is printed or kept: `op` shows a placeholder for each value, which is not read, and the
|
|
170
|
+
* `concealed` flag that says secret from variable. Tries the same spellings as `read`.
|
|
132
171
|
*/
|
|
133
172
|
async inspect(environment) {
|
|
134
|
-
const { name, stdout } = await this.list(environment, []);
|
|
173
|
+
const { name, stdout } = await this.list(environment, [], "json");
|
|
174
|
+
const entries = parseEnvironmentJson(stdout);
|
|
135
175
|
return {
|
|
136
176
|
environment: name,
|
|
137
|
-
names:
|
|
177
|
+
names: entries.map((e) => e.name),
|
|
178
|
+
visible: entries.filter((e) => !e.concealed).map((e) => e.name)
|
|
138
179
|
};
|
|
139
180
|
}
|
|
140
|
-
async list(environment, flags) {
|
|
181
|
+
async list(environment, flags, format = "dotenv") {
|
|
141
182
|
const tried = spellings(environment);
|
|
142
183
|
for (const name of tried) {
|
|
143
184
|
const result = this.shell.run([
|
|
@@ -146,7 +187,7 @@ var OpCredentials = class {
|
|
|
146
187
|
"list",
|
|
147
188
|
name,
|
|
148
189
|
...flags,
|
|
149
|
-
|
|
190
|
+
`--format=${format}`
|
|
150
191
|
], { timeoutMs: READ_TIMEOUT_MS });
|
|
151
192
|
if (result.ok) return {
|
|
152
193
|
name,
|
|
@@ -157,48 +198,6 @@ var OpCredentials = class {
|
|
|
157
198
|
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
199
|
}
|
|
159
200
|
};
|
|
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
201
|
// src/capabilities/vault.ts
|
|
203
202
|
/** `vault` capability for 1Password, implemented by shelling out to the `op` CLI against one vault. */
|
|
204
203
|
var OpVault = class {
|
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.436",
|
|
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.
|
|
33
|
+
"@theholocron/kyber": "^5.0.0-alpha.436"
|
|
34
34
|
},
|
|
35
35
|
"devDependencies": {
|
|
36
36
|
"@types/node": "^26",
|
|
@@ -44,13 +44,13 @@
|
|
|
44
44
|
"typescript": "^5.9.3",
|
|
45
45
|
"vitest": "^5.1.0",
|
|
46
46
|
"@theholocron/eslint-config": "^8.9.0-alpha.17",
|
|
47
|
-
"@theholocron/cli": "5.0.0-alpha.
|
|
48
|
-
"@theholocron/tsdown-config": "^8.9.0-alpha.17",
|
|
47
|
+
"@theholocron/cli": "5.0.0-alpha.436",
|
|
49
48
|
"@theholocron/tsconfig": "^8.9.0-alpha.17",
|
|
50
|
-
"@theholocron/vitest-config": "^8.9.0-alpha.17"
|
|
49
|
+
"@theholocron/vitest-config": "^8.9.0-alpha.17",
|
|
50
|
+
"@theholocron/tsdown-config": "^8.9.0-alpha.17"
|
|
51
51
|
},
|
|
52
52
|
"peerDependencies": {
|
|
53
|
-
"@theholocron/cli": "5.0.0-alpha.
|
|
53
|
+
"@theholocron/cli": "5.0.0-alpha.436"
|
|
54
54
|
},
|
|
55
55
|
"engines": {
|
|
56
56
|
"node": ">=22"
|