Chore: Export Cli login interface

This commit is contained in:
Daniel Hougaard
2024-03-17 18:49:29 +01:00
parent 8ff37e3ec9
commit 214894c88b
@@ -11,7 +11,7 @@ import SecurityClient from "./SecurityClient";
// eslint-disable-next-line new-cap
const client = new jsrp.client();
interface IsCliLoginSuccessful {
export interface IsCliLoginSuccessful {
mfaEnabled: boolean;
loginResponse?: {
email: string;
@@ -27,18 +27,15 @@ interface IsCliLoginSuccessful {
* @param {string} email - email of user to log in
* @param {string} password - password of user to log in
*/
const attemptLogin = async (
{
const attemptLogin = async ({
email,
password,
providerAuthToken,
}: {
providerAuthToken
}: {
email: string;
password: string;
providerAuthToken?: string;
}
): Promise<IsCliLoginSuccessful> => {
}): Promise<IsCliLoginSuccessful> => {
const telemetry = new Telemetry().getInstance();
return new Promise((resolve, reject) => {
client.init(
@@ -52,7 +49,7 @@ const attemptLogin = async (
const { serverPublicKey, salt } = await login1({
email,
clientPublicKey,
providerAuthToken,
providerAuthToken
});
client.setSalt(salt);
@@ -70,13 +67,11 @@ const attemptLogin = async (
encryptedPrivateKey,
iv,
tag
} = await login2(
{
} = await login2({
email,
clientProof,
providerAuthToken,
}
);
providerAuthToken
});
if (mfaEnabled) {
// case: MFA is enabled
@@ -135,8 +130,7 @@ const attemptLogin = async (
JTWToken: token
},
success: true
})
});
}
} catch (err) {
reject(err);