@theholocron/infisical-client 1.32.0 → 1.33.0

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.
@@ -0,0 +1,80 @@
1
+ import "@theholocron/http-client";
2
+ import { ErrorSink, Logger } from "@theholocron/observability/core";
3
+ //#region ../../../../../src/utils.d.ts
4
+ interface InfisicalClientOptions {
5
+ /** Infisical Universal Auth machine identity token or personal token. */
6
+ token: string;
7
+ /** Override base URL for testing. Defaults to https://app.infisical.com/api. */
8
+ baseUrl?: string;
9
+ /** Override fetch for testing. Defaults to globalThis.fetch. */
10
+ fetch?: typeof fetch;
11
+ /** Structured logger for request/response diagnostics. Defaults to a no-op. */
12
+ logger?: Logger;
13
+ /** Reports transport failures and unexpected 5xx. Defaults to a no-op. */
14
+ errors?: ErrorSink;
15
+ }
16
+ //#endregion
17
+ //#region ../../../../../src/secrets/secrets.d.ts
18
+ interface InfisicalSecret {
19
+ secretKey?: string;
20
+ secretValue?: string;
21
+ }
22
+ interface InfisicalSecretsListResponse {
23
+ secrets?: InfisicalSecret[];
24
+ }
25
+ interface InfisicalSecretResponse {
26
+ secret?: InfisicalSecret;
27
+ }
28
+ interface InfisicalSecretScope {
29
+ workspaceId: string;
30
+ environment: string;
31
+ secretPath?: string;
32
+ }
33
+ interface InfisicalCreateSecretInput extends InfisicalSecretScope {
34
+ secretValue: string;
35
+ type?: "shared" | "personal";
36
+ }
37
+ interface InfisicalUpdateSecretInput extends InfisicalSecretScope {
38
+ secretValue: string;
39
+ }
40
+ //#endregion
41
+ //#region ../../../../../src/workspaces/workspaces.d.ts
42
+ interface InfisicalWorkspace {
43
+ _id?: string;
44
+ id?: string;
45
+ name?: string;
46
+ slug?: string;
47
+ }
48
+ interface InfisicalWorkspaceEnvironment {
49
+ id?: string;
50
+ name?: string;
51
+ slug?: string;
52
+ }
53
+ interface InfisicalWorkspaceDetails {
54
+ environments?: InfisicalWorkspaceEnvironment[];
55
+ }
56
+ interface InfisicalWorkspaceListResponse {
57
+ workspaces?: InfisicalWorkspace[];
58
+ }
59
+ interface InfisicalWorkspaceDetailsResponse {
60
+ workspace?: InfisicalWorkspaceDetails;
61
+ }
62
+ //#endregion
63
+ //#region ../../../../../src/index.d.ts
64
+ declare function createInfisicalClient(opts: InfisicalClientOptions): {
65
+ secrets: {
66
+ list: (scope: InfisicalSecretScope) => Promise<InfisicalSecretsListResponse>;
67
+ get: (name: string, scope: InfisicalSecretScope) => Promise<InfisicalSecretResponse>;
68
+ create: (name: string, input: InfisicalCreateSecretInput) => Promise<unknown>;
69
+ update: (name: string, input: InfisicalUpdateSecretInput) => Promise<unknown>;
70
+ };
71
+ workspaces: {
72
+ list: () => Promise<InfisicalWorkspaceListResponse>;
73
+ get: (workspaceId: string) => Promise<InfisicalWorkspaceDetailsResponse>;
74
+ create: (name: string, slug: string) => Promise<unknown>;
75
+ createEnvironment: (workspaceId: string, name: string, slug: string) => Promise<unknown>;
76
+ };
77
+ };
78
+ type InfisicalClient = ReturnType<typeof createInfisicalClient>;
79
+ //#endregion
80
+ export { InfisicalClient, type InfisicalClientOptions, type InfisicalCreateSecretInput, type InfisicalSecret, type InfisicalSecretResponse, type InfisicalSecretScope, type InfisicalSecretsListResponse, type InfisicalUpdateSecretInput, type InfisicalWorkspace, type InfisicalWorkspaceDetails, type InfisicalWorkspaceDetailsResponse, type InfisicalWorkspaceEnvironment, type InfisicalWorkspaceListResponse, createInfisicalClient };
package/dist/index.mjs ADDED
@@ -0,0 +1,86 @@
1
+ import { createRestClient } from "@theholocron/http-client";
2
+ //#region ../../../../../src/secrets/secrets.ts
3
+ function secrets(rest) {
4
+ return {
5
+ list: (scope) => {
6
+ const query = {
7
+ workspaceId: scope.workspaceId,
8
+ environment: scope.environment,
9
+ secretPath: scope.secretPath ?? "/"
10
+ };
11
+ return rest.request("/v3/secrets/raw", { query });
12
+ },
13
+ get: (name, scope) => {
14
+ const query = {
15
+ workspaceId: scope.workspaceId,
16
+ environment: scope.environment,
17
+ secretPath: scope.secretPath ?? "/"
18
+ };
19
+ return rest.request(`/v3/secrets/raw/${encodeURIComponent(name)}`, { query });
20
+ },
21
+ create: (name, input) => rest.request(`/v3/secrets/raw/${encodeURIComponent(name)}`, {
22
+ method: "POST",
23
+ body: {
24
+ workspaceId: input.workspaceId,
25
+ environment: input.environment,
26
+ secretPath: input.secretPath ?? "/",
27
+ secretValue: input.secretValue,
28
+ type: input.type ?? "shared"
29
+ }
30
+ }),
31
+ update: (name, input) => rest.request(`/v3/secrets/raw/${encodeURIComponent(name)}`, {
32
+ method: "PATCH",
33
+ body: {
34
+ workspaceId: input.workspaceId,
35
+ environment: input.environment,
36
+ secretPath: input.secretPath ?? "/",
37
+ secretValue: input.secretValue
38
+ }
39
+ })
40
+ };
41
+ }
42
+ //#endregion
43
+ //#region ../../../../../src/utils.ts
44
+ function createInfisicalRestClient(opts) {
45
+ return createRestClient({
46
+ baseUrl: opts.baseUrl ?? "https://app.infisical.com/api",
47
+ token: opts.token,
48
+ vendor: "Infisical",
49
+ fetch: opts.fetch,
50
+ logger: opts.logger,
51
+ errors: opts.errors
52
+ });
53
+ }
54
+ //#endregion
55
+ //#region ../../../../../src/workspaces/workspaces.ts
56
+ function workspaces(rest) {
57
+ return {
58
+ list: () => rest.request("/v1/workspace"),
59
+ get: (workspaceId) => rest.request(`/v1/workspace/${encodeURIComponent(workspaceId)}`),
60
+ create: (name, slug) => rest.request("/v2/workspace", {
61
+ method: "POST",
62
+ body: {
63
+ projectName: name,
64
+ slug
65
+ }
66
+ }),
67
+ createEnvironment: (workspaceId, name, slug) => rest.request(`/v1/workspace/${encodeURIComponent(workspaceId)}/environments`, {
68
+ method: "POST",
69
+ body: {
70
+ environmentName: name,
71
+ environmentSlug: slug
72
+ }
73
+ })
74
+ };
75
+ }
76
+ //#endregion
77
+ //#region ../../../../../src/index.ts
78
+ function createInfisicalClient(opts) {
79
+ const rest = createInfisicalRestClient(opts);
80
+ return {
81
+ secrets: secrets(rest),
82
+ workspaces: workspaces(rest)
83
+ };
84
+ }
85
+ //#endregion
86
+ export { createInfisicalClient };
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@theholocron/infisical-client",
3
- "version": "1.32.0",
3
+ "version": "1.33.0",
4
4
  "description": "A TypeScript client for the Infisical API",
5
5
  "keywords": [
6
6
  "infisical",
@@ -33,13 +33,13 @@
33
33
  ],
34
34
  "dependencies": {
35
35
  "@theholocron/observability": "^0.3.0",
36
- "@theholocron/http-client": "^1.32.0"
36
+ "@theholocron/http-client": "^1.33.0"
37
37
  },
38
38
  "devDependencies": {
39
39
  "@theholocron/cli": "5.0.0-alpha.79",
40
40
  "@theholocron/eslint-config": "^8.4.3",
41
41
  "@theholocron/tsconfig": "^8.2.0",
42
- "@theholocron/tsdown-config": "^8.5.2",
42
+ "@theholocron/tsdown-config": "^8.6.1",
43
43
  "@theholocron/vitest-config": "^8.2.0",
44
44
  "@types/node": "^26.4.1",
45
45
  "@vitest/coverage-v8": "^5.0.0",