mirror of
https://github.com/awatertrevi/infisical.git
synced 2026-10-05 17:26:36 +00:00
Chore: Export Cli login interface
This commit is contained in:
@@ -11,7 +11,7 @@ import SecurityClient from "./SecurityClient";
|
|||||||
// eslint-disable-next-line new-cap
|
// eslint-disable-next-line new-cap
|
||||||
const client = new jsrp.client();
|
const client = new jsrp.client();
|
||||||
|
|
||||||
interface IsCliLoginSuccessful {
|
export interface IsCliLoginSuccessful {
|
||||||
mfaEnabled: boolean;
|
mfaEnabled: boolean;
|
||||||
loginResponse?: {
|
loginResponse?: {
|
||||||
email: string;
|
email: string;
|
||||||
@@ -27,18 +27,15 @@ interface IsCliLoginSuccessful {
|
|||||||
* @param {string} email - email of user to log in
|
* @param {string} email - email of user to log in
|
||||||
* @param {string} password - password of user to log in
|
* @param {string} password - password of user to log in
|
||||||
*/
|
*/
|
||||||
const attemptLogin = async (
|
const attemptLogin = async ({
|
||||||
{
|
|
||||||
email,
|
email,
|
||||||
password,
|
password,
|
||||||
providerAuthToken,
|
providerAuthToken
|
||||||
}: {
|
}: {
|
||||||
email: string;
|
email: string;
|
||||||
password: string;
|
password: string;
|
||||||
providerAuthToken?: string;
|
providerAuthToken?: string;
|
||||||
}
|
}): Promise<IsCliLoginSuccessful> => {
|
||||||
): Promise<IsCliLoginSuccessful> => {
|
|
||||||
|
|
||||||
const telemetry = new Telemetry().getInstance();
|
const telemetry = new Telemetry().getInstance();
|
||||||
return new Promise((resolve, reject) => {
|
return new Promise((resolve, reject) => {
|
||||||
client.init(
|
client.init(
|
||||||
@@ -52,7 +49,7 @@ const attemptLogin = async (
|
|||||||
const { serverPublicKey, salt } = await login1({
|
const { serverPublicKey, salt } = await login1({
|
||||||
email,
|
email,
|
||||||
clientPublicKey,
|
clientPublicKey,
|
||||||
providerAuthToken,
|
providerAuthToken
|
||||||
});
|
});
|
||||||
|
|
||||||
client.setSalt(salt);
|
client.setSalt(salt);
|
||||||
@@ -70,13 +67,11 @@ const attemptLogin = async (
|
|||||||
encryptedPrivateKey,
|
encryptedPrivateKey,
|
||||||
iv,
|
iv,
|
||||||
tag
|
tag
|
||||||
} = await login2(
|
} = await login2({
|
||||||
{
|
|
||||||
email,
|
email,
|
||||||
clientProof,
|
clientProof,
|
||||||
providerAuthToken,
|
providerAuthToken
|
||||||
}
|
});
|
||||||
);
|
|
||||||
if (mfaEnabled) {
|
if (mfaEnabled) {
|
||||||
// case: MFA is enabled
|
// case: MFA is enabled
|
||||||
|
|
||||||
@@ -135,8 +130,7 @@ const attemptLogin = async (
|
|||||||
JTWToken: token
|
JTWToken: token
|
||||||
},
|
},
|
||||||
success: true
|
success: true
|
||||||
})
|
});
|
||||||
|
|
||||||
}
|
}
|
||||||
} catch (err) {
|
} catch (err) {
|
||||||
reject(err);
|
reject(err);
|
||||||
|
|||||||
Reference in New Issue
Block a user