@theholocron/holocron-plugin-infisical 2.0.0-alpha.5 → 2.0.0-alpha.51

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 CHANGED
@@ -31,8 +31,10 @@ Switch by editing `holocron.config.json`.
31
31
 
32
32
  ## Install
33
33
 
34
+ <!-- prettier-ignore -->
34
35
  ```bash
35
36
  pnpm add -D @theholocron/holocron-plugin-infisical@alpha
37
+
36
38
  ```
37
39
 
38
40
  ## Auth
@@ -65,12 +67,14 @@ Universal Auth is a two-step flow (client id + client secret → login
65
67
  endpoint → short-lived access token). Support for that exchange is
66
68
  tracked as a follow-up; for now, use one of the two above.
67
69
 
70
+ <!-- prettier-ignore -->
68
71
  ```bash
69
72
  # 1. Generate the token per the note above.
70
73
  # 2. Hand it off to holocron's keyring (one-shot):
71
74
  holocron auth set infisical <TOKEN>
72
75
  # 3. Verify (calls GET /v1/workspace and reports accessible workspaces):
73
76
  holocron auth check infisical
77
+
74
78
  ```
75
79
 
76
80
  **If you have a machine identity that's Universal-Auth-only**: add a
@@ -85,12 +89,14 @@ precedence still work; step 4 quietly falls through.
85
89
 
86
90
  ## Config
87
91
 
92
+ <!-- prettier-ignore -->
88
93
  ```jsonc
89
94
  {
90
- "providers": {
91
- "vault": ["infisical", { "workspace": "<workspace-id>", "environment": "dev" }],
92
- },
95
+ "providers": {
96
+ "vault": ["infisical", { "workspace": "<workspace-id>", "environment": "dev" }],
97
+ },
93
98
  }
99
+
94
100
  ```
95
101
 
96
102
  - `workspace` (required) — Infisical workspace (project) id. Find via
@@ -101,8 +107,10 @@ precedence still work; step 4 quietly falls through.
101
107
 
102
108
  Individual `read` / `write` calls take a fully-qualified reference:
103
109
 
110
+ <!-- prettier-ignore -->
104
111
  ```
105
112
  infisical://<workspaceId>/<environment>/<name>
113
+
106
114
  ```
107
115
 
108
116
  The default `workspace` + `environment` in options apply to `list()`,
@@ -133,19 +141,21 @@ convention):
133
141
 
134
142
  Set the `baseUrl` option in `holocron.config.json`:
135
143
 
144
+ <!-- prettier-ignore -->
136
145
  ```jsonc
137
146
  {
138
- "providers": {
139
- "vault": [
140
- "infisical",
141
- {
142
- "workspace": "<id>",
143
- "environment": "dev",
144
- "baseUrl": "https://infisical.internal.example.com/api",
145
- },
146
- ],
147
- },
147
+ "providers": {
148
+ "vault": [
149
+ "infisical",
150
+ {
151
+ "workspace": "<id>",
152
+ "environment": "dev",
153
+ "baseUrl": "https://infisical.internal.example.com/api",
154
+ },
155
+ ],
156
+ },
148
157
  }
158
+
149
159
  ```
150
160
 
151
161
  ## Status
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: InfisicalRestClient, opts: InfisicalVaultOptions);
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: InfisicalRestClient;
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, InfisicalRestClient, InfisicalVault, PluginContext, ResolveTokenInput, type VerifyTokenFailure, type VerifyTokenResult, type VerifyTokenSuccess, createContext, createPlugin, resolveToken, vault, verifyToken };
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, getToken } from "@theholocron/cli";
1
+ import { AuthError, ProviderApiError, createResolveToken, createRestClient } from "@theholocron/cli";
2
2
  //#region src/auth.ts
3
- /**
4
- * Token resolution for the Infisical plugin.
5
- *
6
- * Resolution order (matches the standard 4-step precedence set by
7
- * `.notes/tech-auth-bootstrap.spec.md`):
8
- * 1. explicit `cliToken` argument (from `--token` flag)
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
- * Thin REST wrapper around https://app.infisical.com/api.
227
- *
228
- * Bearer auth, JSON-only bodies, transport-failure wrapping with
229
- * `status: 0` so orchestrator soft-skip paths see a clear message
230
- * instead of a generic `TypeError: fetch failed`.
231
- */
232
- var InfisicalRestClient = class {
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 restOpts = { token };
306
- if (opts.baseUrl !== void 0) restOpts.baseUrl = opts.baseUrl;
307
- if (opts.fetch !== void 0) restOpts.fetch = opts.fetch;
308
- const rest = new InfisicalRestClient(restOpts);
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: new InfisicalRestClient(restOpts)
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, InfisicalRestClient, InfisicalVault, createContext, createPlugin, resolveToken, vault, verifyToken };
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.5",
3
+ "version": "2.0.0-alpha.51",
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,19 +21,23 @@
21
21
  }
22
22
  },
23
23
  "peerDependencies": {
24
- "@theholocron/cli": "2.0.0-alpha.5"
24
+ "@theholocron/cli": "2.0.0-alpha.51"
25
25
  },
26
26
  "devDependencies": {
27
- "@theholocron/tsconfig": "^4.1.0",
28
- "@tsconfig/node-lts": "^24.0.0",
29
- "@vitest/coverage-v8": "^3.2.6",
30
- "eslint": "^9.36.0",
31
- "globals": "^16.5.0",
27
+ "@types/node": "^26",
28
+ "@theholocron/eslint-config": "^7.0.0",
29
+ "@theholocron/tsconfig": "^7.0.0",
30
+ "@theholocron/tsdown-config": "^7.0.0",
31
+ "@theholocron/vitest-config": "^7.0.0",
32
+ "@vitest/eslint-plugin": "^1.6.23",
33
+ "eslint": "^10.7.0",
34
+ "eslint-plugin-n": "^18.2.2",
35
+ "globals": "^17.7.0",
32
36
  "tsdown": "^0.22.3",
33
37
  "tsx": "^4.22.4",
34
38
  "typescript": "^5.9.3",
35
- "vitest": "^3.2.6",
36
- "@theholocron/cli": "2.0.0-alpha.5"
39
+ "vitest": "^4.1.10",
40
+ "@theholocron/cli": "2.0.0-alpha.51"
37
41
  },
38
42
  "publishConfig": {
39
43
  "access": "public"