ref(frontend): add ~/const path

This commit is contained in:
이강준
2022-11-27 16:12:25 +09:00
parent 2729b409e6
commit 66d2a2724e
59 changed files with 1077 additions and 1086 deletions
+2 -2
View File
@@ -1,10 +1,10 @@
import { useEffect,useState } from "react"; import { useEffect, useState } from "react";
import Image from "next/image"; import Image from "next/image";
import { useRouter } from "next/router"; import { useRouter } from "next/router";
import checkAuth from "~/pages/api/auth/CheckAuth"; import checkAuth from "~/pages/api/auth/CheckAuth";
import { publicPaths } from "../const"; import { publicPaths } from "~/const";
// #TODO: finish spinner only when the data loads fully // #TODO: finish spinner only when the data loads fully
// #TODO: Redirect somewhere if the page does not exist // #TODO: Redirect somewhere if the page does not exist
@@ -1,6 +1,6 @@
import token from "~/pages/api/auth/Token"; import token from "~/pages/api/auth/Token";
import { PATH } from "../../const"; import { PATH } from "~/const";
export default class SecurityClient { export default class SecurityClient {
static authOrigins = [PATH]; static authOrigins = [PATH];
+3
View File
@@ -8,6 +8,9 @@
"~/utilities/*": [ "~/utilities/*": [
"components/utilities/*" "components/utilities/*"
], ],
"~/*": [
"const"
],
"~/pages/*": [ "~/pages/*": [
"pages/*" "pages/*"
], ],
+1 -1
View File
@@ -7,7 +7,7 @@ import Layout from "~/components/basic/layout";
import RouteGuard from "~/components/RouteGuard"; import RouteGuard from "~/components/RouteGuard";
import { ENV } from "~/utilities/config"; import { ENV } from "~/utilities/config";
import { publicPaths } from "../const.js"; import { publicPaths } from "~/const";
import "@fortawesome/fontawesome-svg-core/styles.css"; import "@fortawesome/fontawesome-svg-core/styles.css";
import "../styles/globals.css"; import "../styles/globals.css";
+1 -1
View File
@@ -1,6 +1,6 @@
import SecurityClient from "~/utilities/SecurityClient"; import SecurityClient from "~/utilities/SecurityClient";
import { PATH } from "../../../const"; import { PATH } from "~/const";
/** /**
* This is the second step of the change password process (pake) * This is the second step of the change password process (pake)
+1 -1
View File
@@ -1,6 +1,6 @@
import SecurityClient from "~/utilities/SecurityClient.js"; import SecurityClient from "~/utilities/SecurityClient.js";
import { PATH } from "../../../const.js"; import { PATH } from "~/const";
/** /**
* This function is used to check if the user is authenticated. * This function is used to check if the user is authenticated.
@@ -1,4 +1,4 @@
import { PATH } from "../../../const.js"; import { PATH } from "~/const";
/** /**
* This route check the verification code from the email that user just recieved * This route check the verification code from the email that user just recieved
@@ -1,4 +1,4 @@
import { PATH } from "../../../const"; import { PATH } from "~/const";
/** /**
* This function is called in the end of the signup process. * This function is called in the end of the signup process.
@@ -26,13 +26,13 @@ const completeAccountInformationSignup = ({
tag, tag,
salt, salt,
verifier, verifier,
token token,
}) => { }) => {
return fetch(PATH + "/api/v1/signup/complete-account/signup", { return fetch(PATH + "/api/v1/signup/complete-account/signup", {
method: "POST", method: "POST",
headers: { headers: {
"Content-Type": "application/json", "Content-Type": "application/json",
"Authorization": "Bearer " + token, Authorization: "Bearer " + token,
}, },
body: JSON.stringify({ body: JSON.stringify({
email, email,
@@ -1,4 +1,4 @@
import { PATH } from "../../../const"; import { PATH } from "~/const";
/** /**
* This function is called in the end of the signup process. * This function is called in the end of the signup process.
@@ -24,13 +24,13 @@ const completeAccountInformationSignupInvite = ({
tag, tag,
salt, salt,
verifier, verifier,
token token,
}) => { }) => {
return fetch(PATH + "/api/v1/signup/complete-account/invite", { return fetch(PATH + "/api/v1/signup/complete-account/invite", {
method: "POST", method: "POST",
headers: { headers: {
"Content-Type": "application/json", "Content-Type": "application/json",
"Authorization": "Bearer " + token, Authorization: "Bearer " + token,
}, },
body: JSON.stringify({ body: JSON.stringify({
email: email, email: email,
@@ -41,7 +41,7 @@ const completeAccountInformationSignupInvite = ({
iv: iv, iv: iv,
tag: tag, tag: tag,
salt: salt, salt: salt,
verifier: verifier verifier: verifier,
}), }),
}); });
}; };
@@ -1,6 +1,6 @@
import SecurityClient from "~/utilities/SecurityClient"; import SecurityClient from "~/utilities/SecurityClient";
import { PATH } from "../../../const"; import { PATH } from "~/const";
/** /**
* This is the route that issues a backup private key that will afterwards be added into a pdf * This is the route that issues a backup private key that will afterwards be added into a pdf
+1 -1
View File
@@ -1,4 +1,4 @@
import { PATH } from "../../../const.js"; import { PATH } from "~/const";
/** /**
* This is the first step of the login process (pake) * This is the first step of the login process (pake)
+4 -5
View File
@@ -1,4 +1,4 @@
import { PATH } from "../../../const"; import { PATH } from "~/const";
/** /**
* This is the second step of the login process * This is the second step of the login process
@@ -16,16 +16,15 @@ const login2 = (email, clientProof) => {
email: email, email: email,
clientProof, clientProof,
}), }),
credentials: "include" credentials: "include",
}) }).then((res) => {
.then(res => {
if (res.status == 200) { if (res.status == 200) {
console.log("User logged in", res); console.log("User logged in", res);
return res; return res;
} else { } else {
console.log("Failed to log in"); console.log("Failed to log in");
} }
}) });
}; };
export default login2; export default login2;
+1 -1
View File
@@ -1,6 +1,6 @@
import SecurityClient from "~/utilities/SecurityClient"; import SecurityClient from "~/utilities/SecurityClient";
import { PATH } from "../../../const"; import { PATH } from "~/const";
/** /**
* This route logs the user out. Note: the user should authorized to do this. * This route logs the user out. Note: the user should authorized to do this.
+1 -1
View File
@@ -1,6 +1,6 @@
import SecurityClient from "~/utilities/SecurityClient"; import SecurityClient from "~/utilities/SecurityClient";
import { PATH } from "../../../const"; import { PATH } from "~/const";
/** /**
* This is the first step of the change password process (pake) * This is the first step of the change password process (pake)
@@ -1,4 +1,4 @@
import { PATH } from "../../../const.js"; import { PATH } from "~/const";
/** /**
* This route send the verification email to the user's email (contains a 6-digit verification code) * This route send the verification email to the user's email (contains a 6-digit verification code)
+5 -6
View File
@@ -1,4 +1,4 @@
import { PATH } from "../../../const.js"; import { PATH } from "~/const";
const token = async (req, res) => { const token = async (req, res) => {
return fetch(PATH + "/api/v1/auth/token", { return fetch(PATH + "/api/v1/auth/token", {
@@ -6,15 +6,14 @@ const token = async (req, res) => {
headers: { headers: {
"Content-Type": "application/json", "Content-Type": "application/json",
}, },
credentials: "include" credentials: "include",
}) }).then(async (res) => {
.then(async res => {
if (res.status == 200) { if (res.status == 200) {
return (await res.json()).token; return (await res.json()).token;
} else { } else {
console.log('Getting a new token failed'); console.log("Getting a new token failed");
} }
}) });
}; };
export default token; export default token;
@@ -1,4 +1,4 @@
import { PATH } from "../../../const"; import { PATH } from "~/const";
/** /**
* This route verifies the signup invite link * This route verifies the signup invite link
@@ -6,7 +6,7 @@ import { PATH } from "../../../const";
* @param {*} code * @param {*} code
* @returns * @returns
*/ */
const verifySignupInvite = ({email, code}) => { const verifySignupInvite = ({ email, code }) => {
return fetch(PATH + "/api/v1/invite-org/verify", { return fetch(PATH + "/api/v1/invite-org/verify", {
method: "POST", method: "POST",
headers: { headers: {
@@ -1,4 +1,4 @@
import { PATH } from "../../../const.js"; import { PATH } from "~/const";
/** /**
* This route lets us get the public key of infisical. Th euser doesn't have to be authenticated since this is just the public key. * This route lets us get the public key of infisical. Th euser doesn't have to be authenticated since this is just the public key.
+1 -1
View File
@@ -1,6 +1,6 @@
import SecurityClient from "~/utilities/SecurityClient.js"; import SecurityClient from "~/utilities/SecurityClient.js";
import { PATH } from "../../../const.js"; import { PATH } from "~/const";
/** /**
* This function fetches the encrypted secrets from the .env file * This function fetches the encrypted secrets from the .env file
+1 -1
View File
@@ -1,6 +1,6 @@
import SecurityClient from "~/utilities/SecurityClient"; import SecurityClient from "~/utilities/SecurityClient";
import { PATH } from "../../../const"; import { PATH } from "~/const";
/** /**
* This function uploads the encrypted .env file * This function uploads the encrypted .env file
@@ -1,6 +1,6 @@
import SecurityClient from "~/utilities/SecurityClient"; import SecurityClient from "~/utilities/SecurityClient";
import { PATH } from "../../../const"; import { PATH } from "~/const";
const changeHerokuConfigVars = ({ integrationId, key, secrets }) => { const changeHerokuConfigVars = ({ integrationId, key, secrets }) => {
return SecurityClient.fetchCall( return SecurityClient.fetchCall(
@@ -1,6 +1,6 @@
import SecurityClient from "~/utilities/SecurityClient"; import SecurityClient from "~/utilities/SecurityClient";
import { PATH } from "../../../const"; import { PATH } from "~/const";
/** /**
* This route deletes an integration from a certain project * This route deletes an integration from a certain project
@@ -1,6 +1,6 @@
import SecurityClient from "~/utilities/SecurityClient"; import SecurityClient from "~/utilities/SecurityClient";
import { PATH } from "../../../const"; import { PATH } from "~/const";
/** /**
* This route deletes an integration authorization from a certain project * This route deletes an integration authorization from a certain project
@@ -1,6 +1,6 @@
import SecurityClient from "~/utilities/SecurityClient"; import SecurityClient from "~/utilities/SecurityClient";
import { PATH } from "../../../const"; import { PATH } from "~/const";
const getIntegrationApps = ({ integrationAuthId }) => { const getIntegrationApps = ({ integrationAuthId }) => {
return SecurityClient.fetchCall( return SecurityClient.fetchCall(
@@ -1,6 +1,6 @@
import SecurityClient from "~/utilities/SecurityClient"; import SecurityClient from "~/utilities/SecurityClient";
import { PATH } from "../../../const"; import { PATH } from "~/const";
const getIntegrations = () => { const getIntegrations = () => {
return SecurityClient.fetchCall(PATH + "/api/v1/integration/integrations", { return SecurityClient.fetchCall(PATH + "/api/v1/integration/integrations", {
@@ -1,6 +1,6 @@
import SecurityClient from "~/utilities/SecurityClient"; import SecurityClient from "~/utilities/SecurityClient";
import { PATH } from "../../../const"; 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.
@@ -1,6 +1,6 @@
import SecurityClient from "~/utilities/SecurityClient"; import SecurityClient from "~/utilities/SecurityClient";
import { PATH } from "../../../const"; import { PATH } from "~/const";
/** /**
* This is the first step of the change password process (pake) * This is the first step of the change password process (pake)
@@ -1,6 +1,6 @@
import SecurityClient from "~/utilities/SecurityClient"; import SecurityClient from "~/utilities/SecurityClient";
import { PATH } from "../../../const"; import { PATH } from "~/const";
/** /**
* This route gets authorizations of a certain project (Heroku, etc.) * This route gets authorizations of a certain project (Heroku, etc.)
@@ -1,6 +1,6 @@
import SecurityClient from "~/utilities/SecurityClient"; import SecurityClient from "~/utilities/SecurityClient";
import { PATH } from "../../../const"; import { PATH } from "~/const";
/** /**
* This route gets integrations of a certain project (Heroku, etc.) * This route gets integrations of a certain project (Heroku, etc.)
+3 -6
View File
@@ -1,6 +1,6 @@
import SecurityClient from "~/utilities/SecurityClient"; import SecurityClient from "~/utilities/SecurityClient";
import { PATH } from "../../../const"; import { PATH } from "~/const";
/** /**
* This route lets us get info about a certain org * This route lets us get info about a certain org
@@ -9,15 +9,12 @@ import { PATH } from "../../../const";
* @returns * @returns
*/ */
const getOrganization = (req, res) => { const getOrganization = (req, res) => {
return SecurityClient.fetchCall( return SecurityClient.fetchCall(PATH + "/api/v1/organization/" + req.orgId, {
PATH + "/api/v1/organization/" + req.orgId,
{
method: "GET", method: "GET",
headers: { headers: {
"Content-Type": "application/json", "Content-Type": "application/json",
}, },
} }).then(async (res) => {
).then(async (res) => {
if (res.status == 200) { if (res.status == 200) {
return (await res.json()).organization; return (await res.json()).organization;
} else { } else {
@@ -1,6 +1,6 @@
import SecurityClient from "~/utilities/SecurityClient"; import SecurityClient from "~/utilities/SecurityClient";
import { PATH } from "../../../const"; import { PATH } from "~/const";
/** /**
* This route lets us get all the users in an org. * This route lets us get all the users in an org.
@@ -1,6 +1,6 @@
import SecurityClient from "~/utilities/SecurityClient"; import SecurityClient from "~/utilities/SecurityClient";
import { PATH } from "../../../const"; import { PATH } from "~/const";
/** /**
* This route lets us get the current subscription of an org. * This route lets us get the current subscription of an org.
@@ -1,6 +1,6 @@
import SecurityClient from "~/utilities/SecurityClient"; import SecurityClient from "~/utilities/SecurityClient";
import { PATH } from "../../../const"; import { PATH } from "~/const";
/** /**
* This route lets us get all the projects of a certain user in an org. * This route lets us get all the projects of a certain user in an org.
@@ -1,6 +1,6 @@
import SecurityClient from "~/utilities/SecurityClient"; import SecurityClient from "~/utilities/SecurityClient";
import { PATH } from "../../../const"; import { PATH } from "~/const";
/** /**
* This route lets us get all the users in an org. * This route lets us get all the users in an org.
@@ -1,6 +1,6 @@
import SecurityClient from "~/utilities/SecurityClient"; import SecurityClient from "~/utilities/SecurityClient";
import { PATH } from "../../../const"; import { PATH } from "~/const";
/** /**
* This route redirects the user to the right stripe billing page. * This route redirects the user to the right stripe billing page.
@@ -1,6 +1,6 @@
import SecurityClient from "~/utilities/SecurityClient"; import SecurityClient from "~/utilities/SecurityClient";
import { PATH } from "../../../const"; import { PATH } from "~/const";
/** /**
* This route add an incident contact email to a certain organization * This route add an incident contact email to a certain organization
@@ -1,6 +1,6 @@
import SecurityClient from "~/utilities/SecurityClient"; import SecurityClient from "~/utilities/SecurityClient";
import { PATH } from "../../../const"; import { PATH } from "~/const";
/** /**
* This function sends an email invite to a user to join an org * This function sends an email invite to a user to join an org
@@ -1,6 +1,6 @@
import SecurityClient from "~/utilities/SecurityClient"; import SecurityClient from "~/utilities/SecurityClient";
import { PATH } from "../../../const"; import { PATH } from "~/const";
/** /**
* This route deletes an incident Contact from a certain organization * This route deletes an incident Contact from a certain organization
@@ -1,6 +1,6 @@
import SecurityClient from "~/utilities/SecurityClient"; import SecurityClient from "~/utilities/SecurityClient";
import { PATH } from "../../../const"; import { PATH } from "~/const";
/** /**
* This function removes a certain member from a certain organization * This function removes a certain member from a certain organization
@@ -1,6 +1,6 @@
import SecurityClient from "~/utilities/SecurityClient"; import SecurityClient from "~/utilities/SecurityClient";
import { PATH } from "../../../const"; import { PATH } from "~/const";
/** /**
* This routes gets all the incident contacts of a certain organization * This routes gets all the incident contacts of a certain organization
+1 -1
View File
@@ -1,6 +1,6 @@
import SecurityClient from "~/utilities/SecurityClient"; import SecurityClient from "~/utilities/SecurityClient";
import { PATH } from "../../../const"; import { PATH } from "~/const";
/** /**
* This route lets us get the all the orgs of a certain user. * This route lets us get the all the orgs of a certain user.
+1 -1
View File
@@ -1,6 +1,6 @@
import SecurityClient from "~/utilities/SecurityClient"; import SecurityClient from "~/utilities/SecurityClient";
import { PATH } from "../../../const"; import { PATH } from "~/const";
/** /**
* This route lets us rename a certain org. * This route lets us rename a certain org.
@@ -1,6 +1,6 @@
import SecurityClient from "~/utilities/SecurityClient"; import SecurityClient from "~/utilities/SecurityClient";
import { PATH } from "../../../const"; import { PATH } from "~/const";
/** /**
* This route gets service tokens for a specific user in a project * This route gets service tokens for a specific user in a project
@@ -1,6 +1,6 @@
import SecurityClient from "~/utilities/SecurityClient"; import SecurityClient from "~/utilities/SecurityClient";
import { PATH } from "../../../const"; import { PATH } from "~/const";
/** /**
* This route gets service tokens for a specific user in a project * This route gets service tokens for a specific user in a project
+1 -1
View File
@@ -1,6 +1,6 @@
import SecurityClient from "~/utilities/SecurityClient"; import SecurityClient from "~/utilities/SecurityClient";
import { PATH } from "../../../const"; import { PATH } from "~/const";
/** /**
* This route gets the information about a specific user. * This route gets the information about a specific user.
@@ -1,6 +1,6 @@
import SecurityClient from "~/utilities/SecurityClient"; import SecurityClient from "~/utilities/SecurityClient";
import { PATH } from "../../../const"; import { PATH } from "~/const";
/** /**
* This route registers a certain action for a user * This route registers a certain action for a user
@@ -1,6 +1,6 @@
import SecurityClient from "~/utilities/SecurityClient"; import SecurityClient from "~/utilities/SecurityClient";
import { PATH } from "../../../const"; import { PATH } from "~/const";
/** /**
* This route registers a certain action for a user * This route registers a certain action for a user
@@ -1,6 +1,6 @@
import SecurityClient from "~/utilities/SecurityClient"; import SecurityClient from "~/utilities/SecurityClient";
import { PATH } from "../../../const"; import { PATH } from "~/const";
/** /**
* This function adds a user to a project * This function adds a user to a project
@@ -1,6 +1,6 @@
import SecurityClient from "~/utilities/SecurityClient"; import SecurityClient from "~/utilities/SecurityClient";
import { PATH } from "../../../const"; import { PATH } from "~/const";
/** /**
* This function change the access of a user in a certain workspace * This function change the access of a user in a certain workspace
@@ -1,6 +1,6 @@
import SecurityClient from "~/utilities/SecurityClient"; import SecurityClient from "~/utilities/SecurityClient";
import { PATH } from "../../../const"; import { PATH } from "~/const";
/** /**
* This route creates a new workspace for a user. * This route creates a new workspace for a user.
@@ -1,6 +1,6 @@
import SecurityClient from "~/utilities/SecurityClient"; import SecurityClient from "~/utilities/SecurityClient";
import { PATH } from "../../../const"; import { PATH } from "~/const";
/** /**
* This function removes a certain member from a certain workspace * This function removes a certain member from a certain workspace
@@ -8,15 +8,12 @@ import { PATH } from "../../../const";
* @returns * @returns
*/ */
const deleteUserFromWorkspace = (membershipId) => { const deleteUserFromWorkspace = (membershipId) => {
return SecurityClient.fetchCall( return SecurityClient.fetchCall(PATH + "/api/v1/membership/" + membershipId, {
PATH + "/api/v1/membership/" + membershipId,
{
method: "DELETE", method: "DELETE",
headers: { headers: {
"Content-Type": "application/json", "Content-Type": "application/json",
}, },
} }).then(async (res) => {
).then(async (res) => {
if (res.status == 200) { if (res.status == 200) {
return res; return res;
} else { } else {
@@ -1,6 +1,6 @@
import SecurityClient from "~/utilities/SecurityClient"; import SecurityClient from "~/utilities/SecurityClient";
import { PATH } from "../../../const"; import { PATH } from "~/const";
/** /**
* This route deletes a specified workspace. * This route deletes a specified workspace.
@@ -1,6 +1,6 @@
import SecurityClient from "~/utilities/SecurityClient"; import SecurityClient from "~/utilities/SecurityClient";
import { PATH } from "../../../const"; import { PATH } from "~/const";
/** /**
* Get the latest key pairs from a certain workspace * Get the latest key pairs from a certain workspace
@@ -20,9 +20,7 @@ const getLatestFileKey = (workspaceId) => {
if (res.status == 200) { if (res.status == 200) {
return await res.json(); return await res.json();
} else { } else {
console.log( console.log("Failed to get the latest key pairs for a certain project");
"Failed to get the latest key pairs for a certain project"
);
} }
}); });
}; };
@@ -1,6 +1,6 @@
import SecurityClient from "~/utilities/SecurityClient"; import SecurityClient from "~/utilities/SecurityClient";
import { PATH } from "../../../const"; import { PATH } from "~/const";
/** /**
* This route lets us get the information of a certain project. * This route lets us get the information of a certain project.
@@ -1,6 +1,6 @@
import SecurityClient from "~/utilities/SecurityClient"; import SecurityClient from "~/utilities/SecurityClient";
import { PATH } from "../../../const"; import { PATH } from "~/const";
/** /**
* This route lets us get the public keys of everyone in your workspace. * This route lets us get the public keys of everyone in your workspace.
@@ -21,9 +21,7 @@ const getWorkspaceKeys = (req, res) => {
if (res.status == 200) { if (res.status == 200) {
return (await res.json()).publicKeys; return (await res.json()).publicKeys;
} else { } else {
console.log( console.log("Failed to get the public keys of everyone in the workspace");
"Failed to get the public keys of everyone in the workspace"
);
} }
}); });
}; };
@@ -1,6 +1,6 @@
import SecurityClient from "~/utilities/SecurityClient"; import SecurityClient from "~/utilities/SecurityClient";
import { PATH } from "../../../const"; import { PATH } from "~/const";
/** /**
* This route lets us get all the users in the workspace. * This route lets us get all the users in the workspace.
@@ -1,6 +1,6 @@
import SecurityClient from "~/utilities/SecurityClient"; import SecurityClient from "~/utilities/SecurityClient";
import { PATH } from "../../../const"; import { PATH } from "~/const";
/** /**
* This route lets us get the public keys of everyone in your workspace. * This route lets us get the public keys of everyone in your workspace.
@@ -1,6 +1,6 @@
import SecurityClient from "~/utilities/SecurityClient"; import SecurityClient from "~/utilities/SecurityClient";
import { PATH } from "../../../const"; import { PATH } from "~/const";
/** /**
* This route lets us rename a certain workspace. * This route lets us rename a certain workspace.
+1 -1
View File
@@ -1,6 +1,6 @@
import SecurityClient from "~/utilities/SecurityClient"; import SecurityClient from "~/utilities/SecurityClient";
import { PATH } from "../../../const"; import { PATH } from "~/const";
/** /**
* This route uplods the keys in an encrypted format. * This route uplods the keys in an encrypted format.