Add eslint rule and fix as many issues as possible

This commit is contained in:
Khoa Le
2023-06-19 23:42:04 -04:00
parent e9eacc445d
commit 9d33e4756b
689 changed files with 9446 additions and 21821 deletions
@@ -28,7 +28,7 @@ const changePassword2 = async ({
salt,
verifier
}: Props) => {
const { data } = await apiRequest.post('/api/v1/password/change-password', {
const { data } = await apiRequest.post("/api/v1/password/change-password", {
clientProof,
protectedKey,
protectedKeyIV,
+4 -4
View File
@@ -1,14 +1,14 @@
import SecurityClient from '@app/components/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 () =>
SecurityClient.fetchCall('/api/v1/auth/checkAuth', {
method: 'POST',
SecurityClient.fetchCall("/api/v1/auth/checkAuth", {
method: "POST",
headers: {
'Content-Type': 'application/json'
"Content-Type": "application/json"
}
}).then((res) => res);
@@ -10,10 +10,10 @@ interface Props {
* @param {string} obj.code
* @returns
*/
const checkEmailVerificationCode = ({ email, code }: Props) => fetch('/api/v1/signup/email/verify', {
method: 'POST',
const checkEmailVerificationCode = ({ email, code }: Props) => fetch("/api/v1/signup/email/verify", {
method: "POST",
headers: {
'Content-Type': 'application/json'
"Content-Type": "application/json"
},
body: JSON.stringify({
email,
@@ -55,7 +55,7 @@ const completeAccountInformationSignup = async ({
providerAuthToken,
attributionSource
}: Props) => {
const { data } = await apiRequest.post('/api/v3/signup/complete-account/signup', {
const { data } = await apiRequest.post("/api/v3/signup/complete-account/signup", {
email,
firstName,
lastName,
@@ -49,7 +49,7 @@ const completeAccountInformationSignupInvite = async ({
salt,
verifier
}: Props) => {
const { data } = await apiRequest.post('/api/v2/signup/complete-account/invite', {
const { data } = await apiRequest.post("/api/v2/signup/complete-account/invite", {
email,
firstName,
lastName,
@@ -12,10 +12,10 @@ interface Props {
* @returns
*/
const EmailVerifyOnPasswordReset = async ({ email, code }: Props) => {
const response = await fetch('/api/v1/password/email/password-reset-verify', {
method: 'POST',
const response = await fetch("/api/v1/password/email/password-reset-verify", {
method: "POST",
headers: {
'Content-Type': 'application/json'
"Content-Type": "application/json"
},
body: JSON.stringify({
email,
@@ -27,7 +27,7 @@ const EmailVerifyOnPasswordReset = async ({ email, code }: Props) => {
}
throw new Error(
'Something went wrong during email verification on password reset.'
"Something went wrong during email verification on password reset."
);
};
@@ -1,4 +1,4 @@
import SecurityClient from '@app/components/utilities/SecurityClient';
import SecurityClient from "@app/components/utilities/SecurityClient";
interface Props {
encryptedPrivateKey: string;
@@ -28,10 +28,10 @@ const issueBackupPrivateKey = ({
verifier,
clientProof
}: Props) =>
SecurityClient.fetchCall('/api/v1/password/backup-private-key', {
method: 'POST',
SecurityClient.fetchCall("/api/v1/password/backup-private-key", {
method: "POST",
headers: {
'Content-Type': 'application/json'
"Content-Type": "application/json"
},
body: JSON.stringify({
clientProof,
@@ -43,7 +43,7 @@ const issueBackupPrivateKey = ({
})
}).then((res) => {
if (res?.status !== 200) {
console.log('Failed to issue the backup key');
console.log("Failed to issue the backup key");
}
return res;
});
+5 -5
View File
@@ -22,13 +22,13 @@ const login2 = async (loginDetails: {
clientProof: string;
providerAuthToken?: string;
}) => {
const response = await fetch('/api/v3/auth/login2', {
method: 'POST',
const response = await fetch("/api/v3/auth/login2", {
method: "POST",
headers: {
'Content-Type': 'application/json'
"Content-Type": "application/json"
},
body: JSON.stringify(loginDetails),
credentials: 'include'
credentials: "include"
});
// need precise error handling about the status code
if (response.status === 200) {
@@ -36,7 +36,7 @@ const login2 = async (loginDetails: {
return data;
}
throw new Error('Password verification failed');
throw new Error("Password verification failed");
};
export default login2;
+17 -17
View File
@@ -1,4 +1,4 @@
import SecurityClient from '@app/components/utilities/SecurityClient';
import SecurityClient from "@app/components/utilities/SecurityClient";
/**
* This route logs the user out. Note: the user should authorized to do this.
@@ -6,33 +6,33 @@ import SecurityClient from '@app/components/utilities/SecurityClient';
*/
const logout = async () => {
try {
const res = await SecurityClient.fetchCall('/api/v1/auth/logout', {
method: 'POST',
const res = await SecurityClient.fetchCall("/api/v1/auth/logout", {
method: "POST",
headers: {
'Content-Type': 'application/json'
"Content-Type": "application/json"
},
credentials: 'include'
credentials: "include"
});
if (res?.status === 200) {
SecurityClient.setToken('');
SecurityClient.setToken("");
// Delete the cookie by not setting a value; Alternatively clear the local storage
localStorage.removeItem('protectedKey');
localStorage.removeItem('protectedKeyIV');
localStorage.removeItem('protectedKeyTag');
localStorage.removeItem('publicKey');
localStorage.removeItem('encryptedPrivateKey');
localStorage.removeItem('iv');
localStorage.removeItem('tag');
localStorage.removeItem('PRIVATE_KEY');
localStorage.removeItem('orgData.id');
localStorage.removeItem('projectData.id');
localStorage.removeItem("protectedKey");
localStorage.removeItem("protectedKeyIV");
localStorage.removeItem("protectedKeyTag");
localStorage.removeItem("publicKey");
localStorage.removeItem("encryptedPrivateKey");
localStorage.removeItem("iv");
localStorage.removeItem("tag");
localStorage.removeItem("PRIVATE_KEY");
localStorage.removeItem("orgData.id");
localStorage.removeItem("projectData.id");
return res;
}
} catch (error) {
console.log('Error logging out', error);
console.log("Error logging out", error);
}
return undefined;
+5 -5
View File
@@ -1,4 +1,4 @@
import SecurityClient from '@app/components/utilities/SecurityClient';
import SecurityClient from "@app/components/utilities/SecurityClient";
interface Props {
clientPublicKey: string;
@@ -10,10 +10,10 @@ interface Props {
* @returns
*/
const SRP1 = ({ clientPublicKey }: Props) =>
SecurityClient.fetchCall('/api/v1/password/srp1', {
method: 'POST',
SecurityClient.fetchCall("/api/v1/password/srp1", {
method: "POST",
headers: {
'Content-Type': 'application/json'
"Content-Type": "application/json"
},
body: JSON.stringify({
clientPublicKey
@@ -22,7 +22,7 @@ const SRP1 = ({ clientPublicKey }: Props) =>
if (res && res.status === 200) {
return res.json();
}
console.log('Failed to do the first step of SRP');
console.log("Failed to do the first step of SRP");
return undefined;
});
@@ -10,10 +10,10 @@ interface Props {
* @returns
*/
const SendEmailOnPasswordReset = async ({ email }: Props) => {
const response = await fetch('/api/v1/password/email/password-reset', {
method: 'POST',
const response = await fetch("/api/v1/password/email/password-reset", {
method: "POST",
headers: {
'Content-Type': 'application/json'
"Content-Type": "application/json"
},
body: JSON.stringify({
email
@@ -26,7 +26,7 @@ const SendEmailOnPasswordReset = async ({ email }: Props) => {
}
throw new Error(
'Something went wrong while sending the email verification for password reset.'
"Something went wrong while sending the email verification for password reset."
);
};
@@ -3,10 +3,10 @@
* @param {*} email
*/
const sendVerificationEmail = (email: string) => {
fetch('/api/v1/signup/email/signup', {
method: 'POST',
fetch("/api/v1/signup/email/signup", {
method: "POST",
headers: {
'Content-Type': 'application/json'
"Content-Type": "application/json"
},
body: JSON.stringify({
email
+5 -5
View File
@@ -1,15 +1,15 @@
const token = async () =>
fetch('/api/v1/auth/token', {
method: 'POST',
fetch("/api/v1/auth/token", {
method: "POST",
headers: {
'Content-Type': 'application/json'
"Content-Type": "application/json"
},
credentials: 'include'
credentials: "include"
}).then(async (res) => {
if (res.status === 200) {
return (await res.json()).token;
}
console.log('Getting a new token failed');
console.log("Getting a new token failed");
return undefined;
});
@@ -12,10 +12,10 @@ interface Props {
* @param {string} obj.code - code that a user received to the abovementioned email
* @returns
*/
const verifySignupInvite = ({ email, organizationId, code }: Props) => fetch('/api/v1/invite-org/verify', {
method: 'POST',
const verifySignupInvite = ({ email, organizationId, code }: Props) => fetch("/api/v1/invite-org/verify", {
method: "POST",
headers: {
'Content-Type': 'application/json'
"Content-Type": "application/json"
},
body: JSON.stringify({
email,
@@ -8,15 +8,15 @@ const getBackupEncryptedPrivateKey = ({
verificationToken
}: {
verificationToken: string;
}) => fetch('/api/v1/password/backup-private-key', {
method: 'GET',
}) => fetch("/api/v1/password/backup-private-key", {
method: "GET",
headers: {
'Content-Type': 'application/json',
"Content-Type": "application/json",
Authorization: `Bearer ${ verificationToken}`
}
}).then(async (res) => {
if (res?.status !== 200) {
console.log('Failed to get the backup key');
console.log("Failed to get the backup key");
}
return (await res?.json())?.backupPrivateKey;
});
@@ -1,7 +1,7 @@
const publicKeyInfisical = () => fetch('/api/v1/key/publicKey/infisical', {
method: 'GET',
const publicKeyInfisical = () => fetch("/api/v1/key/publicKey/infisical", {
method: "GET",
headers: {
'Content-Type': 'application/json'
"Content-Type": "application/json"
}
});
@@ -31,10 +31,10 @@ const resetPasswordOnAccountRecovery = ({
salt,
verifier,
verificationToken,
}: Props) => fetch('/api/v1/password/password-reset', {
method: 'POST',
}: Props) => fetch("/api/v1/password/password-reset", {
method: "POST",
headers: {
'Content-Type': 'application/json',
"Content-Type": "application/json",
Authorization: `Bearer ${verificationToken}`
},
body: JSON.stringify({
@@ -49,7 +49,7 @@ const resetPasswordOnAccountRecovery = ({
})
}).then(async (res) => {
if (res?.status !== 200) {
console.log('Failed to get the backup key');
console.log("Failed to get the backup key");
}
return res;
});
@@ -14,7 +14,7 @@ const verifyMfaToken = async ({
email: string;
mfaToken: string;
}) => {
const { data } = await apiRequest.post('/api/v2/auth/mfa/verify', {
const { data } = await apiRequest.post("/api/v2/auth/mfa/verify", {
email,
mfaToken
});