Skip to content

Commit d8aa5b5

Browse files
I-36 Remove dependency to PATH const
1 parent f9bf418 commit d8aa5b5

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

57 files changed

+54
-125
lines changed

frontend/components/utilities/SecurityClient.js

+1-4
Original file line numberDiff line numberDiff line change
@@ -1,8 +1,6 @@
1-
import { PATH } from "~/const";
21
import token from "~/pages/api/auth/Token";
32

43
export default class SecurityClient {
5-
static authOrigins = [PATH];
64
static #token = "";
75

86
contructor() {}
@@ -13,13 +11,12 @@ export default class SecurityClient {
1311

1412
static async fetchCall(resource, options) {
1513
let req = new Request(resource, options);
16-
const destOrigin = new URL(req.url).origin;
1714

1815
if (this.#token == "") {
1916
this.setToken(await token());
2017
}
2118

22-
if (this.#token && this.authOrigins.includes(destOrigin)) {
19+
if (this.#token) {
2320
req.headers.set("Authorization", "Bearer " + this.#token);
2421
return fetch(req);
2522
}

frontend/const.js

-2
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,3 @@
1-
export const PATH = process.env.NEXT_PUBLIC_WEBSITE_URL;
2-
31
export const publicPaths = [
42
`/`,
53
// `/integrations`,

frontend/pages/api/auth/ChangePassword2.js

+1-2
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,3 @@
1-
import { PATH } from "~/const";
21
import SecurityClient from "~/utilities/SecurityClient";
32

43
/**
@@ -14,7 +13,7 @@ const changePassword2 = ({
1413
verifier,
1514
clientProof,
1615
}) => {
17-
return SecurityClient.fetchCall(PATH + "/api/v1/password/change-password", {
16+
return SecurityClient.fetchCall("/api/v1/password/change-password", {
1817
method: "POST",
1918
headers: {
2019
"Content-Type": "application/json",

frontend/pages/api/auth/CheckAuth.js

+1-2
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,3 @@
1-
import { PATH } from "~/const";
21
import SecurityClient from "~/utilities/SecurityClient.js";
32

43
/**
@@ -9,7 +8,7 @@ import SecurityClient from "~/utilities/SecurityClient.js";
98
* @returns
109
*/
1110
const checkAuth = async (req, res) => {
12-
return SecurityClient.fetchCall(PATH + "/api/v1/auth/checkAuth", {
11+
return SecurityClient.fetchCall("/api/v1/auth/checkAuth", {
1312
method: "POST",
1413
headers: {
1514
"Content-Type": "application/json",

frontend/pages/api/auth/CheckEmailVerificationCode.js

+1-3
Original file line numberDiff line numberDiff line change
@@ -1,13 +1,11 @@
1-
import { PATH } from "~/const";
2-
31
/**
42
* This route check the verification code from the email that user just recieved
53
* @param {*} email
64
* @param {*} code
75
* @returns
86
*/
97
const checkEmailVerificationCode = (email, code) => {
10-
return fetch(PATH + "/api/v1/signup/email/verify", {
8+
return fetch("/api/v1/signup/email/verify", {
119
method: "POST",
1210
headers: {
1311
"Content-Type": "application/json",

frontend/pages/api/auth/CompleteAccountInformationSignup.js

+1-3
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,3 @@
1-
import { PATH } from "~/const";
2-
31
/**
42
* This function is called in the end of the signup process.
53
* It sends all the necessary nformation to the server.
@@ -28,7 +26,7 @@ const completeAccountInformationSignup = ({
2826
verifier,
2927
token,
3028
}) => {
31-
return fetch(PATH + "/api/v1/signup/complete-account/signup", {
29+
return fetch("/api/v1/signup/complete-account/signup", {
3230
method: "POST",
3331
headers: {
3432
"Content-Type": "application/json",

frontend/pages/api/auth/CompleteAccountInformationSignupInvite.js

+1-3
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,3 @@
1-
import { PATH } from "~/const";
2-
31
/**
42
* This function is called in the end of the signup process.
53
* It sends all the necessary nformation to the server.
@@ -26,7 +24,7 @@ const completeAccountInformationSignupInvite = ({
2624
verifier,
2725
token,
2826
}) => {
29-
return fetch(PATH + "/api/v1/signup/complete-account/invite", {
27+
return fetch("/api/v1/signup/complete-account/invite", {
3028
method: "POST",
3129
headers: {
3230
"Content-Type": "application/json",

frontend/pages/api/auth/IssueBackupPrivateKey.js

+1-2
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,3 @@
1-
import { PATH } from "~/const";
21
import SecurityClient from "~/utilities/SecurityClient";
32

43
/**
@@ -13,7 +12,7 @@ const issueBackupPrivateKey = ({
1312
clientProof,
1413
}) => {
1514
return SecurityClient.fetchCall(
16-
PATH + "/api/v1/password/backup-private-key",
15+
"/api/v1/password/backup-private-key",
1716
{
1817
method: "POST",
1918
headers: {

frontend/pages/api/auth/Login1.js

+1-3
Original file line numberDiff line numberDiff line change
@@ -1,13 +1,11 @@
1-
import { PATH } from "~/const";
2-
31
/**
42
* This is the first step of the login process (pake)
53
* @param {*} email
64
* @param {*} clientPublicKey
75
* @returns
86
*/
97
const login1 = (email, clientPublicKey) => {
10-
return fetch(PATH + "/api/v1/auth/login1", {
8+
return fetch("/api/v1/auth/login1", {
119
method: "POST",
1210
headers: {
1311
"Content-Type": "application/json",

frontend/pages/api/auth/Login2.js

+1-3
Original file line numberDiff line numberDiff line change
@@ -1,13 +1,11 @@
1-
import { PATH } from "~/const";
2-
31
/**
42
* This is the second step of the login process
53
* @param {*} email
64
* @param {*} clientPublicKey
75
* @returns
86
*/
97
const login2 = (email, clientProof) => {
10-
return fetch(PATH + "/api/v1/auth/login2", {
8+
return fetch("/api/v1/auth/login2", {
119
method: "POST",
1210
headers: {
1311
"Content-Type": "application/json",

frontend/pages/api/auth/Logout.js

+1-2
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,3 @@
1-
import { PATH } from "~/const";
21
import SecurityClient from "~/utilities/SecurityClient";
32

43
/**
@@ -9,7 +8,7 @@ import SecurityClient from "~/utilities/SecurityClient";
98
* @returns
109
*/
1110
const logout = async (req, res) => {
12-
return SecurityClient.fetchCall(PATH + "/api/v1/auth/logout", {
11+
return SecurityClient.fetchCall("/api/v1/auth/logout", {
1312
method: "POST",
1413
headers: {
1514
"Content-Type": "application/json",

frontend/pages/api/auth/SRP1.js

+1-2
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,3 @@
1-
import { PATH } from "~/const";
21
import SecurityClient from "~/utilities/SecurityClient";
32

43
/**
@@ -7,7 +6,7 @@ import SecurityClient from "~/utilities/SecurityClient";
76
* @returns
87
*/
98
const SRP1 = ({ clientPublicKey }) => {
10-
return SecurityClient.fetchCall(PATH + "/api/v1/password/srp1", {
9+
return SecurityClient.fetchCall("/api/v1/password/srp1", {
1110
method: "POST",
1211
headers: {
1312
"Content-Type": "application/json",

frontend/pages/api/auth/SendVerificationEmail.js

+1-3
Original file line numberDiff line numberDiff line change
@@ -1,11 +1,9 @@
1-
import { PATH } from "~/const";
2-
31
/**
42
* This route send the verification email to the user's email (contains a 6-digit verification code)
53
* @param {*} email
64
*/
75
const sendVerificationEmail = (email) => {
8-
fetch(PATH + "/api/v1/signup/email/signup", {
6+
fetch("/api/v1/signup/email/signup", {
97
method: "POST",
108
headers: {
119
"Content-Type": "application/json",

frontend/pages/api/auth/Token.js

+1-3
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,5 @@
1-
import { PATH } from "~/const";
2-
31
const token = async (req, res) => {
4-
return fetch(PATH + "/api/v1/auth/token", {
2+
return fetch("/api/v1/auth/token", {
53
method: "POST",
64
headers: {
75
"Content-Type": "application/json",

frontend/pages/api/auth/VerifySignupInvite.js

+1-3
Original file line numberDiff line numberDiff line change
@@ -1,13 +1,11 @@
1-
import { PATH } from "~/const";
2-
31
/**
42
* This route verifies the signup invite link
53
* @param {*} email
64
* @param {*} code
75
* @returns
86
*/
97
const verifySignupInvite = ({ email, code }) => {
10-
return fetch(PATH + "/api/v1/invite-org/verify", {
8+
return fetch("/api/v1/invite-org/verify", {
119
method: "POST",
1210
headers: {
1311
"Content-Type": "application/json",

frontend/pages/api/auth/publicKeyInfisical.js

+1-3
Original file line numberDiff line numberDiff line change
@@ -1,13 +1,11 @@
1-
import { PATH } from "~/const";
2-
31
/**
42
* 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.
53
* @param {*} req
64
* @param {*} res
75
* @returns
86
*/
97
const publicKeyInfisical = (req, res) => {
10-
return fetch(PATH + "/api/v1/key/publicKey/infisical", {
8+
return fetch("/api/v1/key/publicKey/infisical", {
119
method: "GET",
1210
headers: {
1311
"Content-Type": "application/json",

frontend/pages/api/files/GetSecrets.js

-2
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,3 @@
1-
import { PATH } from "~/const";
21
import SecurityClient from "~/utilities/SecurityClient.js";
32

43
/**
@@ -9,7 +8,6 @@ import SecurityClient from "~/utilities/SecurityClient.js";
98
*/
109
const getSecrets = async (workspaceId, env) => {
1110
return SecurityClient.fetchCall(
12-
PATH +
1311
"/api/v1/secret/" +
1412
workspaceId +
1513
"?" +

frontend/pages/api/files/UploadSecrets.js

+1-2
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,3 @@
1-
import { PATH } from "~/const";
21
import SecurityClient from "~/utilities/SecurityClient";
32

43
/**
@@ -8,7 +7,7 @@ import SecurityClient from "~/utilities/SecurityClient";
87
* @returns
98
*/
109
const uploadSecrets = async ({ workspaceId, secrets, keys, environment }) => {
11-
return SecurityClient.fetchCall(PATH + "/api/v1/secret/" + workspaceId, {
10+
return SecurityClient.fetchCall("/api/v1/secret/" + workspaceId, {
1211
method: "POST",
1312
headers: {
1413
"Content-Type": "application/json",

frontend/pages/api/integrations/ChangeHerokuConfigVars.js

+1-2
Original file line numberDiff line numberDiff line change
@@ -1,9 +1,8 @@
1-
import { PATH } from "~/const";
21
import SecurityClient from "~/utilities/SecurityClient";
32

43
const changeHerokuConfigVars = ({ integrationId, key, secrets }) => {
54
return SecurityClient.fetchCall(
6-
PATH + "/api/v1/integration/" + integrationId + "/sync",
5+
"/api/v1/integration/" + integrationId + "/sync",
76
{
87
method: "POST",
98
headers: {

frontend/pages/api/integrations/DeleteIntegration.js

+1-2
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,3 @@
1-
import { PATH } from "~/const";
21
import SecurityClient from "~/utilities/SecurityClient";
32

43
/**
@@ -8,7 +7,7 @@ import SecurityClient from "~/utilities/SecurityClient";
87
*/
98
const deleteIntegration = ({ integrationId }) => {
109
return SecurityClient.fetchCall(
11-
PATH + "/api/v1/integration/" + integrationId,
10+
"/api/v1/integration/" + integrationId,
1211
{
1312
method: "DELETE",
1413
headers: {

frontend/pages/api/integrations/DeleteIntegrationAuth.js

+1-2
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,3 @@
1-
import { PATH } from "~/const";
21
import SecurityClient from "~/utilities/SecurityClient";
32

43
/**
@@ -8,7 +7,7 @@ import SecurityClient from "~/utilities/SecurityClient";
87
*/
98
const deleteIntegrationAuth = ({ integrationAuthId }) => {
109
return SecurityClient.fetchCall(
11-
PATH + "/api/v1/integration-auth/" + integrationAuthId,
10+
"/api/v1/integration-auth/" + integrationAuthId,
1211
{
1312
method: "DELETE",
1413
headers: {

frontend/pages/api/integrations/GetIntegrationApps.js

+1-2
Original file line numberDiff line numberDiff line change
@@ -1,9 +1,8 @@
1-
import { PATH } from "~/const";
21
import SecurityClient from "~/utilities/SecurityClient";
32

43
const getIntegrationApps = ({ integrationAuthId }) => {
54
return SecurityClient.fetchCall(
6-
PATH + "/api/v1/integration-auth/" + integrationAuthId + "/apps",
5+
"/api/v1/integration-auth/" + integrationAuthId + "/apps",
76
{
87
method: "GET",
98
headers: {

frontend/pages/api/integrations/GetIntegrations.js

+1-2
Original file line numberDiff line numberDiff line change
@@ -1,8 +1,7 @@
1-
import { PATH } from "~/const";
21
import SecurityClient from "~/utilities/SecurityClient";
32

43
const getIntegrations = () => {
5-
return SecurityClient.fetchCall(PATH + "/api/v1/integration/integrations", {
4+
return SecurityClient.fetchCall("/api/v1/integration/integrations", {
65
method: "GET",
76
headers: {
87
"Content-Type": "application/json",

frontend/pages/api/integrations/StartIntegration.js

+1-2
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,3 @@
1-
import { PATH } from "~/const";
21
import SecurityClient from "~/utilities/SecurityClient";
32

43
/**
@@ -8,7 +7,7 @@ import SecurityClient from "~/utilities/SecurityClient";
87
*/
98
const startIntegration = ({ integrationId, appName, environment }) => {
109
return SecurityClient.fetchCall(
11-
PATH + "/api/v1/integration/" + integrationId,
10+
"/api/v1/integration/" + integrationId,
1211
{
1312
method: "PATCH",
1413
headers: {

frontend/pages/api/integrations/authorizeIntegration.js

+1-2
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,3 @@
1-
import { PATH } from "~/const";
21
import SecurityClient from "~/utilities/SecurityClient";
32

43
/**
@@ -8,7 +7,7 @@ import SecurityClient from "~/utilities/SecurityClient";
87
*/
98
const AuthorizeIntegration = ({ workspaceId, code, integration }) => {
109
return SecurityClient.fetchCall(
11-
PATH + "/api/v1/integration-auth/oauth-token",
10+
"/api/v1/integration-auth/oauth-token",
1211
{
1312
method: "POST",
1413
headers: {

frontend/pages/api/integrations/getWorkspaceAuthorizations.js

+1-2
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,3 @@
1-
import { PATH } from "~/const";
21
import SecurityClient from "~/utilities/SecurityClient";
32

43
/**
@@ -8,7 +7,7 @@ import SecurityClient from "~/utilities/SecurityClient";
87
*/
98
const getWorkspaceAuthorizations = ({ workspaceId }) => {
109
return SecurityClient.fetchCall(
11-
PATH + "/api/v1/workspace/" + workspaceId + "/authorizations",
10+
"/api/v1/workspace/" + workspaceId + "/authorizations",
1211
{
1312
method: "GET",
1413
headers: {

frontend/pages/api/integrations/getWorkspaceIntegrations.js

+1-2
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,3 @@
1-
import { PATH } from "~/const";
21
import SecurityClient from "~/utilities/SecurityClient";
32

43
/**
@@ -8,7 +7,7 @@ import SecurityClient from "~/utilities/SecurityClient";
87
*/
98
const getWorkspaceIntegrations = ({ workspaceId }) => {
109
return SecurityClient.fetchCall(
11-
PATH + "/api/v1/workspace/" + workspaceId + "/integrations",
10+
"/api/v1/workspace/" + workspaceId + "/integrations",
1211
{
1312
method: "GET",
1413
headers: {

frontend/pages/api/organization/GetOrg.js

+1-2
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,3 @@
1-
import { PATH } from "~/const";
21
import SecurityClient from "~/utilities/SecurityClient";
32

43
/**
@@ -8,7 +7,7 @@ import SecurityClient from "~/utilities/SecurityClient";
87
* @returns
98
*/
109
const getOrganization = (req, res) => {
11-
return SecurityClient.fetchCall(PATH + "/api/v1/organization/" + req.orgId, {
10+
return SecurityClient.fetchCall("/api/v1/organization/" + req.orgId, {
1211
method: "GET",
1312
headers: {
1413
"Content-Type": "application/json",

frontend/pages/api/organization/GetOrgProjects.js

+1-2
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,3 @@
1-
import { PATH } from "~/const";
21
import SecurityClient from "~/utilities/SecurityClient";
32

43
/**
@@ -9,7 +8,7 @@ import SecurityClient from "~/utilities/SecurityClient";
98
*/
109
const getOrganizationProjects = (req, res) => {
1110
return SecurityClient.fetchCall(
12-
PATH + "/api/organization/" + req.orgId + "/workspaces",
11+
"/api/organization/" + req.orgId + "/workspaces",
1312
{
1413
method: "GET",
1514
headers: {

0 commit comments

Comments
 (0)