avo 3.3.1 → 3.4.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.
- package/cli.js +46 -4
- package/package.json +3 -3
package/cli.js
CHANGED
|
@@ -1434,11 +1434,44 @@ function _respondWithRedirect(req, res, Location) {
|
|
|
1434
1434
|
resolve();
|
|
1435
1435
|
});
|
|
1436
1436
|
}
|
|
1437
|
+
function _extractAuthorizationCode(codeOrUrl) {
|
|
1438
|
+
const input = codeOrUrl.trim();
|
|
1439
|
+
if (!input) {
|
|
1440
|
+
return input;
|
|
1441
|
+
}
|
|
1442
|
+
try {
|
|
1443
|
+
const parsedUrl = new URL(input);
|
|
1444
|
+
const code = parsedUrl.searchParams.get('code');
|
|
1445
|
+
if (code) {
|
|
1446
|
+
return code.trim();
|
|
1447
|
+
}
|
|
1448
|
+
}
|
|
1449
|
+
catch {
|
|
1450
|
+
// Not a full URL, fall back to parsing possible query-like input.
|
|
1451
|
+
}
|
|
1452
|
+
const query = input.includes('?')
|
|
1453
|
+
? input.split('?').slice(1).join('?')
|
|
1454
|
+
: input;
|
|
1455
|
+
const code = new URLSearchParams(query).get('code');
|
|
1456
|
+
return code ? code.trim() : input;
|
|
1457
|
+
}
|
|
1437
1458
|
function _loginWithoutLocalhost() {
|
|
1438
1459
|
const callbackUrl = _getCallbackUrl();
|
|
1439
1460
|
const authUrl = _getLoginUrl(callbackUrl);
|
|
1440
1461
|
report.info(`Visit this URL on any device to login: ${new URL(authUrl)}`);
|
|
1441
|
-
|
|
1462
|
+
open(authUrl);
|
|
1463
|
+
return inquirer
|
|
1464
|
+
.prompt([
|
|
1465
|
+
{
|
|
1466
|
+
type: 'input',
|
|
1467
|
+
name: 'codeOrUrl',
|
|
1468
|
+
message: 'Paste full redirect URL or code (value after code=):',
|
|
1469
|
+
},
|
|
1470
|
+
])
|
|
1471
|
+
.then((answers) => _getTokensFromAuthorizationCode(_extractAuthorizationCode(answers.codeOrUrl), callbackUrl).then((tokens) => ({
|
|
1472
|
+
user: jwt.decode(tokens.idToken),
|
|
1473
|
+
tokens,
|
|
1474
|
+
})));
|
|
1442
1475
|
}
|
|
1443
1476
|
function _loginWithLocalhost(port) {
|
|
1444
1477
|
return new Promise((resolve, reject) => {
|
|
@@ -1476,7 +1509,10 @@ function _loginWithLocalhost(port) {
|
|
|
1476
1509
|
});
|
|
1477
1510
|
});
|
|
1478
1511
|
}
|
|
1479
|
-
function login() {
|
|
1512
|
+
function login(forceManual = false) {
|
|
1513
|
+
if (forceManual) {
|
|
1514
|
+
return _loginWithoutLocalhost();
|
|
1515
|
+
}
|
|
1480
1516
|
return _getPort().then(_loginWithLocalhost, _loginWithoutLocalhost);
|
|
1481
1517
|
}
|
|
1482
1518
|
function logout(refreshToken) {
|
|
@@ -2044,14 +2080,20 @@ if (isMainModule) {
|
|
|
2044
2080
|
.command({
|
|
2045
2081
|
command: 'login',
|
|
2046
2082
|
describe: 'Log into the Avo platform',
|
|
2047
|
-
|
|
2083
|
+
builder: (yargs) => yargs.option('force-manual', {
|
|
2084
|
+
alias: 'm',
|
|
2085
|
+
describe: 'Force manual login (copy-paste code)',
|
|
2086
|
+
type: 'boolean',
|
|
2087
|
+
default: false,
|
|
2088
|
+
}),
|
|
2089
|
+
handler: (argv) => {
|
|
2048
2090
|
const command = () => {
|
|
2049
2091
|
const user = conf.get('user');
|
|
2050
2092
|
if (user) {
|
|
2051
2093
|
report.info(`Already logged in as ${email(user.email)}`);
|
|
2052
2094
|
return;
|
|
2053
2095
|
}
|
|
2054
|
-
login()
|
|
2096
|
+
login(argv.forceManual)
|
|
2055
2097
|
.then((result) => {
|
|
2056
2098
|
conf.set('user', result.user);
|
|
2057
2099
|
conf.set('tokens', result.tokens);
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "avo",
|
|
3
|
-
"version": "3.
|
|
3
|
+
"version": "3.4.0",
|
|
4
4
|
"type": "module",
|
|
5
5
|
"description": "The command-line interface for Avo",
|
|
6
6
|
"author": "Avo (https://www.avo.app)",
|
|
@@ -37,7 +37,7 @@
|
|
|
37
37
|
"got": "^12.1.0",
|
|
38
38
|
"http-shutdown": "^1.2.0",
|
|
39
39
|
"ignore-walk": "^5.0.1",
|
|
40
|
-
"inquirer": "
|
|
40
|
+
"inquirer": "8.2.6",
|
|
41
41
|
"inquirer-fuzzy-path": "^2.3.0",
|
|
42
42
|
"jsonwebtoken": "^9.0.3",
|
|
43
43
|
"load-json-file": "^7.0.1",
|
|
@@ -59,7 +59,7 @@
|
|
|
59
59
|
"@types/ignore-walk": "^4.0.0",
|
|
60
60
|
"@types/jest": "^29.5.14",
|
|
61
61
|
"@types/minimatch": "^5.1.2",
|
|
62
|
-
"@types/node": "^
|
|
62
|
+
"@types/node": "^25.3.0",
|
|
63
63
|
"@typescript-eslint/eslint-plugin": "^5.30.5",
|
|
64
64
|
"@typescript-eslint/parser": "^5.30.5",
|
|
65
65
|
"eslint": "^7.32.0 || ^8.2.0",
|