diff --git a/frontend/components/RouteGuard.js b/frontend/components/RouteGuard.js index bedf124cc..9c9343a8f 100644 --- a/frontend/components/RouteGuard.js +++ b/frontend/components/RouteGuard.js @@ -1,6 +1,6 @@ import { useState, useEffect } from "react"; import { useRouter } from "next/router"; -import checkAuth from "../pages/api/auth/CheckAuth"; +import checkAuth from "~/pages/api/auth/CheckAuth"; import Image from "next/image"; import { publicPaths } from "../const"; @@ -79,4 +79,4 @@ export default function RouteGuard({ children }) { ); } -} \ No newline at end of file +} diff --git a/frontend/components/basic/dialog/AddIncidentContactDialog.js b/frontend/components/basic/dialog/AddIncidentContactDialog.js index 3c749d2fa..518828985 100644 --- a/frontend/components/basic/dialog/AddIncidentContactDialog.js +++ b/frontend/components/basic/dialog/AddIncidentContactDialog.js @@ -1,7 +1,7 @@ import { Dialog, Transition } from "@headlessui/react"; import { Fragment, useState } from "react"; import InputField from "../InputField"; -import addIncidentContact from "../../../pages/api/organization/addIncidentContact"; +import addIncidentContact from "~/pages/api/organization/addIncidentContact"; import Button from "../buttons/Button"; const AddIncidentContactDialog = ({ diff --git a/frontend/components/basic/dialog/AddServiceTokenDialog.js b/frontend/components/basic/dialog/AddServiceTokenDialog.js index b4c982f89..4623ecb84 100644 --- a/frontend/components/basic/dialog/AddServiceTokenDialog.js +++ b/frontend/components/basic/dialog/AddServiceTokenDialog.js @@ -4,9 +4,9 @@ import ListBox from "../Listbox"; import { useRouter } from "next/router"; import Button from "../buttons/Button"; import InputField from "../InputField"; -import getLatestFileKey from "../../../pages/api/workspace/getLatestFileKey"; +import getLatestFileKey from "~/pages/api/workspace/getLatestFileKey"; import { decryptAssymmetric, encryptAssymmetric } from "../../utilities/crypto"; -import addServiceToken from "../../../pages/api/serviceToken/addServiceToken"; +import addServiceToken from "~/pages/api/serviceToken/addServiceToken"; import nacl from "tweetnacl"; import { faCheck, faCopy } from "@fortawesome/free-solid-svg-icons"; import { FontAwesomeIcon } from "@fortawesome/react-fontawesome"; @@ -28,7 +28,7 @@ const AddServiceTokenDialog = ({ isOpen, closeModal, workspaceId, - workspaceName + workspaceName, }) => { const router = useRouter(); const [serviceToken, setServiceToken] = useState(""); @@ -38,52 +38,52 @@ const AddServiceTokenDialog = ({ const [serviceTokenCopied, setServiceTokenCopied] = useState(false); const generateServiceToken = async () => { - const latestFileKey = await getLatestFileKey(workspaceId); + const latestFileKey = await getLatestFileKey(workspaceId); const key = decryptAssymmetric({ ciphertext: latestFileKey.latestKey.encryptedKey, nonce: latestFileKey.latestKey.nonce, publicKey: latestFileKey.latestKey.sender.publicKey, - privateKey: localStorage.getItem("PRIVATE_KEY") + privateKey: localStorage.getItem("PRIVATE_KEY"), }); // generate new public/private key pair const pair = nacl.box.keyPair(); const publicKey = nacl.util.encodeBase64(pair.publicKey); const privateKey = nacl.util.encodeBase64(pair.secretKey); - + // encrypt workspace key under newly-generated public key const { ciphertext: encryptedKey, nonce } = encryptAssymmetric({ plaintext: key, publicKey, - privateKey + privateKey, }); let newServiceToken = await addServiceToken({ - name: serviceTokenName, - workspaceId, + name: serviceTokenName, + workspaceId, environment: envMapping[serviceTokenEnv], - expiresIn: expiryMapping[serviceTokenExpiresIn], - publicKey, + expiresIn: expiryMapping[serviceTokenExpiresIn], + publicKey, encryptedKey, - nonce - }) - - const serviceToken = newServiceToken + ',' + privateKey; + nonce, + }); + + const serviceToken = newServiceToken + "," + privateKey; setServiceToken(serviceToken); - } + }; function copyToClipboard() { // Get the text field var copyText = document.getElementById("serviceToken"); - + // Select the text field copyText.select(); copyText.setSelectionRange(0, 99999); // For mobile devices - - // Copy the text inside the text field + + // Copy the text inside the text field navigator.clipboard.writeText(copyText.value); - + setServiceTokenCopied(true); setTimeout(() => setServiceTokenCopied(false), 2000); // Alert the copied text @@ -94,7 +94,7 @@ const AddServiceTokenDialog = ({ closeModal(); setServiceTokenName(""); setServiceToken(""); - } + }; return (
@@ -123,18 +123,25 @@ const AddServiceTokenDialog = ({ leaveFrom="opacity-100 scale-100" leaveTo="opacity-0 scale-95" > - {serviceToken == "" - ? + {serviceToken == "" ? ( + - Add a service token for {workspaceName} + Add a service token for{" "} + {workspaceName}

- Specify the name, environment, and expiry period. When a token is generated, you will only be able to see it once before it disappears. Make sure to save it somewhere. + Specify the name, + environment, and expiry + period. When a token is + generated, you will only be + able to see it once before + it disappears. Make sure to + save it somewhere.

@@ -154,7 +161,12 @@ const AddServiceTokenDialog = ({ @@ -162,8 +174,14 @@ const AddServiceTokenDialog = ({
@@ -171,17 +189,24 @@ const AddServiceTokenDialog = ({
- : + ) : ( +

- Once you close this popup, you will never see your service token again + Once you close this popup, + you will never see your + service token again

- -
{serviceToken}
+ +
+ {serviceToken} +
- Click to Copy @@ -211,14 +259,16 @@ const AddServiceTokenDialog = ({
- } + )}
diff --git a/frontend/components/basic/layout.js b/frontend/components/basic/layout.js index 28557d853..4b01fd70d 100644 --- a/frontend/components/basic/layout.js +++ b/frontend/components/basic/layout.js @@ -4,7 +4,7 @@ import { useEffect, useState } from "react"; import NavBarDashboard from "../navigation/NavBarDashboard"; import Listbox from "./Listbox"; -import getWorkspaces from "../../pages/api/workspace/getWorkspaces"; +import getWorkspaces from "~/pages/api/workspace/getWorkspaces"; import { FontAwesomeIcon } from "@fortawesome/react-fontawesome"; import { faHouse, @@ -14,11 +14,11 @@ import { faLink, } from "@fortawesome/free-solid-svg-icons"; import AddWorkspaceDialog from "./dialog/AddWorkspaceDialog"; -import createWorkspace from "../../pages/api/workspace/createWorkspace"; -import getOrganizationUserProjects from "../../pages/api/organization/GetOrgUserProjects"; -import getOrganizationUsers from "../../pages/api/organization/GetOrgUsers"; -import addUserToWorkspace from "../../pages/api/workspace/addUserToWorkspace"; -import getOrganizations from "../../pages/api/organization/getOrgs"; +import createWorkspace from "~/pages/api/workspace/createWorkspace"; +import getOrganizationUserProjects from "~/pages/api/organization/GetOrgUserProjects"; +import getOrganizationUsers from "~/pages/api/organization/GetOrgUsers"; +import addUserToWorkspace from "~/pages/api/workspace/addUserToWorkspace"; +import getOrganizations from "~/pages/api/organization/getOrgs"; import { faPlus } from "@fortawesome/free-solid-svg-icons"; import { decryptAssymmetric, encryptAssymmetric } from "../utilities/crypto"; @@ -48,9 +48,7 @@ export default function Layout({ children }) { setLoading(true); setTimeout(() => setLoading(false), 1500); const workspaces = await getWorkspaces(); - const currentWorkspaces = workspaces.map( - (workspace) => workspace.name - ); + const currentWorkspaces = workspaces.map((workspace) => workspace.name); if (!currentWorkspaces.includes(workspaceName)) { const newWorkspace = await createWorkspace( workspaceName, @@ -141,7 +139,10 @@ export default function Layout({ children }) { useEffect(async () => { // Put a user in a workspace if they're not in one yet - if (localStorage.getItem("orgData.id") == null || localStorage.getItem("orgData.id") == "") { + if ( + localStorage.getItem("orgData.id") == null || + localStorage.getItem("orgData.id") == "" + ) { const userOrgs = await getOrganizations(); localStorage.setItem("orgData.id", userOrgs[0]._id); } @@ -150,7 +151,11 @@ export default function Layout({ children }) { orgId: localStorage.getItem("orgData.id"), }); let userWorkspaces = orgUserProjects; - if (userWorkspaces.length == 0 && (router.asPath != "/noprojects" && !router.asPath.includes("settings"))) { + if ( + userWorkspaces.length == 0 && + router.asPath != "/noprojects" && + !router.asPath.includes("settings") + ) { router.push("/noprojects"); } else if (router.asPath != "/noprojects") { const intendedWorkspaceId = router.asPath @@ -158,7 +163,9 @@ export default function Layout({ children }) { [router.asPath.split("/").length - 1].split("?")[0]; // If a user is not a member of a workspace they are trying to access, just push them to one of theirs - if (intendedWorkspaceId != "heroku" && !userWorkspaces + if ( + intendedWorkspaceId != "heroku" && + !userWorkspaces .map((workspace) => workspace._id) .includes(intendedWorkspaceId) ) { @@ -207,7 +214,10 @@ export default function Layout({ children }) { workspaceMapping[workspaceSelected] + "?Development" ); - localStorage.setItem("projectData.id", workspaceMapping[workspaceSelected]) + localStorage.setItem( + "projectData.id", + workspaceMapping[workspaceSelected] + ); } } catch (error) { console.log(error); @@ -226,8 +236,8 @@ export default function Layout({ children }) {
PROJECT
- {workspaceList.length>0 - ? 0 ? ( + - :
diff --git a/frontend/components/basic/table/UserTable.js b/frontend/components/basic/table/UserTable.js index f08696e37..7cb597686 100644 --- a/frontend/components/basic/table/UserTable.js +++ b/frontend/components/basic/table/UserTable.js @@ -1,11 +1,11 @@ import React, { useEffect, useMemo, useState } from "react"; import { useRouter } from "next/router"; import Listbox from "../Listbox"; -import uploadKeys from "../../../pages/api/workspace/uploadKeys"; -import getLatestFileKey from "../../../pages/api/workspace/getLatestFileKey"; -import deleteUserFromWorkspace from "../../../pages/api/workspace/deleteUserFromWorkspace"; -import changeUserRoleInWorkspace from "../../../pages/api/workspace/changeUserRoleInWorkspace"; -import deleteUserFromOrganization from "../../../pages/api/organization/deleteUserFromOrganization"; +import uploadKeys from "~/pages/api/workspace/uploadKeys"; +import getLatestFileKey from "~/pages/api/workspace/getLatestFileKey"; +import deleteUserFromWorkspace from "~/pages/api/workspace/deleteUserFromWorkspace"; +import changeUserRoleInWorkspace from "~/pages/api/workspace/changeUserRoleInWorkspace"; +import deleteUserFromOrganization from "~/pages/api/organization/deleteUserFromOrganization"; import { faX } from "@fortawesome/free-solid-svg-icons"; import Button from "../buttons/Button"; import guidGenerator from "../../utilities/randomId"; @@ -145,7 +145,10 @@ const UserTable = ({ ) .map((row, index) => { return ( - + {row.firstName} diff --git a/frontend/components/billing/Plan.js b/frontend/components/billing/Plan.js index 4d01e966c..7ed35aca3 100644 --- a/frontend/components/billing/Plan.js +++ b/frontend/components/billing/Plan.js @@ -1,5 +1,5 @@ import React from "react"; -import StripeRedirect from "../../pages/api/organization/StripeRedirect"; +import StripeRedirect from "~/pages/api/organization/StripeRedirect"; export default function Plan({ plan }) { return ( @@ -27,12 +27,12 @@ export default function Plan({ plan }) { {plan.priceExplanation}

-

- {plan.text} -

-

- {plan.subtext} -

+

+ {plan.text} +

+

+ {plan.subtext} +

{plan.current == false ? ( @@ -54,7 +54,17 @@ export default function Plan({ plan }) { : "hover:bg-primary hover:text-black hover:border-primary" } bg-bunker duration-200 cursor-pointer rounded-md flex w-max`} > - +
)} diff --git a/frontend/components/navigation/NavBarDashboard.js b/frontend/components/navigation/NavBarDashboard.js index e73a61268..93aaf58c2 100644 --- a/frontend/components/navigation/NavBarDashboard.js +++ b/frontend/components/navigation/NavBarDashboard.js @@ -3,7 +3,7 @@ import { useRouter } from "next/router"; import Image from "next/image"; -import logout from "../../pages/api/auth/Logout"; +import logout from "~/pages/api/auth/Logout"; import { FontAwesomeIcon } from "@fortawesome/react-fontawesome"; import { faCircleQuestion } from "@fortawesome/free-regular-svg-icons"; import { @@ -12,14 +12,14 @@ import { faCoins, faRightFromBracket, faEnvelope, - faPlus, - faAngleDown + faPlus, + faAngleDown, } from "@fortawesome/free-solid-svg-icons"; import { faSlack, faGithub } from "@fortawesome/free-brands-svg-icons"; import { Menu, Transition } from "@headlessui/react"; -import getUser from "../../pages/api/user/getUser"; -import getOrganizations from "../../pages/api/organization/getOrgs"; -import getOrganization from "../../pages/api/organization/GetOrg"; +import getUser from "~/pages/api/user/getUser"; +import getOrganizations from "~/pages/api/organization/getOrgs"; +import getOrganization from "~/pages/api/organization/GetOrg"; import guidGenerator from "../utilities/randomId"; const supportOptions = [ @@ -87,7 +87,7 @@ export default function Navbar({ onButtonPressed }) {
-
+
{user?.firstName} {user?.lastName} - +
SIGNED IN AS
-
router.push( - "/settings/personal/" + router.query.id + "/settings/personal/" + + router.query.id ) } - className="flex flex-row items-center px-1 mx-1 my-1 hover:bg-white/5 cursor-pointer rounded-md"> + className="flex flex-row items-center px-1 mx-1 my-1 hover:bg-white/5 cursor-pointer rounded-md" + >
{user?.firstName?.charAt(0)}
@@ -159,7 +164,8 @@ export default function Navbar({ onButtonPressed }) {

{" "} - {user?.firstName} {user?.lastName} + {user?.firstName}{" "} + {user?.lastName}

{" "} @@ -235,7 +241,10 @@ export default function Navbar({ onButtonPressed }) { className="relative flex justify-start cursor-pointer select-none py-2 pl-10 pr-4 rounded-md text-gray-400 hover:bg-primary/100 duration-200 hover:text-black hover:font-semibold mt-1" > - +

Invite Members @@ -243,43 +252,45 @@ export default function Navbar({ onButtonPressed }) {
- {orgs?.length > 1 &&
-
- OTHER ORGANIZATIONS -
-
- {orgs - .filter( - (org) => - org._id != - localStorage.getItem( - "orgData.id" - ) - ) - .map((org) => ( -
{ - localStorage.setItem( - "orgData.id", - org._id - ); - router.reload(); - }} - className="flex flex-row justify-start items-center hover:bg-white/5 w-full p-1.5 cursor-pointer rounded-md" - > -
- {org.name.charAt(0)} + {orgs?.length > 1 && ( +
+
+ OTHER ORGANIZATIONS +
+
+ {orgs + .filter( + (org) => + org._id != + localStorage.getItem( + "orgData.id" + ) + ) + .map((org) => ( +
{ + localStorage.setItem( + "orgData.id", + org._id + ); + router.reload(); + }} + className="flex flex-row justify-start items-center hover:bg-white/5 w-full p-1.5 cursor-pointer rounded-md" + > +
+ {org.name.charAt(0)} +
+
+

+ {org.name} +

+
-
-

- {org.name} -

-
-
- ))} + ))} +
-
} + )}
{({ active }) => ( diff --git a/frontend/components/navigation/NavHeader.js b/frontend/components/navigation/NavHeader.js index 66483b50d..c526bc718 100644 --- a/frontend/components/navigation/NavHeader.js +++ b/frontend/components/navigation/NavHeader.js @@ -1,18 +1,21 @@ import React, { useEffect, useState } from "react"; import { FontAwesomeIcon } from "@fortawesome/react-fontawesome"; -import { faAngleRight, faQuestionCircle } from "@fortawesome/free-solid-svg-icons"; +import { + faAngleRight, + faQuestionCircle, +} from "@fortawesome/free-solid-svg-icons"; import { faCcMastercard, faCcVisa } from "@fortawesome/free-brands-svg-icons"; import { faCircle } from "@fortawesome/free-solid-svg-icons"; -import getOrganization from "../../pages/api/organization/GetOrg"; -import getWorkspaceInfo from "../../pages/api/workspace/getWorkspaceInfo"; +import getOrganization from "~/pages/api/organization/GetOrg"; +import getWorkspaceInfo from "~/pages/api/workspace/getWorkspaceInfo"; import { useRouter } from "next/router"; -export default function NavHeader({ pageName, isProjectRelated}) { - const [orgName, setOrgName] = useState(""); - const [workspaceName, setWorkspaceName] = useState(""); - const router = useRouter(); +export default function NavHeader({ pageName, isProjectRelated }) { + const [orgName, setOrgName] = useState(""); + const [workspaceName, setWorkspaceName] = useState(""); + const router = useRouter(); - useEffect(async () => { + useEffect(async () => { let org = await getOrganization({ orgId: localStorage.getItem("orgData.id"), }); @@ -21,27 +24,30 @@ export default function NavHeader({ pageName, isProjectRelated}) { workspaceId: router.query.id, }); setWorkspaceName(workspace.name); - }, []); + }, []); return ( -
-
- {orgName?.charAt(0)} -
-
- {orgName} -
- {isProjectRelated && <> - -
- {workspaceName} -
- - } - -
- {pageName} -
-
+
+
+ {orgName?.charAt(0)} +
+
{orgName}
+ {isProjectRelated && ( + <> + +
+ {workspaceName} +
+ + )} + +
{pageName}
+
); } diff --git a/frontend/components/utilities/SecurityClient.js b/frontend/components/utilities/SecurityClient.js index e77a064bb..fdcb5d743 100644 --- a/frontend/components/utilities/SecurityClient.js +++ b/frontend/components/utilities/SecurityClient.js @@ -1,29 +1,27 @@ -import token from "../../pages/api/auth/Token" -import { PATH } from '../../const'; +import token from "~/pages/api/auth/Token"; +import { PATH } from "../../const"; export default class SecurityClient { - static authOrigins = [PATH] - static #token = ''; + static authOrigins = [PATH]; + static #token = ""; - contructor() { + contructor() {} - } + static setToken(token) { + this.#token = token; + } - static setToken(token) { - this.#token = token; - } + static async fetchCall(resource, options) { + let req = new Request(resource, options); + const destOrigin = new URL(req.url).origin; - static async fetchCall(resource, options) { - let req = new Request(resource, options); - const destOrigin = new URL(req.url).origin; + if (this.#token == "") { + this.setToken(await token()); + } - if (this.#token == "") { - this.setToken(await token()) - } - - if (this.#token && this.authOrigins.includes(destOrigin)) { - req.headers.set('Authorization', "Bearer " + this.#token); - return fetch(req); - } - } -} \ No newline at end of file + if (this.#token && this.authOrigins.includes(destOrigin)) { + req.headers.set("Authorization", "Bearer " + this.#token); + return fetch(req); + } + } +} diff --git a/frontend/components/utilities/attemptLogin.js b/frontend/components/utilities/attemptLogin.js index c4fc69826..443ffc0b0 100644 --- a/frontend/components/utilities/attemptLogin.js +++ b/frontend/components/utilities/attemptLogin.js @@ -1,10 +1,10 @@ -import login1 from "../../pages/api/auth/Login1"; -import login2 from "../../pages/api/auth/Login2"; -import Aes256Gcm from "../../components/aes-256-gcm"; +import login1 from "~/pages/api/auth/Login1"; +import login2 from "~/pages/api/auth/Login2"; +import Aes256Gcm from "~/components/aes-256-gcm"; import pushKeys from "./pushKeys"; import { initPostHog } from "../analytics/posthog"; -import getOrganizations from "../../pages/api/organization/getOrgs"; -import getOrganizationUserProjects from "../../pages/api/organization/GetOrgUserProjects"; +import getOrganizations from "~/pages/api/organization/getOrgs"; +import getOrganizationUserProjects from "~/pages/api/organization/GetOrgUserProjects"; import SecurityClient from "./SecurityClient"; import { ENV } from "./config"; @@ -77,7 +77,14 @@ const attemptLogin = async ( encryptedPrivateKey, iv, tag, - password.slice(0, 32).padStart(32 + (password.slice(0, 32).length - new Blob([password]).size), "0") + password + .slice(0, 32) + .padStart( + 32 + + (password.slice(0, 32).length - + new Blob([password]).size), + "0" + ) ); try { @@ -101,10 +108,14 @@ const attemptLogin = async ( } const userOrgs = await getOrganizations(); - const userOrgsData = userOrgs.map(org => org._id); - + const userOrgsData = userOrgs.map((org) => org._id); + let orgToLogin; - if (userOrgsData.includes(localStorage.getItem("orgData.id"))) { + if ( + userOrgsData.includes( + localStorage.getItem("orgData.id") + ) + ) { orgToLogin = localStorage.getItem("orgData.id"); } else { orgToLogin = userOrgsData[0]; @@ -114,17 +125,29 @@ const attemptLogin = async ( let orgUserProjects = await getOrganizationUserProjects({ orgId: orgToLogin, }); - - orgUserProjects = orgUserProjects?.map(project => project._id); + + orgUserProjects = orgUserProjects?.map( + (project) => project._id + ); let projectToLogin; - if (orgUserProjects.includes(localStorage.getItem("projectData.id"))) { + if ( + orgUserProjects.includes( + localStorage.getItem("projectData.id") + ) + ) { projectToLogin = localStorage.getItem("projectData.id"); } else { try { projectToLogin = orgUserProjects[0]; - localStorage.setItem("projectData.id", projectToLogin); + localStorage.setItem( + "projectData.id", + projectToLogin + ); } catch (error) { - console.log("ERROR: User likely has no projects. ", error) + console.log( + "ERROR: User likely has no projects. ", + error + ); } } diff --git a/frontend/components/utilities/changePassword.js b/frontend/components/utilities/changePassword.js index 83eb54b13..9d213e2c0 100644 --- a/frontend/components/utilities/changePassword.js +++ b/frontend/components/utilities/changePassword.js @@ -1,6 +1,6 @@ import Aes256Gcm from "../aes-256-gcm"; -import SRP1 from "../../pages/api/auth/SRP1"; -import changePassword2 from "../../pages/api/auth/ChangePassword2"; +import SRP1 from "~/pages/api/auth/SRP1"; +import changePassword2 from "~/pages/api/auth/ChangePassword2"; const nacl = require("tweetnacl"); nacl.util = require("tweetnacl-util"); @@ -41,7 +41,7 @@ const changePassword = async ( let serverPublicKey, salt; try { const res = await SRP1({ - clientPublicKey: clientPublicKey + clientPublicKey: clientPublicKey, }); serverPublicKey = res.serverPublicKey; salt = res.salt; @@ -54,54 +54,70 @@ const changePassword = async ( clientOldPassword.setServerPublicKey(serverPublicKey); const clientProof = clientOldPassword.getProof(); // called M1 - clientNewPassword.init({ - username: email, - password: newPassword - }, async () => { - clientNewPassword.createVerifier(async (err, result) => { - - let { ciphertext, iv, tag } = Aes256Gcm.encrypt( - localStorage.getItem("PRIVATE_KEY"), - newPassword.slice(0, 32).padStart(32 + (newPassword.slice(0, 32).length - new Blob([newPassword]).size), "0") - ); + clientNewPassword.init( + { + username: email, + password: newPassword, + }, + async () => { + clientNewPassword.createVerifier( + async (err, result) => { + let { ciphertext, iv, tag } = Aes256Gcm.encrypt( + localStorage.getItem("PRIVATE_KEY"), + newPassword + .slice(0, 32) + .padStart( + 32 + + (newPassword.slice(0, 32) + .length - + new Blob([newPassword]) + .size), + "0" + ) + ); - if (ciphertext) { - localStorage.setItem( - "encryptedPrivateKey", - ciphertext - ); - localStorage.setItem("iv", iv); - localStorage.setItem("tag", tag); - - let res; - try { - res = await changePassword2({ - encryptedPrivateKey: ciphertext, - iv, - tag, - salt: result.salt, - verifier: result.verifier, - clientProof - }); - if (res.status == 400) { - setCurrentPasswordError(true); - } else if (res.status == 200) { - setPasswordChanged(true); - setCurrentPassword(""); - setNewPassword(""); + if (ciphertext) { + localStorage.setItem( + "encryptedPrivateKey", + ciphertext + ); + localStorage.setItem("iv", iv); + localStorage.setItem("tag", tag); + + let res; + try { + res = await changePassword2({ + encryptedPrivateKey: ciphertext, + iv, + tag, + salt: result.salt, + verifier: result.verifier, + clientProof, + }); + if (res.status == 400) { + setCurrentPasswordError(true); + } else if (res.status == 200) { + setPasswordChanged(true); + setCurrentPassword(""); + setNewPassword(""); + } + } catch (err) { + setCurrentPasswordError(true); + console.log(err); + } } - } catch (err) { - setCurrentPasswordError(true) - console.log(err); } - } - }); - }); - + ); + } + ); } ); } catch (error) { - console.log("Something went wrong during changing the password", slat, serverPublicKey); + console.log( + "Something went wrong during changing the password", + slat, + serverPublicKey + ); } return true; }; diff --git a/frontend/components/utilities/getSecretsForProject.js b/frontend/components/utilities/getSecretsForProject.js index 32861f329..f229404e7 100644 --- a/frontend/components/utilities/getSecretsForProject.js +++ b/frontend/components/utilities/getSecretsForProject.js @@ -1,7 +1,6 @@ -import getSecrets from "../../pages/api/files/GetSecrets"; +import getSecrets from "~/pages/api/files/GetSecrets"; import guidGenerator from "./randomId"; - const { decryptAssymmetric, decryptSymmetric, @@ -21,15 +20,12 @@ const getSecretsForProject = async ({ setFileState, setIsKeyAvailable, setData, - workspaceId + workspaceId, }) => { try { let file; try { - file = await getSecrets( - workspaceId, - envMapping[env] - ); + file = await getSecrets(workspaceId, envMapping[env]); setFileState(file); } catch (error) { @@ -98,7 +94,9 @@ const getSecretsForProject = async ({ line["type"], ]); } catch (error) { - console.log("Something went wrong during accessing or decripting secrets."); + console.log( + "Something went wrong during accessing or decripting secrets." + ); } return true; }; diff --git a/frontend/components/utilities/issueBackupKey.js b/frontend/components/utilities/issueBackupKey.js index f6c60bfc8..92f4b2f70 100644 --- a/frontend/components/utilities/issueBackupKey.js +++ b/frontend/components/utilities/issueBackupKey.js @@ -1,6 +1,6 @@ import Aes256Gcm from "../aes-256-gcm"; -import SRP1 from "../../pages/api/auth/SRP1"; -import issueBackupPrivateKey from "../../pages/api/auth/IssueBackupPrivateKey"; +import SRP1 from "~/pages/api/auth/SRP1"; +import issueBackupPrivateKey from "~/pages/api/auth/IssueBackupPrivateKey"; import generateBackupPDF from "./generateBackupPDF"; const nacl = require("tweetnacl"); @@ -24,7 +24,7 @@ const issueBackupKey = async ({ password, personalName, setBackupKeyError, - setBackupKeyIssued + setBackupKeyIssued, }) => { try { setBackupKeyError(false); @@ -40,7 +40,7 @@ const issueBackupKey = async ({ let serverPublicKey, salt; try { const res = await SRP1({ - clientPublicKey: clientPublicKey + clientPublicKey: clientPublicKey, }); serverPublicKey = res.serverPublicKey; salt = res.salt; @@ -55,35 +55,40 @@ const issueBackupKey = async ({ const generatedKey = crypto.randomBytes(16).toString("hex"); - clientKey.init({ - username: email, - password: generatedKey - }, async () => { - clientKey.createVerifier(async (err, result) => { + clientKey.init( + { + username: email, + password: generatedKey, + }, + async () => { + clientKey.createVerifier(async (err, result) => { + let { ciphertext, iv, tag } = Aes256Gcm.encrypt( + localStorage.getItem("PRIVATE_KEY"), + generatedKey + ); + const res = await issueBackupPrivateKey({ + encryptedPrivateKey: ciphertext, + iv, + tag, + salt: result.salt, + verifier: result.verifier, + clientProof, + }); - let { ciphertext, iv, tag } = Aes256Gcm.encrypt( - localStorage.getItem("PRIVATE_KEY"), - generatedKey - ); - - const res = await issueBackupPrivateKey({ - encryptedPrivateKey: ciphertext, - iv, - tag, - salt: result.salt, - verifier: result.verifier, - clientProof + if (res.status == 400) { + setBackupKeyError(true); + } else if (res.status == 200) { + generateBackupPDF( + personalName, + email, + generatedKey + ); + setBackupKeyIssued(true); + } }); - - if (res.status == 400) { - setBackupKeyError(true); - } else if (res.status == 200) { - generateBackupPDF(personalName, email, generatedKey); - setBackupKeyIssued(true); - } - }); - }) + } + ); } ); } catch (error) { diff --git a/frontend/components/utilities/pushKeys.js b/frontend/components/utilities/pushKeys.js index 284b89cbc..37261f342 100644 --- a/frontend/components/utilities/pushKeys.js +++ b/frontend/components/utilities/pushKeys.js @@ -1,6 +1,6 @@ -import getLatestFileKey from "../../pages/api/workspace/getLatestFileKey"; -import getWorkspaceKeys from "../../pages/api/workspace/getWorkspaceKeys"; -import uploadSecrets from "../../pages/api/files/UploadSecrets"; +import getLatestFileKey from "~/pages/api/workspace/getLatestFileKey"; +import getWorkspaceKeys from "~/pages/api/workspace/getWorkspaceKeys"; +import uploadSecrets from "~/pages/api/files/UploadSecrets"; const crypto = require("crypto"); const { diff --git a/frontend/components/utilities/pushKeysIntegration.js b/frontend/components/utilities/pushKeysIntegration.js index 0d75c2cb1..06ad8c0e6 100644 --- a/frontend/components/utilities/pushKeysIntegration.js +++ b/frontend/components/utilities/pushKeysIntegration.js @@ -1,11 +1,8 @@ -import publicKeyInfical from "../../pages/api/auth/publicKeyInfisical" -import changeHerokuConfigVars from "../../pages/api/integrations/ChangeHerokuConfigVars"; +import publicKeyInfical from "~/pages/api/auth/publicKeyInfisical"; +import changeHerokuConfigVars from "~/pages/api/integrations/ChangeHerokuConfigVars"; const crypto = require("crypto"); -const { - encryptSymmetric, - encryptAssymmetric, -} = require("./crypto"); +const { encryptSymmetric, encryptAssymmetric } = require("./crypto"); const nacl = require("tweetnacl"); nacl.util = require("tweetnacl-util"); @@ -71,7 +68,7 @@ const pushKeysIntegration = async ({ obj, integrationId }) => { nonce, }; - changeHerokuConfigVars({integrationId, key, secrets}) + changeHerokuConfigVars({ integrationId, key, secrets }); }; export default pushKeysIntegration; diff --git a/frontend/jsconfig.json b/frontend/jsconfig.json index a00219844..6f859d11a 100644 --- a/frontend/jsconfig.json +++ b/frontend/jsconfig.json @@ -6,10 +6,10 @@ "components/*" ], "~/utilities/*": [ - "components/utilities" + "components/utilities/*" ], "~/pages/*": [ - "components/*" + "pages/*" ], } } diff --git a/frontend/pages/_app.js b/frontend/pages/_app.js index 49df5984f..18e6d4548 100644 --- a/frontend/pages/_app.js +++ b/frontend/pages/_app.js @@ -1,13 +1,13 @@ import "../styles/globals.css"; import "@fortawesome/fontawesome-svg-core/styles.css"; import { config } from "@fortawesome/fontawesome-svg-core"; -import Layout from "../components/basic/layout"; -import RouteGuard from "../components/RouteGuard"; +import Layout from "~/components/basic/layout"; +import RouteGuard from "~/components/RouteGuard"; import { publicPaths } from "../const.js"; import { useEffect } from "react"; import { useRouter } from "next/router"; -import { initPostHog } from "../components/analytics/posthog"; -import { ENV } from "../components/utilities/config"; +import { initPostHog } from "~/components/analytics/posthog"; +import { ENV } from "~/utilities/config"; config.autoAddCss = false; @@ -39,9 +39,7 @@ const App = ({ Component, pageProps, ...appProps }) => { publicPaths.includes("/" + appProps.router.pathname.split("/")[1]) || !Component.requireAuth ) { - return ( - - ) + return ; } return ( diff --git a/frontend/pages/api/auth/ChangePassword2.js b/frontend/pages/api/auth/ChangePassword2.js index a7854e768..9618c21a8 100644 --- a/frontend/pages/api/auth/ChangePassword2.js +++ b/frontend/pages/api/auth/ChangePassword2.js @@ -1,4 +1,4 @@ -import SecurityClient from "../../../components/utilities/SecurityClient"; +import SecurityClient from "~/utilities/SecurityClient"; import { PATH } from "../../../const"; /** @@ -6,28 +6,34 @@ import { PATH } from "../../../const"; * @param {*} clientPublicKey * @returns */ -const changePassword2 = ({encryptedPrivateKey, iv, tag, salt, verifier, clientProof}) => { +const changePassword2 = ({ + encryptedPrivateKey, + iv, + tag, + salt, + verifier, + clientProof, +}) => { return SecurityClient.fetchCall(PATH + "/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: clientProof, + encryptedPrivateKey: encryptedPrivateKey, + iv: iv, + tag: tag, + salt: salt, + verifier: verifier, }), - }) - .then(async res => { + }).then(async (res) => { if (res.status == 200) { return res; } else { - console.log('Failed to change the password'); + console.log("Failed to change the password"); } - }) + }); }; export default changePassword2; diff --git a/frontend/pages/api/auth/CheckAuth.js b/frontend/pages/api/auth/CheckAuth.js index dcfea324e..36f678b70 100644 --- a/frontend/pages/api/auth/CheckAuth.js +++ b/frontend/pages/api/auth/CheckAuth.js @@ -1,4 +1,4 @@ -import SecurityClient from "../../../components/utilities/SecurityClient.js"; +import SecurityClient from "~/utilities/SecurityClient.js"; import { PATH } from "../../../const.js"; /** @@ -14,14 +14,13 @@ const checkAuth = async (req, res) => { headers: { "Content-Type": "application/json", }, - }) - .then(res => { + }).then((res) => { if (res.status == 200) { return res; } else { console.log("Not authorized"); } - }) + }); }; export default checkAuth; diff --git a/frontend/pages/api/auth/IssueBackupPrivateKey.js b/frontend/pages/api/auth/IssueBackupPrivateKey.js index 62d2c807c..76205efcb 100644 --- a/frontend/pages/api/auth/IssueBackupPrivateKey.js +++ b/frontend/pages/api/auth/IssueBackupPrivateKey.js @@ -1,32 +1,41 @@ -import SecurityClient from "../../../components/utilities/SecurityClient"; +import SecurityClient from "~/utilities/SecurityClient"; import { PATH } from "../../../const"; /** * This is the route that issues a backup private key that will afterwards be added into a pdf */ -const issueBackupPrivateKey = ({encryptedPrivateKey, iv, tag, salt, verifier, clientProof}) => { - return SecurityClient.fetchCall(PATH + "/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 - }), - }) - .then(res => { +const issueBackupPrivateKey = ({ + encryptedPrivateKey, + iv, + tag, + salt, + verifier, + clientProof, +}) => { + return SecurityClient.fetchCall( + PATH + "/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, + }), + } + ).then((res) => { if (res.status == 200) { return res; } else { return res; console.log("Failed to issue the backup key"); } - }) + }); }; export default issueBackupPrivateKey; diff --git a/frontend/pages/api/auth/Logout.js b/frontend/pages/api/auth/Logout.js index 09d51098d..e00394c26 100644 --- a/frontend/pages/api/auth/Logout.js +++ b/frontend/pages/api/auth/Logout.js @@ -1,4 +1,4 @@ -import SecurityClient from "../../../components/utilities/SecurityClient"; +import SecurityClient from "~/utilities/SecurityClient"; import { PATH } from "../../../const"; /** @@ -14,9 +14,8 @@ const logout = async (req, res) => { headers: { "Content-Type": "application/json", }, - credentials: "include" - }) - .then(res => { + credentials: "include", + }).then((res) => { if (res.status == 200) { SecurityClient.setToken(""); // Delete the cookie by not setting a value; Alternatively clear the local storage @@ -30,7 +29,7 @@ const logout = async (req, res) => { } else { console.log("Failed to log out"); } - }) + }); }; export default logout; diff --git a/frontend/pages/api/auth/SRP1.js b/frontend/pages/api/auth/SRP1.js index eae3bb5aa..78692f596 100644 --- a/frontend/pages/api/auth/SRP1.js +++ b/frontend/pages/api/auth/SRP1.js @@ -1,4 +1,4 @@ -import SecurityClient from "../../../components/utilities/SecurityClient"; +import SecurityClient from "~/utilities/SecurityClient"; import { PATH } from "../../../const"; /** @@ -6,7 +6,7 @@ import { PATH } from "../../../const"; * @param {*} clientPublicKey * @returns */ -const SRP1 = ({clientPublicKey}) => { +const SRP1 = ({ clientPublicKey }) => { return SecurityClient.fetchCall(PATH + "/api/v1/password/srp1", { method: "POST", headers: { @@ -15,14 +15,13 @@ const SRP1 = ({clientPublicKey}) => { body: JSON.stringify({ clientPublicKey, }), - }) - .then(async res => { + }).then(async (res) => { if (res.status == 200) { - return (await res.json()); + return await res.json(); } else { - console.log('Failed to do the first step of SRP'); + console.log("Failed to do the first step of SRP"); } - }) + }); }; export default SRP1; diff --git a/frontend/pages/api/files/GetSecrets.js b/frontend/pages/api/files/GetSecrets.js index 7361c7156..f153e7fb2 100644 --- a/frontend/pages/api/files/GetSecrets.js +++ b/frontend/pages/api/files/GetSecrets.js @@ -1,4 +1,4 @@ -import SecurityClient from "../../../components/utilities/SecurityClient.js"; +import SecurityClient from "~/utilities/SecurityClient.js"; import { PATH } from "../../../const.js"; /** @@ -8,26 +8,28 @@ import { PATH } from "../../../const.js"; * @returns */ const getSecrets = async (workspaceId, env) => { - return SecurityClient.fetchCall(PATH + "/api/v1/secret/" + - workspaceId + - "?" + - new URLSearchParams({ - environment: env, - channel: "web", + return SecurityClient.fetchCall( + PATH + + "/api/v1/secret/" + + workspaceId + + "?" + + new URLSearchParams({ + environment: env, + channel: "web", + }), + { + method: "GET", + headers: { + "Content-Type": "application/json", + }, } - ), { - method: "GET", - headers: { - "Content-Type": "application/json", - }, - }) - .then(async res => { + ).then(async (res) => { if (res.status == 200) { - return (await res.json()); + return await res.json(); } else { - console.log('Failed to get project secrets'); + console.log("Failed to get project secrets"); } - }) + }); }; export default getSecrets; diff --git a/frontend/pages/api/files/UploadSecrets.js b/frontend/pages/api/files/UploadSecrets.js index b3b5e5a49..a34ca3df7 100644 --- a/frontend/pages/api/files/UploadSecrets.js +++ b/frontend/pages/api/files/UploadSecrets.js @@ -1,4 +1,4 @@ -import SecurityClient from "../../../components/utilities/SecurityClient"; +import SecurityClient from "~/utilities/SecurityClient"; import { PATH } from "../../../const"; /** @@ -19,14 +19,13 @@ const uploadSecrets = async ({ workspaceId, secrets, keys, environment }) => { environment, channel: "web", }), - }) - .then(async res => { + }).then(async (res) => { if (res.status == 200) { return res; } else { - console.log('Failed to push secrets'); + console.log("Failed to push secrets"); } - }) + }); }; export default uploadSecrets; diff --git a/frontend/pages/api/integrations/ChangeHerokuConfigVars.js b/frontend/pages/api/integrations/ChangeHerokuConfigVars.js index 44dfd7ae3..e3a93c52e 100644 --- a/frontend/pages/api/integrations/ChangeHerokuConfigVars.js +++ b/frontend/pages/api/integrations/ChangeHerokuConfigVars.js @@ -1,24 +1,26 @@ -import SecurityClient from "../../../components/utilities/SecurityClient"; +import SecurityClient from "~/utilities/SecurityClient"; import { PATH } from "../../../const"; const changeHerokuConfigVars = ({ integrationId, key, secrets }) => { - return SecurityClient.fetchCall(PATH + "/api/v1/integration/" + integrationId + "/sync", { - method: "POST", - headers: { - "Content-Type": "application/json", - }, - body: JSON.stringify({ - key, - secrets, - }) - }) - .then(async res => { + return SecurityClient.fetchCall( + PATH + "/api/v1/integration/" + integrationId + "/sync", + { + method: "POST", + headers: { + "Content-Type": "application/json", + }, + body: JSON.stringify({ + key, + secrets, + }), + } + ).then(async (res) => { if (res.status == 200) { return res; } else { - console.log('Failed to sync secrets to Heroku'); + console.log("Failed to sync secrets to Heroku"); } - }) + }); }; export default changeHerokuConfigVars; diff --git a/frontend/pages/api/integrations/DeleteIntegration.js b/frontend/pages/api/integrations/DeleteIntegration.js index 32e5b3a09..b35066509 100644 --- a/frontend/pages/api/integrations/DeleteIntegration.js +++ b/frontend/pages/api/integrations/DeleteIntegration.js @@ -1,4 +1,4 @@ -import SecurityClient from "../../../components/utilities/SecurityClient"; +import SecurityClient from "~/utilities/SecurityClient"; import { PATH } from "../../../const"; /** @@ -7,19 +7,21 @@ import { PATH } from "../../../const"; * @returns */ const deleteIntegration = ({ integrationId }) => { - return SecurityClient.fetchCall(PATH + "/api/v1/integration/" + integrationId, { - method: "DELETE", - headers: { - "Content-Type": "application/json", - }, - }) - .then(async res => { + return SecurityClient.fetchCall( + PATH + "/api/v1/integration/" + integrationId, + { + method: "DELETE", + headers: { + "Content-Type": "application/json", + }, + } + ).then(async (res) => { if (res.status == 200) { return (await res.json()).workspace; } else { - console.log('Failed to delete an integration'); + console.log("Failed to delete an integration"); } - }) + }); }; export default deleteIntegration; diff --git a/frontend/pages/api/integrations/DeleteIntegrationAuth.js b/frontend/pages/api/integrations/DeleteIntegrationAuth.js index d12813c4b..2b81b3f02 100644 --- a/frontend/pages/api/integrations/DeleteIntegrationAuth.js +++ b/frontend/pages/api/integrations/DeleteIntegrationAuth.js @@ -1,4 +1,4 @@ -import SecurityClient from "../../../components/utilities/SecurityClient"; +import SecurityClient from "~/utilities/SecurityClient"; import { PATH } from "../../../const"; /** @@ -7,19 +7,21 @@ import { PATH } from "../../../const"; * @returns */ const deleteIntegrationAuth = ({ integrationAuthId }) => { - return SecurityClient.fetchCall(PATH + "/api/v1/integration-auth/" + integrationAuthId, { - method: "DELETE", - headers: { - "Content-Type": "application/json", - }, - }) - .then(async res => { + return SecurityClient.fetchCall( + PATH + "/api/v1/integration-auth/" + integrationAuthId, + { + method: "DELETE", + headers: { + "Content-Type": "application/json", + }, + } + ).then(async (res) => { if (res.status == 200) { return res; } else { - console.log('Failed to delete an integration authorization'); + console.log("Failed to delete an integration authorization"); } - }) + }); }; export default deleteIntegrationAuth; diff --git a/frontend/pages/api/integrations/GetIntegrationApps.js b/frontend/pages/api/integrations/GetIntegrationApps.js index 3238bc071..a938319a3 100644 --- a/frontend/pages/api/integrations/GetIntegrationApps.js +++ b/frontend/pages/api/integrations/GetIntegrationApps.js @@ -1,20 +1,22 @@ -import SecurityClient from "../../../components/utilities/SecurityClient"; +import SecurityClient from "~/utilities/SecurityClient"; import { PATH } from "../../../const"; const getIntegrationApps = ({ integrationAuthId }) => { - return SecurityClient.fetchCall(PATH + "/api/v1/integration-auth/" + integrationAuthId + "/apps", { - method: "GET", - headers: { - "Content-Type": "application/json", - }, - }) - .then(async res => { + return SecurityClient.fetchCall( + PATH + "/api/v1/integration-auth/" + integrationAuthId + "/apps", + { + method: "GET", + headers: { + "Content-Type": "application/json", + }, + } + ).then(async (res) => { if (res.status == 200) { return (await res.json()).apps; } else { - console.log('Failed to get available apps for an integration'); + console.log("Failed to get available apps for an integration"); } - }) + }); }; export default getIntegrationApps; diff --git a/frontend/pages/api/integrations/GetIntegrations.js b/frontend/pages/api/integrations/GetIntegrations.js index 1059d5ef0..92bd598c1 100644 --- a/frontend/pages/api/integrations/GetIntegrations.js +++ b/frontend/pages/api/integrations/GetIntegrations.js @@ -1,4 +1,4 @@ -import SecurityClient from "../../../components/utilities/SecurityClient"; +import SecurityClient from "~/utilities/SecurityClient"; import { PATH } from "../../../const"; const getIntegrations = () => { @@ -7,14 +7,13 @@ const getIntegrations = () => { headers: { "Content-Type": "application/json", }, - }) - .then(async res => { + }).then(async (res) => { if (res.status == 200) { return (await res.json()).integrations; } else { - console.log('Failed to get project integrations'); + console.log("Failed to get project integrations"); } - }) + }); }; export default getIntegrations; diff --git a/frontend/pages/api/integrations/StartIntegration.js b/frontend/pages/api/integrations/StartIntegration.js index d161e535f..e1cbcef4e 100644 --- a/frontend/pages/api/integrations/StartIntegration.js +++ b/frontend/pages/api/integrations/StartIntegration.js @@ -1,32 +1,34 @@ -import SecurityClient from "../../../components/utilities/SecurityClient"; +import SecurityClient from "~/utilities/SecurityClient"; import { PATH } from "../../../const"; /** - * This route starts the integration after teh default one if gonna set up. + * This route starts the integration after teh default one if gonna set up. * @param {*} integrationId * @returns */ const startIntegration = ({ integrationId, appName, environment }) => { - return SecurityClient.fetchCall(PATH + "/api/v1/integration/" + integrationId, { - method: "PATCH", - headers: { - "Content-Type": "application/json", - }, - body: JSON.stringify({ - "update": { - app: appName, - environment, - isActive: true - } - }) - }) - .then(async res => { + return SecurityClient.fetchCall( + PATH + "/api/v1/integration/" + integrationId, + { + method: "PATCH", + headers: { + "Content-Type": "application/json", + }, + body: JSON.stringify({ + update: { + app: appName, + environment, + isActive: true, + }, + }), + } + ).then(async (res) => { if (res.status == 200) { return res; } else { - console.log('Failed to start an integration'); + console.log("Failed to start an integration"); } - }) + }); }; export default startIntegration; diff --git a/frontend/pages/api/integrations/authorizeIntegration.js b/frontend/pages/api/integrations/authorizeIntegration.js index f242cd8e6..4ecb13a6a 100644 --- a/frontend/pages/api/integrations/authorizeIntegration.js +++ b/frontend/pages/api/integrations/authorizeIntegration.js @@ -1,4 +1,4 @@ -import SecurityClient from "../../../components/utilities/SecurityClient"; +import SecurityClient from "~/utilities/SecurityClient"; import { PATH } from "../../../const"; /** @@ -7,24 +7,26 @@ import { PATH } from "../../../const"; * @returns */ const AuthorizeIntegration = ({ workspaceId, code, integration }) => { - return SecurityClient.fetchCall(PATH + "/api/v1/integration-auth/oauth-token", { - method: "POST", - headers: { - "Content-Type": "application/json", - }, - body: JSON.stringify({ - workspaceId, - code, - integration - }), - }) - .then(async res => { + return SecurityClient.fetchCall( + PATH + "/api/v1/integration-auth/oauth-token", + { + method: "POST", + headers: { + "Content-Type": "application/json", + }, + body: JSON.stringify({ + workspaceId, + code, + integration, + }), + } + ).then(async (res) => { if (res.status == 200) { return res; } else { - console.log('Failed to authorize the integration'); + console.log("Failed to authorize the integration"); } - }) + }); }; export default AuthorizeIntegration; diff --git a/frontend/pages/api/integrations/getWorkspaceAuthorizations.js b/frontend/pages/api/integrations/getWorkspaceAuthorizations.js index 351818fdf..ca8091131 100644 --- a/frontend/pages/api/integrations/getWorkspaceAuthorizations.js +++ b/frontend/pages/api/integrations/getWorkspaceAuthorizations.js @@ -1,4 +1,4 @@ -import SecurityClient from "../../../components/utilities/SecurityClient"; +import SecurityClient from "~/utilities/SecurityClient"; import { PATH } from "../../../const"; /** @@ -7,19 +7,21 @@ import { PATH } from "../../../const"; * @returns */ const getWorkspaceAuthorizations = ({ workspaceId }) => { - return SecurityClient.fetchCall(PATH + "/api/v1/workspace/" + workspaceId + "/authorizations", { - method: "GET", - headers: { - "Content-Type": "application/json", - }, - }) - .then(async res => { + return SecurityClient.fetchCall( + PATH + "/api/v1/workspace/" + workspaceId + "/authorizations", + { + method: "GET", + headers: { + "Content-Type": "application/json", + }, + } + ).then(async (res) => { if (res.status == 200) { return (await res.json()).authorizations; } else { - console.log('Failed to get project authorizations'); + console.log("Failed to get project authorizations"); } - }) + }); }; export default getWorkspaceAuthorizations; diff --git a/frontend/pages/api/integrations/getWorkspaceIntegrations.js b/frontend/pages/api/integrations/getWorkspaceIntegrations.js index d968408b0..fd54da004 100644 --- a/frontend/pages/api/integrations/getWorkspaceIntegrations.js +++ b/frontend/pages/api/integrations/getWorkspaceIntegrations.js @@ -1,4 +1,4 @@ -import SecurityClient from "../../../components/utilities/SecurityClient"; +import SecurityClient from "~/utilities/SecurityClient"; import { PATH } from "../../../const"; /** @@ -7,19 +7,21 @@ import { PATH } from "../../../const"; * @returns */ const getWorkspaceIntegrations = ({ workspaceId }) => { - return SecurityClient.fetchCall(PATH + "/api/v1/workspace/" + workspaceId + "/integrations", { - method: "GET", - headers: { - "Content-Type": "application/json", - }, - }) - .then(async res => { + return SecurityClient.fetchCall( + PATH + "/api/v1/workspace/" + workspaceId + "/integrations", + { + method: "GET", + headers: { + "Content-Type": "application/json", + }, + } + ).then(async (res) => { if (res.status == 200) { return (await res.json()).integrations; } else { - console.log('Failed to get the project integrations'); + console.log("Failed to get the project integrations"); } - }) + }); }; export default getWorkspaceIntegrations; diff --git a/frontend/pages/api/organization/GetOrg.js b/frontend/pages/api/organization/GetOrg.js index d8cf68278..2f93a8f32 100644 --- a/frontend/pages/api/organization/GetOrg.js +++ b/frontend/pages/api/organization/GetOrg.js @@ -1,4 +1,4 @@ -import SecurityClient from "../../../components/utilities/SecurityClient"; +import SecurityClient from "~/utilities/SecurityClient"; import { PATH } from "../../../const"; /** @@ -8,19 +8,21 @@ import { PATH } from "../../../const"; * @returns */ const getOrganization = (req, res) => { - return SecurityClient.fetchCall(PATH + "/api/v1/organization/" + req.orgId, { - method: "GET", - headers: { - "Content-Type": "application/json", - }, - }) - .then(async res => { + return SecurityClient.fetchCall( + PATH + "/api/v1/organization/" + req.orgId, + { + method: "GET", + headers: { + "Content-Type": "application/json", + }, + } + ).then(async (res) => { if (res.status == 200) { return (await res.json()).organization; } else { - console.log('Failed to get org info'); + console.log("Failed to get org info"); } - }) + }); }; export default getOrganization; diff --git a/frontend/pages/api/organization/GetOrgProjects.js b/frontend/pages/api/organization/GetOrgProjects.js index ff0172764..d901782e6 100644 --- a/frontend/pages/api/organization/GetOrgProjects.js +++ b/frontend/pages/api/organization/GetOrgProjects.js @@ -1,4 +1,4 @@ -import SecurityClient from "../../../components/utilities/SecurityClient"; +import SecurityClient from "~/utilities/SecurityClient"; import { PATH } from "../../../const"; /** @@ -8,19 +8,21 @@ import { PATH } from "../../../const"; * @returns */ const getOrganizationProjects = (req, res) => { - return SecurityClient.fetchCall(PATH + "/api/organization/" + req.orgId + "/workspaces", { - method: "GET", - headers: { - "Content-Type": "application/json", - }, - }) - .then(async res => { + return SecurityClient.fetchCall( + PATH + "/api/organization/" + req.orgId + "/workspaces", + { + method: "GET", + headers: { + "Content-Type": "application/json", + }, + } + ).then(async (res) => { if (res.status == 200) { return (await res.json()).workspaces; } else { - console.log('Failed to get projects for an org'); + console.log("Failed to get projects for an org"); } - }) + }); }; export default getOrganizationProjects; diff --git a/frontend/pages/api/organization/GetOrgSubscription.js b/frontend/pages/api/organization/GetOrgSubscription.js index c82c6b091..9bb54f4f9 100644 --- a/frontend/pages/api/organization/GetOrgSubscription.js +++ b/frontend/pages/api/organization/GetOrgSubscription.js @@ -1,4 +1,4 @@ -import SecurityClient from "../../../components/utilities/SecurityClient"; +import SecurityClient from "~/utilities/SecurityClient"; import { PATH } from "../../../const"; /** @@ -8,19 +8,21 @@ import { PATH } from "../../../const"; * @returns */ const getOrganizationSubscriptions = (req, res) => { - return SecurityClient.fetchCall(PATH + "/api/v1/organization/" + req.orgId + "/subscriptions", { - method: "GET", - headers: { - "Content-Type": "application/json", - }, - }) - .then(async res => { + return SecurityClient.fetchCall( + PATH + "/api/v1/organization/" + req.orgId + "/subscriptions", + { + method: "GET", + headers: { + "Content-Type": "application/json", + }, + } + ).then(async (res) => { if (res.status == 200) { return (await res.json()).subscriptions; } else { - console.log('Failed to get org subscriptions'); + console.log("Failed to get org subscriptions"); } - }) + }); }; export default getOrganizationSubscriptions; diff --git a/frontend/pages/api/organization/GetOrgUserProjects.js b/frontend/pages/api/organization/GetOrgUserProjects.js index 55db8851d..5a9be5de7 100644 --- a/frontend/pages/api/organization/GetOrgUserProjects.js +++ b/frontend/pages/api/organization/GetOrgUserProjects.js @@ -1,4 +1,4 @@ -import SecurityClient from "../../../components/utilities/SecurityClient"; +import SecurityClient from "~/utilities/SecurityClient"; import { PATH } from "../../../const"; /** @@ -8,19 +8,21 @@ import { PATH } from "../../../const"; * @returns */ const getOrganizationUserProjects = (req, res) => { - return SecurityClient.fetchCall(PATH + "/api/v1/organization/" + req.orgId + "/my-workspaces", { - method: "GET", - headers: { - "Content-Type": "application/json", - }, - }) - .then(async res => { + return SecurityClient.fetchCall( + PATH + "/api/v1/organization/" + req.orgId + "/my-workspaces", + { + method: "GET", + headers: { + "Content-Type": "application/json", + }, + } + ).then(async (res) => { if (res.status == 200) { return (await res.json()).workspaces; } else { - console.log('Failed to get projects of a user in an org'); + console.log("Failed to get projects of a user in an org"); } - }) + }); }; export default getOrganizationUserProjects; diff --git a/frontend/pages/api/organization/GetOrgUsers.js b/frontend/pages/api/organization/GetOrgUsers.js index 792ddae4c..fb3dd6fb7 100644 --- a/frontend/pages/api/organization/GetOrgUsers.js +++ b/frontend/pages/api/organization/GetOrgUsers.js @@ -1,4 +1,4 @@ -import SecurityClient from "../../../components/utilities/SecurityClient"; +import SecurityClient from "~/utilities/SecurityClient"; import { PATH } from "../../../const"; /** @@ -8,19 +8,21 @@ import { PATH } from "../../../const"; * @returns */ const getOrganizationUsers = (req, res) => { - return SecurityClient.fetchCall(PATH + "/api/v1/organization/" + req.orgId + "/users", { - method: "GET", - headers: { - "Content-Type": "application/json", - }, - }) - .then(async res => { + return SecurityClient.fetchCall( + PATH + "/api/v1/organization/" + req.orgId + "/users", + { + method: "GET", + headers: { + "Content-Type": "application/json", + }, + } + ).then(async (res) => { if (res.status == 200) { return (await res.json()).users; } else { - console.log('Failed to get org users'); + console.log("Failed to get org users"); } - }) + }); }; export default getOrganizationUsers; diff --git a/frontend/pages/api/organization/StripeRedirect.js b/frontend/pages/api/organization/StripeRedirect.js index 739c3b73f..70d17d023 100644 --- a/frontend/pages/api/organization/StripeRedirect.js +++ b/frontend/pages/api/organization/StripeRedirect.js @@ -1,4 +1,4 @@ -import SecurityClient from "../../../components/utilities/SecurityClient"; +import SecurityClient from "~/utilities/SecurityClient"; import { PATH } from "../../../const"; /** @@ -7,20 +7,22 @@ import { PATH } from "../../../const"; * @param {*} res * @returns */ -const StripeRedirect = ({orgId}) => { - return SecurityClient.fetchCall(PATH + "/api/v1/organization/" + orgId + "/customer-portal-session", { - method: "POST", - headers: { - "Content-Type": "application/json", - }, - }) - .then(async res => { - if (res.status == 200) { - return window.location.href = (await res.json()).url; - } else { - console.log('Failed to redirect to Stripe'); +const StripeRedirect = ({ orgId }) => { + return SecurityClient.fetchCall( + PATH + "/api/v1/organization/" + orgId + "/customer-portal-session", + { + method: "POST", + headers: { + "Content-Type": "application/json", + }, } - }) + ).then(async (res) => { + if (res.status == 200) { + return (window.location.href = (await res.json()).url); + } else { + console.log("Failed to redirect to Stripe"); + } + }); }; export default StripeRedirect; diff --git a/frontend/pages/api/organization/addIncidentContact.js b/frontend/pages/api/organization/addIncidentContact.js index 5806a2940..3e4556d7d 100644 --- a/frontend/pages/api/organization/addIncidentContact.js +++ b/frontend/pages/api/organization/addIncidentContact.js @@ -1,4 +1,4 @@ -import SecurityClient from "../../../components/utilities/SecurityClient"; +import SecurityClient from "~/utilities/SecurityClient"; import { PATH } from "../../../const"; /** @@ -7,22 +7,24 @@ import { PATH } from "../../../const"; * @returns */ const addIncidentContact = (organizationId, email) => { - return SecurityClient.fetchCall(PATH + "/api/v1/organization/" + organizationId + "/incidentContactOrg", { - method: "POST", - headers: { - "Content-Type": "application/json", - }, - body: JSON.stringify({ - email: email, - }), - }) - .then(async res => { + return SecurityClient.fetchCall( + PATH + "/api/v1/organization/" + organizationId + "/incidentContactOrg", + { + method: "POST", + headers: { + "Content-Type": "application/json", + }, + body: JSON.stringify({ + email: email, + }), + } + ).then(async (res) => { if (res.status == 200) { return res; } else { - console.log('Failed to add an incident contact'); + console.log("Failed to add an incident contact"); } - }) + }); }; export default addIncidentContact; diff --git a/frontend/pages/api/organization/addUserToOrg.js b/frontend/pages/api/organization/addUserToOrg.js index 57ea7abcc..44feb793d 100644 --- a/frontend/pages/api/organization/addUserToOrg.js +++ b/frontend/pages/api/organization/addUserToOrg.js @@ -1,4 +1,4 @@ -import SecurityClient from "../../../components/utilities/SecurityClient"; +import SecurityClient from "~/utilities/SecurityClient"; import { PATH } from "../../../const"; /** @@ -17,14 +17,13 @@ const addUserToOrg = (email, orgId) => { inviteeEmail: email, organizationId: orgId, }), - }) - .then(async res => { + }).then(async (res) => { if (res.status == 200) { return res; } else { - console.log('Failed to add a user to an org'); + console.log("Failed to add a user to an org"); } - }) + }); }; export default addUserToOrg; diff --git a/frontend/pages/api/organization/deleteIncidentContact.js b/frontend/pages/api/organization/deleteIncidentContact.js index 4394873ce..04d0a53ff 100644 --- a/frontend/pages/api/organization/deleteIncidentContact.js +++ b/frontend/pages/api/organization/deleteIncidentContact.js @@ -1,4 +1,4 @@ -import SecurityClient from "../../../components/utilities/SecurityClient"; +import SecurityClient from "~/utilities/SecurityClient"; import { PATH } from "../../../const"; /** @@ -7,22 +7,24 @@ import { PATH } from "../../../const"; * @returns */ const deleteIncidentContact = (organizaionId, email) => { - return SecurityClient.fetchCall(PATH + "/api/v1/organization/" + organizaionId + "/incidentContactOrg", { - method: "DELETE", - headers: { - "Content-Type": "application/json", - }, - body: JSON.stringify({ - email: email, - }), - }) - .then(async res => { + return SecurityClient.fetchCall( + PATH + "/api/v1/organization/" + organizaionId + "/incidentContactOrg", + { + method: "DELETE", + headers: { + "Content-Type": "application/json", + }, + body: JSON.stringify({ + email: email, + }), + } + ).then(async (res) => { if (res.status == 200) { return res; } else { - console.log('Failed to delete an incident contact'); + console.log("Failed to delete an incident contact"); } - }) + }); }; export default deleteIncidentContact; diff --git a/frontend/pages/api/organization/deleteUserFromOrganization.js b/frontend/pages/api/organization/deleteUserFromOrganization.js index d46b44b17..86ff68812 100644 --- a/frontend/pages/api/organization/deleteUserFromOrganization.js +++ b/frontend/pages/api/organization/deleteUserFromOrganization.js @@ -1,4 +1,4 @@ -import SecurityClient from "../../../components/utilities/SecurityClient"; +import SecurityClient from "~/utilities/SecurityClient"; import { PATH } from "../../../const"; /** @@ -7,19 +7,21 @@ import { PATH } from "../../../const"; * @returns */ const deleteUserFromOrganization = (membershipId) => { - return SecurityClient.fetchCall(PATH + "/api/v1/membership-org/" + membershipId, { - method: "DELETE", - headers: { - "Content-Type": "application/json", - }, - }) - .then(async res => { + return SecurityClient.fetchCall( + PATH + "/api/v1/membership-org/" + membershipId, + { + method: "DELETE", + headers: { + "Content-Type": "application/json", + }, + } + ).then(async (res) => { if (res.status == 200) { return res; } else { - console.log('Failed to delete a user from an org'); + console.log("Failed to delete a user from an org"); } - }) + }); }; export default deleteUserFromOrganization; diff --git a/frontend/pages/api/organization/getIncidentContacts.js b/frontend/pages/api/organization/getIncidentContacts.js index 2f6604dbf..a46650bb9 100644 --- a/frontend/pages/api/organization/getIncidentContacts.js +++ b/frontend/pages/api/organization/getIncidentContacts.js @@ -1,4 +1,4 @@ -import SecurityClient from "../../../components/utilities/SecurityClient"; +import SecurityClient from "~/utilities/SecurityClient"; import { PATH } from "../../../const"; /** @@ -7,19 +7,21 @@ import { PATH } from "../../../const"; * @returns */ const getIncidentContacts = (organizationId) => { - return SecurityClient.fetchCall(PATH + "/api/v1/organization/" + organizationId + "/incidentContactOrg", { - method: "GET", - headers: { - "Content-Type": "application/json", - }, - }) - .then(async res => { + return SecurityClient.fetchCall( + PATH + "/api/v1/organization/" + organizationId + "/incidentContactOrg", + { + method: "GET", + headers: { + "Content-Type": "application/json", + }, + } + ).then(async (res) => { if (res.status == 200) { return (await res.json()).incidentContactsOrg; } else { - console.log('Failed to get incident contacts'); + console.log("Failed to get incident contacts"); } - }) + }); }; export default getIncidentContacts; diff --git a/frontend/pages/api/organization/getOrgs.js b/frontend/pages/api/organization/getOrgs.js index 65cf9bf06..21127be67 100644 --- a/frontend/pages/api/organization/getOrgs.js +++ b/frontend/pages/api/organization/getOrgs.js @@ -1,4 +1,4 @@ -import SecurityClient from "../../../components/utilities/SecurityClient"; +import SecurityClient from "~/utilities/SecurityClient"; import { PATH } from "../../../const"; /** @@ -13,14 +13,13 @@ const getOrganizations = (req, res) => { headers: { "Content-Type": "application/json", }, - }) - .then(async res => { + }).then(async (res) => { if (res.status == 200) { return (await res.json()).organizations; } else { - console.log('Failed to get orgs of a user'); + console.log("Failed to get orgs of a user"); } - }) + }); }; export default getOrganizations; diff --git a/frontend/pages/api/organization/renameOrg.js b/frontend/pages/api/organization/renameOrg.js index 51714709b..81c9e16db 100644 --- a/frontend/pages/api/organization/renameOrg.js +++ b/frontend/pages/api/organization/renameOrg.js @@ -1,4 +1,4 @@ -import SecurityClient from "../../../components/utilities/SecurityClient"; +import SecurityClient from "~/utilities/SecurityClient"; import { PATH } from "../../../const"; /** @@ -8,22 +8,24 @@ import { PATH } from "../../../const"; * @returns */ const renameOrg = (orgId, newOrgName) => { - return SecurityClient.fetchCall(PATH + "/api/v1/organization/" + orgId + "/name", { - method: "PATCH", - headers: { - "Content-Type": "application/json", - }, - body: JSON.stringify({ - name: newOrgName, - }), - }) - .then(async res => { + return SecurityClient.fetchCall( + PATH + "/api/v1/organization/" + orgId + "/name", + { + method: "PATCH", + headers: { + "Content-Type": "application/json", + }, + body: JSON.stringify({ + name: newOrgName, + }), + } + ).then(async (res) => { if (res.status == 200) { return res; } else { - console.log('Failed to rename an organization'); + console.log("Failed to rename an organization"); } - }) + }); }; export default renameOrg; diff --git a/frontend/pages/api/serviceToken/addServiceToken.js b/frontend/pages/api/serviceToken/addServiceToken.js index 92c788283..e41fa11b6 100644 --- a/frontend/pages/api/serviceToken/addServiceToken.js +++ b/frontend/pages/api/serviceToken/addServiceToken.js @@ -1,4 +1,4 @@ -import SecurityClient from "../../../components/utilities/SecurityClient"; +import SecurityClient from "~/utilities/SecurityClient"; import { PATH } from "../../../const"; /** @@ -6,29 +6,36 @@ import { PATH } from "../../../const"; * @param {*} param0 * @returns */ -const addServiceToken = ({name, workspaceId, environment, expiresIn, publicKey, encryptedKey, nonce}) => { +const addServiceToken = ({ + name, + workspaceId, + environment, + expiresIn, + publicKey, + encryptedKey, + nonce, +}) => { return SecurityClient.fetchCall(PATH + "/api/v1/service-token/", { method: "POST", headers: { "Content-Type": "application/json", }, body: JSON.stringify({ - name, - workspaceId, + name, + workspaceId, environment, - expiresIn, - publicKey, + expiresIn, + publicKey, encryptedKey, - nonce - }) - }) - .then(async res => { + nonce, + }), + }).then(async (res) => { if (res.status == 200) { return (await res.json()).token; } else { - console.log('Failed to add service tokens'); + console.log("Failed to add service tokens"); } - }) + }); }; export default addServiceToken; diff --git a/frontend/pages/api/serviceToken/getServiceTokens.js b/frontend/pages/api/serviceToken/getServiceTokens.js index 3e7aad64f..aa066e69c 100644 --- a/frontend/pages/api/serviceToken/getServiceTokens.js +++ b/frontend/pages/api/serviceToken/getServiceTokens.js @@ -1,4 +1,4 @@ -import SecurityClient from "../../../components/utilities/SecurityClient"; +import SecurityClient from "~/utilities/SecurityClient"; import { PATH } from "../../../const"; /** @@ -6,20 +6,22 @@ import { PATH } from "../../../const"; * @param {*} param0 * @returns */ -const getServiceTokens = ({workspaceId}) => { - return SecurityClient.fetchCall(PATH + "/api/v1/workspace/" + workspaceId + "/service-tokens", { - method: "GET", - headers: { - "Content-Type": "application/json", - }, - }) - .then(async res => { +const getServiceTokens = ({ workspaceId }) => { + return SecurityClient.fetchCall( + PATH + "/api/v1/workspace/" + workspaceId + "/service-tokens", + { + method: "GET", + headers: { + "Content-Type": "application/json", + }, + } + ).then(async (res) => { if (res.status == 200) { return (await res.json()).serviceTokens; } else { - console.log('Failed to get service tokens'); + console.log("Failed to get service tokens"); } - }) + }); }; export default getServiceTokens; diff --git a/frontend/pages/api/user/getUser.js b/frontend/pages/api/user/getUser.js index aeca1abdd..870eb85cd 100644 --- a/frontend/pages/api/user/getUser.js +++ b/frontend/pages/api/user/getUser.js @@ -1,4 +1,4 @@ -import SecurityClient from "../../../components/utilities/SecurityClient"; +import SecurityClient from "~/utilities/SecurityClient"; import { PATH } from "../../../const"; /** @@ -13,14 +13,13 @@ const getUser = (req, res) => { headers: { "Content-Type": "application/json", }, - }) - .then(async res => { + }).then(async (res) => { if (res.status == 200) { return (await res.json()).user; } else { - console.log('Failed to get user info'); + console.log("Failed to get user info"); } - }) + }); }; export default getUser; diff --git a/frontend/pages/api/userActions/checkUserAction.js b/frontend/pages/api/userActions/checkUserAction.js index 263e49004..d50202ce2 100644 --- a/frontend/pages/api/userActions/checkUserAction.js +++ b/frontend/pages/api/userActions/checkUserAction.js @@ -1,4 +1,4 @@ -import SecurityClient from "../../../components/utilities/SecurityClient"; +import SecurityClient from "~/utilities/SecurityClient"; import { PATH } from "../../../const"; /** @@ -8,23 +8,26 @@ import { PATH } from "../../../const"; * @returns */ const checkUserAction = ({ action }) => { - return SecurityClient.fetchCall(PATH + "/api/v1/user-action" + - "?" + - new URLSearchParams({ - action, - }), { - method: "GET", - headers: { - "Content-Type": "application/json", - }, - }) - .then(async res => { + return SecurityClient.fetchCall( + PATH + + "/api/v1/user-action" + + "?" + + new URLSearchParams({ + action, + }), + { + method: "GET", + headers: { + "Content-Type": "application/json", + }, + } + ).then(async (res) => { if (res.status == 200) { return (await res.json()).userAction; } else { - console.log('Failed to check a user action'); + console.log("Failed to check a user action"); } - }) + }); }; export default checkUserAction; diff --git a/frontend/pages/api/userActions/registerUserAction.js b/frontend/pages/api/userActions/registerUserAction.js index e4666acd8..cc1053a24 100644 --- a/frontend/pages/api/userActions/registerUserAction.js +++ b/frontend/pages/api/userActions/registerUserAction.js @@ -1,4 +1,4 @@ -import SecurityClient from "../../../components/utilities/SecurityClient"; +import SecurityClient from "~/utilities/SecurityClient"; import { PATH } from "../../../const"; /** @@ -15,14 +15,13 @@ const registerUserAction = ({ action }) => { body: JSON.stringify({ action, }), - }) - .then(async res => { + }).then(async (res) => { if (res.status == 200) { return res; } else { - console.log('Failed to register a user action'); + console.log("Failed to register a user action"); } - }) + }); }; export default registerUserAction; diff --git a/frontend/pages/api/workspace/addUserToWorkspace.js b/frontend/pages/api/workspace/addUserToWorkspace.js index 6fa4caa85..20608fc00 100644 --- a/frontend/pages/api/workspace/addUserToWorkspace.js +++ b/frontend/pages/api/workspace/addUserToWorkspace.js @@ -1,4 +1,4 @@ -import SecurityClient from "../../../components/utilities/SecurityClient"; +import SecurityClient from "~/utilities/SecurityClient"; import { PATH } from "../../../const"; /** @@ -8,22 +8,24 @@ import { PATH } from "../../../const"; * @returns */ const addUserToWorkspace = (email, workspaceId) => { - return SecurityClient.fetchCall(PATH + "/api/v1/workspace/" + workspaceId + "/invite-signup", { - method: "POST", - headers: { - "Content-Type": "application/json", - }, - body: JSON.stringify({ - email: email, - }), - }) - .then(async res => { - if (res.status == 200) { - return (await res.json()); - } else { - console.log('Failed to add a user to project'); + return SecurityClient.fetchCall( + PATH + "/api/v1/workspace/" + workspaceId + "/invite-signup", + { + method: "POST", + headers: { + "Content-Type": "application/json", + }, + body: JSON.stringify({ + email: email, + }), } - }) + ).then(async (res) => { + if (res.status == 200) { + return await res.json(); + } else { + console.log("Failed to add a user to project"); + } + }); }; export default addUserToWorkspace; diff --git a/frontend/pages/api/workspace/changeUserRoleInWorkspace.js b/frontend/pages/api/workspace/changeUserRoleInWorkspace.js index 89b858754..3faa88292 100644 --- a/frontend/pages/api/workspace/changeUserRoleInWorkspace.js +++ b/frontend/pages/api/workspace/changeUserRoleInWorkspace.js @@ -1,4 +1,4 @@ -import SecurityClient from "../../../components/utilities/SecurityClient"; +import SecurityClient from "~/utilities/SecurityClient"; import { PATH } from "../../../const"; /** @@ -8,22 +8,24 @@ import { PATH } from "../../../const"; * @returns */ const changeUserRoleInWorkspace = (membershipId, role) => { - return SecurityClient.fetchCall(PATH + "/api/v1/membership/" + membershipId + "/change-role", { - method: "POST", - headers: { - "Content-Type": "application/json", - }, - body: JSON.stringify({ - role: role, - }), - }) - .then(async res => { + return SecurityClient.fetchCall( + PATH + "/api/v1/membership/" + membershipId + "/change-role", + { + method: "POST", + headers: { + "Content-Type": "application/json", + }, + body: JSON.stringify({ + role: role, + }), + } + ).then(async (res) => { if (res.status == 200) { return res; } else { - console.log('Failed to change the user role in a project'); + console.log("Failed to change the user role in a project"); } - }) + }); }; export default changeUserRoleInWorkspace; diff --git a/frontend/pages/api/workspace/createWorkspace.js b/frontend/pages/api/workspace/createWorkspace.js index 70f05c6b0..2b6ee4e77 100644 --- a/frontend/pages/api/workspace/createWorkspace.js +++ b/frontend/pages/api/workspace/createWorkspace.js @@ -1,4 +1,4 @@ -import SecurityClient from "../../../components/utilities/SecurityClient"; +import SecurityClient from "~/utilities/SecurityClient"; import { PATH } from "../../../const"; /** @@ -16,14 +16,13 @@ const createWorkspace = (workspaceName, organizationId) => { workspaceName: workspaceName, organizationId: organizationId, }), - }) - .then(async res => { + }).then(async (res) => { if (res.status == 200) { return (await res.json()).workspace; } else { - console.log('Failed to create a project'); + console.log("Failed to create a project"); } - }) + }); }; export default createWorkspace; diff --git a/frontend/pages/api/workspace/deleteUserFromWorkspace.js b/frontend/pages/api/workspace/deleteUserFromWorkspace.js index 36b7ce56f..bebc032a0 100644 --- a/frontend/pages/api/workspace/deleteUserFromWorkspace.js +++ b/frontend/pages/api/workspace/deleteUserFromWorkspace.js @@ -1,4 +1,4 @@ -import SecurityClient from "../../../components/utilities/SecurityClient"; +import SecurityClient from "~/utilities/SecurityClient"; import { PATH } from "../../../const"; /** @@ -7,19 +7,21 @@ import { PATH } from "../../../const"; * @returns */ const deleteUserFromWorkspace = (membershipId) => { - return SecurityClient.fetchCall(PATH + "/api/v1/membership/" + membershipId, { - method: "DELETE", - headers: { - "Content-Type": "application/json", - }, - }) - .then(async res => { + return SecurityClient.fetchCall( + PATH + "/api/v1/membership/" + membershipId, + { + method: "DELETE", + headers: { + "Content-Type": "application/json", + }, + } + ).then(async (res) => { if (res.status == 200) { return res; } else { - console.log('Failed to delete a user from a project'); + console.log("Failed to delete a user from a project"); } - }) + }); }; export default deleteUserFromWorkspace; diff --git a/frontend/pages/api/workspace/deleteWorkspace.js b/frontend/pages/api/workspace/deleteWorkspace.js index 223cc4c9d..ed0787c22 100644 --- a/frontend/pages/api/workspace/deleteWorkspace.js +++ b/frontend/pages/api/workspace/deleteWorkspace.js @@ -1,4 +1,4 @@ -import SecurityClient from "../../../components/utilities/SecurityClient"; +import SecurityClient from "~/utilities/SecurityClient"; import { PATH } from "../../../const"; /** @@ -12,14 +12,13 @@ const deleteWorkspace = (workspaceId) => { headers: { "Content-Type": "application/json", }, - }) - .then(async res => { + }).then(async (res) => { if (res.status == 200) { return res; } else { - console.log('Failed to delete a project'); + console.log("Failed to delete a project"); } - }) + }); }; export default deleteWorkspace; diff --git a/frontend/pages/api/workspace/getLatestFileKey.js b/frontend/pages/api/workspace/getLatestFileKey.js index 861d1281f..a3f1b5620 100644 --- a/frontend/pages/api/workspace/getLatestFileKey.js +++ b/frontend/pages/api/workspace/getLatestFileKey.js @@ -1,4 +1,4 @@ -import SecurityClient from "../../../components/utilities/SecurityClient"; +import SecurityClient from "~/utilities/SecurityClient"; import { PATH } from "../../../const"; /** @@ -7,19 +7,23 @@ import { PATH } from "../../../const"; * @returns */ const getLatestFileKey = (workspaceId) => { - return SecurityClient.fetchCall(PATH + "/api/v1/key/" + workspaceId + "/latest", { - method: "GET", - headers: { - "Content-Type": "application/json", - }, - }) - .then(async res => { - if (res.status == 200) { - return (await res.json()); - } else { - console.log('Failed to get the latest key pairs for a certain project'); + return SecurityClient.fetchCall( + PATH + "/api/v1/key/" + workspaceId + "/latest", + { + method: "GET", + headers: { + "Content-Type": "application/json", + }, } - }) + ).then(async (res) => { + if (res.status == 200) { + return await res.json(); + } else { + console.log( + "Failed to get the latest key pairs for a certain project" + ); + } + }); }; export default getLatestFileKey; diff --git a/frontend/pages/api/workspace/getWorkspaceInfo.js b/frontend/pages/api/workspace/getWorkspaceInfo.js index df48ee62e..f528a319e 100644 --- a/frontend/pages/api/workspace/getWorkspaceInfo.js +++ b/frontend/pages/api/workspace/getWorkspaceInfo.js @@ -1,4 +1,4 @@ -import SecurityClient from "../../../components/utilities/SecurityClient"; +import SecurityClient from "~/utilities/SecurityClient"; import { PATH } from "../../../const"; /** @@ -8,19 +8,21 @@ import { PATH } from "../../../const"; * @returns */ const getWorkspaceInfo = (req, res) => { - return SecurityClient.fetchCall(PATH + "/api/v1/workspace/" + req.workspaceId, { - method: "GET", - headers: { - "Content-Type": "application/json", - }, - }) - .then(async res => { + return SecurityClient.fetchCall( + PATH + "/api/v1/workspace/" + req.workspaceId, + { + method: "GET", + headers: { + "Content-Type": "application/json", + }, + } + ).then(async (res) => { if (res.status == 200) { return (await res.json()).workspace; } else { - console.log('Failed to get project info'); + console.log("Failed to get project info"); } - }) + }); }; export default getWorkspaceInfo; diff --git a/frontend/pages/api/workspace/getWorkspaceKeys.js b/frontend/pages/api/workspace/getWorkspaceKeys.js index fa11aaca7..b366fb5ef 100644 --- a/frontend/pages/api/workspace/getWorkspaceKeys.js +++ b/frontend/pages/api/workspace/getWorkspaceKeys.js @@ -1,4 +1,4 @@ -import SecurityClient from "../../../components/utilities/SecurityClient"; +import SecurityClient from "~/utilities/SecurityClient"; import { PATH } from "../../../const"; /** @@ -8,19 +8,23 @@ import { PATH } from "../../../const"; * @returns */ const getWorkspaceKeys = (req, res) => { - return SecurityClient.fetchCall(PATH + "/api/v1/workspace/" + req.workspaceId + "/keys", { - method: "GET", - headers: { - "Content-Type": "application/json", - }, - }) - .then(async res => { + return SecurityClient.fetchCall( + PATH + "/api/v1/workspace/" + req.workspaceId + "/keys", + { + method: "GET", + headers: { + "Content-Type": "application/json", + }, + } + ).then(async (res) => { if (res.status == 200) { return (await res.json()).publicKeys; } else { - console.log('Failed to get the public keys of everyone in the workspace'); + console.log( + "Failed to get the public keys of everyone in the workspace" + ); } - }) + }); }; export default getWorkspaceKeys; diff --git a/frontend/pages/api/workspace/getWorkspaceUsers.js b/frontend/pages/api/workspace/getWorkspaceUsers.js index df8896418..6bbdc633b 100644 --- a/frontend/pages/api/workspace/getWorkspaceUsers.js +++ b/frontend/pages/api/workspace/getWorkspaceUsers.js @@ -1,4 +1,4 @@ -import SecurityClient from "../../../components/utilities/SecurityClient"; +import SecurityClient from "~/utilities/SecurityClient"; import { PATH } from "../../../const"; /** @@ -8,19 +8,21 @@ import { PATH } from "../../../const"; * @returns */ const getWorkspaceUsers = (req, res) => { - return SecurityClient.fetchCall(PATH + "/api/v1/workspace/" + req.workspaceId + "/users", { - method: "GET", - headers: { - "Content-Type": "application/json", - }, - }) - .then(async res => { + return SecurityClient.fetchCall( + PATH + "/api/v1/workspace/" + req.workspaceId + "/users", + { + method: "GET", + headers: { + "Content-Type": "application/json", + }, + } + ).then(async (res) => { if (res.status == 200) { return (await res.json()).users; } else { - console.log('Failed to get Project Users'); + console.log("Failed to get Project Users"); } - }) + }); }; export default getWorkspaceUsers; diff --git a/frontend/pages/api/workspace/getWorkspaces.js b/frontend/pages/api/workspace/getWorkspaces.js index c11313006..0bc213e62 100644 --- a/frontend/pages/api/workspace/getWorkspaces.js +++ b/frontend/pages/api/workspace/getWorkspaces.js @@ -1,4 +1,4 @@ -import SecurityClient from "../../../components/utilities/SecurityClient"; +import SecurityClient from "~/utilities/SecurityClient"; import { PATH } from "../../../const"; /** @@ -13,14 +13,13 @@ const getWorkspaces = (req, res) => { headers: { "Content-Type": "application/json", }, - }) - .then(async res => { + }).then(async (res) => { if (res.status == 200) { return (await res.json()).workspaces; } else { - console.log('Failed to get projects'); + console.log("Failed to get projects"); } - }) + }); }; export default getWorkspaces; diff --git a/frontend/pages/api/workspace/renameWorkspace.js b/frontend/pages/api/workspace/renameWorkspace.js index ca8a45599..da3cf83bc 100644 --- a/frontend/pages/api/workspace/renameWorkspace.js +++ b/frontend/pages/api/workspace/renameWorkspace.js @@ -1,4 +1,4 @@ -import SecurityClient from "../../../components/utilities/SecurityClient"; +import SecurityClient from "~/utilities/SecurityClient"; import { PATH } from "../../../const"; /** @@ -8,22 +8,24 @@ import { PATH } from "../../../const"; * @returns */ const renameWorkspace = (workspaceId, newWorkspaceName) => { - return SecurityClient.fetchCall(PATH + "/api/v1/workspace/" + workspaceId + "/name", { - method: "POST", - headers: { - "Content-Type": "application/json", - }, - body: JSON.stringify({ - name: newWorkspaceName, - }), - }) - .then(async res => { + return SecurityClient.fetchCall( + PATH + "/api/v1/workspace/" + workspaceId + "/name", + { + method: "POST", + headers: { + "Content-Type": "application/json", + }, + body: JSON.stringify({ + name: newWorkspaceName, + }), + } + ).then(async (res) => { if (res.status == 200) { return res; } else { - console.log('Failed to rename a project'); + console.log("Failed to rename a project"); } - }) + }); }; export default renameWorkspace; diff --git a/frontend/pages/api/workspace/uploadKeys.js b/frontend/pages/api/workspace/uploadKeys.js index 8b3b719c5..b1e638555 100644 --- a/frontend/pages/api/workspace/uploadKeys.js +++ b/frontend/pages/api/workspace/uploadKeys.js @@ -1,4 +1,4 @@ -import SecurityClient from "../../../components/utilities/SecurityClient"; +import SecurityClient from "~/utilities/SecurityClient"; import { PATH } from "../../../const"; /** @@ -22,14 +22,13 @@ const uploadKeys = (workspaceId, userId, encryptedKey, nonce) => { nonce: nonce, }, }), - }) - .then(async res => { + }).then(async (res) => { if (res.status == 200) { return res; } else { - console.log('Failed to upload keys for a new user'); + console.log("Failed to upload keys for a new user"); } - }) + }); }; export default uploadKeys; diff --git a/frontend/pages/dashboard/[id].js b/frontend/pages/dashboard/[id].js index 42f1f81d3..f55e7d689 100644 --- a/frontend/pages/dashboard/[id].js +++ b/frontend/pages/dashboard/[id].js @@ -2,14 +2,14 @@ import React, { useState, useEffect, useCallback, Fragment } from "react"; import { useRouter } from "next/router"; import Head from "next/head"; import Image from "next/image"; -import guidGenerator from "../../components/utilities/randomId"; -import getSecretsForProject from "../../components/utilities/getSecretsForProject"; -import pushKeys from "../../components/utilities/pushKeys"; +import guidGenerator from "~/utilities/randomId"; +import getSecretsForProject from "~/utilities/getSecretsForProject"; +import pushKeys from "~/utilities/pushKeys"; import getWorkspaces from "../api/workspace/getWorkspaces"; import getUser from "../api/user/getUser"; -import NavHeader from "../../components/navigation/NavHeader"; +import NavHeader from "~/components/navigation/NavHeader"; -import DashboardInputField from "../../components/dashboard/DashboardInputField"; +import DashboardInputField from "~/components/dashboard/DashboardInputField"; import { FontAwesomeIcon } from "@fortawesome/react-fontawesome"; import { faMagnifyingGlass, @@ -26,19 +26,26 @@ import { faCheck, faCopy, faCircleInfo, - faX + faX, } from "@fortawesome/free-solid-svg-icons"; -import ListBox from "../../components/basic/Listbox"; -import DropZone from "../../components/dashboard/DropZone"; +import ListBox from "~/components/basic/Listbox"; +import DropZone from "~/components/dashboard/DropZone"; import { Menu, Transition } from "@headlessui/react"; import getWorkspaceIntegrations from "../api/integrations/getWorkspaceIntegrations"; -import BottonRightPopup from "../../components/basic/popups/BottomRightPopup"; +import BottonRightPopup from "~/components/basic/popups/BottomRightPopup"; import checkUserAction from "../api/userActions/checkUserAction"; import registerUserAction from "../api/userActions/registerUserAction"; -import pushKeysIntegration from "../../components/utilities/pushKeysIntegration"; -import Button from "../../components/basic/buttons/Button"; +import pushKeysIntegration from "~/utilities/pushKeysIntegration"; +import Button from "~/components/basic/buttons/Button"; -const KeyPair = ({ keyPair, deleteRow, modifyKey, modifyValue, modifyVisibility, isBlurred }) => { +const KeyPair = ({ + keyPair, + deleteRow, + modifyKey, + modifyValue, + modifyVisibility, + isBlurred, +}) => { return (
@@ -86,9 +93,12 @@ const KeyPair = ({ keyPair, deleteRow, modifyKey, modifyValue, modifyVisibility,
- modifyVisibility(keyPair[4] == "personal" - ? "shared" - : "personal", keyPair[1]) + modifyVisibility( + keyPair[4] == "personal" + ? "shared" + : "personal", + keyPair[1] + ) } className="relative flex justify-start items-center cursor-pointer select-none py-2 px-2 rounded-md text-gray-400 hover:bg-white/10 duration-200 hover:text-gray-200 w-full" > @@ -123,7 +133,6 @@ const KeyPair = ({ keyPair, deleteRow, modifyKey, modifyValue, modifyVisibility, ); }; - const envMapping = { Development: "dev", Staging: "staging", @@ -186,7 +195,6 @@ export default function Dashboard() { }; }, [buttonReady]); - const reorderRows = () => { setSortMethod( sortMethod == "alphabetical" ? "-alphabetical" : "alphabetical" @@ -218,21 +226,21 @@ export default function Dashboard() { setFileState, setIsKeyAvailable, setData, - workspaceId: router.query.id - }) + workspaceId: router.query.id, + }); const user = await getUser(); setIsNew( - (Date.parse(new Date()) - - Date.parse(user.createdAt)) / - 60000 < + (Date.parse(new Date()) - Date.parse(user.createdAt)) / 60000 < 3 ? true : false ); - let userAction = await checkUserAction({action: "first_time_secrets_pushed"}); - setHasUserEverPushed(userAction ? true : false) + let userAction = await checkUserAction({ + action: "first_time_secrets_pushed", + }); + setHasUserEverPushed(userAction ? true : false); } catch (error) { console.log("Error", error); setData([]); @@ -252,39 +260,38 @@ export default function Dashboard() { const modifyValue = (value, id) => { setData((oldData) => { oldData[id][3] = value; - return [...oldData] + return [...oldData]; }); setButtonReady(true); - } + }; const modifyKey = (value, id) => { setData((oldData) => { oldData[id][2] = value; - return [...oldData] + return [...oldData]; }); setButtonReady(true); - } + }; const modifyVisibility = (value, id) => { setData((oldData) => { oldData[id][4] = value; - return [...oldData] + return [...oldData]; }); setButtonReady(true); - } - + }; const listenChangeValue = useCallback((value, id) => { - modifyValue(value, id) - }, []) + modifyValue(value, id); + }, []); const listenChangeKey = useCallback((value, id) => { - modifyKey(value, id) - }, []) + modifyKey(value, id); + }, []); const listenChangeVisibility = useCallback((value, id) => { - modifyVisibility(value, id) - }, []) + modifyVisibility(value, id); + }, []); const savePush = async () => { let obj = Object.assign( @@ -294,19 +301,28 @@ export default function Dashboard() { setButtonReady(false); pushKeys(obj, router.query.id, env); - let integrations = await getWorkspaceIntegrations({workspaceId: router.query.id}); + let integrations = await getWorkspaceIntegrations({ + workspaceId: router.query.id, + }); integrations.map(async (integration) => { - if (envMapping[env] == integration.environment && integration.isActive == true) { + if ( + envMapping[env] == integration.environment && + integration.isActive == true + ) { let objIntegration = Object.assign( {}, ...data.map((row) => ({ [row[2]]: row[3] })) ); - await pushKeysIntegration({obj: objIntegration, integrationId: integration._id});} + await pushKeysIntegration({ + obj: objIntegration, + integrationId: integration._id, + }); + } }); if (!hasUserEverPushed) { - setCheckDocsPopUpVisible(true) - await registerUserAction({action: "first_time_secrets_pushed"}); + setCheckDocsPopUpVisible(true); + await registerUserAction({ action: "first_time_secrets_pushed" }); } }; @@ -339,20 +355,19 @@ export default function Dashboard() { function copyToClipboard() { // Get the text field var copyText = document.getElementById("myInput"); - + // Select the text field copyText.select(); copyText.setSelectionRange(0, 99999); // For mobile devices - - // Copy the text inside the text field + + // Copy the text inside the text field navigator.clipboard.writeText(copyText.value); - + setProjectIdCopied(true); setTimeout(() => setProjectIdCopied(false), 2000); // Alert the copied text // alert("Copied the text: " + copyText.value); - } - + } return data ? (
@@ -371,41 +386,61 @@ export default function Dashboard() {
- - {checkDocsPopUpVisible && - + {checkDocsPopUpVisible && ( + - } + )}

Secrets

- {data?.length==0 && } + {data?.length == 0 && ( + + )}
-

Project ID:

- +

+ Project ID: +

+
- Click to Copy @@ -455,7 +490,9 @@ export default function Dashboard() { className="pl-2 text-gray-400 rounded-r-md bg-white/5 w-full h-full outline-none" value={searchKeys} onChange={(e) => - setSearchKeys(e.target.value) + setSearchKeys( + e.target.value + ) } placeholder={"Search keys..."} /> @@ -465,7 +502,11 @@ export default function Dashboard() { onButtonPressed={reorderRows} color="mineshaft" size="icon-md" - icon={sortMethod == "alphabetical" ? faArrowDownAZ : faArrowDownZA} + icon={ + sortMethod == "alphabetical" + ? faArrowDownAZ + : faArrowDownZA + } />
@@ -481,7 +522,9 @@ export default function Dashboard() { onButtonPressed={changeBlurred} color="mineshaft" size="icon-md" - icon={blurred ? faEye : faEyeSlash} + icon={ + blurred ? faEye : faEyeSlash + } />
@@ -514,14 +557,17 @@ export default function Dashboard() {
{/* */}
-

Personal

+

+ Personal +

- Personal keys are only visible to you + Personal keys are only + visible to you
@@ -534,7 +580,8 @@ export default function Dashboard() { .toLowerCase() .includes( searchKeys.toLowerCase() - ) && keyPair[4] == "personal" + ) && + keyPair[4] == "personal" ) .sort((a, b) => sortMethod == "alphabetical" @@ -546,9 +593,13 @@ export default function Dashboard() { key={keyPair[0]} keyPair={keyPair} deleteRow={deleteCertainRow} - modifyValue={listenChangeValue} + modifyValue={ + listenChangeValue + } modifyKey={listenChangeKey} - modifyVisibility={listenChangeVisibility} + modifyVisibility={ + listenChangeVisibility + } isBlurred={blurred} /> ))} @@ -562,15 +613,17 @@ export default function Dashboard() {
{/* */}
-

Shared

+

+ Shared +

- Shared keys are visible to your whole - team + Shared keys are visible to + your whole team
@@ -583,7 +636,8 @@ export default function Dashboard() { .toLowerCase() .includes( searchKeys.toLowerCase() - ) && keyPair[4] == "shared" + ) && + keyPair[4] == "shared" ) .sort((a, b) => sortMethod == "alphabetical" @@ -595,9 +649,13 @@ export default function Dashboard() { key={keyPair[0]} keyPair={keyPair} deleteRow={deleteCertainRow} - modifyValue={listenChangeValue} + modifyValue={ + listenChangeValue + } modifyKey={listenChangeKey} - modifyVisibility={listenChangeVisibility} + modifyVisibility={ + listenChangeVisibility + } isBlurred={blurred} /> ))} @@ -606,7 +664,9 @@ export default function Dashboard() {
) : (
- {fileState.message != "There's nothing to pull" && + {fileState.message != + "There's nothing to pull" && fileState.message != undefined && ( )} - {(fileState.message == "There's nothing to pull" || + {(fileState.message == + "There's nothing to pull" || fileState.message == undefined) && isKeyAvailable && ( You are not authorized to view this project.

+

+ You are not authorized to view this + project. +

)} {fileState.message == "Access needed to pull the latest file" || @@ -653,8 +720,8 @@ export default function Dashboard() { administrator for permission.

- They need to grant you access in the team - tab. + They need to grant you access in + the team tab.

))} diff --git a/frontend/pages/integrations/[id].js b/frontend/pages/integrations/[id].js index f6117656f..19e211796 100644 --- a/frontend/pages/integrations/[id].js +++ b/frontend/pages/integrations/[id].js @@ -3,20 +3,25 @@ import { useRouter } from "next/router"; import Head from "next/head"; import Image from "next/image"; import { FontAwesomeIcon } from "@fortawesome/react-fontawesome"; -import { faCheck, faArrowRight, faRotate, faX } from "@fortawesome/free-solid-svg-icons"; -import ListBox from "../../components/basic/Listbox"; -import NavHeader from "../../components/navigation/NavHeader"; +import { + faCheck, + faArrowRight, + faRotate, + faX, +} from "@fortawesome/free-solid-svg-icons"; +import ListBox from "~/components/basic/Listbox"; +import NavHeader from "~/components/navigation/NavHeader"; import getIntegrations from "../api/integrations/GetIntegrations"; import getIntegrationApps from "../api/integrations/GetIntegrationApps"; import getWorkspaceAuthorizations from "../api/integrations/getWorkspaceAuthorizations"; import getWorkspaceIntegrations from "../api/integrations/getWorkspaceIntegrations"; import startIntegration from "../api/integrations/StartIntegration"; import deleteIntegration from "../api/integrations/DeleteIntegration"; -import getSecretsForProject from "../../components/utilities/getSecretsForProject"; -import pushKeysIntegration from "../../components/utilities/pushKeysIntegration"; +import getSecretsForProject from "~/utilities/getSecretsForProject"; +import pushKeysIntegration from "~/utilities/pushKeysIntegration"; import deleteIntegrationAuth from "../api/integrations/DeleteIntegrationAuth"; -import Button from "../../components/basic/buttons/Button"; -import guidGenerator from "../../components/utilities/randomId"; +import Button from "~/components/basic/buttons/Button"; +import guidGenerator from "~/utilities/randomId"; const crypto = require("crypto"); @@ -28,104 +33,138 @@ const envMapping = { }; const reverseEnvMapping = { - "dev": "Development", - "staging": "Staging", - "prod": "Production", - "test": "Testing" -} + dev: "Development", + staging: "Staging", + prod: "Production", + test: "Testing", +}; -const Integration = ({projectIntegration}) => { - const [integrationEnvironment, setIntegrationEnvironment] = useState(reverseEnvMapping[projectIntegration.environment]); +const Integration = ({ projectIntegration }) => { + const [integrationEnvironment, setIntegrationEnvironment] = useState( + reverseEnvMapping[projectIntegration.environment] + ); const [fileState, setFileState] = useState([]); const [data, setData] = useState(); const [isKeyAvailable, setIsKeyAvailable] = useState(true); const router = useRouter(); const [apps, setApps] = useState([]); - const [integrationApp, setIntegrationApp] = useState(projectIntegration.app ? projectIntegration.app : apps[0]); + const [integrationApp, setIntegrationApp] = useState( + projectIntegration.app ? projectIntegration.app : apps[0] + ); useEffect(async () => { - const tempHerokuApps = await getIntegrationApps({integrationAuthId: projectIntegration.integrationAuth}); - const tempHerokuAppNames = tempHerokuApps.map(app => app.name); + const tempHerokuApps = await getIntegrationApps({ + integrationAuthId: projectIntegration.integrationAuth, + }); + const tempHerokuAppNames = tempHerokuApps.map((app) => app.name); setApps(tempHerokuAppNames); - setIntegrationApp(projectIntegration.app ? projectIntegration.app : tempHerokuAppNames[0]) + setIntegrationApp( + projectIntegration.app + ? projectIntegration.app + : tempHerokuAppNames[0] + ); }, []); - - return
-
-
-
-
- ENVIRONMENT -
- -
- -
-
- INTEGRATION -
-
- {projectIntegration.integration.charAt(0).toUpperCase() + projectIntegration.integration.slice(1)} -
-
-
-
- HEROKU APP -
- -
-
-
- {projectIntegration.isActive - ?
- -
In Sync
-
- :
+
-
; -} + ); +}; export default function Integrations() { const [integrations, setIntegrations] = useState(); @@ -150,12 +190,16 @@ export default function Integrations() { setCsrfToken(tempCSRFToken); localStorage.setItem("latestCSRFToken", tempCSRFToken); - let projectAuthorizations = await getWorkspaceAuthorizations({workspaceId: router.query.id}); + let projectAuthorizations = await getWorkspaceAuthorizations({ + workspaceId: router.query.id, + }); setAuthorizations(projectAuthorizations); - const projectIntegrations = await getWorkspaceIntegrations({workspaceId: router.query.id}); + const projectIntegrations = await getWorkspaceIntegrations({ + workspaceId: router.query.id, + }); setProjectIntegrations(projectIntegrations); - + try { const integrationsData = await getIntegrations(); setIntegrations(integrationsData); @@ -181,7 +225,10 @@ export default function Integrations() {
- +

@@ -189,24 +236,31 @@ export default function Integrations() {

- Manage your integrations of Infisical with third-party services. + Manage your integrations of Infisical with + third-party services.

- {projectIntegrations.length > 0 - ? projectIntegrations.map(projectIntegration => - - ) - :
+ {projectIntegrations.length > 0 ? ( + projectIntegrations.map((projectIntegration) => ( + + )) + ) : ( +
- You don't have any integrations set up yet. When you do, they will appear here. + You don't have any integrations set up yet. + When you do, they will appear here.
- To start, click on any of the options below. It takes 5 clicks to set up. + To start, click on any of the options below. + It takes 5 clicks to set up.
- } + )}

@@ -214,50 +268,151 @@ export default function Integrations() {

- Click on the itegration you want to connect. This will let your environment variables flow automatically into selected third-party services. + Click on the itegration you want to connect. This + will let your environment variables flow + automatically into selected third-party services.

- Note: during an integration with Heroku, for security reasons, it is impossible to maintain end-to-end encryption. In theory, this lets Infisical decrypt yor environment variables. In practice, we can assure you that this will never be done, and it allows us to protect your secrets from bad actors online. The core Infisical service will always stay end-to-end encrypted. With any questions, reach out support@infisical.com. + Note: during an integration with Heroku, for + security reasons, it is impossible to maintain + end-to-end encryption. In theory, this lets + Infisical decrypt yor environment variables. In + practice, we can assure you that this will never be + done, and it allows us to protect your secrets from + bad actors online. The core Infisical service will + always stay end-to-end encrypted. With any + questions, reach out support@infisical.com.

- {Object.keys(integrations).map(integration => -
- ( +
+ + className={`relative flex flex-row bg-white/5 h-32 rounded-md p-4 items-center ${ + ["Heroku"].includes( + integrations[integration].name + ) + ? "hover:bg-white/10 duration-200 cursor-pointer" + : "cursor-default grayscale" + }`} + > integration logo - {integrations[integration].name.split(" ").length > 2 - ?
-
{integrations[integration].name.split(" ")[0]}
-
{integrations[integration].name.split(" ")[1]}{" "}{integrations[integration].name.split(" ")[2]}
+ {integrations[integration].name.split(" ") + .length > 2 ? ( +
+
+ { + integrations[ + integration + ].name.split(" ")[0] + }
- :
{integrations[integration].name}
- } - +
+ { + integrations[ + integration + ].name.split(" ")[1] + }{" "} + { + integrations[ + integration + ].name.split(" ")[2] + } +
+
+ ) : ( +
+ {integrations[integration].name} +
+ )}
- {["Heroku"].includes(integrations[integration].name) && authorizations.map(authorization => authorization.integration).includes(integrations[integration].name.toLowerCase()) && + {["Heroku"].includes( + integrations[integration].name + ) && + authorizations + .map( + (authorization) => + authorization.integration + ) + .includes( + integrations[ + integration + ].name.toLowerCase() + ) && ( +
+
{ + deleteIntegrationAuth({ + integrationAuthId: + authorizations + .filter( + ( + authorization + ) => + authorization.integration == + integrations[ + integration + ].name.toLowerCase() + ) + .map( + ( + authorization + ) => + authorization._id + )[0], + }); + router.reload(); + }} + className="cursor-pointer w-max bg-red py-0.5 px-2 rounded-b-md text-xs flex flex-row items-center opacity-0 group-hover:opacity-100 duration-200" + > + + Revoke +
+
+ + Authorized +
+
+ )} + {!["Heroku"].includes( + integrations[integration].name + ) && (
-
{ - deleteIntegrationAuth({integrationAuthId: authorizations.filter(authorization => authorization.integration == integrations[integration].name.toLowerCase()).map(authorization => authorization._id)[0]}); - router.reload(); - }} className="cursor-pointer w-max bg-red py-0.5 px-2 rounded-b-md text-xs flex flex-row items-center opacity-0 group-hover:opacity-100 duration-200">Revoke
-
Authorized
+
+ Coming Soon +
- } - {!["Heroku"].includes(integrations[integration].name) && -
-
Coming Soon
-
- } + )}
- )} + ))}
diff --git a/frontend/pages/login.js b/frontend/pages/login.js index d4d6d684d..ed13db377 100644 --- a/frontend/pages/login.js +++ b/frontend/pages/login.js @@ -5,11 +5,11 @@ import Head from "next/head"; import Image from "next/image"; import Link from "next/link"; -import InputField from "../components/basic/InputField"; -import Error from "../components/basic/Error"; -import Button from "../components/basic/buttons/Button"; +import InputField from "~/components/basic/InputField"; +import Error from "~/components/basic/Error"; +import Button from "~/components/basic/buttons/Button"; import getWorkspaces from "./api/workspace/getWorkspaces"; -import attemptLogin from "../components/utilities/attemptLogin"; +import attemptLogin from "~/utilities/attemptLogin"; import { FontAwesomeIcon } from "@fortawesome/react-fontawesome"; import { faWarning } from "@fortawesome/free-solid-svg-icons"; @@ -36,13 +36,18 @@ export default function Login() { */ const loginCheck = async () => { setIsLoading(true); - await attemptLogin(email, password, setErrorLogin, router, false, true).then( - () => { - setTimeout(function () { - setIsLoading(false); - }, 2000); - } - ); + await attemptLogin( + email, + password, + setErrorLogin, + router, + false, + true + ).then(() => { + setTimeout(function () { + setIsLoading(false); + }, 2000); + }); }; return ( @@ -122,11 +127,17 @@ export default function Login() {

I may have forgotten my password.

*/}
- {false && + {false && (
- - We are experiencing minor technical difficulties. We are working on solving it right now. Please come back in a few minutes. -
} + + We are experiencing minor technical difficulties. We are + working on solving it right now. Please come back in a few + minutes. +
+ )}
); -} \ No newline at end of file +} diff --git a/frontend/pages/settings/billing/[id].js b/frontend/pages/settings/billing/[id].js index 13871ab8a..ea14a4395 100644 --- a/frontend/pages/settings/billing/[id].js +++ b/frontend/pages/settings/billing/[id].js @@ -1,11 +1,10 @@ import React, { useState, useEffect } from "react"; import Head from "next/head"; -import Plan from "../../../components/billing/Plan"; -import getOrganizationSubscriptions from "../../api/organization/GetOrgSubscription" -import getOrganizationUsers from "../../api/organization/GetOrgUsers" -import NavHeader from "../../../components/navigation/NavHeader"; -import { STRIPE_PRODUCT_PRO, STRIPE_PRODUCT_STARTER } from "../../../components/utilities/config"; - +import Plan from "~/components/billing/Plan"; +import getOrganizationSubscriptions from "../../api/organization/GetOrgSubscription"; +import getOrganizationUsers from "../../api/organization/GetOrgUsers"; +import NavHeader from "~/components/navigation/NavHeader"; +import { STRIPE_PRODUCT_PRO, STRIPE_PRODUCT_STARTER } from "~/utilities/config"; export default function SettingsBilling() { let [currentPlan, setCurrentPlan] = useState(""); @@ -46,57 +45,62 @@ export default function SettingsBilling() { ]; useEffect(async () => { - const subscriptions = await getOrganizationSubscriptions({orgId: localStorage.getItem("orgData.id")}); - setCurrentPlan(subscriptions.data[0].plan.product) - const orgUsers = await getOrganizationUsers({orgId: localStorage.getItem("orgData.id")}) - setNumUsers(orgUsers.length) + const subscriptions = await getOrganizationSubscriptions({ + orgId: localStorage.getItem("orgData.id"), + }); + setCurrentPlan(subscriptions.data[0].plan.product); + const orgUsers = await getOrganizationUsers({ + orgId: localStorage.getItem("orgData.id"), + }); + setNumUsers(orgUsers.length); }, []); return ( -
- - Settings - Billing - - -
-
- -
-
-

- Usage & Billing -

-

- View and manage your organization's subscription here. -

-
+
+ + Settings - Billing + + +
+
+ +
+
+

+ Usage & Billing +

+

+ View and manage your organization's subscription + here. +

-
-

Subscription

-
- {plans.map((plan) => ( - - ))} +
+
+

Subscription

+
+ {plans.map((plan) => ( + + ))} +
+

Current Usage

+
+
+

{numUsers}

+

+ {numUsers > 1 + ? "Organization members" + : "Organization member"} +

-

Current Usage

-
-
-

{numUsers}

-

{numUsers > 1 ? "Organization members" : "Organization member"}

-
- {/*
+ {/*

1

Organization projects

*/} -
-
+
); } diff --git a/frontend/pages/settings/org/[id].js b/frontend/pages/settings/org/[id].js index 9bbf0046d..604bb7ef3 100644 --- a/frontend/pages/settings/org/[id].js +++ b/frontend/pages/settings/org/[id].js @@ -2,26 +2,29 @@ import React, { useState, useEffect } from "react"; import { useRouter } from "next/router"; import Head from "next/head"; import { FontAwesomeIcon } from "@fortawesome/react-fontawesome"; -import { faMagnifyingGlass, faPlus, faX } from "@fortawesome/free-solid-svg-icons"; +import { + faMagnifyingGlass, + faPlus, + faX, +} from "@fortawesome/free-solid-svg-icons"; import { faCheck } from "@fortawesome/free-solid-svg-icons"; -import InputField from "../../../components/basic/InputField"; +import InputField from "~/components/basic/InputField"; import getWorkspaces from "../../api/workspace/getWorkspaces"; -import AddIncidentContactDialog from "../../../components/basic/dialog/AddIncidentContactDialog"; +import AddIncidentContactDialog from "~/components/basic/dialog/AddIncidentContactDialog"; import getIncidentContacts from "../../api/organization/getIncidentContacts"; import deleteIncidentContact from "../../api/organization/deleteIncidentContact"; import deleteWorkspace from "../../api/workspace/deleteWorkspace"; -import AddUserDialog from "../../../components/basic/dialog/AddUserDialog"; -import UserTable from "../../../components/basic/table/UserTable"; +import AddUserDialog from "~/components/basic/dialog/AddUserDialog"; +import UserTable from "~/components/basic/table/UserTable"; import getUser from "../../api/user/getUser"; -import guidGenerator from "../../../components/utilities/randomId"; +import guidGenerator from "~/utilities/randomId"; import addUserToOrg from "../../api/organization/addUserToOrg"; import getOrganizationUsers from "../../api/organization/GetOrgUsers"; import renameOrg from "../../api/organization/renameOrg"; import getOrganization from "../../api/organization/GetOrg"; import getOrganizationSubscriptions from "../../api/organization/GetOrgSubscription"; -import NavHeader from "../../../components/navigation/NavHeader"; -import Button from "../../../components/basic/buttons/Button"; - +import NavHeader from "~/components/navigation/NavHeader"; +import Button from "~/components/basic/buttons/Button"; export default function SettingsOrg() { const [buttonReady, setButtonReady] = useState(false); @@ -51,12 +54,12 @@ export default function SettingsOrg() { }); let orgData = org; setOrgName(orgData.name); - let incidentContactsData = await getIncidentContacts(localStorage.getItem("orgData.id")); + let incidentContactsData = await getIncidentContacts( + localStorage.getItem("orgData.id") + ); setIncidentContacts( - incidentContactsData?.map( - (contact) => contact.email - ) + incidentContactsData?.map((contact) => contact.email) ); const user = await getUser(); @@ -82,8 +85,10 @@ export default function SettingsOrg() { publicKey: user.user?.publicKey, })) ); - const subscriptions = await getOrganizationSubscriptions({orgId: localStorage.getItem("orgData.id")}); - setCurrentPlan(subscriptions.data[0].plan.product) + const subscriptions = await getOrganizationSubscriptions({ + orgId: localStorage.getItem("orgData.id"), + }); + setCurrentPlan(subscriptions.data[0].plan.product); }, []); const modifyOrgName = (newName) => { @@ -127,7 +132,10 @@ export default function SettingsOrg() { setIncidentContacts( incidentContacts.filter((contact) => contact != incidentContact) ); - deleteIncidentContact(localStorage.getItem("orgData.id"), incidentContact); + deleteIncidentContact( + localStorage.getItem("orgData.id"), + incidentContact + ); }; /** @@ -160,7 +168,7 @@ export default function SettingsOrg() {
- +
@@ -193,10 +274,14 @@ export default function PersonalSettings() { Emergency Kit

- Your Emergency Kit contains the information you’ll need to sign in to your Infisical account. + Your Emergency Kit contains the + information you’ll need to sign in to + your Infisical account.

- Only the latest issued Emergency Kit remains valid. To get a new Emergency Kit, verify your password. + Only the latest issued Emergency Kit + remains valid. To get a new Emergency + Kit, verify your password.

@@ -216,11 +301,11 @@ export default function PersonalSettings() { text="Download Emergency Kit" onButtonPressed={() => { issueBackupKey({ - email: personalEmail, - password: backupPassword, - personalName, + email: personalEmail, + password: backupPassword, + personalName, setBackupKeyError, - setBackupKeyIssued + setBackupKeyIssued, }); }} color="mineshaft" @@ -228,7 +313,14 @@ export default function PersonalSettings() { active={backupPassword != ""} textDisabled="Download Emergency Kit" /> - +
diff --git a/frontend/pages/settings/project/[id].js b/frontend/pages/settings/project/[id].js index 09edc0ba6..61637a042 100644 --- a/frontend/pages/settings/project/[id].js +++ b/frontend/pages/settings/project/[id].js @@ -3,15 +3,15 @@ import { useRouter } from "next/router"; import Head from "next/head"; import { faCheck, faPlus } from "@fortawesome/free-solid-svg-icons"; -import InputField from "../../../components/basic/InputField"; +import InputField from "~/components/basic/InputField"; import getWorkspaces from "../../api/workspace/getWorkspaces"; import renameWorkspace from "../../api/workspace/renameWorkspace"; import deleteWorkspace from "../../api/workspace/deleteWorkspace"; -import NavHeader from "../../../components/navigation/NavHeader"; -import Button from "../../../components/basic/buttons/Button"; -import ServiceTokenTable from "../../../components/basic/table/ServiceTokenTable"; -import getServiceTokens from "../../api/serviceToken/getServiceTokens" -import AddServiceTokenDialog from "../../../components/basic/dialog/AddServiceTokenDialog"; +import NavHeader from "~/components/navigation/NavHeader"; +import Button from "~/components/basic/buttons/Button"; +import ServiceTokenTable from "~/components/basic/table/ServiceTokenTable"; +import getServiceTokens from "../../api/serviceToken/getServiceTokens"; +import AddServiceTokenDialog from "~/components/basic/dialog/AddServiceTokenDialog"; export default function SettingsBasic() { const [buttonReady, setButtonReady] = useState(false); @@ -22,7 +22,8 @@ export default function SettingsBasic() { useState(""); const [workspaceId, setWorkspaceId] = useState(""); const [isAddOpen, setIsAddOpen] = useState(false); - let [isAddServiceTokenDialogOpen, setIsAddServiceTokenDialogOpen] = useState(false); + let [isAddServiceTokenDialogOpen, setIsAddServiceTokenDialogOpen] = + useState(false); useEffect(async () => { let userWorkspaces = await getWorkspaces(); @@ -31,7 +32,9 @@ export default function SettingsBasic() { setWorkspaceName(userWorkspace.name); } }); - let tempServiceTokens = await getServiceTokens({workspaceId: router.query.id}); + let tempServiceTokens = await getServiceTokens({ + workspaceId: router.query.id, + }); setServiceTokens(tempServiceTokens); }, []); @@ -59,8 +62,8 @@ export default function SettingsBasic() { const closeAddServiceTokenModal = () => { setIsAddServiceTokenDialogOpen(false); - } - + }; + /** * This function deleted a workspace. * It first checks if there is more than one workspace aviable. Otherwise, it doesn't delete @@ -97,7 +100,10 @@ export default function SettingsBasic() { />
- +

@@ -133,7 +139,9 @@ export default function SettingsBasic() { >

- +
{/*
diff --git a/frontend/pages/signup.js b/frontend/pages/signup.js index 6f0f07f24..ed81ce8b7 100644 --- a/frontend/pages/signup.js +++ b/frontend/pages/signup.js @@ -6,19 +6,19 @@ import Image from "next/image"; import Link from "next/link"; import dynamic from "next/dynamic"; -import InputField from "../components/basic/InputField"; -import Error from "../components/basic/Error"; -import Button from "../components/basic/buttons/Button"; +import InputField from "~/compoennts/basic/InputField"; +import Error from "~/compoennts/basic/Error"; +import Button from "~/compoennts/basic/buttons/Button"; import sendVerificationEmail from "./api/auth/SendVerificationEmail"; import checkEmailVerificationCode from "./api/auth/CheckEmailVerificationCode"; import completeAccountInformationSignup from "./api/auth/CompleteAccountInformationSignup"; -import Aes256Gcm from "../components/aes-256-gcm"; -import passwordCheck from "../components/utilities/checks/PasswordCheck"; +import Aes256Gcm from "~/compoennts/aes-256-gcm"; +import passwordCheck from "~/compoennts/utilities/checks/PasswordCheck"; import getWorkspaces from "./api/workspace/getWorkspaces"; -import attemptLogin from "../components/utilities/attemptLogin"; +import attemptLogin from "~/compoennts/utilities/attemptLogin"; import { FontAwesomeIcon } from "@fortawesome/react-fontawesome"; import { faCheck, faX, faWarning } from "@fortawesome/free-solid-svg-icons"; -import issueBackupKey from "../components/utilities/issueBackupKey"; +import issueBackupKey from "~/compoennts/utilities/issueBackupKey"; const ReactCodeInput = dynamic(import("react-code-input")); const nacl = require("tweetnacl"); @@ -73,7 +73,8 @@ export default function SignUp() { const [passwordErrorNumber, setPasswordErrorNumber] = useState(false); const [passwordErrorUpperCase, setPasswordErrorUpperCase] = useState(false); const [passwordErrorLowerCase, setPasswordErrorLowerCase] = useState(false); - const [passwordErrorSpecialChar, setPasswordErrorSpecialChar] = useState(false); + const [passwordErrorSpecialChar, setPasswordErrorSpecialChar] = + useState(false); const [emailError, setEmailError] = useState(false); const [emailErrorMessage, setEmailErrorMessage] = useState(""); const [step, setStep] = useState(1); @@ -108,7 +109,7 @@ export default function SignUp() { // Checking if the code matches the email. const response = await checkEmailVerificationCode(email, code); if (response.status == "200" || code == "111222") { - setVerificationToken((await response.json()).token) + setVerificationToken((await response.json()).token); setStep(3); } else { setCodeError(true); @@ -180,7 +181,14 @@ export default function SignUp() { const { ciphertext, iv, tag } = Aes256Gcm.encrypt( PRIVATE_KEY, - password.slice(0, 32).padStart(32 + (password.slice(0, 32).length - new Blob([password]).size), "0") + password + .slice(0, 32) + .padStart( + 32 + + (password.slice(0, 32).length - + new Blob([password]).size), + "0" + ) ); localStorage.setItem("PRIVATE_KEY", PRIVATE_KEY); @@ -191,19 +199,21 @@ export default function SignUp() { }, async () => { client.createVerifier(async (err, result) => { - const response = await completeAccountInformationSignup({ - email, - firstName, - lastName, - organizationName: firstName + "'s organization", - publicKey: PUBLIC_KEY, - ciphertext, - iv, - tag, - salt: result.salt, - verifier: result.verifier, - token: verificationToken - }); + const response = await completeAccountInformationSignup( + { + email, + firstName, + lastName, + organizationName: firstName + "'s organization", + publicKey: PUBLIC_KEY, + ciphertext, + iv, + tag, + salt: result.salt, + verifier: result.verifier, + token: verificationToken, + } + ); // if everything works, go the main dashboard page. if (!errorCheck && response.status == "200") { @@ -276,7 +286,11 @@ export default function SignUp() { and acknowledged the Privacy Policy.

-
@@ -313,7 +327,11 @@ export default function SignUp() { )}
-
{/* @@ -374,37 +392,101 @@ export default function SignUp() { type="password" value={password} isRequired - error={passwordErrorLength && passwordErrorNumber && passwordErrorLowerCase} + error={ + passwordErrorLength && + passwordErrorNumber && + passwordErrorLowerCase + } /> - {(passwordErrorLength || passwordErrorLowerCase || passwordErrorNumber) ?
-
Password should contain at least:
-
- {passwordErrorLength - ? - : } -
14 characters
+ {passwordErrorLength || + passwordErrorLowerCase || + passwordErrorNumber ? ( +
+
+ Password should contain at least: +
+
+ {passwordErrorLength ? ( + + ) : ( + + )} +
+ 14 characters +
+
+
+ {passwordErrorLowerCase ? ( + + ) : ( + + )} +
+ 1 lowercase character +
+
+
+ {passwordErrorNumber ? ( + + ) : ( + + )} +
+ 1 number +
+
-
- {passwordErrorLowerCase - ? - : } -
1 lowercase character
-
-
- {passwordErrorNumber - ? - : } -
1 number
-
-
:
} + ) : ( +
+ )}
-
); - // Step 4 of the sign up process (download the emergency kit pdf) const step4 = (
@@ -412,23 +494,32 @@ export default function SignUp() { Save your Emergency Kit

-
If you get locked out of your account, your Emergency Kit is the only way to sign in.
-
We recommend you download it and keep it somewhere safe.
+
+ If you get locked out of your account, your Emergency Kit is + the only way to sign in. +
+
+ We recommend you download it and keep it somewhere safe. +
- - It contains your Secret Key which we cannot access or recover for you if you lose it. + + It contains your Secret Key which we cannot access or recover + for you if you lose it.
-
- {step == 1 ? step1 : step == 2 ? step2 : step == 3 ? step3 : step4} + {step == 1 + ? step1 + : step == 2 + ? step2 + : step == 3 + ? step3 + : step4}
); diff --git a/frontend/pages/signupinvite.js b/frontend/pages/signupinvite.js index d8c99ddda..cb1a10b8a 100644 --- a/frontend/pages/signupinvite.js +++ b/frontend/pages/signupinvite.js @@ -5,15 +5,15 @@ import Head from "next/head"; import Image from "next/image"; import Link from "next/link"; -import InputField from "../components/basic/InputField"; -import Button from "../components/basic/buttons/Button"; +import InputField from "~/components/basic/InputField"; +import Button from "~/components/basic/buttons/Button"; import completeAccountInformationSignupInvite from "./api/auth/CompleteAccountInformationSignupInvite"; -import Aes256Gcm from "../components/aes-256-gcm"; -import passwordCheck from "../components/utilities/checks/PasswordCheck"; -import attemptLogin from "../components/utilities/attemptLogin"; +import Aes256Gcm from "~/components/aes-256-gcm"; +import passwordCheck from "~/utilities/checks/PasswordCheck"; +import attemptLogin from "~/utilities/attemptLogin"; import { FontAwesomeIcon } from "@fortawesome/react-fontawesome"; import { faCheck, faX, faWarning } from "@fortawesome/free-solid-svg-icons"; -import issueBackupKey from "../components/utilities/issueBackupKey"; +import issueBackupKey from "~/utilities/issueBackupKey"; import verifySignupInvite from "./api/auth/VerifySignupInvite"; const nacl = require("tweetnacl"); @@ -76,7 +76,14 @@ export default function SignupInvite() { const { ciphertext, iv, tag } = Aes256Gcm.encrypt( PRIVATE_KEY, - password.slice(0, 32).padStart(32 + (password.slice(0, 32).length - new Blob([password]).size), "0") + password + .slice(0, 32) + .padStart( + 32 + + (password.slice(0, 32).length - + new Blob([password]).size), + "0" + ) ); localStorage.setItem("PRIVATE_KEY", PRIVATE_KEY); @@ -87,18 +94,19 @@ export default function SignupInvite() { }, async () => { client.createVerifier(async (err, result) => { - const response = await completeAccountInformationSignupInvite({ - email, - firstName, - lastName, - publicKey: PUBLIC_KEY, - ciphertext, - iv, - tag, - salt: result.salt, - verifier: result.verifier, - token: verificationToken - }); + const response = + await completeAccountInformationSignupInvite({ + email, + firstName, + lastName, + publicKey: PUBLIC_KEY, + ciphertext, + iv, + tag, + salt: result.salt, + verifier: result.verifier, + token: verificationToken, + }); // if everything works, go the main dashboard page. if (!errorCheck && response.status == "200") { @@ -148,19 +156,19 @@ export default function SignupInvite() { alt="verify email" >
-