@solidactions/cli 3.8.0 → 3.9.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.
|
@@ -16,13 +16,46 @@ const login_1 = require("./login");
|
|
|
16
16
|
const CLI_OAUTH_CLIENT_ID = '9f1b6e2a-9c1e-4b6e-8f0a-6c9f2b1e7d4c';
|
|
17
17
|
// CLI capability scopes requested at device-code issuance — the server
|
|
18
18
|
// rejects any scope not pre-registered via Passport::tokensCan().
|
|
19
|
-
|
|
19
|
+
//
|
|
20
|
+
// `env:reveal` is REQUESTED here but not necessarily GRANTED: the consent
|
|
21
|
+
// screen renders it as a default-off checkbox, and the server strips it from
|
|
22
|
+
// the issued token unless the user ticks it. Requesting it is what makes the
|
|
23
|
+
// opt-in reachable at all — a scope absent from this string can never be
|
|
24
|
+
// added at consent time, because the device code's scope set is frozen when
|
|
25
|
+
// the code is created (#1252).
|
|
26
|
+
const CLI_SCOPES_WITH_REVEAL = 'env env:reveal deploy runs docs databases';
|
|
27
|
+
// Pre-#1252 scope list, kept as the fallback for servers that haven't
|
|
28
|
+
// registered `env:reveal` yet (older production, a lagging staging, a
|
|
29
|
+
// self-hosted install). Passport rejects the entire device-code request with
|
|
30
|
+
// `invalid_scope` if ANY requested scope is unregistered, so requesting
|
|
31
|
+
// `env:reveal` unconditionally would hard-break device login everywhere
|
|
32
|
+
// until every server picks up the companion change.
|
|
33
|
+
const CLI_SCOPES_LEGACY = 'env deploy runs docs databases';
|
|
34
|
+
/**
|
|
35
|
+
* Request a device code with the full (env:reveal-including) scope list. If
|
|
36
|
+
* the server doesn't yet recognize `env:reveal` it rejects the whole request
|
|
37
|
+
* with 400 `invalid_scope` — retry once with the legacy scope list so login
|
|
38
|
+
* still succeeds. Any other rejection (e.g. a bad client_id) still fails
|
|
39
|
+
* loudly; only this specific, detectable condition is swallowed.
|
|
40
|
+
*/
|
|
20
41
|
async function requestDeviceCode(host) {
|
|
21
|
-
|
|
22
|
-
|
|
23
|
-
|
|
24
|
-
|
|
25
|
-
|
|
42
|
+
try {
|
|
43
|
+
const response = await axios_1.default.post(`${host}/oauth/device/code`, {
|
|
44
|
+
client_id: CLI_OAUTH_CLIENT_ID,
|
|
45
|
+
scope: CLI_SCOPES_WITH_REVEAL,
|
|
46
|
+
});
|
|
47
|
+
return response.data;
|
|
48
|
+
}
|
|
49
|
+
catch (e) {
|
|
50
|
+
if (e?.response?.status === 400 && e.response.data?.error === 'invalid_scope') {
|
|
51
|
+
const response = await axios_1.default.post(`${host}/oauth/device/code`, {
|
|
52
|
+
client_id: CLI_OAUTH_CLIENT_ID,
|
|
53
|
+
scope: CLI_SCOPES_LEGACY,
|
|
54
|
+
});
|
|
55
|
+
return response.data;
|
|
56
|
+
}
|
|
57
|
+
throw e;
|
|
58
|
+
}
|
|
26
59
|
}
|
|
27
60
|
function sleep(ms) {
|
|
28
61
|
return new Promise((resolve) => setTimeout(resolve, ms));
|
|
@@ -213,6 +213,17 @@ async function envPull(projectName, options = {}) {
|
|
|
213
213
|
console.log(chalk_1.default.gray(`Try deploying with: solidactions project deploy ${projectName} -e ${environment} --create`));
|
|
214
214
|
}
|
|
215
215
|
}
|
|
216
|
+
else if (error.response.status === 403) {
|
|
217
|
+
// Only the reveal step is named as the culprit — a 403 here can
|
|
218
|
+
// also be a workspace-scope or project-policy denial, and
|
|
219
|
+
// blaming env:reveal for those sends the user to the wrong fix.
|
|
220
|
+
const detail = typeof error.response.data?.message === 'string' ? error.response.data.message : undefined;
|
|
221
|
+
const needsReveal = error.response.data?.required_ability === 'env:reveal';
|
|
222
|
+
const lead = needsReveal
|
|
223
|
+
? "Reading variable values requires the 'env:reveal' ability."
|
|
224
|
+
: 'Permission denied.';
|
|
225
|
+
console.error(chalk_1.default.red(detail ? `${lead}\n\n${detail}` : lead));
|
|
226
|
+
}
|
|
216
227
|
else {
|
|
217
228
|
console.error(chalk_1.default.red(`Failed: ${error.response.status}`), error.response.data);
|
|
218
229
|
}
|
package/dist/commands/env-set.js
CHANGED
|
@@ -81,9 +81,13 @@ async function envSet(keyOrProject, valueOrKey, valueIfProject, options = {}) {
|
|
|
81
81
|
`in project "${projectName}" (${environment}).`));
|
|
82
82
|
return;
|
|
83
83
|
}
|
|
84
|
-
// Check if variable already has a value
|
|
84
|
+
// Check if variable already has a value. Deliberately do NOT pass
|
|
85
|
+
// reveal=true: this only reads `existing.has_value` (returned
|
|
86
|
+
// unconditionally by the mappings projection), never the
|
|
87
|
+
// plaintext value, so requesting reveal would force every write
|
|
88
|
+
// to also carry the env:reveal ability it doesn't need (#1252).
|
|
85
89
|
if (!options.yes) {
|
|
86
|
-
const mappingsResponse = await axios_1.default.get(`${config.host}/api/v1/projects/${projectSlug}/variable-mappings
|
|
90
|
+
const mappingsResponse = await axios_1.default.get(`${config.host}/api/v1/projects/${projectSlug}/variable-mappings`, { headers: (0, api_1.getApiHeaders)(config) });
|
|
87
91
|
const mappings = mappingsResponse.data || [];
|
|
88
92
|
const existing = mappings.find((m) => m.env_name === key);
|
|
89
93
|
if (existing && existing.has_value) {
|
package/dist/utils/api.js
CHANGED
|
@@ -156,6 +156,21 @@ function augmentTokenMissingAbilityMessage(error) {
|
|
|
156
156
|
response.data.message = `${message}\n\n${hint}`;
|
|
157
157
|
}
|
|
158
158
|
}
|
|
159
|
+
const isEnvRevealAbility = requiredAbility === 'env:reveal';
|
|
160
|
+
if (response?.status === 403
|
|
161
|
+
&& response.data?.code === 'token_missing_ability'
|
|
162
|
+
&& isEnvRevealAbility) {
|
|
163
|
+
const hint = "The 'env:reveal' ability grants plaintext disclosure of secret values. "
|
|
164
|
+
+ 'Re-run `solidactions login --device` and tick "Reveal secret values" on the consent screen, '
|
|
165
|
+
+ 'or create an API key with the \'env:reveal\' ability checked at Settings → API keys '
|
|
166
|
+
+ 'and `solidactions login` with that key.';
|
|
167
|
+
const message = typeof response.data.message === 'string' && response.data.message.length > 0
|
|
168
|
+
? response.data.message
|
|
169
|
+
: "This session does not have the 'env:reveal' ability.";
|
|
170
|
+
if (!message.includes('Settings → API keys')) {
|
|
171
|
+
response.data.message = `${message}\n\n${hint}`;
|
|
172
|
+
}
|
|
173
|
+
}
|
|
159
174
|
return error;
|
|
160
175
|
}
|
|
161
176
|
axios_1.default.interceptors.response.use((response) => response, (error) => Promise.reject(augmentTokenMissingAbilityMessage(augmentWorkspaceForbiddenMessage(augmentNotFoundMessage(augmentSandboxEgressMessage(error))))));
|