mirror of
https://github.com/awatertrevi/infisical.git
synced 2026-10-08 14:28:20 +00:00
Add frontend, backend and CLI
This commit is contained in:
@@ -0,0 +1,33 @@
|
||||
import SecurityClient from "../../../components/utilities/SecurityClient";
|
||||
import { PATH } from "../../../const";
|
||||
|
||||
/**
|
||||
* This is the second step of the change password process (pake)
|
||||
* @param {*} clientPublicKey
|
||||
* @returns
|
||||
*/
|
||||
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
|
||||
}),
|
||||
})
|
||||
.then(async res => {
|
||||
if (res.status == 200) {
|
||||
return res;
|
||||
} else {
|
||||
console.log('Failed to change the password');
|
||||
}
|
||||
})
|
||||
};
|
||||
|
||||
export default changePassword2;
|
||||
@@ -0,0 +1,27 @@
|
||||
import SecurityClient from "../../../components/utilities/SecurityClient.js";
|
||||
import { PATH } from "../../../const.js";
|
||||
|
||||
/**
|
||||
* This function is used to check if the user is authenticated.
|
||||
* To do that, we get their tokens from cookies, and verify if they are good.
|
||||
* @param {*} req
|
||||
* @param {*} res
|
||||
* @returns
|
||||
*/
|
||||
const checkAuth = async (req, res) => {
|
||||
return SecurityClient.fetchCall(PATH + "/api/v1/auth/checkAuth", {
|
||||
method: "POST",
|
||||
headers: {
|
||||
"Content-Type": "application/json",
|
||||
},
|
||||
})
|
||||
.then(res => {
|
||||
if (res.status == 200) {
|
||||
return res;
|
||||
} else {
|
||||
console.log("Not authorized");
|
||||
}
|
||||
})
|
||||
};
|
||||
|
||||
export default checkAuth;
|
||||
@@ -0,0 +1,22 @@
|
||||
import { PATH } from "../../../const.js";
|
||||
|
||||
/**
|
||||
* This route check the verification code from the email that user just recieved
|
||||
* @param {*} email
|
||||
* @param {*} code
|
||||
* @returns
|
||||
*/
|
||||
const checkEmailVerificationCode = (email, code) => {
|
||||
return fetch(PATH + "/api/v1/signup/email/verify", {
|
||||
method: "POST",
|
||||
headers: {
|
||||
"Content-Type": "application/json",
|
||||
},
|
||||
body: JSON.stringify({
|
||||
email: email,
|
||||
code: code,
|
||||
}),
|
||||
});
|
||||
};
|
||||
|
||||
export default checkEmailVerificationCode;
|
||||
@@ -0,0 +1,52 @@
|
||||
import { PATH } from "../../../const";
|
||||
|
||||
/**
|
||||
* This function is called in the end of the signup process.
|
||||
* It sends all the necessary nformation to the server.
|
||||
* @param {*} email
|
||||
* @param {*} firstName
|
||||
* @param {*} lastName
|
||||
* @param {*} workspace
|
||||
* @param {*} publicKey
|
||||
* @param {*} ciphertext
|
||||
* @param {*} iv
|
||||
* @param {*} tag
|
||||
* @param {*} salt
|
||||
* @param {*} verifier
|
||||
* @returns
|
||||
*/
|
||||
const completeAccountInformationSignup = ({
|
||||
email,
|
||||
firstName,
|
||||
lastName,
|
||||
organizationName,
|
||||
publicKey,
|
||||
ciphertext,
|
||||
iv,
|
||||
tag,
|
||||
salt,
|
||||
verifier,
|
||||
token
|
||||
}) => {
|
||||
return fetch(PATH + "/api/v1/signup/complete-account/signup", {
|
||||
method: "POST",
|
||||
headers: {
|
||||
"Content-Type": "application/json",
|
||||
"Authorization": "Bearer " + token,
|
||||
},
|
||||
body: JSON.stringify({
|
||||
email,
|
||||
firstName,
|
||||
lastName,
|
||||
publicKey,
|
||||
encryptedPrivateKey: ciphertext,
|
||||
organizationName,
|
||||
iv,
|
||||
tag,
|
||||
salt,
|
||||
verifier,
|
||||
}),
|
||||
});
|
||||
};
|
||||
|
||||
export default completeAccountInformationSignup;
|
||||
@@ -0,0 +1,49 @@
|
||||
import { PATH } from "../../../const";
|
||||
|
||||
/**
|
||||
* This function is called in the end of the signup process.
|
||||
* It sends all the necessary nformation to the server.
|
||||
* @param {*} email
|
||||
* @param {*} firstName
|
||||
* @param {*} lastName
|
||||
* @param {*} publicKey
|
||||
* @param {*} ciphertext
|
||||
* @param {*} iv
|
||||
* @param {*} tag
|
||||
* @param {*} salt
|
||||
* @param {*} verifier
|
||||
* @returns
|
||||
*/
|
||||
const completeAccountInformationSignupInvite = ({
|
||||
email,
|
||||
firstName,
|
||||
lastName,
|
||||
publicKey,
|
||||
ciphertext,
|
||||
iv,
|
||||
tag,
|
||||
salt,
|
||||
verifier,
|
||||
token
|
||||
}) => {
|
||||
return fetch(PATH + "/api/v1/signup/complete-account/invite", {
|
||||
method: "POST",
|
||||
headers: {
|
||||
"Content-Type": "application/json",
|
||||
"Authorization": "Bearer " + token,
|
||||
},
|
||||
body: JSON.stringify({
|
||||
email: email,
|
||||
firstName: firstName,
|
||||
lastName: lastName,
|
||||
publicKey: publicKey,
|
||||
encryptedPrivateKey: ciphertext,
|
||||
iv: iv,
|
||||
tag: tag,
|
||||
salt: salt,
|
||||
verifier: verifier
|
||||
}),
|
||||
});
|
||||
};
|
||||
|
||||
export default completeAccountInformationSignupInvite;
|
||||
@@ -0,0 +1,32 @@
|
||||
import SecurityClient from "../../../components/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 => {
|
||||
if (res.status == 200) {
|
||||
return res;
|
||||
} else {
|
||||
return res;
|
||||
console.log("Failed to issue the backup key");
|
||||
}
|
||||
})
|
||||
};
|
||||
|
||||
export default issueBackupPrivateKey;
|
||||
@@ -0,0 +1,22 @@
|
||||
import { PATH } from "../../../const.js";
|
||||
|
||||
/**
|
||||
* This is the first step of the login process (pake)
|
||||
* @param {*} email
|
||||
* @param {*} clientPublicKey
|
||||
* @returns
|
||||
*/
|
||||
const login1 = (email, clientPublicKey) => {
|
||||
return fetch(PATH + "/api/v1/auth/login1", {
|
||||
method: "POST",
|
||||
headers: {
|
||||
"Content-Type": "application/json",
|
||||
},
|
||||
body: JSON.stringify({
|
||||
email: email,
|
||||
clientPublicKey,
|
||||
}),
|
||||
});
|
||||
};
|
||||
|
||||
export default login1;
|
||||
@@ -0,0 +1,31 @@
|
||||
import { PATH } from "../../../const";
|
||||
|
||||
/**
|
||||
* This is the second step of the login process
|
||||
* @param {*} email
|
||||
* @param {*} clientPublicKey
|
||||
* @returns
|
||||
*/
|
||||
const login2 = (email, clientProof) => {
|
||||
return fetch(PATH + "/api/v1/auth/login2", {
|
||||
method: "POST",
|
||||
headers: {
|
||||
"Content-Type": "application/json",
|
||||
},
|
||||
body: JSON.stringify({
|
||||
email: email,
|
||||
clientProof,
|
||||
}),
|
||||
credentials: "include"
|
||||
})
|
||||
.then(res => {
|
||||
if (res.status == 200) {
|
||||
console.log("User logged in", res);
|
||||
return res;
|
||||
} else {
|
||||
console.log("Failed to log in");
|
||||
}
|
||||
})
|
||||
};
|
||||
|
||||
export default login2;
|
||||
@@ -0,0 +1,36 @@
|
||||
import SecurityClient from "../../../components/utilities/SecurityClient";
|
||||
import { PATH } from "../../../const";
|
||||
|
||||
/**
|
||||
* This route logs the user out. Note: the user should authorized to do this.
|
||||
* We first try to log out - if the authorization fails (response.status = 401), we refetch the new token, and then retry
|
||||
* @param {*} req
|
||||
* @param {*} res
|
||||
* @returns
|
||||
*/
|
||||
const logout = async (req, res) => {
|
||||
return SecurityClient.fetchCall(PATH + "/api/v1/auth/logout", {
|
||||
method: "POST",
|
||||
headers: {
|
||||
"Content-Type": "application/json",
|
||||
},
|
||||
credentials: "include"
|
||||
})
|
||||
.then(res => {
|
||||
if (res.status == 200) {
|
||||
SecurityClient.setToken("");
|
||||
// Delete the cookie by not setting a value; Alternatively clear the local storage
|
||||
localStorage.setItem("publicKey", "");
|
||||
localStorage.setItem("encryptedPrivateKey", "");
|
||||
localStorage.setItem("iv", "");
|
||||
localStorage.setItem("tag", "");
|
||||
localStorage.setItem("PRIVATE_KEY", "");
|
||||
console.log("User logged out", res);
|
||||
return res;
|
||||
} else {
|
||||
console.log("Failed to log out");
|
||||
}
|
||||
})
|
||||
};
|
||||
|
||||
export default logout;
|
||||
@@ -0,0 +1,28 @@
|
||||
import SecurityClient from "../../../components/utilities/SecurityClient";
|
||||
import { PATH } from "../../../const";
|
||||
|
||||
/**
|
||||
* This is the first step of the change password process (pake)
|
||||
* @param {*} clientPublicKey
|
||||
* @returns
|
||||
*/
|
||||
const SRP1 = ({clientPublicKey}) => {
|
||||
return SecurityClient.fetchCall(PATH + "/api/v1/password/srp1", {
|
||||
method: "POST",
|
||||
headers: {
|
||||
"Content-Type": "application/json",
|
||||
},
|
||||
body: JSON.stringify({
|
||||
clientPublicKey,
|
||||
}),
|
||||
})
|
||||
.then(async res => {
|
||||
if (res.status == 200) {
|
||||
return (await res.json());
|
||||
} else {
|
||||
console.log('Failed to do the first step of SRP');
|
||||
}
|
||||
})
|
||||
};
|
||||
|
||||
export default SRP1;
|
||||
@@ -0,0 +1,19 @@
|
||||
import { PATH } from "../../../const.js";
|
||||
|
||||
/**
|
||||
* This route send the verification email to the user's email (contains a 6-digit verification code)
|
||||
* @param {*} email
|
||||
*/
|
||||
const sendVerificationEmail = (email) => {
|
||||
fetch(PATH + "/api/v1/signup/email/signup", {
|
||||
method: "POST",
|
||||
headers: {
|
||||
"Content-Type": "application/json",
|
||||
},
|
||||
body: JSON.stringify({
|
||||
email: email,
|
||||
}),
|
||||
});
|
||||
};
|
||||
|
||||
export default sendVerificationEmail;
|
||||
@@ -0,0 +1,20 @@
|
||||
import { PATH } from "../../../const.js";
|
||||
|
||||
const token = async (req, res) => {
|
||||
return fetch(PATH + "/api/v1/auth/token", {
|
||||
method: "POST",
|
||||
headers: {
|
||||
"Content-Type": "application/json",
|
||||
},
|
||||
credentials: "include"
|
||||
})
|
||||
.then(async res => {
|
||||
if (res.status == 200) {
|
||||
return (await res.json()).token;
|
||||
} else {
|
||||
console.log('Getting a new token failed');
|
||||
}
|
||||
})
|
||||
};
|
||||
|
||||
export default token;
|
||||
@@ -0,0 +1,22 @@
|
||||
import { PATH } from "../../../const";
|
||||
|
||||
/**
|
||||
* This route verifies the signup invite link
|
||||
* @param {*} email
|
||||
* @param {*} code
|
||||
* @returns
|
||||
*/
|
||||
const verifySignupInvite = ({email, code}) => {
|
||||
return fetch(PATH + "/api/v1/invite-org/verify", {
|
||||
method: "POST",
|
||||
headers: {
|
||||
"Content-Type": "application/json",
|
||||
},
|
||||
body: JSON.stringify({
|
||||
email,
|
||||
code,
|
||||
}),
|
||||
});
|
||||
};
|
||||
|
||||
export default verifySignupInvite;
|
||||
@@ -0,0 +1,18 @@
|
||||
import { PATH } from "../../../const.js";
|
||||
|
||||
/**
|
||||
* 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.
|
||||
* @param {*} req
|
||||
* @param {*} res
|
||||
* @returns
|
||||
*/
|
||||
const publicKeyInfisical = (req, res) => {
|
||||
return fetch(PATH + "/api/v1/key/publicKey/infisical", {
|
||||
method: "GET",
|
||||
headers: {
|
||||
"Content-Type": "application/json",
|
||||
},
|
||||
});
|
||||
};
|
||||
|
||||
export default publicKeyInfisical;
|
||||
@@ -0,0 +1,33 @@
|
||||
import SecurityClient from "../../../components/utilities/SecurityClient.js";
|
||||
import { PATH } from "../../../const.js";
|
||||
|
||||
/**
|
||||
* This function fetches the encrypted secrets from the .env file
|
||||
* @param {*} workspaceId
|
||||
* @param {*} env
|
||||
* @returns
|
||||
*/
|
||||
const getSecrets = async (workspaceId, env) => {
|
||||
return SecurityClient.fetchCall(PATH + "/api/v1/secret/" +
|
||||
workspaceId +
|
||||
"?" +
|
||||
new URLSearchParams({
|
||||
environment: env,
|
||||
channel: "web",
|
||||
}
|
||||
), {
|
||||
method: "GET",
|
||||
headers: {
|
||||
"Content-Type": "application/json",
|
||||
},
|
||||
})
|
||||
.then(async res => {
|
||||
if (res.status == 200) {
|
||||
return (await res.json());
|
||||
} else {
|
||||
console.log('Failed to get project secrets');
|
||||
}
|
||||
})
|
||||
};
|
||||
|
||||
export default getSecrets;
|
||||
@@ -0,0 +1,32 @@
|
||||
import SecurityClient from "../../../components/utilities/SecurityClient";
|
||||
import { PATH } from "../../../const";
|
||||
|
||||
/**
|
||||
* This function uploads the encrypted .env file
|
||||
* @param {*} req
|
||||
* @param {*} res
|
||||
* @returns
|
||||
*/
|
||||
const uploadSecrets = async ({ workspaceId, secrets, keys, environment }) => {
|
||||
return SecurityClient.fetchCall(PATH + "/api/v1/secret/" + workspaceId, {
|
||||
method: "POST",
|
||||
headers: {
|
||||
"Content-Type": "application/json",
|
||||
},
|
||||
body: JSON.stringify({
|
||||
secrets,
|
||||
keys,
|
||||
environment,
|
||||
channel: "web",
|
||||
}),
|
||||
})
|
||||
.then(async res => {
|
||||
if (res.status == 200) {
|
||||
return res;
|
||||
} else {
|
||||
console.log('Failed to push secrets');
|
||||
}
|
||||
})
|
||||
};
|
||||
|
||||
export default uploadSecrets;
|
||||
@@ -0,0 +1,24 @@
|
||||
import SecurityClient from "../../../components/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 => {
|
||||
if (res.status == 200) {
|
||||
return res;
|
||||
} else {
|
||||
console.log('Failed to sync secrets to Heroku');
|
||||
}
|
||||
})
|
||||
};
|
||||
|
||||
export default changeHerokuConfigVars;
|
||||
@@ -0,0 +1,25 @@
|
||||
import SecurityClient from "../../../components/utilities/SecurityClient";
|
||||
import { PATH } from "../../../const";
|
||||
|
||||
/**
|
||||
* This route deletes an integration from a certain project
|
||||
* @param {*} integrationId
|
||||
* @returns
|
||||
*/
|
||||
const deleteIntegration = ({ integrationId }) => {
|
||||
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');
|
||||
}
|
||||
})
|
||||
};
|
||||
|
||||
export default deleteIntegration;
|
||||
@@ -0,0 +1,25 @@
|
||||
import SecurityClient from "../../../components/utilities/SecurityClient";
|
||||
import { PATH } from "../../../const";
|
||||
|
||||
/**
|
||||
* This route deletes an integration authorization from a certain project
|
||||
* @param {*} integrationAuthId
|
||||
* @returns
|
||||
*/
|
||||
const deleteIntegrationAuth = ({ integrationAuthId }) => {
|
||||
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');
|
||||
}
|
||||
})
|
||||
};
|
||||
|
||||
export default deleteIntegrationAuth;
|
||||
@@ -0,0 +1,20 @@
|
||||
import SecurityClient from "../../../components/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 => {
|
||||
if (res.status == 200) {
|
||||
return (await res.json()).apps;
|
||||
} else {
|
||||
console.log('Failed to get available apps for an integration');
|
||||
}
|
||||
})
|
||||
};
|
||||
|
||||
export default getIntegrationApps;
|
||||
@@ -0,0 +1,20 @@
|
||||
import SecurityClient from "../../../components/utilities/SecurityClient";
|
||||
import { PATH } from "../../../const";
|
||||
|
||||
const getIntegrations = () => {
|
||||
return SecurityClient.fetchCall(PATH + "/api/v1/integration/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 project integrations');
|
||||
}
|
||||
})
|
||||
};
|
||||
|
||||
export default getIntegrations;
|
||||
@@ -0,0 +1,32 @@
|
||||
import SecurityClient from "../../../components/utilities/SecurityClient";
|
||||
import { PATH } from "../../../const";
|
||||
|
||||
/**
|
||||
* 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 => {
|
||||
if (res.status == 200) {
|
||||
return res;
|
||||
} else {
|
||||
console.log('Failed to start an integration');
|
||||
}
|
||||
})
|
||||
};
|
||||
|
||||
export default startIntegration;
|
||||
@@ -0,0 +1,30 @@
|
||||
import SecurityClient from "../../../components/utilities/SecurityClient";
|
||||
import { PATH } from "../../../const";
|
||||
|
||||
/**
|
||||
* This is the first step of the change password process (pake)
|
||||
* @param {*} clientPublicKey
|
||||
* @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 => {
|
||||
if (res.status == 200) {
|
||||
return res;
|
||||
} else {
|
||||
console.log('Failed to authorize the integration');
|
||||
}
|
||||
})
|
||||
};
|
||||
|
||||
export default AuthorizeIntegration;
|
||||
@@ -0,0 +1,25 @@
|
||||
import SecurityClient from "../../../components/utilities/SecurityClient";
|
||||
import { PATH } from "../../../const";
|
||||
|
||||
/**
|
||||
* This route gets authorizations of a certain project (Heroku, etc.)
|
||||
* @param {*} workspaceId
|
||||
* @returns
|
||||
*/
|
||||
const getWorkspaceAuthorizations = ({ workspaceId }) => {
|
||||
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');
|
||||
}
|
||||
})
|
||||
};
|
||||
|
||||
export default getWorkspaceAuthorizations;
|
||||
@@ -0,0 +1,25 @@
|
||||
import SecurityClient from "../../../components/utilities/SecurityClient";
|
||||
import { PATH } from "../../../const";
|
||||
|
||||
/**
|
||||
* This route gets integrations of a certain project (Heroku, etc.)
|
||||
* @param {*} workspaceId
|
||||
* @returns
|
||||
*/
|
||||
const getWorkspaceIntegrations = ({ workspaceId }) => {
|
||||
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');
|
||||
}
|
||||
})
|
||||
};
|
||||
|
||||
export default getWorkspaceIntegrations;
|
||||
@@ -0,0 +1,26 @@
|
||||
import SecurityClient from "../../../components/utilities/SecurityClient";
|
||||
import { PATH } from "../../../const";
|
||||
|
||||
/**
|
||||
* This route lets us get info about a certain org
|
||||
* @param {*} req
|
||||
* @param {*} res
|
||||
* @returns
|
||||
*/
|
||||
const getOrganization = (req, 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');
|
||||
}
|
||||
})
|
||||
};
|
||||
|
||||
export default getOrganization;
|
||||
@@ -0,0 +1,26 @@
|
||||
import SecurityClient from "../../../components/utilities/SecurityClient";
|
||||
import { PATH } from "../../../const";
|
||||
|
||||
/**
|
||||
* This route lets us get all the users in an org.
|
||||
* @param {*} req
|
||||
* @param {*} res
|
||||
* @returns
|
||||
*/
|
||||
const getOrganizationProjects = (req, 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');
|
||||
}
|
||||
})
|
||||
};
|
||||
|
||||
export default getOrganizationProjects;
|
||||
@@ -0,0 +1,26 @@
|
||||
import SecurityClient from "../../../components/utilities/SecurityClient";
|
||||
import { PATH } from "../../../const";
|
||||
|
||||
/**
|
||||
* This route lets us get the current subscription of an org.
|
||||
* @param {*} req
|
||||
* @param {*} res
|
||||
* @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 => {
|
||||
if (res.status == 200) {
|
||||
return (await res.json()).subscriptions;
|
||||
} else {
|
||||
console.log('Failed to get org subscriptions');
|
||||
}
|
||||
})
|
||||
};
|
||||
|
||||
export default getOrganizationSubscriptions;
|
||||
@@ -0,0 +1,26 @@
|
||||
import SecurityClient from "../../../components/utilities/SecurityClient";
|
||||
import { PATH } from "../../../const";
|
||||
|
||||
/**
|
||||
* This route lets us get all the projects of a certain user in an org.
|
||||
* @param {*} req
|
||||
* @param {*} res
|
||||
* @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 => {
|
||||
if (res.status == 200) {
|
||||
return (await res.json()).workspaces;
|
||||
} else {
|
||||
console.log('Failed to get projects of a user in an org');
|
||||
}
|
||||
})
|
||||
};
|
||||
|
||||
export default getOrganizationUserProjects;
|
||||
@@ -0,0 +1,26 @@
|
||||
import SecurityClient from "../../../components/utilities/SecurityClient";
|
||||
import { PATH } from "../../../const";
|
||||
|
||||
/**
|
||||
* This route lets us get all the users in an org.
|
||||
* @param {*} req
|
||||
* @param {*} res
|
||||
* @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 => {
|
||||
if (res.status == 200) {
|
||||
return (await res.json()).users;
|
||||
} else {
|
||||
console.log('Failed to get org users');
|
||||
}
|
||||
})
|
||||
};
|
||||
|
||||
export default getOrganizationUsers;
|
||||
@@ -0,0 +1,26 @@
|
||||
import SecurityClient from "../../../components/utilities/SecurityClient";
|
||||
import { PATH } from "../../../const";
|
||||
|
||||
/**
|
||||
* This route redirects the user to the right stripe billing page.
|
||||
* @param {*} req
|
||||
* @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');
|
||||
}
|
||||
})
|
||||
};
|
||||
|
||||
export default StripeRedirect;
|
||||
@@ -0,0 +1,28 @@
|
||||
import SecurityClient from "../../../components/utilities/SecurityClient";
|
||||
import { PATH } from "../../../const";
|
||||
|
||||
/**
|
||||
* This route add an incident contact email to a certain organization
|
||||
* @param {*} param0
|
||||
* @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 => {
|
||||
if (res.status == 200) {
|
||||
return res;
|
||||
} else {
|
||||
console.log('Failed to add an incident contact');
|
||||
}
|
||||
})
|
||||
};
|
||||
|
||||
export default addIncidentContact;
|
||||
@@ -0,0 +1,30 @@
|
||||
import SecurityClient from "../../../components/utilities/SecurityClient";
|
||||
import { PATH } from "../../../const";
|
||||
|
||||
/**
|
||||
* This function sends an email invite to a user to join an org
|
||||
* @param {*} email
|
||||
* @param {*} orgId
|
||||
* @returns
|
||||
*/
|
||||
const addUserToOrg = (email, orgId) => {
|
||||
return SecurityClient.fetchCall(PATH + "/api/v1/invite-org/signup", {
|
||||
method: "POST",
|
||||
headers: {
|
||||
"Content-Type": "application/json",
|
||||
},
|
||||
body: JSON.stringify({
|
||||
inviteeEmail: email,
|
||||
organizationId: orgId,
|
||||
}),
|
||||
})
|
||||
.then(async res => {
|
||||
if (res.status == 200) {
|
||||
return res;
|
||||
} else {
|
||||
console.log('Failed to add a user to an org');
|
||||
}
|
||||
})
|
||||
};
|
||||
|
||||
export default addUserToOrg;
|
||||
@@ -0,0 +1,28 @@
|
||||
import SecurityClient from "../../../components/utilities/SecurityClient";
|
||||
import { PATH } from "../../../const";
|
||||
|
||||
/**
|
||||
* This route deletes an incident Contact from a certain organization
|
||||
* @param {*} param0
|
||||
* @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 => {
|
||||
if (res.status == 200) {
|
||||
return res;
|
||||
} else {
|
||||
console.log('Failed to delete an incident contact');
|
||||
}
|
||||
})
|
||||
};
|
||||
|
||||
export default deleteIncidentContact;
|
||||
@@ -0,0 +1,25 @@
|
||||
import SecurityClient from "../../../components/utilities/SecurityClient";
|
||||
import { PATH } from "../../../const";
|
||||
|
||||
/**
|
||||
* This function removes a certain member from a certain organization
|
||||
* @param {*} membershipId
|
||||
* @returns
|
||||
*/
|
||||
const deleteUserFromOrganization = (membershipId) => {
|
||||
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');
|
||||
}
|
||||
})
|
||||
};
|
||||
|
||||
export default deleteUserFromOrganization;
|
||||
@@ -0,0 +1,25 @@
|
||||
import SecurityClient from "../../../components/utilities/SecurityClient";
|
||||
import { PATH } from "../../../const";
|
||||
|
||||
/**
|
||||
* This routes gets all the incident contacts of a certain organization
|
||||
* @param {*} workspaceId
|
||||
* @returns
|
||||
*/
|
||||
const getIncidentContacts = (organizationId) => {
|
||||
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');
|
||||
}
|
||||
})
|
||||
};
|
||||
|
||||
export default getIncidentContacts;
|
||||
@@ -0,0 +1,26 @@
|
||||
import SecurityClient from "../../../components/utilities/SecurityClient";
|
||||
import { PATH } from "../../../const";
|
||||
|
||||
/**
|
||||
* This route lets us get the all the orgs of a certain user.
|
||||
* @param {*} req
|
||||
* @param {*} res
|
||||
* @returns
|
||||
*/
|
||||
const getOrganizations = (req, res) => {
|
||||
return SecurityClient.fetchCall(PATH + "/api/v1/organization", {
|
||||
method: "GET",
|
||||
headers: {
|
||||
"Content-Type": "application/json",
|
||||
},
|
||||
})
|
||||
.then(async res => {
|
||||
if (res.status == 200) {
|
||||
return (await res.json()).organizations;
|
||||
} else {
|
||||
console.log('Failed to get orgs of a user');
|
||||
}
|
||||
})
|
||||
};
|
||||
|
||||
export default getOrganizations;
|
||||
@@ -0,0 +1,29 @@
|
||||
import SecurityClient from "../../../components/utilities/SecurityClient";
|
||||
import { PATH } from "../../../const";
|
||||
|
||||
/**
|
||||
* This route lets us rename a certain org.
|
||||
* @param {*} req
|
||||
* @param {*} res
|
||||
* @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 => {
|
||||
if (res.status == 200) {
|
||||
return res;
|
||||
} else {
|
||||
console.log('Failed to rename an organization');
|
||||
}
|
||||
})
|
||||
};
|
||||
|
||||
export default renameOrg;
|
||||
@@ -0,0 +1,34 @@
|
||||
import SecurityClient from "../../../components/utilities/SecurityClient";
|
||||
import { PATH } from "../../../const";
|
||||
|
||||
/**
|
||||
* This route gets service tokens for a specific user in a project
|
||||
* @param {*} param0
|
||||
* @returns
|
||||
*/
|
||||
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,
|
||||
environment,
|
||||
expiresIn,
|
||||
publicKey,
|
||||
encryptedKey,
|
||||
nonce
|
||||
})
|
||||
})
|
||||
.then(async res => {
|
||||
if (res.status == 200) {
|
||||
return (await res.json()).token;
|
||||
} else {
|
||||
console.log('Failed to add service tokens');
|
||||
}
|
||||
})
|
||||
};
|
||||
|
||||
export default addServiceToken;
|
||||
@@ -0,0 +1,25 @@
|
||||
import SecurityClient from "../../../components/utilities/SecurityClient";
|
||||
import { PATH } from "../../../const";
|
||||
|
||||
/**
|
||||
* This route gets service tokens for a specific user in a project
|
||||
* @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 => {
|
||||
if (res.status == 200) {
|
||||
return (await res.json()).serviceTokens;
|
||||
} else {
|
||||
console.log('Failed to get service tokens');
|
||||
}
|
||||
})
|
||||
};
|
||||
|
||||
export default getServiceTokens;
|
||||
@@ -0,0 +1,26 @@
|
||||
import SecurityClient from "../../../components/utilities/SecurityClient";
|
||||
import { PATH } from "../../../const";
|
||||
|
||||
/**
|
||||
* This route gets the information about a specific user.
|
||||
* @param {*} req
|
||||
* @param {*} res
|
||||
* @returns
|
||||
*/
|
||||
const getUser = (req, res) => {
|
||||
return SecurityClient.fetchCall(PATH + "/api/v1/user", {
|
||||
method: "GET",
|
||||
headers: {
|
||||
"Content-Type": "application/json",
|
||||
},
|
||||
})
|
||||
.then(async res => {
|
||||
if (res.status == 200) {
|
||||
return (await res.json()).user;
|
||||
} else {
|
||||
console.log('Failed to get user info');
|
||||
}
|
||||
})
|
||||
};
|
||||
|
||||
export default getUser;
|
||||
@@ -0,0 +1,30 @@
|
||||
import SecurityClient from "../../../components/utilities/SecurityClient";
|
||||
import { PATH } from "../../../const";
|
||||
|
||||
/**
|
||||
* This route registers a certain action for a user
|
||||
* @param {*} email
|
||||
* @param {*} workspaceId
|
||||
* @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 => {
|
||||
if (res.status == 200) {
|
||||
return (await res.json()).userAction;
|
||||
} else {
|
||||
console.log('Failed to check a user action');
|
||||
}
|
||||
})
|
||||
};
|
||||
|
||||
export default checkUserAction;
|
||||
@@ -0,0 +1,28 @@
|
||||
import SecurityClient from "../../../components/utilities/SecurityClient";
|
||||
import { PATH } from "../../../const";
|
||||
|
||||
/**
|
||||
* This route registers a certain action for a user
|
||||
* @param {*} action
|
||||
* @returns
|
||||
*/
|
||||
const registerUserAction = ({ action }) => {
|
||||
return SecurityClient.fetchCall(PATH + "/api/v1/user-action", {
|
||||
method: "POST",
|
||||
headers: {
|
||||
"Content-Type": "application/json",
|
||||
},
|
||||
body: JSON.stringify({
|
||||
action,
|
||||
}),
|
||||
})
|
||||
.then(async res => {
|
||||
if (res.status == 200) {
|
||||
return res;
|
||||
} else {
|
||||
console.log('Failed to register a user action');
|
||||
}
|
||||
})
|
||||
};
|
||||
|
||||
export default registerUserAction;
|
||||
@@ -0,0 +1,29 @@
|
||||
import SecurityClient from "../../../components/utilities/SecurityClient";
|
||||
import { PATH } from "../../../const";
|
||||
|
||||
/**
|
||||
* This function adds a user to a project
|
||||
* @param {*} email
|
||||
* @param {*} workspaceId
|
||||
* @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');
|
||||
}
|
||||
})
|
||||
};
|
||||
|
||||
export default addUserToWorkspace;
|
||||
@@ -0,0 +1,29 @@
|
||||
import SecurityClient from "../../../components/utilities/SecurityClient";
|
||||
import { PATH } from "../../../const";
|
||||
|
||||
/**
|
||||
* This function change the access of a user in a certain workspace
|
||||
* @param {*} membershipId
|
||||
* @param {*} role
|
||||
* @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 => {
|
||||
if (res.status == 200) {
|
||||
return res;
|
||||
} else {
|
||||
console.log('Failed to change the user role in a project');
|
||||
}
|
||||
})
|
||||
};
|
||||
|
||||
export default changeUserRoleInWorkspace;
|
||||
@@ -0,0 +1,29 @@
|
||||
import SecurityClient from "../../../components/utilities/SecurityClient";
|
||||
import { PATH } from "../../../const";
|
||||
|
||||
/**
|
||||
* This route creates a new workspace for a user.
|
||||
* @param {*} workspaceName
|
||||
* @returns
|
||||
*/
|
||||
const createWorkspace = (workspaceName, organizationId) => {
|
||||
return SecurityClient.fetchCall(PATH + "/api/v1/workspace", {
|
||||
method: "POST",
|
||||
headers: {
|
||||
"Content-Type": "application/json",
|
||||
},
|
||||
body: JSON.stringify({
|
||||
workspaceName: workspaceName,
|
||||
organizationId: organizationId,
|
||||
}),
|
||||
})
|
||||
.then(async res => {
|
||||
if (res.status == 200) {
|
||||
return (await res.json()).workspace;
|
||||
} else {
|
||||
console.log('Failed to create a project');
|
||||
}
|
||||
})
|
||||
};
|
||||
|
||||
export default createWorkspace;
|
||||
@@ -0,0 +1,25 @@
|
||||
import SecurityClient from "../../../components/utilities/SecurityClient";
|
||||
import { PATH } from "../../../const";
|
||||
|
||||
/**
|
||||
* This function removes a certain member from a certain workspace
|
||||
* @param {*} membershipId
|
||||
* @returns
|
||||
*/
|
||||
const deleteUserFromWorkspace = (membershipId) => {
|
||||
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');
|
||||
}
|
||||
})
|
||||
};
|
||||
|
||||
export default deleteUserFromWorkspace;
|
||||
@@ -0,0 +1,25 @@
|
||||
import SecurityClient from "../../../components/utilities/SecurityClient";
|
||||
import { PATH } from "../../../const";
|
||||
|
||||
/**
|
||||
* This route deletes a specified workspace.
|
||||
* @param {*} workspaceId
|
||||
* @returns
|
||||
*/
|
||||
const deleteWorkspace = (workspaceId) => {
|
||||
return SecurityClient.fetchCall(PATH + "/api/v1/workspace/" + workspaceId, {
|
||||
method: "DELETE",
|
||||
headers: {
|
||||
"Content-Type": "application/json",
|
||||
},
|
||||
})
|
||||
.then(async res => {
|
||||
if (res.status == 200) {
|
||||
return res;
|
||||
} else {
|
||||
console.log('Failed to delete a project');
|
||||
}
|
||||
})
|
||||
};
|
||||
|
||||
export default deleteWorkspace;
|
||||
@@ -0,0 +1,25 @@
|
||||
import SecurityClient from "../../../components/utilities/SecurityClient";
|
||||
import { PATH } from "../../../const";
|
||||
|
||||
/**
|
||||
* Get the latest key pairs from a certain workspace
|
||||
* @param {*} workspaceId
|
||||
* @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');
|
||||
}
|
||||
})
|
||||
};
|
||||
|
||||
export default getLatestFileKey;
|
||||
@@ -0,0 +1,26 @@
|
||||
import SecurityClient from "../../../components/utilities/SecurityClient";
|
||||
import { PATH } from "../../../const";
|
||||
|
||||
/**
|
||||
* This route lets us get the information of a certain project.
|
||||
* @param {*} req
|
||||
* @param {*} res
|
||||
* @returns
|
||||
*/
|
||||
const getWorkspaceInfo = (req, 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');
|
||||
}
|
||||
})
|
||||
};
|
||||
|
||||
export default getWorkspaceInfo;
|
||||
@@ -0,0 +1,26 @@
|
||||
import SecurityClient from "../../../components/utilities/SecurityClient";
|
||||
import { PATH } from "../../../const";
|
||||
|
||||
/**
|
||||
* This route lets us get the public keys of everyone in your workspace.
|
||||
* @param {*} req
|
||||
* @param {*} res
|
||||
* @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 => {
|
||||
if (res.status == 200) {
|
||||
return (await res.json()).publicKeys;
|
||||
} else {
|
||||
console.log('Failed to get the public keys of everyone in the workspace');
|
||||
}
|
||||
})
|
||||
};
|
||||
|
||||
export default getWorkspaceKeys;
|
||||
@@ -0,0 +1,26 @@
|
||||
import SecurityClient from "../../../components/utilities/SecurityClient";
|
||||
import { PATH } from "../../../const";
|
||||
|
||||
/**
|
||||
* This route lets us get all the users in the workspace.
|
||||
* @param {*} req
|
||||
* @param {*} res
|
||||
* @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 => {
|
||||
if (res.status == 200) {
|
||||
return (await res.json()).users;
|
||||
} else {
|
||||
console.log('Failed to get Project Users');
|
||||
}
|
||||
})
|
||||
};
|
||||
|
||||
export default getWorkspaceUsers;
|
||||
@@ -0,0 +1,26 @@
|
||||
import SecurityClient from "../../../components/utilities/SecurityClient";
|
||||
import { PATH } from "../../../const";
|
||||
|
||||
/**
|
||||
* This route lets us get the public keys of everyone in your workspace.
|
||||
* @param {*} req
|
||||
* @param {*} res
|
||||
* @returns
|
||||
*/
|
||||
const getWorkspaces = (req, res) => {
|
||||
return SecurityClient.fetchCall(PATH + "/api/v1/workspace", {
|
||||
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');
|
||||
}
|
||||
})
|
||||
};
|
||||
|
||||
export default getWorkspaces;
|
||||
@@ -0,0 +1,29 @@
|
||||
import SecurityClient from "../../../components/utilities/SecurityClient";
|
||||
import { PATH } from "../../../const";
|
||||
|
||||
/**
|
||||
* This route lets us rename a certain workspace.
|
||||
* @param {*} req
|
||||
* @param {*} res
|
||||
* @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 => {
|
||||
if (res.status == 200) {
|
||||
return res;
|
||||
} else {
|
||||
console.log('Failed to rename a project');
|
||||
}
|
||||
})
|
||||
};
|
||||
|
||||
export default renameWorkspace;
|
||||
@@ -0,0 +1,35 @@
|
||||
import SecurityClient from "../../../components/utilities/SecurityClient";
|
||||
import { PATH } from "../../../const";
|
||||
|
||||
/**
|
||||
* This route uplods the keys in an encrypted format.
|
||||
* @param {*} workspaceId
|
||||
* @param {*} userId
|
||||
* @param {*} encryptedKey
|
||||
* @param {*} nonce
|
||||
* @returns
|
||||
*/
|
||||
const uploadKeys = (workspaceId, userId, encryptedKey, nonce) => {
|
||||
return SecurityClient.fetchCall(PATH + "/api/v1/key/" + workspaceId, {
|
||||
method: "POST",
|
||||
headers: {
|
||||
"Content-Type": "application/json",
|
||||
},
|
||||
body: JSON.stringify({
|
||||
key: {
|
||||
userId: userId,
|
||||
encryptedKey: encryptedKey,
|
||||
nonce: nonce,
|
||||
},
|
||||
}),
|
||||
})
|
||||
.then(async res => {
|
||||
if (res.status == 200) {
|
||||
return res;
|
||||
} else {
|
||||
console.log('Failed to upload keys for a new user');
|
||||
}
|
||||
})
|
||||
};
|
||||
|
||||
export default uploadKeys;
|
||||
Reference in New Issue
Block a user