@theholocron/holocron-plugin-infisical 2.0.0-alpha.20 → 2.0.0-alpha.22
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 +12 -55
- package/dist/index.mjs +26 -82
- package/package.json +9 -8
package/dist/index.d.mts
CHANGED
|
@@ -1,57 +1,7 @@
|
|
|
1
|
-
import { EnsureResult, Vault } from "@theholocron/cli";
|
|
1
|
+
import { AuthError, EnsureResult, ResolveTokenInput, RestClient, RestClient as RestClient$1, Vault } from "@theholocron/cli";
|
|
2
2
|
|
|
3
3
|
//#region src/auth.d.ts
|
|
4
|
-
|
|
5
|
-
* Token resolution for the Infisical plugin.
|
|
6
|
-
*
|
|
7
|
-
* Resolution order (matches the standard 4-step precedence set by
|
|
8
|
-
* `.notes/tech-auth-bootstrap.spec.md`):
|
|
9
|
-
* 1. explicit `cliToken` argument (from `--token` flag)
|
|
10
|
-
* 2. HOLOCRON_INFISICAL_TOKEN env var (preferred — explicit intent)
|
|
11
|
-
* 3. INFISICAL_TOKEN env var (vendor-native)
|
|
12
|
-
* 4. keyring (com.theholocron.cli / "infisical")
|
|
13
|
-
* 5. AuthError naming all four options + the bootstrap hint
|
|
14
|
-
*/
|
|
15
|
-
declare class AuthError extends Error {
|
|
16
|
-
name: string;
|
|
17
|
-
}
|
|
18
|
-
interface ResolveTokenInput {
|
|
19
|
-
/** From `--token` CLI flag. */
|
|
20
|
-
cliToken?: string;
|
|
21
|
-
/** Env vars; passed in for testability. Defaults to `process.env`. */
|
|
22
|
-
env?: NodeJS.ProcessEnv;
|
|
23
|
-
/** Keyring lookup fn; passed in for testability. Defaults to `getToken(provider)`. */
|
|
24
|
-
keyring?: (provider: string) => string | null;
|
|
25
|
-
}
|
|
26
|
-
declare function resolveToken(input?: ResolveTokenInput): string;
|
|
27
|
-
//#endregion
|
|
28
|
-
//#region src/rest.d.ts
|
|
29
|
-
/**
|
|
30
|
-
* Thin REST wrapper around https://app.infisical.com/api.
|
|
31
|
-
*
|
|
32
|
-
* Bearer auth, JSON-only bodies, transport-failure wrapping with
|
|
33
|
-
* `status: 0` so orchestrator soft-skip paths see a clear message
|
|
34
|
-
* instead of a generic `TypeError: fetch failed`.
|
|
35
|
-
*/
|
|
36
|
-
interface RestClientOptions {
|
|
37
|
-
token: string;
|
|
38
|
-
fetch?: typeof fetch;
|
|
39
|
-
baseUrl?: string;
|
|
40
|
-
}
|
|
41
|
-
interface RequestOptions {
|
|
42
|
-
method?: "GET" | "POST" | "PATCH" | "PUT" | "DELETE";
|
|
43
|
-
body?: unknown;
|
|
44
|
-
query?: Record<string, string>;
|
|
45
|
-
/** Treat this response as void even if 200 is returned. */
|
|
46
|
-
expectNoContent?: boolean;
|
|
47
|
-
}
|
|
48
|
-
declare class InfisicalRestClient {
|
|
49
|
-
private readonly token;
|
|
50
|
-
private readonly fetchImpl;
|
|
51
|
-
readonly baseUrl: string;
|
|
52
|
-
constructor(opts: RestClientOptions);
|
|
53
|
-
request<T>(path: string, opts?: RequestOptions): Promise<T>;
|
|
54
|
-
}
|
|
4
|
+
declare const resolveToken: (input?: import("@theholocron/http-client").ResolveTokenInput) => string;
|
|
55
5
|
//#endregion
|
|
56
6
|
//#region src/capabilities/vault.d.ts
|
|
57
7
|
interface InfisicalVaultOptions {
|
|
@@ -73,7 +23,7 @@ declare class InfisicalVault implements Vault {
|
|
|
73
23
|
* calls in the same run.
|
|
74
24
|
*/
|
|
75
25
|
private readonly workspaceIdCache;
|
|
76
|
-
constructor(rest:
|
|
26
|
+
constructor(rest: RestClient, opts: InfisicalVaultOptions);
|
|
77
27
|
read(reference: string): Promise<string>;
|
|
78
28
|
write(reference: string, value: string): Promise<void>;
|
|
79
29
|
list(): Promise<string[]>;
|
|
@@ -104,6 +54,13 @@ declare class InfisicalVault implements Vault {
|
|
|
104
54
|
private resolveWorkspaceId;
|
|
105
55
|
}
|
|
106
56
|
//#endregion
|
|
57
|
+
//#region src/rest.d.ts
|
|
58
|
+
declare function createInfisicalRestClient(opts: {
|
|
59
|
+
token: string;
|
|
60
|
+
baseUrl?: string;
|
|
61
|
+
fetch?: typeof fetch;
|
|
62
|
+
}): RestClient$1;
|
|
63
|
+
//#endregion
|
|
107
64
|
//#region src/verify-token.d.ts
|
|
108
65
|
/**
|
|
109
66
|
* `verifyToken` — plugin-level export used by `holocron auth set` +
|
|
@@ -155,7 +112,7 @@ interface InfisicalPluginOptions extends ResolveTokenInput, InfisicalVaultOption
|
|
|
155
112
|
}
|
|
156
113
|
interface PluginContext {
|
|
157
114
|
options: InfisicalPluginOptions;
|
|
158
|
-
rest:
|
|
115
|
+
rest: RestClient;
|
|
159
116
|
}
|
|
160
117
|
declare function createContext(options: InfisicalPluginOptions): PluginContext;
|
|
161
118
|
declare function vault(ctx: PluginContext): Vault;
|
|
@@ -178,4 +135,4 @@ declare function createPlugin(options: InfisicalPluginOptions): {
|
|
|
178
135
|
*/
|
|
179
136
|
declare const AUTH_HINT: string;
|
|
180
137
|
//#endregion
|
|
181
|
-
export { AUTH_HINT, AuthError, InfisicalPluginOptions,
|
|
138
|
+
export { AUTH_HINT, AuthError, InfisicalPluginOptions, InfisicalVault, PluginContext, type ResolveTokenInput, type VerifyTokenFailure, type VerifyTokenResult, type VerifyTokenSuccess, createContext, createInfisicalRestClient, createPlugin, resolveToken, vault, verifyToken };
|
package/dist/index.mjs
CHANGED
|
@@ -1,26 +1,11 @@
|
|
|
1
|
-
import { ProviderApiError,
|
|
1
|
+
import { AuthError, ProviderApiError, createResolveToken, createRestClient } from "@theholocron/cli";
|
|
2
2
|
//#region src/auth.ts
|
|
3
|
-
|
|
4
|
-
|
|
5
|
-
|
|
6
|
-
|
|
7
|
-
|
|
8
|
-
|
|
9
|
-
* 2. HOLOCRON_INFISICAL_TOKEN env var (preferred — explicit intent)
|
|
10
|
-
* 3. INFISICAL_TOKEN env var (vendor-native)
|
|
11
|
-
* 4. keyring (com.theholocron.cli / "infisical")
|
|
12
|
-
* 5. AuthError naming all four options + the bootstrap hint
|
|
13
|
-
*/
|
|
14
|
-
var AuthError = class extends Error {
|
|
15
|
-
name = "AuthError";
|
|
16
|
-
};
|
|
17
|
-
function resolveToken(input = {}) {
|
|
18
|
-
const env = input.env ?? process.env;
|
|
19
|
-
const keyring = input.keyring ?? getToken;
|
|
20
|
-
const token = input.cliToken || env["HOLOCRON_INFISICAL_TOKEN"] || env["INFISICAL_TOKEN"] || keyring("infisical");
|
|
21
|
-
if (!token) throw new AuthError("no Infisical token found. Pass --token <TOKEN>, set HOLOCRON_INFISICAL_TOKEN / INFISICAL_TOKEN, or run: holocron auth set infisical <TOKEN>");
|
|
22
|
-
return token;
|
|
23
|
-
}
|
|
3
|
+
const resolveToken = createResolveToken({
|
|
4
|
+
envName: "HOLOCRON_INFISICAL_TOKEN",
|
|
5
|
+
vendorEnvName: "INFISICAL_TOKEN",
|
|
6
|
+
keyringService: "infisical",
|
|
7
|
+
errorMessage: "no Infisical token found. Pass --token <TOKEN>, set HOLOCRON_INFISICAL_TOKEN / INFISICAL_TOKEN, or run: holocron auth set infisical <TOKEN>"
|
|
8
|
+
});
|
|
24
9
|
//#endregion
|
|
25
10
|
//#region src/capabilities/vault.ts
|
|
26
11
|
/**
|
|
@@ -222,57 +207,14 @@ function hasAlreadyExistsBody(details) {
|
|
|
222
207
|
}
|
|
223
208
|
//#endregion
|
|
224
209
|
//#region src/rest.ts
|
|
225
|
-
|
|
226
|
-
|
|
227
|
-
|
|
228
|
-
|
|
229
|
-
|
|
230
|
-
|
|
231
|
-
|
|
232
|
-
|
|
233
|
-
token;
|
|
234
|
-
fetchImpl;
|
|
235
|
-
baseUrl;
|
|
236
|
-
constructor(opts) {
|
|
237
|
-
this.token = opts.token;
|
|
238
|
-
this.fetchImpl = opts.fetch ?? globalThis.fetch;
|
|
239
|
-
let url = opts.baseUrl ?? "https://app.infisical.com/api";
|
|
240
|
-
while (url.endsWith("/")) url = url.slice(0, -1);
|
|
241
|
-
this.baseUrl = url;
|
|
242
|
-
}
|
|
243
|
-
async request(path, opts = {}) {
|
|
244
|
-
const url = new URL(`${this.baseUrl}${path.startsWith("/") ? path : "/" + path}`);
|
|
245
|
-
for (const [k, v] of Object.entries(opts.query ?? {})) url.searchParams.set(k, v);
|
|
246
|
-
const fullUrl = url.toString();
|
|
247
|
-
const headers = {
|
|
248
|
-
authorization: `Bearer ${this.token}`,
|
|
249
|
-
accept: "application/json"
|
|
250
|
-
};
|
|
251
|
-
const init = {
|
|
252
|
-
method: opts.method ?? "GET",
|
|
253
|
-
headers
|
|
254
|
-
};
|
|
255
|
-
if (opts.body !== void 0) {
|
|
256
|
-
headers["content-type"] = "application/json";
|
|
257
|
-
init.body = JSON.stringify(opts.body);
|
|
258
|
-
}
|
|
259
|
-
let res;
|
|
260
|
-
try {
|
|
261
|
-
res = await this.fetchImpl(fullUrl, init);
|
|
262
|
-
} catch (err) {
|
|
263
|
-
const detail = err instanceof Error ? `${err.name}: ${err.message}` : String(err);
|
|
264
|
-
throw new ProviderApiError(`Infisical ${init.method} ${path} failed: ${detail}`, 0, void 0);
|
|
265
|
-
}
|
|
266
|
-
if (!res.ok) {
|
|
267
|
-
const body = await res.text().catch(() => "");
|
|
268
|
-
throw new ProviderApiError(`Infisical ${init.method} ${path} → ${res.status}`, res.status, body);
|
|
269
|
-
}
|
|
270
|
-
if (opts.expectNoContent || res.status === 204) return void 0;
|
|
271
|
-
const text = await res.text();
|
|
272
|
-
if (!text) return void 0;
|
|
273
|
-
return JSON.parse(text);
|
|
274
|
-
}
|
|
275
|
-
};
|
|
210
|
+
function createInfisicalRestClient(opts) {
|
|
211
|
+
return createRestClient({
|
|
212
|
+
baseUrl: opts.baseUrl ?? "https://app.infisical.com/api",
|
|
213
|
+
token: opts.token,
|
|
214
|
+
vendor: "Infisical",
|
|
215
|
+
fetch: opts.fetch
|
|
216
|
+
});
|
|
217
|
+
}
|
|
276
218
|
//#endregion
|
|
277
219
|
//#region src/verify-token.ts
|
|
278
220
|
/**
|
|
@@ -302,10 +244,11 @@ var InfisicalRestClient = class {
|
|
|
302
244
|
* what we don't have yet at bootstrap time.
|
|
303
245
|
*/
|
|
304
246
|
async function verifyToken(token, opts = {}) {
|
|
305
|
-
const
|
|
306
|
-
|
|
307
|
-
|
|
308
|
-
|
|
247
|
+
const rest = createInfisicalRestClient({
|
|
248
|
+
token,
|
|
249
|
+
baseUrl: opts.baseUrl,
|
|
250
|
+
fetch: opts.fetch
|
|
251
|
+
});
|
|
309
252
|
try {
|
|
310
253
|
const res = await rest.request("/v1/workspace");
|
|
311
254
|
const count = res?.workspaces?.length ?? 0;
|
|
@@ -329,12 +272,13 @@ async function verifyToken(token, opts = {}) {
|
|
|
329
272
|
//#endregion
|
|
330
273
|
//#region src/index.ts
|
|
331
274
|
function createContext(options) {
|
|
332
|
-
const restOpts = { token: resolveToken(options) };
|
|
333
|
-
if (options.baseUrl !== void 0) restOpts.baseUrl = options.baseUrl;
|
|
334
|
-
if (options.fetch !== void 0) restOpts.fetch = options.fetch;
|
|
335
275
|
return {
|
|
336
276
|
options,
|
|
337
|
-
rest:
|
|
277
|
+
rest: createInfisicalRestClient({
|
|
278
|
+
token: resolveToken(options),
|
|
279
|
+
baseUrl: options.baseUrl,
|
|
280
|
+
fetch: options.fetch
|
|
281
|
+
})
|
|
338
282
|
};
|
|
339
283
|
}
|
|
340
284
|
function vault(ctx) {
|
|
@@ -363,4 +307,4 @@ function createPlugin(options) {
|
|
|
363
307
|
*/
|
|
364
308
|
const AUTH_HINT = "generate a Token Auth token on your machine identity (organization → access control → identities → your identity → add auth method → Token Auth → create token) OR a Personal API Token, then: holocron auth set infisical <TOKEN>. NOT Universal Auth's Client Secret — that needs a login exchange this plugin doesn't do yet.";
|
|
365
309
|
//#endregion
|
|
366
|
-
export { AUTH_HINT, AuthError,
|
|
310
|
+
export { AUTH_HINT, AuthError, InfisicalVault, createContext, createInfisicalRestClient, createPlugin, resolveToken, vault, verifyToken };
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@theholocron/holocron-plugin-infisical",
|
|
3
|
-
"version": "2.0.0-alpha.
|
|
3
|
+
"version": "2.0.0-alpha.22",
|
|
4
4
|
"description": "Holocron plugin for Infisical. Implements the vault capability against Infisical's REST API, plus exports verifyToken + AUTH_HINT for `holocron auth`.",
|
|
5
5
|
"homepage": "https://github.com/theholocron/holocron/tree/main/packages/holocron-plugin-infisical#readme",
|
|
6
6
|
"bugs": "https://github.com/theholocron/holocron/issues",
|
|
@@ -21,13 +21,14 @@
|
|
|
21
21
|
}
|
|
22
22
|
},
|
|
23
23
|
"peerDependencies": {
|
|
24
|
-
"@theholocron/cli": "2.0.0-alpha.
|
|
24
|
+
"@theholocron/cli": "2.0.0-alpha.22"
|
|
25
25
|
},
|
|
26
26
|
"devDependencies": {
|
|
27
|
-
"@
|
|
28
|
-
"@theholocron/
|
|
29
|
-
"@tsconfig
|
|
30
|
-
"@
|
|
27
|
+
"@types/node": "^26",
|
|
28
|
+
"@theholocron/eslint-config": "^5.2.0",
|
|
29
|
+
"@theholocron/tsconfig": "^6.0.0",
|
|
30
|
+
"@theholocron/tsdown-config": "^5.1.2",
|
|
31
|
+
"@theholocron/vitest-config": "^5.2.0",
|
|
31
32
|
"@vitest/eslint-plugin": "^1.6.23",
|
|
32
33
|
"eslint": "^10.7.0",
|
|
33
34
|
"eslint-plugin-n": "^18.2.2",
|
|
@@ -35,8 +36,8 @@
|
|
|
35
36
|
"tsdown": "^0.22.3",
|
|
36
37
|
"tsx": "^4.22.4",
|
|
37
38
|
"typescript": "^5.9.3",
|
|
38
|
-
"vitest": "^
|
|
39
|
-
"@theholocron/cli": "2.0.0-alpha.
|
|
39
|
+
"vitest": "^4.1.10",
|
|
40
|
+
"@theholocron/cli": "2.0.0-alpha.22"
|
|
40
41
|
},
|
|
41
42
|
"publishConfig": {
|
|
42
43
|
"access": "public"
|