chore(frontend): fixed all eslint errors

This commit is contained in:
akhilmhdh
2023-01-17 21:06:14 +05:30
parent 9f82e2d836
commit cf7834bfc3
184 changed files with 6255 additions and 6117 deletions
+12 -20
View File
@@ -1,4 +1,4 @@
import SecurityClient from '~/utilities/SecurityClient';
import SecurityClient from '@app/components/utilities/SecurityClient';
interface Props {
encryptedPrivateKey: string;
@@ -14,34 +14,26 @@ interface Props {
* @param {*} clientPublicKey
* @returns
*/
const changePassword2 = ({
encryptedPrivateKey,
iv,
tag,
salt,
verifier,
clientProof
}: Props) => {
return SecurityClient.fetchCall('/api/v1/password/change-password', {
const changePassword2 = ({ encryptedPrivateKey, iv, tag, salt, verifier, clientProof }: Props) =>
SecurityClient.fetchCall('/api/v1/password/change-password', {
method: 'POST',
headers: {
'Content-Type': 'application/json'
},
body: JSON.stringify({
clientProof: clientProof,
encryptedPrivateKey: encryptedPrivateKey,
iv: iv,
tag: tag,
salt: salt,
verifier: verifier
clientProof,
encryptedPrivateKey,
iv,
tag,
salt,
verifier
})
}).then(async (res) => {
if (res && res.status == 200) {
if (res && res.status === 200) {
return res;
} else {
console.log('Failed to change the password');
}
console.log('Failed to change the password');
return undefined;
});
};
export default changePassword2;
+3 -4
View File
@@ -1,16 +1,15 @@
import SecurityClient from '~/utilities/SecurityClient';
import SecurityClient from '@app/components/utilities/SecurityClient';
/**
* This function is used to check if the user is authenticated.
* To do that, we get their tokens from cookies, and verify if they are good.
*/
const checkAuth = async () => {
return SecurityClient.fetchCall('/api/v1/auth/checkAuth', {
const checkAuth = async () =>
SecurityClient.fetchCall('/api/v1/auth/checkAuth', {
method: 'POST',
headers: {
'Content-Type': 'application/json'
}
}).then((res) => res);
};
export default checkAuth;
@@ -10,17 +10,15 @@ interface Props {
* @param {string} obj.code
* @returns
*/
const checkEmailVerificationCode = ({ email, code }: Props) => {
return fetch('/api/v1/signup/email/verify', {
const checkEmailVerificationCode = ({ email, code }: Props) => fetch('/api/v1/signup/email/verify', {
method: 'POST',
headers: {
'Content-Type': 'application/json'
},
body: JSON.stringify({
email: email,
code: code
email,
code
})
});
};
export default checkEmailVerificationCode;
@@ -41,12 +41,11 @@ const completeAccountInformationSignup = ({
salt,
verifier,
token
}: Props) => {
return fetch('/api/v1/signup/complete-account/signup', {
}: Props) => fetch('/api/v1/signup/complete-account/signup', {
method: 'POST',
headers: {
'Content-Type': 'application/json',
Authorization: 'Bearer ' + token
Authorization: `Bearer ${ token}`
},
body: JSON.stringify({
email,
@@ -61,6 +60,5 @@ const completeAccountInformationSignup = ({
verifier
})
});
};
export default completeAccountInformationSignup;
@@ -38,25 +38,23 @@ const completeAccountInformationSignupInvite = ({
salt,
verifier,
token
}: Props) => {
return fetch('/api/v1/signup/complete-account/invite', {
}: Props) => fetch('/api/v1/signup/complete-account/invite', {
method: 'POST',
headers: {
'Content-Type': 'application/json',
Authorization: 'Bearer ' + token
Authorization: `Bearer ${ token}`
},
body: JSON.stringify({
email: email,
firstName: firstName,
lastName: lastName,
publicKey: publicKey,
email,
firstName,
lastName,
publicKey,
encryptedPrivateKey: ciphertext,
iv: iv,
tag: tag,
salt: salt,
verifier: verifier
iv,
tag,
salt,
verifier
})
});
};
export default completeAccountInformationSignupInvite;
@@ -18,8 +18,8 @@ const EmailVerifyOnPasswordReset = async ({ email, code }: Props) => {
'Content-Type': 'application/json'
},
body: JSON.stringify({
email: email,
code: code
email,
code
})
});
if (response?.status === 200) {
@@ -1,4 +1,4 @@
import SecurityClient from '~/utilities/SecurityClient';
import SecurityClient from '@app/components/utilities/SecurityClient';
interface Props {
encryptedPrivateKey: string;
@@ -27,19 +27,19 @@ const issueBackupPrivateKey = ({
salt,
verifier,
clientProof
}: Props) => {
return SecurityClient.fetchCall('/api/v1/password/backup-private-key', {
}: Props) =>
SecurityClient.fetchCall('/api/v1/password/backup-private-key', {
method: 'POST',
headers: {
'Content-Type': 'application/json'
},
body: JSON.stringify({
clientProof: clientProof,
encryptedPrivateKey: encryptedPrivateKey,
iv: iv,
tag: tag,
salt: salt,
verifier: verifier
clientProof,
encryptedPrivateKey,
iv,
tag,
salt,
verifier
})
}).then((res) => {
if (res?.status !== 200) {
@@ -47,6 +47,5 @@ const issueBackupPrivateKey = ({
}
return res;
});
};
export default issueBackupPrivateKey;
+1 -1
View File
@@ -16,7 +16,7 @@ const login1 = async (email: string, clientPublicKey: string) => {
"Content-Type": "application/json",
},
body: JSON.stringify({
email: email,
email,
clientPublicKey,
}),
});
+8 -8
View File
@@ -13,24 +13,24 @@ interface Login2Response {
* @returns
*/
const login2 = async (email: string, clientProof: string) => {
const response = await fetch("/api/v1/auth/login2", {
method: "POST",
const response = await fetch('/api/v1/auth/login2', {
method: 'POST',
headers: {
"Content-Type": "application/json",
'Content-Type': 'application/json'
},
body: JSON.stringify({
email: email,
clientProof,
email,
clientProof
}),
credentials: "include",
credentials: 'include'
});
// need precise error handling about the status code
if (response.status == 200) {
if (response.status === 200) {
const data = (await response.json()) as unknown as Login2Response;
return data;
}
throw new Error("Password verification failed");
throw new Error('Password verification failed');
};
export default login2;
+6 -7
View File
@@ -1,18 +1,18 @@
import SecurityClient from '~/utilities/SecurityClient';
import SecurityClient from '@app/components/utilities/SecurityClient';
/**
* This route logs the user out. Note: the user should authorized to do this.
* We first try to log out - if the authorization fails (response.status = 401), we refetch the new token, and then retry
*/
const logout = async () => {
return SecurityClient.fetchCall('/api/v1/auth/logout', {
const logout = async () =>
SecurityClient.fetchCall('/api/v1/auth/logout', {
method: 'POST',
headers: {
'Content-Type': 'application/json'
},
credentials: 'include'
}).then((res) => {
if (res?.status == 200) {
if (res?.status === 200) {
SecurityClient.setToken('');
// Delete the cookie by not setting a value; Alternatively clear the local storage
localStorage.setItem('publicKey', '');
@@ -22,10 +22,9 @@ const logout = async () => {
localStorage.setItem('PRIVATE_KEY', '');
console.log('User logged out', res);
return res;
} else {
console.log('Failed to log out');
}
console.log('Failed to log out');
return undefined;
});
};
export default logout;
+7 -8
View File
@@ -1,4 +1,4 @@
import SecurityClient from '~/utilities/SecurityClient';
import SecurityClient from '@app/components/utilities/SecurityClient';
interface Props {
clientPublicKey: string;
@@ -9,8 +9,8 @@ interface Props {
* @param {string} clientPublicKey
* @returns
*/
const SRP1 = ({ clientPublicKey }: Props) => {
return SecurityClient.fetchCall('/api/v1/password/srp1', {
const SRP1 = ({ clientPublicKey }: Props) =>
SecurityClient.fetchCall('/api/v1/password/srp1', {
method: 'POST',
headers: {
'Content-Type': 'application/json'
@@ -19,12 +19,11 @@ const SRP1 = ({ clientPublicKey }: Props) => {
clientPublicKey
})
}).then(async (res) => {
if (res && res.status == 200) {
return await res.json();
} else {
console.log('Failed to do the first step of SRP');
if (res && res.status === 200) {
return res.json();
}
console.log('Failed to do the first step of SRP');
return undefined;
});
};
export default SRP1;
@@ -16,7 +16,7 @@ const SendEmailOnPasswordReset = async ({ email }: Props) => {
'Content-Type': 'application/json'
},
body: JSON.stringify({
email: email
email
})
});
// need precise error handling about the status code
@@ -9,7 +9,7 @@ const sendVerificationEmail = (email: string) => {
'Content-Type': 'application/json'
},
body: JSON.stringify({
email: email
email
})
});
};
+5 -6
View File
@@ -1,17 +1,16 @@
const token = async () => {
return fetch('/api/v1/auth/token', {
const token = async () =>
fetch('/api/v1/auth/token', {
method: 'POST',
headers: {
'Content-Type': 'application/json'
},
credentials: 'include'
}).then(async (res) => {
if (res.status == 200) {
if (res.status === 200) {
return (await res.json()).token;
} else {
console.log('Getting a new token failed');
}
console.log('Getting a new token failed');
return undefined;
});
};
export default token;
@@ -10,8 +10,7 @@ interface Props {
* @param {string} obj.code - code that a user received to the abovementioned email
* @returns
*/
const verifySignupInvite = ({ email, code }: Props) => {
return fetch('/api/v1/invite-org/verify', {
const verifySignupInvite = ({ email, code }: Props) => fetch('/api/v1/invite-org/verify', {
method: 'POST',
headers: {
'Content-Type': 'application/json'
@@ -21,6 +20,5 @@ const verifySignupInvite = ({ email, code }: Props) => {
code
})
});
};
export default verifySignupInvite;
@@ -8,12 +8,11 @@ const getBackupEncryptedPrivateKey = ({
verificationToken
}: {
verificationToken: string;
}) => {
return fetch('/api/v1/password/backup-private-key', {
}) => fetch('/api/v1/password/backup-private-key', {
method: 'GET',
headers: {
'Content-Type': 'application/json',
Authorization: 'Bearer ' + verificationToken
Authorization: `Bearer ${ verificationToken}`
}
}).then(async (res) => {
if (res?.status !== 200) {
@@ -21,6 +20,5 @@ const getBackupEncryptedPrivateKey = ({
}
return (await res?.json())?.backupPrivateKey;
});
};
export default getBackupEncryptedPrivateKey;
@@ -1,10 +1,8 @@
const publicKeyInfisical = () => {
return fetch('/api/v1/key/publicKey/infisical', {
const publicKeyInfisical = () => fetch('/api/v1/key/publicKey/infisical', {
method: 'GET',
headers: {
'Content-Type': 'application/json'
}
});
};
export default publicKeyInfisical;
@@ -25,19 +25,18 @@ const resetPasswordOnAccountRecovery = ({
tag,
salt,
verifier
}: Props) => {
return fetch('/api/v1/password/password-reset', {
}: Props) => fetch('/api/v1/password/password-reset', {
method: 'POST',
headers: {
'Content-Type': 'application/json',
Authorization: 'Bearer ' + verificationToken
Authorization: `Bearer ${ verificationToken}`
},
body: JSON.stringify({
encryptedPrivateKey: encryptedPrivateKey,
iv: iv,
tag: tag,
salt: salt,
verifier: verifier
encryptedPrivateKey,
iv,
tag,
salt,
verifier
})
}).then(async (res) => {
if (res?.status !== 200) {
@@ -45,6 +44,5 @@ const resetPasswordOnAccountRecovery = ({
}
return res;
});
};
export default resetPasswordOnAccountRecovery;