puter-cli 1.0.3 → 1.1.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/commands/auth.js +31 -1
- package/package.json +1 -1
package/commands/auth.js
CHANGED
|
@@ -40,7 +40,37 @@ export async function login() {
|
|
|
40
40
|
})
|
|
41
41
|
});
|
|
42
42
|
|
|
43
|
-
|
|
43
|
+
let data = await response.json();
|
|
44
|
+
|
|
45
|
+
while ( data.proceed && data.next_step ) {
|
|
46
|
+
if ( data.next_step === 'otp') {
|
|
47
|
+
spinner.succeed(chalk.green('2FA is enabled'));
|
|
48
|
+
const answers = await inquirer.prompt([
|
|
49
|
+
{
|
|
50
|
+
type: 'input',
|
|
51
|
+
name: 'otp',
|
|
52
|
+
message: 'Authenticator Code:',
|
|
53
|
+
validate: input => input.length === 6 || 'OTP must be 6 digits'
|
|
54
|
+
}
|
|
55
|
+
]);
|
|
56
|
+
spinner = ora('Logging in to Puter...').start();
|
|
57
|
+
const response = await fetch(`${BASE_URL}/login/otp`, {
|
|
58
|
+
method: 'POST',
|
|
59
|
+
headers: getHeaders(),
|
|
60
|
+
body: JSON.stringify({
|
|
61
|
+
token: data.otp_jwt_token,
|
|
62
|
+
code: answers.otp,
|
|
63
|
+
}),
|
|
64
|
+
});
|
|
65
|
+
data = await response.json();
|
|
66
|
+
continue;
|
|
67
|
+
}
|
|
68
|
+
|
|
69
|
+
if ( data.next_step === 'complete' ) break;
|
|
70
|
+
|
|
71
|
+
spinner.fail(chalk.red(`Unrecognized login step "${data.next_step}"; you might need to update puter-cli.`));
|
|
72
|
+
return;
|
|
73
|
+
}
|
|
44
74
|
|
|
45
75
|
if (data.proceed && data.token) {
|
|
46
76
|
config.set('auth_token', data.token);
|