@theholocron/holocron-plugin-doppler 5.0.0-alpha.506 → 5.0.0-alpha.508
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 +13 -1
- package/dist/index.mjs +72 -0
- package/package.json +8 -8
package/dist/index.d.mts
CHANGED
|
@@ -5,7 +5,7 @@
|
|
|
5
5
|
* exports `verifyToken` + `AUTH_HINT` for `holocron check token`. See README
|
|
6
6
|
* for auth + config docs.
|
|
7
7
|
*/
|
|
8
|
-
import { AuthError, EnsureResult, PluginToken, ResolveTokenInput, Vault, VerifyTokenFailure, VerifyTokenResult, VerifyTokenResult as VerifyTokenResult$1, VerifyTokenSuccess } from "@theholocron/cli";
|
|
8
|
+
import { AuthError, EnsureRelaySourceInput, EnsureRelaySourceResult, EnsureResult, InspectRelaySourceInput, PluginToken, RelaySourceState, ResolveTokenInput, Vault, VerifyTokenFailure, VerifyTokenResult, VerifyTokenResult as VerifyTokenResult$1, VerifyTokenSuccess } from "@theholocron/cli";
|
|
9
9
|
import { DopplerClient, DopplerClientOptions, createDopplerClient } from "@theholocron/doppler-client";
|
|
10
10
|
/** Resolves the Doppler token from `--token`, `HOLOCRON_DOPPLER_TOKEN`, `DOPPLER_TOKEN` or the keyring entry for `doppler`, and throws `AuthError` when none is set. */
|
|
11
11
|
export declare const resolveToken: import("@theholocron/cli").TokenResolver;
|
|
@@ -33,6 +33,18 @@ export declare class DopplerVault implements Vault {
|
|
|
33
33
|
list(): Promise<string[]>;
|
|
34
34
|
environments(): Promise<string[]>;
|
|
35
35
|
readEnvironment(environmentId: string): Promise<Record<string, string>>;
|
|
36
|
+
/**
|
|
37
|
+
* Make the Doppler webhook for a relay source, found again by its URL in the project (`options.project`, else the
|
|
38
|
+
* vault's). `scope` is the config slugs it applies to; `events` has no meaning here (a Doppler webhook is sent on
|
|
39
|
+
* secret changes) and is ignored. The secret in the input is the signing secret and is sent only on create; Doppler
|
|
40
|
+
* never returns it. An existing webhook is adopted unchanged: no update call is made, `inspectRelaySource` reports
|
|
41
|
+
* a difference. Doppler does not document which token type may manage webhooks, so a 401/403 is a `todo`.
|
|
42
|
+
*/
|
|
43
|
+
ensureRelaySource(input: EnsureRelaySourceInput): Promise<EnsureRelaySourceResult>;
|
|
44
|
+
/** Read the webhook back by URL: whether it exists, is enabled, covers every declared config and has a secret. */
|
|
45
|
+
inspectRelaySource(input: InspectRelaySourceInput): Promise<RelaySourceState>;
|
|
46
|
+
private relayProject;
|
|
47
|
+
private findWebhook;
|
|
36
48
|
ensureProject(name: string): Promise<EnsureResult>;
|
|
37
49
|
ensureEnvironment(project: string, name: string): Promise<EnsureResult>;
|
|
38
50
|
}
|
package/dist/index.mjs
CHANGED
|
@@ -69,6 +69,71 @@ var DopplerVault = class {
|
|
|
69
69
|
for (const [k, v] of Object.entries(res)) if (typeof v === "string" && !DOPPLER_INJECTED_KEYS.has(k)) out[k] = v;
|
|
70
70
|
return out;
|
|
71
71
|
}
|
|
72
|
+
/**
|
|
73
|
+
* Make the Doppler webhook for a relay source, found again by its URL in the project (`options.project`, else the
|
|
74
|
+
* vault's). `scope` is the config slugs it applies to; `events` has no meaning here (a Doppler webhook is sent on
|
|
75
|
+
* secret changes) and is ignored. The secret in the input is the signing secret and is sent only on create; Doppler
|
|
76
|
+
* never returns it. An existing webhook is adopted unchanged: no update call is made, `inspectRelaySource` reports
|
|
77
|
+
* a difference. Doppler does not document which token type may manage webhooks, so a 401/403 is a `todo`.
|
|
78
|
+
*/
|
|
79
|
+
async ensureRelaySource(input) {
|
|
80
|
+
const project = this.relayProject(input);
|
|
81
|
+
let found;
|
|
82
|
+
try {
|
|
83
|
+
found = await this.findWebhook(project, input.url);
|
|
84
|
+
} catch (err) {
|
|
85
|
+
const todo = webhookAccessTodo(err, project);
|
|
86
|
+
if (todo) return {
|
|
87
|
+
created: false,
|
|
88
|
+
updated: [],
|
|
89
|
+
todo: [todo]
|
|
90
|
+
};
|
|
91
|
+
throw err;
|
|
92
|
+
}
|
|
93
|
+
if (found) return {
|
|
94
|
+
created: false,
|
|
95
|
+
updated: []
|
|
96
|
+
};
|
|
97
|
+
try {
|
|
98
|
+
await this.client().webhooks.create(project, {
|
|
99
|
+
url: input.url,
|
|
100
|
+
name: input.name,
|
|
101
|
+
...input.secret ? { secret: input.secret } : {},
|
|
102
|
+
...input.scope ? { enableConfigs: input.scope } : {}
|
|
103
|
+
});
|
|
104
|
+
} catch (err) {
|
|
105
|
+
const todo = webhookAccessTodo(err, project);
|
|
106
|
+
if (todo) return {
|
|
107
|
+
created: false,
|
|
108
|
+
updated: [],
|
|
109
|
+
todo: [todo]
|
|
110
|
+
};
|
|
111
|
+
throw err;
|
|
112
|
+
}
|
|
113
|
+
return {
|
|
114
|
+
created: true,
|
|
115
|
+
updated: [],
|
|
116
|
+
...input.secret ? { secret: input.secret } : {}
|
|
117
|
+
};
|
|
118
|
+
}
|
|
119
|
+
/** Read the webhook back by URL: whether it exists, is enabled, covers every declared config and has a secret. */
|
|
120
|
+
async inspectRelaySource(input) {
|
|
121
|
+
const found = await this.findWebhook(this.relayProject(input), input.url);
|
|
122
|
+
if (!found) return { exists: false };
|
|
123
|
+
return {
|
|
124
|
+
exists: true,
|
|
125
|
+
...found.enabled !== void 0 ? { enabled: found.enabled } : {},
|
|
126
|
+
...found.enabledConfigs ? { scope: found.enabledConfigs } : {},
|
|
127
|
+
...found.hasSecret !== void 0 ? { hasSecret: found.hasSecret } : {}
|
|
128
|
+
};
|
|
129
|
+
}
|
|
130
|
+
relayProject(input) {
|
|
131
|
+
const project = input.options?.project;
|
|
132
|
+
return typeof project === "string" && project ? project : this.project;
|
|
133
|
+
}
|
|
134
|
+
async findWebhook(project, url) {
|
|
135
|
+
return ((await this.client().webhooks.list(project)).webhooks ?? []).find((w) => w.url === url);
|
|
136
|
+
}
|
|
72
137
|
async ensureProject(name) {
|
|
73
138
|
try {
|
|
74
139
|
await this.client().projects.create(name, "Managed by holocron");
|
|
@@ -105,6 +170,13 @@ function parseReference(reference) {
|
|
|
105
170
|
};
|
|
106
171
|
}
|
|
107
172
|
/**
|
|
173
|
+
* A refused webhook call as a step for a person. Doppler's reference does not say which token type may manage
|
|
174
|
+
* webhooks (a service token is limited to one config's secrets), so a refusal names what to try, never a guess.
|
|
175
|
+
*/
|
|
176
|
+
function webhookAccessTodo(err, project) {
|
|
177
|
+
if (err instanceof ProviderApiError && (err.status === 401 || err.status === 403)) return `Doppler refused the webhook call for project ${project}: use a token that can manage the project's webhooks (a personal token of a member who can, not a config-scoped service token), or add the webhook in the project's Webhooks page and set the secret yourself`;
|
|
178
|
+
}
|
|
179
|
+
/**
|
|
108
180
|
* Doppler returns duplicate-create errors inconsistently across
|
|
109
181
|
* endpoints:
|
|
110
182
|
*
|
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.508",
|
|
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",
|
|
@@ -40,19 +40,19 @@
|
|
|
40
40
|
"tsx": "4.23.15",
|
|
41
41
|
"typescript": "^5.9.3",
|
|
42
42
|
"vitest": "^5.1.0",
|
|
43
|
-
"@theholocron/cli": "5.0.0-alpha.
|
|
44
|
-
"@theholocron/
|
|
45
|
-
"@theholocron/http-client": "^1.58.0-alpha.
|
|
43
|
+
"@theholocron/cli": "5.0.0-alpha.508",
|
|
44
|
+
"@theholocron/doppler-client": "^1.58.0-alpha.47",
|
|
45
|
+
"@theholocron/http-client": "^1.58.0-alpha.47",
|
|
46
|
+
"@theholocron/tsconfig": "^8.9.0-alpha.21",
|
|
46
47
|
"@theholocron/eslint-config": "^8.9.0-alpha.21",
|
|
48
|
+
"@theholocron/tsdown-config": "^8.9.0-alpha.21",
|
|
47
49
|
"@theholocron/vitest-config": "^8.9.0-alpha.21",
|
|
48
|
-
"@theholocron/misc-utils": "^1.17.0-alpha.5"
|
|
49
|
-
"@theholocron/doppler-client": "^1.58.0-alpha.46",
|
|
50
|
-
"@theholocron/tsconfig": "^8.9.0-alpha.21"
|
|
50
|
+
"@theholocron/misc-utils": "^1.17.0-alpha.5"
|
|
51
51
|
},
|
|
52
52
|
"peerDependencies": {
|
|
53
53
|
"@theholocron/doppler-client": "^1.43.1",
|
|
54
54
|
"@theholocron/misc-utils": "^1.16.0",
|
|
55
|
-
"@theholocron/cli": "5.0.0-alpha.
|
|
55
|
+
"@theholocron/cli": "5.0.0-alpha.508"
|
|
56
56
|
},
|
|
57
57
|
"engines": {
|
|
58
58
|
"node": ">=22"
|