@theholocron/holocron-plugin-doppler 5.0.0-alpha.32 → 5.0.0-alpha.327
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 +29 -38
- package/dist/index.mjs +32 -21
- package/package.json +23 -21
package/dist/index.d.mts
CHANGED
|
@@ -1,23 +1,27 @@
|
|
|
1
|
-
import { AuthError, EnsureResult, ResolveTokenInput, Vault } from "@theholocron/cli";
|
|
1
|
+
import { AuthError, EnsureResult, PluginToken, ResolveTokenInput, Vault, VerifyTokenFailure, VerifyTokenResult, VerifyTokenResult as VerifyTokenResult$1, VerifyTokenSuccess } from "@theholocron/cli";
|
|
2
2
|
import { DopplerClient, DopplerClientOptions, createDopplerClient } from "@theholocron/doppler-client";
|
|
3
|
-
|
|
4
|
-
declare const resolveToken: (
|
|
5
|
-
|
|
6
|
-
|
|
3
|
+
/** Resolves the Doppler token from `--token`, `HOLOCRON_DOPPLER_TOKEN`, `DOPPLER_TOKEN` or the keyring entry for `doppler`, and throws `AuthError` when none is set. */
|
|
4
|
+
export declare const resolveToken: import("@theholocron/cli").TokenResolver;
|
|
5
|
+
/** Every token this plugin takes, for `holocron doctor tokens`. */
|
|
6
|
+
export declare const tokens: PluginToken[];
|
|
7
7
|
interface DopplerVaultOptions {
|
|
8
8
|
/** Default project — read/list/etc. operate here unless overridden. */
|
|
9
9
|
project: string;
|
|
10
10
|
/** Default config name — dev / stg / prd, etc. */
|
|
11
11
|
config: string;
|
|
12
12
|
}
|
|
13
|
-
|
|
13
|
+
/** `vault` capability for Doppler, with references shaped `doppler://<project>/<config>/<name>`. */
|
|
14
|
+
export declare class DopplerVault implements Vault {
|
|
14
15
|
private readonly client;
|
|
16
|
+
/** Capability key; always `"vault"`. */
|
|
15
17
|
readonly key: "vault";
|
|
18
|
+
/** Provider name; always `"doppler"`. */
|
|
16
19
|
readonly providerName = "doppler";
|
|
17
20
|
private readonly project;
|
|
18
21
|
private readonly config;
|
|
19
22
|
constructor(client: () => DopplerClient, opts: DopplerVaultOptions);
|
|
20
23
|
read(reference: string): Promise<string>;
|
|
24
|
+
readSecret(name: string): Promise<string>;
|
|
21
25
|
write(reference: string, value: string): Promise<void>;
|
|
22
26
|
list(): Promise<string[]>;
|
|
23
27
|
environments(): Promise<string[]>;
|
|
@@ -25,48 +29,36 @@ declare class DopplerVault implements Vault {
|
|
|
25
29
|
ensureProject(name: string): Promise<EnsureResult>;
|
|
26
30
|
ensureEnvironment(project: string, name: string): Promise<EnsureResult>;
|
|
27
31
|
}
|
|
28
|
-
//#endregion
|
|
29
|
-
//#region src/verify-token.d.ts
|
|
30
|
-
/**
|
|
31
|
-
* `verifyToken` — plugin-level export used by `holocron auth set` +
|
|
32
|
-
* `holocron auth check`. Hits `GET /v3/me` and translates the response
|
|
33
|
-
* into the normalized `VerifyTokenResult` shape.
|
|
34
|
-
*
|
|
35
|
-
* Kept as a standalone function (not a capability method) so the auth
|
|
36
|
-
* command can call it without initializing the full plugin — plugin
|
|
37
|
-
* construction requires an already-resolved token, which is exactly
|
|
38
|
-
* what we don't have yet at bootstrap time.
|
|
39
|
-
*/
|
|
40
|
-
interface VerifyTokenSuccess {
|
|
41
|
-
ok: true;
|
|
42
|
-
subject: string;
|
|
43
|
-
}
|
|
44
|
-
interface VerifyTokenFailure {
|
|
45
|
-
ok: false;
|
|
46
|
-
message: string;
|
|
47
|
-
}
|
|
48
|
-
type VerifyTokenResult = VerifyTokenSuccess | VerifyTokenFailure;
|
|
49
32
|
interface VerifyTokenOptions {
|
|
50
33
|
baseUrl?: string;
|
|
51
34
|
fetch?: typeof fetch;
|
|
52
35
|
}
|
|
53
|
-
|
|
54
|
-
|
|
55
|
-
|
|
56
|
-
interface DopplerPluginOptions extends ResolveTokenInput, DopplerVaultOptions {
|
|
36
|
+
/** Checks a Doppler token by fetching the caller and reports its kind and workplace, or why it was rejected. */
|
|
37
|
+
export declare function verifyToken(token: string, opts?: VerifyTokenOptions): Promise<VerifyTokenResult$1>;
|
|
38
|
+
/** Options for the Doppler plugin: the token lookup inputs plus the default project and config. */
|
|
39
|
+
export interface DopplerPluginOptions extends ResolveTokenInput, DopplerVaultOptions {
|
|
57
40
|
/** Override base URL for tests. */
|
|
58
41
|
baseUrl?: string;
|
|
59
42
|
/** Override `fetch` for tests. */
|
|
60
43
|
fetch?: typeof fetch;
|
|
61
44
|
}
|
|
62
|
-
|
|
45
|
+
/** Shared state for one Doppler plugin instance: its options and a lazily created client. */
|
|
46
|
+
export interface PluginContext {
|
|
47
|
+
/** The options the plugin was created with. */
|
|
63
48
|
options: DopplerPluginOptions;
|
|
49
|
+
/** Returns the memoized Doppler client; the token is resolved on the first call, not at plugin load. */
|
|
64
50
|
client: () => DopplerClient;
|
|
65
51
|
}
|
|
66
|
-
|
|
67
|
-
declare function
|
|
68
|
-
|
|
52
|
+
/** Builds the plugin context from its options. */
|
|
53
|
+
export declare function createContext(options: DopplerPluginOptions): PluginContext;
|
|
54
|
+
/** Builds the `vault` capability for the context's default project and config. */
|
|
55
|
+
export declare function vault(ctx: PluginContext): Vault;
|
|
56
|
+
/** Creates the Doppler plugin: its `connection` probe and the `vault` capability. */
|
|
57
|
+
export declare function createPlugin(options: DopplerPluginOptions): {
|
|
69
58
|
name: string;
|
|
59
|
+
probes: {
|
|
60
|
+
connection: import("@theholocron/cli").Probe;
|
|
61
|
+
};
|
|
70
62
|
capabilities: {
|
|
71
63
|
vault: () => Vault;
|
|
72
64
|
};
|
|
@@ -75,6 +67,5 @@ declare function createPlugin(options: DopplerPluginOptions): {
|
|
|
75
67
|
* One-line hint shown by `holocron auth set doppler` when no token is
|
|
76
68
|
* supplied or when the supplied token is rejected.
|
|
77
69
|
*/
|
|
78
|
-
declare const AUTH_HINT: string;
|
|
79
|
-
|
|
80
|
-
export { AUTH_HINT, AuthError, type DopplerClientOptions, DopplerPluginOptions, DopplerVault, PluginContext, type ResolveTokenInput, type VerifyTokenFailure, type VerifyTokenResult, type VerifyTokenSuccess, createContext, createDopplerClient, createPlugin, resolveToken, vault, verifyToken };
|
|
70
|
+
export declare const AUTH_HINT: string;
|
|
71
|
+
export { AuthError, type DopplerClientOptions, type ResolveTokenInput, type VerifyTokenFailure, type VerifyTokenResult, type VerifyTokenSuccess, createDopplerClient };
|
package/dist/index.mjs
CHANGED
|
@@ -1,14 +1,17 @@
|
|
|
1
|
-
import { AuthError, ProviderApiError, createResolveToken } from "@theholocron/cli";
|
|
1
|
+
import { AuthError, ProviderApiError, connectionProbe, createResolveToken } from "@theholocron/cli";
|
|
2
2
|
import { createDopplerClient } from "@theholocron/doppler-client";
|
|
3
|
-
|
|
3
|
+
import { errorMessage } from "@theholocron/misc-utils";
|
|
4
|
+
// src/auth.ts
|
|
5
|
+
/** Resolves the Doppler token from `--token`, `HOLOCRON_DOPPLER_TOKEN`, `DOPPLER_TOKEN` or the keyring entry for `doppler`, and throws `AuthError` when none is set. */
|
|
4
6
|
const resolveToken = createResolveToken({
|
|
5
7
|
envName: "HOLOCRON_DOPPLER_TOKEN",
|
|
6
8
|
vendorEnvName: "DOPPLER_TOKEN",
|
|
7
9
|
keyringService: "doppler",
|
|
8
10
|
errorMessage: "no Doppler token found. Pass --token <TOKEN>, set HOLOCRON_DOPPLER_TOKEN / DOPPLER_TOKEN, or run: holocron auth set doppler $(doppler configure get token --plain)"
|
|
9
11
|
});
|
|
10
|
-
|
|
11
|
-
|
|
12
|
+
/** Every token this plugin takes, for `holocron doctor tokens`. */
|
|
13
|
+
const tokens = [resolveToken.token];
|
|
14
|
+
// src/capabilities/vault.ts
|
|
12
15
|
/**
|
|
13
16
|
* Doppler auto-injects these into every config's secrets download —
|
|
14
17
|
* bookkeeping about the config itself, not something any caller
|
|
@@ -24,9 +27,12 @@ const DOPPLER_INJECTED_KEYS = /* @__PURE__ */ new Set([
|
|
|
24
27
|
"DOPPLER_CONFIG",
|
|
25
28
|
"DOPPLER_ENVIRONMENT"
|
|
26
29
|
]);
|
|
30
|
+
/** `vault` capability for Doppler, with references shaped `doppler://<project>/<config>/<name>`. */
|
|
27
31
|
var DopplerVault = class {
|
|
28
32
|
client;
|
|
33
|
+
/** Capability key; always `"vault"`. */
|
|
29
34
|
key = "vault";
|
|
35
|
+
/** Provider name; always `"doppler"`. */
|
|
30
36
|
providerName = "doppler";
|
|
31
37
|
project;
|
|
32
38
|
config;
|
|
@@ -42,6 +48,10 @@ var DopplerVault = class {
|
|
|
42
48
|
const res = await this.client().secrets.get(parsed.project, parsed.config, parsed.name);
|
|
43
49
|
return res.value?.computed ?? res.value?.raw ?? "";
|
|
44
50
|
}
|
|
51
|
+
async readSecret(name) {
|
|
52
|
+
const res = await this.client().secrets.get(this.project, this.config, name);
|
|
53
|
+
return res.value?.computed ?? res.value?.raw ?? "";
|
|
54
|
+
}
|
|
45
55
|
async write(reference, value) {
|
|
46
56
|
const parsed = parseReference(reference);
|
|
47
57
|
await this.client().secrets.update(parsed.project, parsed.config, { [parsed.name]: value });
|
|
@@ -116,18 +126,8 @@ function hasAlreadyExistsBody(details) {
|
|
|
116
126
|
if (typeof details !== "string") return false;
|
|
117
127
|
return /already exists/i.test(details);
|
|
118
128
|
}
|
|
119
|
-
|
|
120
|
-
|
|
121
|
-
/**
|
|
122
|
-
* `verifyToken` — plugin-level export used by `holocron auth set` +
|
|
123
|
-
* `holocron auth check`. Hits `GET /v3/me` and translates the response
|
|
124
|
-
* into the normalized `VerifyTokenResult` shape.
|
|
125
|
-
*
|
|
126
|
-
* Kept as a standalone function (not a capability method) so the auth
|
|
127
|
-
* command can call it without initializing the full plugin — plugin
|
|
128
|
-
* construction requires an already-resolved token, which is exactly
|
|
129
|
-
* what we don't have yet at bootstrap time.
|
|
130
|
-
*/
|
|
129
|
+
// src/verify-token.ts
|
|
130
|
+
/** Checks a Doppler token by fetching the caller and reports its kind and workplace, or why it was rejected. */
|
|
131
131
|
async function verifyToken(token, opts = {}) {
|
|
132
132
|
const client = createDopplerClient({
|
|
133
133
|
token,
|
|
@@ -144,12 +144,12 @@ async function verifyToken(token, opts = {}) {
|
|
|
144
144
|
} catch (err) {
|
|
145
145
|
return {
|
|
146
146
|
ok: false,
|
|
147
|
-
message:
|
|
147
|
+
message: errorMessage(err)
|
|
148
148
|
};
|
|
149
149
|
}
|
|
150
150
|
}
|
|
151
|
-
|
|
152
|
-
|
|
151
|
+
// src/index.ts
|
|
152
|
+
/** Builds the plugin context from its options. */
|
|
153
153
|
function createContext(options) {
|
|
154
154
|
let client;
|
|
155
155
|
return {
|
|
@@ -161,16 +161,28 @@ function createContext(options) {
|
|
|
161
161
|
})
|
|
162
162
|
};
|
|
163
163
|
}
|
|
164
|
+
/** Builds the `vault` capability for the context's default project and config. */
|
|
164
165
|
function vault(ctx) {
|
|
165
166
|
return new DopplerVault(ctx.client, {
|
|
166
167
|
project: ctx.options.project,
|
|
167
168
|
config: ctx.options.config
|
|
168
169
|
});
|
|
169
170
|
}
|
|
171
|
+
/** Creates the Doppler plugin: its `connection` probe and the `vault` capability. */
|
|
170
172
|
function createPlugin(options) {
|
|
171
173
|
const ctx = createContext(options);
|
|
172
174
|
return {
|
|
173
175
|
name: "@theholocron/holocron-plugin-doppler",
|
|
176
|
+
probes: { connection: connectionProbe({
|
|
177
|
+
provider: "Doppler",
|
|
178
|
+
url: options.baseUrl ?? "https://api.doppler.com",
|
|
179
|
+
fetch: options.fetch,
|
|
180
|
+
token: () => resolveToken(options),
|
|
181
|
+
verify: (token) => verifyToken(token, {
|
|
182
|
+
baseUrl: options.baseUrl,
|
|
183
|
+
fetch: options.fetch
|
|
184
|
+
})
|
|
185
|
+
}) },
|
|
174
186
|
capabilities: { vault: () => vault(ctx) }
|
|
175
187
|
};
|
|
176
188
|
}
|
|
@@ -179,5 +191,4 @@ function createPlugin(options) {
|
|
|
179
191
|
* supplied or when the supplied token is rejected.
|
|
180
192
|
*/
|
|
181
193
|
const AUTH_HINT = "install the Doppler CLI (`brew install dopplerhq/cli/doppler`), run `doppler login`, then `holocron auth set doppler $(doppler configure get token --plain)`";
|
|
182
|
-
|
|
183
|
-
export { AUTH_HINT, AuthError, DopplerVault, createContext, createDopplerClient, createPlugin, resolveToken, vault, verifyToken };
|
|
194
|
+
export { AUTH_HINT, AuthError, DopplerVault, createContext, createDopplerClient, createPlugin, resolveToken, tokens, vault, verifyToken };
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@theholocron/holocron-plugin-doppler",
|
|
3
|
-
"version": "5.0.0-alpha.
|
|
3
|
+
"version": "5.0.0-alpha.327",
|
|
4
4
|
"description": "Holocron plugin for Doppler. Implements the vault capability against Doppler's REST API — projects, configs, secrets, plus verifyToken + AUTH_HINT for `holocron auth`.",
|
|
5
5
|
"keywords": [
|
|
6
6
|
"doppler",
|
|
@@ -8,12 +8,12 @@
|
|
|
8
8
|
"plugin",
|
|
9
9
|
"vault"
|
|
10
10
|
],
|
|
11
|
-
"homepage": "https://
|
|
11
|
+
"homepage": "https://docs.theholocron.dev/holocron/plugins/doppler/",
|
|
12
12
|
"bugs": "https://github.com/theholocron/holocron/issues",
|
|
13
13
|
"repository": {
|
|
14
14
|
"type": "git",
|
|
15
15
|
"url": "git+https://github.com/theholocron/holocron.git",
|
|
16
|
-
"directory": "
|
|
16
|
+
"directory": "plugins/holocron-plugin-doppler"
|
|
17
17
|
},
|
|
18
18
|
"license": "MIT",
|
|
19
19
|
"author": "Newton Koumantzelis",
|
|
@@ -30,27 +30,29 @@
|
|
|
30
30
|
"dist"
|
|
31
31
|
],
|
|
32
32
|
"devDependencies": {
|
|
33
|
-
"@theholocron/doppler-client": "^1.24.0",
|
|
34
|
-
"@theholocron/eslint-config": "^8.0.0",
|
|
35
|
-
"@theholocron/http-client": "^1.24.0",
|
|
36
|
-
"@theholocron/tsconfig": "^8.0.0",
|
|
37
|
-
"@theholocron/tsdown-config": "^8.0.0",
|
|
38
|
-
"@theholocron/vitest-config": "^8.0.0",
|
|
39
33
|
"@types/node": "^26",
|
|
40
|
-
"@vitest/coverage-v8": "^
|
|
34
|
+
"@vitest/coverage-v8": "^5.0.5",
|
|
41
35
|
"@vitest/eslint-plugin": "^1.6.27",
|
|
42
36
|
"eslint": "^10.8.1",
|
|
43
37
|
"eslint-plugin-n": "^18.3.0",
|
|
44
38
|
"globals": "^17.11.0",
|
|
45
|
-
"tsdown": "^0.
|
|
46
|
-
"tsx": "4.23.
|
|
39
|
+
"tsdown": "^0.23.3",
|
|
40
|
+
"tsx": "4.23.15",
|
|
47
41
|
"typescript": "^5.9.3",
|
|
48
|
-
"vitest": "^
|
|
49
|
-
"@theholocron/cli": "5.0.0-alpha.
|
|
42
|
+
"vitest": "^5.0.5",
|
|
43
|
+
"@theholocron/cli": "5.0.0-alpha.327",
|
|
44
|
+
"@theholocron/doppler-client": "^1.58.0-alpha.7",
|
|
45
|
+
"@theholocron/http-client": "^1.58.0-alpha.7",
|
|
46
|
+
"@theholocron/eslint-config": "^8.9.0-alpha.8",
|
|
47
|
+
"@theholocron/misc-utils": "^1.17.0-alpha.1",
|
|
48
|
+
"@theholocron/tsdown-config": "^8.9.0-alpha.8",
|
|
49
|
+
"@theholocron/vitest-config": "^8.9.0-alpha.8",
|
|
50
|
+
"@theholocron/tsconfig": "^8.9.0-alpha.8"
|
|
50
51
|
},
|
|
51
52
|
"peerDependencies": {
|
|
52
|
-
"@theholocron/doppler-client": "^1.
|
|
53
|
-
"@theholocron/
|
|
53
|
+
"@theholocron/doppler-client": "^1.43.1",
|
|
54
|
+
"@theholocron/misc-utils": "^1.16.0",
|
|
55
|
+
"@theholocron/cli": "5.0.0-alpha.327"
|
|
54
56
|
},
|
|
55
57
|
"engines": {
|
|
56
58
|
"node": ">=22"
|
|
@@ -59,11 +61,11 @@
|
|
|
59
61
|
"access": "public"
|
|
60
62
|
},
|
|
61
63
|
"scripts": {
|
|
62
|
-
"
|
|
63
|
-
"
|
|
64
|
+
"build": "tsdown",
|
|
65
|
+
"lint:code": "eslint .",
|
|
66
|
+
"test:unit": "vitest run --coverage",
|
|
64
67
|
"test:watch": "vitest",
|
|
65
|
-
"
|
|
66
|
-
"
|
|
67
|
-
"verification.unitTests": "holocron run verification.unitTests --"
|
|
68
|
+
"typecheck": "tsc --noEmit",
|
|
69
|
+
"validate:plugin": "tsx scripts/validate.mjs"
|
|
68
70
|
}
|
|
69
71
|
}
|