@theholocron/holocron-plugin-doppler 2.0.0-alpha.46 → 2.0.0-alpha.48
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 +6 -12
- package/dist/index.mjs +17 -57
- package/package.json +5 -3
package/dist/index.d.mts
CHANGED
|
@@ -1,4 +1,5 @@
|
|
|
1
|
-
import { AuthError, EnsureResult, ResolveTokenInput,
|
|
1
|
+
import { AuthError, EnsureResult, ResolveTokenInput, Vault } from "@theholocron/cli";
|
|
2
|
+
import { DopplerClient, createDopplerClient } from "@theholocron/doppler-client";
|
|
2
3
|
|
|
3
4
|
//#region src/auth.d.ts
|
|
4
5
|
declare const resolveToken: (input?: import("@theholocron/http-client").ResolveTokenInput) => string;
|
|
@@ -11,12 +12,12 @@ interface DopplerVaultOptions {
|
|
|
11
12
|
config: string;
|
|
12
13
|
}
|
|
13
14
|
declare class DopplerVault implements Vault {
|
|
14
|
-
private readonly
|
|
15
|
+
private readonly client;
|
|
15
16
|
readonly key: "vault";
|
|
16
17
|
readonly providerName = "doppler";
|
|
17
18
|
private readonly project;
|
|
18
19
|
private readonly config;
|
|
19
|
-
constructor(
|
|
20
|
+
constructor(client: DopplerClient, opts: DopplerVaultOptions);
|
|
20
21
|
read(reference: string): Promise<string>;
|
|
21
22
|
write(reference: string, value: string): Promise<void>;
|
|
22
23
|
list(): Promise<string[]>;
|
|
@@ -26,13 +27,6 @@ declare class DopplerVault implements Vault {
|
|
|
26
27
|
ensureEnvironment(project: string, name: string): Promise<EnsureResult>;
|
|
27
28
|
}
|
|
28
29
|
//#endregion
|
|
29
|
-
//#region src/rest.d.ts
|
|
30
|
-
declare function createDopplerRestClient(opts: {
|
|
31
|
-
token: string;
|
|
32
|
-
baseUrl?: string;
|
|
33
|
-
fetch?: typeof fetch;
|
|
34
|
-
}): RestClient$1;
|
|
35
|
-
//#endregion
|
|
36
30
|
//#region src/verify-token.d.ts
|
|
37
31
|
/**
|
|
38
32
|
* `verifyToken` — plugin-level export used by `holocron auth set` +
|
|
@@ -68,7 +62,7 @@ interface DopplerPluginOptions extends ResolveTokenInput, DopplerVaultOptions {
|
|
|
68
62
|
}
|
|
69
63
|
interface PluginContext {
|
|
70
64
|
options: DopplerPluginOptions;
|
|
71
|
-
|
|
65
|
+
client: DopplerClient;
|
|
72
66
|
}
|
|
73
67
|
declare function createContext(options: DopplerPluginOptions): PluginContext;
|
|
74
68
|
declare function vault(ctx: PluginContext): Vault;
|
|
@@ -84,4 +78,4 @@ declare function createPlugin(options: DopplerPluginOptions): {
|
|
|
84
78
|
*/
|
|
85
79
|
declare const AUTH_HINT: string;
|
|
86
80
|
//#endregion
|
|
87
|
-
export { AUTH_HINT, AuthError, DopplerPluginOptions, DopplerVault, PluginContext, type ResolveTokenInput, type VerifyTokenFailure, type VerifyTokenResult, type VerifyTokenSuccess, createContext,
|
|
81
|
+
export { AUTH_HINT, AuthError, DopplerPluginOptions, DopplerVault, PluginContext, type ResolveTokenInput, type VerifyTokenFailure, type VerifyTokenResult, type VerifyTokenSuccess, createContext, createDopplerClient, createPlugin, resolveToken, vault, verifyToken };
|
package/dist/index.mjs
CHANGED
|
@@ -1,4 +1,5 @@
|
|
|
1
|
-
import { AuthError, ProviderApiError, createResolveToken
|
|
1
|
+
import { AuthError, ProviderApiError, createResolveToken } from "@theholocron/cli";
|
|
2
|
+
import { createDopplerClient } from "@theholocron/doppler-client";
|
|
2
3
|
//#region src/auth.ts
|
|
3
4
|
const resolveToken = createResolveToken({
|
|
4
5
|
envName: "HOLOCRON_DOPPLER_TOKEN",
|
|
@@ -33,13 +34,13 @@ const resolveToken = createResolveToken({
|
|
|
33
34
|
* ProviderApiError with `status: 409` which we catch and swallow.
|
|
34
35
|
*/
|
|
35
36
|
var DopplerVault = class {
|
|
36
|
-
|
|
37
|
+
client;
|
|
37
38
|
key = "vault";
|
|
38
39
|
providerName = "doppler";
|
|
39
40
|
project;
|
|
40
41
|
config;
|
|
41
|
-
constructor(
|
|
42
|
-
this.
|
|
42
|
+
constructor(client, opts) {
|
|
43
|
+
this.client = client;
|
|
43
44
|
if (!opts.project) throw new Error("DopplerVault requires `project` in options");
|
|
44
45
|
if (!opts.config) throw new Error("DopplerVault requires `config` in options");
|
|
45
46
|
this.project = opts.project;
|
|
@@ -47,53 +48,29 @@ var DopplerVault = class {
|
|
|
47
48
|
}
|
|
48
49
|
async read(reference) {
|
|
49
50
|
const parsed = parseReference(reference);
|
|
50
|
-
const res = await this.
|
|
51
|
-
project: parsed.project,
|
|
52
|
-
config: parsed.config,
|
|
53
|
-
name: parsed.name
|
|
54
|
-
} });
|
|
51
|
+
const res = await this.client.secrets.get(parsed.project, parsed.config, parsed.name);
|
|
55
52
|
return res.value?.computed ?? res.value?.raw ?? "";
|
|
56
53
|
}
|
|
57
54
|
async write(reference, value) {
|
|
58
55
|
const parsed = parseReference(reference);
|
|
59
|
-
await this.
|
|
60
|
-
method: "POST",
|
|
61
|
-
body: {
|
|
62
|
-
project: parsed.project,
|
|
63
|
-
config: parsed.config,
|
|
64
|
-
secrets: { [parsed.name]: value }
|
|
65
|
-
}
|
|
66
|
-
});
|
|
56
|
+
await this.client.secrets.update(parsed.project, parsed.config, { [parsed.name]: value });
|
|
67
57
|
}
|
|
68
58
|
async list() {
|
|
69
|
-
const res = await this.
|
|
70
|
-
project: this.project,
|
|
71
|
-
config: this.config
|
|
72
|
-
} });
|
|
59
|
+
const res = await this.client.secrets.list(this.project, this.config);
|
|
73
60
|
return Object.keys(res.secrets ?? {});
|
|
74
61
|
}
|
|
75
62
|
async environments() {
|
|
76
|
-
return ((await this.
|
|
63
|
+
return ((await this.client.environments.list(this.project)).environments ?? []).map((e) => e.slug ?? e.name ?? "").filter(Boolean);
|
|
77
64
|
}
|
|
78
65
|
async readEnvironment(environmentId) {
|
|
79
|
-
const res = await this.
|
|
80
|
-
project: this.project,
|
|
81
|
-
config: environmentId,
|
|
82
|
-
format: "json"
|
|
83
|
-
} });
|
|
66
|
+
const res = await this.client.secrets.download(this.project, environmentId);
|
|
84
67
|
const out = {};
|
|
85
68
|
for (const [k, v] of Object.entries(res)) if (typeof v === "string") out[k] = v;
|
|
86
69
|
return out;
|
|
87
70
|
}
|
|
88
71
|
async ensureProject(name) {
|
|
89
72
|
try {
|
|
90
|
-
await this.
|
|
91
|
-
method: "POST",
|
|
92
|
-
body: {
|
|
93
|
-
name,
|
|
94
|
-
description: `Managed by holocron`
|
|
95
|
-
}
|
|
96
|
-
});
|
|
73
|
+
await this.client.projects.create(name, "Managed by holocron");
|
|
97
74
|
return { alreadyExists: false };
|
|
98
75
|
} catch (err) {
|
|
99
76
|
if (isConflict(err)) return { alreadyExists: true };
|
|
@@ -102,14 +79,7 @@ var DopplerVault = class {
|
|
|
102
79
|
}
|
|
103
80
|
async ensureEnvironment(project, name) {
|
|
104
81
|
try {
|
|
105
|
-
await this.
|
|
106
|
-
method: "POST",
|
|
107
|
-
body: {
|
|
108
|
-
project,
|
|
109
|
-
name,
|
|
110
|
-
slug: name
|
|
111
|
-
}
|
|
112
|
-
});
|
|
82
|
+
await this.client.environments.create(project, name, name);
|
|
113
83
|
return { alreadyExists: false };
|
|
114
84
|
} catch (err) {
|
|
115
85
|
if (isConflict(err)) return { alreadyExists: true };
|
|
@@ -156,16 +126,6 @@ function hasAlreadyExistsBody(details) {
|
|
|
156
126
|
return /already exists/i.test(details);
|
|
157
127
|
}
|
|
158
128
|
//#endregion
|
|
159
|
-
//#region src/rest.ts
|
|
160
|
-
function createDopplerRestClient(opts) {
|
|
161
|
-
return createRestClient({
|
|
162
|
-
baseUrl: opts.baseUrl ?? "https://api.doppler.com/v3",
|
|
163
|
-
token: opts.token,
|
|
164
|
-
vendor: "Doppler",
|
|
165
|
-
fetch: opts.fetch
|
|
166
|
-
});
|
|
167
|
-
}
|
|
168
|
-
//#endregion
|
|
169
129
|
//#region src/verify-token.ts
|
|
170
130
|
/**
|
|
171
131
|
* `verifyToken` — plugin-level export used by `holocron auth set` +
|
|
@@ -178,13 +138,13 @@ function createDopplerRestClient(opts) {
|
|
|
178
138
|
* what we don't have yet at bootstrap time.
|
|
179
139
|
*/
|
|
180
140
|
async function verifyToken(token, opts = {}) {
|
|
181
|
-
const
|
|
141
|
+
const client = createDopplerClient({
|
|
182
142
|
token,
|
|
183
143
|
baseUrl: opts.baseUrl,
|
|
184
144
|
fetch: opts.fetch
|
|
185
145
|
});
|
|
186
146
|
try {
|
|
187
|
-
const me = await
|
|
147
|
+
const me = await client.me.get();
|
|
188
148
|
const workplace = me.workplace?.name ?? me.slug ?? "unknown";
|
|
189
149
|
return {
|
|
190
150
|
ok: true,
|
|
@@ -202,7 +162,7 @@ async function verifyToken(token, opts = {}) {
|
|
|
202
162
|
function createContext(options) {
|
|
203
163
|
return {
|
|
204
164
|
options,
|
|
205
|
-
|
|
165
|
+
client: createDopplerClient({
|
|
206
166
|
token: resolveToken(options),
|
|
207
167
|
baseUrl: options.baseUrl,
|
|
208
168
|
fetch: options.fetch
|
|
@@ -210,7 +170,7 @@ function createContext(options) {
|
|
|
210
170
|
};
|
|
211
171
|
}
|
|
212
172
|
function vault(ctx) {
|
|
213
|
-
return new DopplerVault(ctx.
|
|
173
|
+
return new DopplerVault(ctx.client, {
|
|
214
174
|
project: ctx.options.project,
|
|
215
175
|
config: ctx.options.config
|
|
216
176
|
});
|
|
@@ -228,4 +188,4 @@ function createPlugin(options) {
|
|
|
228
188
|
*/
|
|
229
189
|
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)`";
|
|
230
190
|
//#endregion
|
|
231
|
-
export { AUTH_HINT, AuthError, DopplerVault, createContext,
|
|
191
|
+
export { AUTH_HINT, AuthError, DopplerVault, createContext, createDopplerClient, createPlugin, resolveToken, vault, verifyToken };
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@theholocron/holocron-plugin-doppler",
|
|
3
|
-
"version": "2.0.0-alpha.
|
|
3
|
+
"version": "2.0.0-alpha.48",
|
|
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
|
"homepage": "https://github.com/theholocron/holocron/tree/main/packages/holocron-plugin-doppler#readme",
|
|
6
6
|
"bugs": "https://github.com/theholocron/holocron/issues",
|
|
@@ -21,9 +21,11 @@
|
|
|
21
21
|
}
|
|
22
22
|
},
|
|
23
23
|
"peerDependencies": {
|
|
24
|
-
"@theholocron/
|
|
24
|
+
"@theholocron/doppler-client": "^0.6.2",
|
|
25
|
+
"@theholocron/cli": "2.0.0-alpha.48"
|
|
25
26
|
},
|
|
26
27
|
"devDependencies": {
|
|
28
|
+
"@theholocron/doppler-client": "^0.6.2",
|
|
27
29
|
"@types/node": "^26",
|
|
28
30
|
"@theholocron/eslint-config": "^5.2.0",
|
|
29
31
|
"@theholocron/tsconfig": "^6.0.0",
|
|
@@ -37,7 +39,7 @@
|
|
|
37
39
|
"tsx": "^4.22.4",
|
|
38
40
|
"typescript": "^5.9.3",
|
|
39
41
|
"vitest": "^4.1.10",
|
|
40
|
-
"@theholocron/cli": "2.0.0-alpha.
|
|
42
|
+
"@theholocron/cli": "2.0.0-alpha.48"
|
|
41
43
|
},
|
|
42
44
|
"publishConfig": {
|
|
43
45
|
"access": "public"
|