@yadurajfleetos/cli 0.1.1 → 0.1.3
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/api.js +1 -1
- package/dist/commands/auth.js +16 -2
- package/package.json +1 -1
package/dist/api.js
CHANGED
|
@@ -35,7 +35,7 @@ export async function request(method, path, opts = {}) {
|
|
|
35
35
|
});
|
|
36
36
|
let res;
|
|
37
37
|
try {
|
|
38
|
-
res = await send(profile.accessToken);
|
|
38
|
+
res = await send(opts.auth === false ? undefined : profile.accessToken);
|
|
39
39
|
}
|
|
40
40
|
catch (err) {
|
|
41
41
|
throw new CliError(`Could not reach ${profile.api}. Is the control plane running?\n ${String(err)}`, EXIT.failure);
|
package/dist/commands/auth.js
CHANGED
|
@@ -189,8 +189,22 @@ export const authCommand = {
|
|
|
189
189
|
authData = await task('verifying credentials', async () => (await request('POST', '/auth/login', { body: { email, password }, auth: false, profile })).body, { hints: ['the control plane never stores your password in this CLI'] });
|
|
190
190
|
}
|
|
191
191
|
else {
|
|
192
|
-
// Default: Modern Browser Web OAuth Login
|
|
193
|
-
|
|
192
|
+
// Default: Modern Browser Web OAuth Login with fallback for older control planes
|
|
193
|
+
try {
|
|
194
|
+
authData = await browserAuth(profile);
|
|
195
|
+
}
|
|
196
|
+
catch (err) {
|
|
197
|
+
const isNotFound = err instanceof CliError && /no route|not found|404/i.test(err.message);
|
|
198
|
+
if (isNotFound) {
|
|
199
|
+
console.log(c.dim(' (control plane does not support browser auth — using terminal login)\n'));
|
|
200
|
+
const email = await requiredPrompt('email');
|
|
201
|
+
const password = await requiredPrompt('password', { silent: true, hint: 'Password is hidden while you type.' });
|
|
202
|
+
authData = await task('verifying credentials', async () => (await request('POST', '/auth/login', { body: { email, password }, auth: false, profile })).body, { hints: ['the control plane never stores your password in this CLI'] });
|
|
203
|
+
}
|
|
204
|
+
else {
|
|
205
|
+
throw err;
|
|
206
|
+
}
|
|
207
|
+
}
|
|
194
208
|
}
|
|
195
209
|
await saveProfile({
|
|
196
210
|
...profile,
|