@gopherhole/cli 0.1.21 → 0.1.22
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.js +37 -53
- package/package.json +1 -1
- package/src/index.ts +41 -53
package/dist/index.js
CHANGED
|
@@ -895,62 +895,46 @@ ${chalk_1.default.bold('Example:')}
|
|
|
895
895
|
// Check if logged in
|
|
896
896
|
if (!sessionId) {
|
|
897
897
|
console.log(chalk_1.default.yellow('Not logged in yet.\n'));
|
|
898
|
-
|
|
899
|
-
|
|
900
|
-
|
|
901
|
-
name: 'action',
|
|
902
|
-
message: 'Choose:',
|
|
903
|
-
choices: [
|
|
904
|
-
{ name: 'Create account', value: 'signup' },
|
|
905
|
-
{ name: 'Log in', value: 'login' },
|
|
906
|
-
],
|
|
907
|
-
},
|
|
898
|
+
// OTP-based auth flow
|
|
899
|
+
const { email } = await inquirer_1.default.prompt([
|
|
900
|
+
{ type: 'input', name: 'email', message: 'Email:', validate: (v) => v.includes('@') || 'Enter a valid email' },
|
|
908
901
|
]);
|
|
909
|
-
|
|
910
|
-
|
|
911
|
-
|
|
912
|
-
|
|
913
|
-
|
|
914
|
-
|
|
915
|
-
|
|
916
|
-
const
|
|
917
|
-
|
|
918
|
-
|
|
919
|
-
body: JSON.stringify({ name, email, password }),
|
|
920
|
-
});
|
|
921
|
-
if (!res.ok) {
|
|
922
|
-
spinner.fail('Signup failed');
|
|
923
|
-
process.exit(1);
|
|
924
|
-
}
|
|
925
|
-
const data = await res.json();
|
|
926
|
-
config.set('sessionId', data.sessionId);
|
|
927
|
-
config.set('user', data.user);
|
|
928
|
-
config.set('tenant', data.tenant);
|
|
929
|
-
sessionId = data.sessionId;
|
|
930
|
-
spinner.succeed('Account created!');
|
|
902
|
+
let spinner = (0, ora_1.default)('Sending verification code...').start();
|
|
903
|
+
const sendRes = await fetch(`${API_URL}/auth/send-code`, {
|
|
904
|
+
method: 'POST',
|
|
905
|
+
headers: { 'Content-Type': 'application/json' },
|
|
906
|
+
body: JSON.stringify({ email }),
|
|
907
|
+
});
|
|
908
|
+
if (!sendRes.ok) {
|
|
909
|
+
const err = await sendRes.json().catch(() => ({}));
|
|
910
|
+
spinner.fail(err.error || 'Failed to send code');
|
|
911
|
+
process.exit(1);
|
|
931
912
|
}
|
|
932
|
-
|
|
933
|
-
|
|
934
|
-
|
|
935
|
-
|
|
936
|
-
|
|
937
|
-
|
|
938
|
-
|
|
939
|
-
|
|
940
|
-
|
|
941
|
-
|
|
942
|
-
|
|
943
|
-
|
|
944
|
-
|
|
945
|
-
|
|
946
|
-
|
|
947
|
-
const
|
|
948
|
-
|
|
949
|
-
|
|
950
|
-
config.set('tenant', data.tenant);
|
|
951
|
-
sessionId = data.sessionId;
|
|
952
|
-
spinner.succeed('Logged in!');
|
|
913
|
+
const sendData = await sendRes.json();
|
|
914
|
+
spinner.succeed('Code sent! Check your email.');
|
|
915
|
+
if (sendData.isNewUser) {
|
|
916
|
+
console.log(chalk_1.default.gray(' No account found - we\'ll create one for you.\n'));
|
|
917
|
+
}
|
|
918
|
+
const { code } = await inquirer_1.default.prompt([
|
|
919
|
+
{ type: 'input', name: 'code', message: 'Enter 6-digit code:', validate: (v) => /^\d{6}$/.test(v) || 'Enter 6 digits' },
|
|
920
|
+
]);
|
|
921
|
+
spinner = (0, ora_1.default)('Verifying...').start();
|
|
922
|
+
const verifyRes = await fetch(`${API_URL}/auth/verify-code`, {
|
|
923
|
+
method: 'POST',
|
|
924
|
+
headers: { 'Content-Type': 'application/json' },
|
|
925
|
+
body: JSON.stringify({ email, code }),
|
|
926
|
+
});
|
|
927
|
+
if (!verifyRes.ok) {
|
|
928
|
+
const err = await verifyRes.json().catch(() => ({}));
|
|
929
|
+
spinner.fail(err.error || 'Verification failed');
|
|
930
|
+
process.exit(1);
|
|
953
931
|
}
|
|
932
|
+
const data = await verifyRes.json();
|
|
933
|
+
config.set('sessionId', data.sessionId);
|
|
934
|
+
config.set('user', data.user);
|
|
935
|
+
config.set('tenant', data.tenant);
|
|
936
|
+
sessionId = data.sessionId;
|
|
937
|
+
spinner.succeed(data.isNewUser ? 'Account created!' : 'Logged in!');
|
|
954
938
|
}
|
|
955
939
|
console.log('');
|
|
956
940
|
// Create agent
|
package/package.json
CHANGED
package/src/index.ts
CHANGED
|
@@ -999,68 +999,56 @@ ${chalk.bold('Example:')}
|
|
|
999
999
|
if (!sessionId) {
|
|
1000
1000
|
console.log(chalk.yellow('Not logged in yet.\n'));
|
|
1001
1001
|
|
|
1002
|
-
|
|
1003
|
-
|
|
1004
|
-
|
|
1005
|
-
name: 'action',
|
|
1006
|
-
message: 'Choose:',
|
|
1007
|
-
choices: [
|
|
1008
|
-
{ name: 'Create account', value: 'signup' },
|
|
1009
|
-
{ name: 'Log in', value: 'login' },
|
|
1010
|
-
],
|
|
1011
|
-
},
|
|
1002
|
+
// OTP-based auth flow
|
|
1003
|
+
const { email } = await inquirer.prompt([
|
|
1004
|
+
{ type: 'input', name: 'email', message: 'Email:', validate: (v: string) => v.includes('@') || 'Enter a valid email' },
|
|
1012
1005
|
]);
|
|
1013
1006
|
|
|
1014
|
-
|
|
1015
|
-
const { name, email, password } = await inquirer.prompt([
|
|
1016
|
-
{ type: 'input', name: 'name', message: 'Name:' },
|
|
1017
|
-
{ type: 'input', name: 'email', message: 'Email:' },
|
|
1018
|
-
{ type: 'password', name: 'password', message: 'Password:' },
|
|
1019
|
-
]);
|
|
1007
|
+
let spinner = ora('Sending verification code...').start();
|
|
1020
1008
|
|
|
1021
|
-
|
|
1022
|
-
|
|
1023
|
-
|
|
1024
|
-
|
|
1025
|
-
|
|
1026
|
-
});
|
|
1009
|
+
const sendRes = await fetch(`${API_URL}/auth/send-code`, {
|
|
1010
|
+
method: 'POST',
|
|
1011
|
+
headers: { 'Content-Type': 'application/json' },
|
|
1012
|
+
body: JSON.stringify({ email }),
|
|
1013
|
+
});
|
|
1027
1014
|
|
|
1028
|
-
|
|
1029
|
-
|
|
1030
|
-
|
|
1031
|
-
|
|
1015
|
+
if (!sendRes.ok) {
|
|
1016
|
+
const err = await sendRes.json().catch(() => ({}));
|
|
1017
|
+
spinner.fail(err.error || 'Failed to send code');
|
|
1018
|
+
process.exit(1);
|
|
1019
|
+
}
|
|
1032
1020
|
|
|
1033
|
-
|
|
1034
|
-
|
|
1035
|
-
|
|
1036
|
-
|
|
1037
|
-
|
|
1038
|
-
|
|
1039
|
-
} else {
|
|
1040
|
-
const { email, password } = await inquirer.prompt([
|
|
1041
|
-
{ type: 'input', name: 'email', message: 'Email:' },
|
|
1042
|
-
{ type: 'password', name: 'password', message: 'Password:' },
|
|
1043
|
-
]);
|
|
1021
|
+
const sendData = await sendRes.json();
|
|
1022
|
+
spinner.succeed('Code sent! Check your email.');
|
|
1023
|
+
|
|
1024
|
+
if (sendData.isNewUser) {
|
|
1025
|
+
console.log(chalk.gray(' No account found - we\'ll create one for you.\n'));
|
|
1026
|
+
}
|
|
1044
1027
|
|
|
1045
|
-
|
|
1046
|
-
|
|
1047
|
-
|
|
1048
|
-
headers: { 'Content-Type': 'application/json' },
|
|
1049
|
-
body: JSON.stringify({ email, password }),
|
|
1050
|
-
});
|
|
1028
|
+
const { code } = await inquirer.prompt([
|
|
1029
|
+
{ type: 'input', name: 'code', message: 'Enter 6-digit code:', validate: (v: string) => /^\d{6}$/.test(v) || 'Enter 6 digits' },
|
|
1030
|
+
]);
|
|
1051
1031
|
|
|
1052
|
-
|
|
1053
|
-
spinner.fail('Login failed');
|
|
1054
|
-
process.exit(1);
|
|
1055
|
-
}
|
|
1032
|
+
spinner = ora('Verifying...').start();
|
|
1056
1033
|
|
|
1057
|
-
|
|
1058
|
-
|
|
1059
|
-
|
|
1060
|
-
|
|
1061
|
-
|
|
1062
|
-
|
|
1034
|
+
const verifyRes = await fetch(`${API_URL}/auth/verify-code`, {
|
|
1035
|
+
method: 'POST',
|
|
1036
|
+
headers: { 'Content-Type': 'application/json' },
|
|
1037
|
+
body: JSON.stringify({ email, code }),
|
|
1038
|
+
});
|
|
1039
|
+
|
|
1040
|
+
if (!verifyRes.ok) {
|
|
1041
|
+
const err = await verifyRes.json().catch(() => ({}));
|
|
1042
|
+
spinner.fail(err.error || 'Verification failed');
|
|
1043
|
+
process.exit(1);
|
|
1063
1044
|
}
|
|
1045
|
+
|
|
1046
|
+
const data = await verifyRes.json();
|
|
1047
|
+
config.set('sessionId', data.sessionId);
|
|
1048
|
+
config.set('user', data.user);
|
|
1049
|
+
config.set('tenant', data.tenant);
|
|
1050
|
+
sessionId = data.sessionId;
|
|
1051
|
+
spinner.succeed(data.isNewUser ? 'Account created!' : 'Logged in!');
|
|
1064
1052
|
}
|
|
1065
1053
|
|
|
1066
1054
|
console.log('');
|