ref(frontend): update to absolute import

This commit is contained in:
이강준
2022-11-26 18:19:41 +09:00
parent 001df70e26
commit 22c184840c
73 changed files with 2029 additions and 1287 deletions
+18 -12
View File
@@ -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;
+3 -4
View File
@@ -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;
@@ -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;
+4 -5
View File
@@ -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;
+6 -7
View File
@@ -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;
+19 -17
View File
@@ -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;
+4 -5
View File
@@ -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;
@@ -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;
@@ -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;
@@ -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;
@@ -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;
@@ -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;
@@ -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;
@@ -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;
@@ -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;
@@ -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;
+12 -10
View File
@@ -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;
@@ -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;
@@ -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;
@@ -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;
+12 -10
View File
@@ -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;
@@ -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;
@@ -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;
@@ -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;
@@ -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;
@@ -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;
@@ -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;
+4 -5
View File
@@ -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;
+15 -13
View File
@@ -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;
@@ -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;
@@ -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;
+4 -5
View File
@@ -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;
@@ -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;
@@ -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;
@@ -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;
@@ -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;
@@ -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;
@@ -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;
@@ -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;
@@ -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;
@@ -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;
@@ -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;
@@ -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;
@@ -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;
+15 -13
View File
@@ -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;
+4 -5
View File
@@ -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;