mirror of
https://github.com/Infisical/infisical.git
synced 2026-01-10 07:58:15 -05:00
ref(frontend): add ~/const path
This commit is contained in:
@@ -1,85 +1,85 @@
|
||||
import { useEffect,useState } from "react";
|
||||
import { useEffect, useState } from "react";
|
||||
import Image from "next/image";
|
||||
import { useRouter } from "next/router";
|
||||
|
||||
import checkAuth from "~/pages/api/auth/CheckAuth";
|
||||
|
||||
import { publicPaths } from "../const";
|
||||
import { publicPaths } from "~/const";
|
||||
|
||||
// #TODO: finish spinner only when the data loads fully
|
||||
// #TODO: Redirect somewhere if the page does not exist
|
||||
|
||||
export default function RouteGuard({ children }) {
|
||||
const router = useRouter();
|
||||
const [authorized, setAuthorized] = useState(false);
|
||||
const router = useRouter();
|
||||
const [authorized, setAuthorized] = useState(false);
|
||||
|
||||
useEffect(() => {
|
||||
// on initial load - run auth check
|
||||
(async () => {
|
||||
await authCheck(router.asPath);
|
||||
})();
|
||||
useEffect(() => {
|
||||
// on initial load - run auth check
|
||||
(async () => {
|
||||
await authCheck(router.asPath);
|
||||
})();
|
||||
|
||||
// on route change start - hide page content by setting authorized to false
|
||||
// #TODO: add the loading page when not yet authorized.
|
||||
const hideContent = () => setAuthorized(false);
|
||||
// const onError = () => setAuthorized(true)
|
||||
router.events.on("routeChangeStart", hideContent);
|
||||
// router.events.on("routeChangeError", onError);
|
||||
// on route change start - hide page content by setting authorized to false
|
||||
// #TODO: add the loading page when not yet authorized.
|
||||
const hideContent = () => setAuthorized(false);
|
||||
// const onError = () => setAuthorized(true)
|
||||
router.events.on("routeChangeStart", hideContent);
|
||||
// router.events.on("routeChangeError", onError);
|
||||
|
||||
// on route change complete - run auth check
|
||||
router.events.on("routeChangeComplete", authCheck);
|
||||
// on route change complete - run auth check
|
||||
router.events.on("routeChangeComplete", authCheck);
|
||||
|
||||
// unsubscribe from events in useEffect return function
|
||||
return () => {
|
||||
router.events.off("routeChangeStart", hideContent);
|
||||
router.events.off("routeChangeComplete", authCheck);
|
||||
// router.events.off("routeChangeError", onError);
|
||||
};
|
||||
// eslint-disable-next-line react-hooks/exhaustive-deps
|
||||
}, []);
|
||||
// unsubscribe from events in useEffect return function
|
||||
return () => {
|
||||
router.events.off("routeChangeStart", hideContent);
|
||||
router.events.off("routeChangeComplete", authCheck);
|
||||
// router.events.off("routeChangeError", onError);
|
||||
};
|
||||
// eslint-disable-next-line react-hooks/exhaustive-deps
|
||||
}, []);
|
||||
|
||||
/**
|
||||
* redirect to login page if accessing a private page and not logged in
|
||||
* @param {*} url - the url of the page we are trying to go to
|
||||
*/
|
||||
async function authCheck(url) {
|
||||
// Make sure that we don't redirect when the user is on the following pages.
|
||||
const path = "/" + url.split("?")[0].split("/")[1];
|
||||
/**
|
||||
* redirect to login page if accessing a private page and not logged in
|
||||
* @param {*} url - the url of the page we are trying to go to
|
||||
*/
|
||||
async function authCheck(url) {
|
||||
// Make sure that we don't redirect when the user is on the following pages.
|
||||
const path = "/" + url.split("?")[0].split("/")[1];
|
||||
|
||||
// Check if the user is authenticated
|
||||
const response = await checkAuth();
|
||||
// #TODO: figure our why sometimes it doesn't output a response
|
||||
if (!publicPaths.includes(path)) {
|
||||
try {
|
||||
if (response.status !== 200) {
|
||||
router.push("/login");
|
||||
console.log("Unauthorized to access.");
|
||||
setAuthorized(false);
|
||||
} else {
|
||||
setAuthorized(true);
|
||||
console.log("Authorized to access.");
|
||||
}
|
||||
} catch (error) {
|
||||
console.log(
|
||||
"Error (probably the authCheck route is stuck again...):",
|
||||
error
|
||||
);
|
||||
}
|
||||
}
|
||||
}
|
||||
// Check if the user is authenticated
|
||||
const response = await checkAuth();
|
||||
// #TODO: figure our why sometimes it doesn't output a response
|
||||
if (!publicPaths.includes(path)) {
|
||||
try {
|
||||
if (response.status !== 200) {
|
||||
router.push("/login");
|
||||
console.log("Unauthorized to access.");
|
||||
setAuthorized(false);
|
||||
} else {
|
||||
setAuthorized(true);
|
||||
console.log("Authorized to access.");
|
||||
}
|
||||
} catch (error) {
|
||||
console.log(
|
||||
"Error (probably the authCheck route is stuck again...):",
|
||||
error
|
||||
);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
if (authorized) {
|
||||
return children;
|
||||
} else {
|
||||
return (
|
||||
<div className="w-screen h-screen bg-bunker-800 flex items-center justify-center">
|
||||
<Image
|
||||
src="/images/loading/loading.gif"
|
||||
height={70}
|
||||
width={120}
|
||||
alt="google logo"
|
||||
></Image>
|
||||
</div>
|
||||
);
|
||||
}
|
||||
if (authorized) {
|
||||
return children;
|
||||
} else {
|
||||
return (
|
||||
<div className="w-screen h-screen bg-bunker-800 flex items-center justify-center">
|
||||
<Image
|
||||
src="/images/loading/loading.gif"
|
||||
height={70}
|
||||
width={120}
|
||||
alt="google logo"
|
||||
></Image>
|
||||
</div>
|
||||
);
|
||||
}
|
||||
}
|
||||
|
||||
@@ -1,28 +1,28 @@
|
||||
import token from "~/pages/api/auth/Token";
|
||||
|
||||
import { PATH } from "../../const";
|
||||
import { PATH } from "~/const";
|
||||
|
||||
export default class SecurityClient {
|
||||
static authOrigins = [PATH];
|
||||
static #token = "";
|
||||
static authOrigins = [PATH];
|
||||
static #token = "";
|
||||
|
||||
contructor() {}
|
||||
contructor() {}
|
||||
|
||||
static setToken(token) {
|
||||
this.#token = token;
|
||||
}
|
||||
static setToken(token) {
|
||||
this.#token = token;
|
||||
}
|
||||
|
||||
static async fetchCall(resource, options) {
|
||||
let req = new Request(resource, options);
|
||||
const destOrigin = new URL(req.url).origin;
|
||||
static async fetchCall(resource, options) {
|
||||
let req = new Request(resource, options);
|
||||
const destOrigin = new URL(req.url).origin;
|
||||
|
||||
if (this.#token == "") {
|
||||
this.setToken(await token());
|
||||
}
|
||||
if (this.#token == "") {
|
||||
this.setToken(await token());
|
||||
}
|
||||
|
||||
if (this.#token && this.authOrigins.includes(destOrigin)) {
|
||||
req.headers.set("Authorization", "Bearer " + this.#token);
|
||||
return fetch(req);
|
||||
}
|
||||
}
|
||||
if (this.#token && this.authOrigins.includes(destOrigin)) {
|
||||
req.headers.set("Authorization", "Bearer " + this.#token);
|
||||
return fetch(req);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@@ -8,6 +8,9 @@
|
||||
"~/utilities/*": [
|
||||
"components/utilities/*"
|
||||
],
|
||||
"~/*": [
|
||||
"const"
|
||||
],
|
||||
"~/pages/*": [
|
||||
"pages/*"
|
||||
],
|
||||
|
||||
@@ -7,7 +7,7 @@ import Layout from "~/components/basic/layout";
|
||||
import RouteGuard from "~/components/RouteGuard";
|
||||
import { ENV } from "~/utilities/config";
|
||||
|
||||
import { publicPaths } from "../const.js";
|
||||
import { publicPaths } from "~/const";
|
||||
|
||||
import "@fortawesome/fontawesome-svg-core/styles.css";
|
||||
import "../styles/globals.css";
|
||||
@@ -15,49 +15,49 @@ import "../styles/globals.css";
|
||||
config.autoAddCss = false;
|
||||
|
||||
const App = ({ Component, pageProps, ...appProps }) => {
|
||||
const router = useRouter();
|
||||
const posthog = initPostHog();
|
||||
const router = useRouter();
|
||||
const posthog = initPostHog();
|
||||
|
||||
useEffect(() => {
|
||||
// Init for auto capturing
|
||||
const posthog = initPostHog();
|
||||
useEffect(() => {
|
||||
// Init for auto capturing
|
||||
const posthog = initPostHog();
|
||||
|
||||
const handleRouteChange = () => {
|
||||
if (typeof window !== "undefined") {
|
||||
if (ENV == "production") {
|
||||
posthog.capture("$pageview");
|
||||
}
|
||||
}
|
||||
};
|
||||
const handleRouteChange = () => {
|
||||
if (typeof window !== "undefined") {
|
||||
if (ENV == "production") {
|
||||
posthog.capture("$pageview");
|
||||
}
|
||||
}
|
||||
};
|
||||
|
||||
router.events.on("routeChangeComplete", handleRouteChange);
|
||||
router.events.on("routeChangeComplete", handleRouteChange);
|
||||
|
||||
return () => {
|
||||
router.events.off("routeChangeComplete", handleRouteChange);
|
||||
};
|
||||
}, [router.events]);
|
||||
return () => {
|
||||
router.events.off("routeChangeComplete", handleRouteChange);
|
||||
};
|
||||
}, [router.events]);
|
||||
|
||||
// If it's one of these routes, don't add the layout (e.g., these routes are external)
|
||||
if (
|
||||
publicPaths.includes("/" + appProps.router.pathname.split("/")[1]) ||
|
||||
!Component.requireAuth
|
||||
) {
|
||||
return <Component {...pageProps} />;
|
||||
}
|
||||
// If it's one of these routes, don't add the layout (e.g., these routes are external)
|
||||
if (
|
||||
publicPaths.includes("/" + appProps.router.pathname.split("/")[1]) ||
|
||||
!Component.requireAuth
|
||||
) {
|
||||
return <Component {...pageProps} />;
|
||||
}
|
||||
|
||||
return (
|
||||
<RouteGuard>
|
||||
<Layout>
|
||||
<Component {...pageProps} />
|
||||
</Layout>
|
||||
</RouteGuard>
|
||||
);
|
||||
return (
|
||||
<RouteGuard>
|
||||
<Layout>
|
||||
<Component {...pageProps} />
|
||||
</Layout>
|
||||
</RouteGuard>
|
||||
);
|
||||
};
|
||||
|
||||
export default App;
|
||||
|
||||
{
|
||||
/* <Script
|
||||
/* <Script
|
||||
src="https://www.googletagmanager.com/gtag/js?id=G-DQ1XLJJGG1"
|
||||
strategy="afterInteractive"
|
||||
/>
|
||||
|
||||
@@ -1,6 +1,6 @@
|
||||
import SecurityClient from "~/utilities/SecurityClient";
|
||||
|
||||
import { PATH } from "../../../const";
|
||||
import { PATH } from "~/const";
|
||||
|
||||
/**
|
||||
* This is the second step of the change password process (pake)
|
||||
@@ -8,33 +8,33 @@ import { PATH } from "../../../const";
|
||||
* @returns
|
||||
*/
|
||||
const changePassword2 = ({
|
||||
encryptedPrivateKey,
|
||||
iv,
|
||||
tag,
|
||||
salt,
|
||||
verifier,
|
||||
clientProof,
|
||||
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");
|
||||
}
|
||||
});
|
||||
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;
|
||||
|
||||
@@ -1,6 +1,6 @@
|
||||
import SecurityClient from "~/utilities/SecurityClient.js";
|
||||
|
||||
import { PATH } from "../../../const.js";
|
||||
import { PATH } from "~/const";
|
||||
|
||||
/**
|
||||
* This function is used to check if the user is authenticated.
|
||||
@@ -10,18 +10,18 @@ import { PATH } from "../../../const.js";
|
||||
* @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");
|
||||
}
|
||||
});
|
||||
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;
|
||||
|
||||
@@ -1,4 +1,4 @@
|
||||
import { PATH } from "../../../const.js";
|
||||
import { PATH } from "~/const";
|
||||
|
||||
/**
|
||||
* This route check the verification code from the email that user just recieved
|
||||
@@ -7,16 +7,16 @@ import { PATH } from "../../../const.js";
|
||||
* @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,
|
||||
}),
|
||||
});
|
||||
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;
|
||||
|
||||
@@ -1,4 +1,4 @@
|
||||
import { PATH } from "../../../const";
|
||||
import { PATH } from "~/const";
|
||||
|
||||
/**
|
||||
* This function is called in the end of the signup process.
|
||||
@@ -16,37 +16,37 @@ import { PATH } from "../../../const";
|
||||
* @returns
|
||||
*/
|
||||
const completeAccountInformationSignup = ({
|
||||
email,
|
||||
firstName,
|
||||
lastName,
|
||||
organizationName,
|
||||
publicKey,
|
||||
ciphertext,
|
||||
iv,
|
||||
tag,
|
||||
salt,
|
||||
verifier,
|
||||
token
|
||||
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,
|
||||
}),
|
||||
});
|
||||
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;
|
||||
|
||||
@@ -1,4 +1,4 @@
|
||||
import { PATH } from "../../../const";
|
||||
import { PATH } from "~/const";
|
||||
|
||||
/**
|
||||
* This function is called in the end of the signup process.
|
||||
@@ -15,35 +15,35 @@ import { PATH } from "../../../const";
|
||||
* @returns
|
||||
*/
|
||||
const completeAccountInformationSignupInvite = ({
|
||||
email,
|
||||
firstName,
|
||||
lastName,
|
||||
publicKey,
|
||||
ciphertext,
|
||||
iv,
|
||||
tag,
|
||||
salt,
|
||||
verifier,
|
||||
token
|
||||
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
|
||||
}),
|
||||
});
|
||||
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;
|
||||
|
||||
@@ -1,42 +1,42 @@
|
||||
import SecurityClient from "~/utilities/SecurityClient";
|
||||
|
||||
import { PATH } from "../../../const";
|
||||
import { PATH } from "~/const";
|
||||
|
||||
/**
|
||||
* This is the route that issues a backup private key that will afterwards be added into a pdf
|
||||
*/
|
||||
const issueBackupPrivateKey = ({
|
||||
encryptedPrivateKey,
|
||||
iv,
|
||||
tag,
|
||||
salt,
|
||||
verifier,
|
||||
clientProof,
|
||||
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");
|
||||
}
|
||||
});
|
||||
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;
|
||||
|
||||
@@ -1,4 +1,4 @@
|
||||
import { PATH } from "../../../const.js";
|
||||
import { PATH } from "~/const";
|
||||
|
||||
/**
|
||||
* This is the first step of the login process (pake)
|
||||
@@ -7,16 +7,16 @@ import { PATH } from "../../../const.js";
|
||||
* @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,
|
||||
}),
|
||||
});
|
||||
return fetch(PATH + "/api/v1/auth/login1", {
|
||||
method: "POST",
|
||||
headers: {
|
||||
"Content-Type": "application/json",
|
||||
},
|
||||
body: JSON.stringify({
|
||||
email: email,
|
||||
clientPublicKey,
|
||||
}),
|
||||
});
|
||||
};
|
||||
|
||||
export default login1;
|
||||
|
||||
@@ -1,4 +1,4 @@
|
||||
import { PATH } from "../../../const";
|
||||
import { PATH } from "~/const";
|
||||
|
||||
/**
|
||||
* This is the second step of the login process
|
||||
@@ -7,25 +7,24 @@ import { PATH } from "../../../const";
|
||||
* @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");
|
||||
}
|
||||
})
|
||||
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;
|
||||
|
||||
@@ -1,6 +1,6 @@
|
||||
import SecurityClient from "~/utilities/SecurityClient";
|
||||
|
||||
import { PATH } from "../../../const";
|
||||
import { PATH } from "~/const";
|
||||
|
||||
/**
|
||||
* This route logs the user out. Note: the user should authorized to do this.
|
||||
@@ -10,27 +10,27 @@ import { PATH } from "../../../const";
|
||||
* @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");
|
||||
}
|
||||
});
|
||||
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;
|
||||
|
||||
@@ -1,6 +1,6 @@
|
||||
import SecurityClient from "~/utilities/SecurityClient";
|
||||
|
||||
import { PATH } from "../../../const";
|
||||
import { PATH } from "~/const";
|
||||
|
||||
/**
|
||||
* This is the first step of the change password process (pake)
|
||||
@@ -8,21 +8,21 @@ import { PATH } from "../../../const";
|
||||
* @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");
|
||||
}
|
||||
});
|
||||
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;
|
||||
|
||||
@@ -1,19 +1,19 @@
|
||||
import { PATH } from "../../../const.js";
|
||||
import { PATH } from "~/const";
|
||||
|
||||
/**
|
||||
* This route send the verification email to the user's email (contains a 6-digit verification code)
|
||||
* @param {*} email
|
||||
*/
|
||||
const sendVerificationEmail = (email) => {
|
||||
fetch(PATH + "/api/v1/signup/email/signup", {
|
||||
method: "POST",
|
||||
headers: {
|
||||
"Content-Type": "application/json",
|
||||
},
|
||||
body: JSON.stringify({
|
||||
email: email,
|
||||
}),
|
||||
});
|
||||
fetch(PATH + "/api/v1/signup/email/signup", {
|
||||
method: "POST",
|
||||
headers: {
|
||||
"Content-Type": "application/json",
|
||||
},
|
||||
body: JSON.stringify({
|
||||
email: email,
|
||||
}),
|
||||
});
|
||||
};
|
||||
|
||||
export default sendVerificationEmail;
|
||||
|
||||
@@ -1,20 +1,19 @@
|
||||
import { PATH } from "../../../const.js";
|
||||
import { PATH } from "~/const";
|
||||
|
||||
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');
|
||||
}
|
||||
})
|
||||
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;
|
||||
|
||||
@@ -1,4 +1,4 @@
|
||||
import { PATH } from "../../../const";
|
||||
import { PATH } from "~/const";
|
||||
|
||||
/**
|
||||
* This route verifies the signup invite link
|
||||
@@ -6,17 +6,17 @@ import { PATH } from "../../../const";
|
||||
* @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,
|
||||
}),
|
||||
});
|
||||
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;
|
||||
|
||||
@@ -1,4 +1,4 @@
|
||||
import { PATH } from "../../../const.js";
|
||||
import { PATH } from "~/const";
|
||||
|
||||
/**
|
||||
* This route lets us get the public key of infisical. Th euser doesn't have to be authenticated since this is just the public key.
|
||||
@@ -7,12 +7,12 @@ import { PATH } from "../../../const.js";
|
||||
* @returns
|
||||
*/
|
||||
const publicKeyInfisical = (req, res) => {
|
||||
return fetch(PATH + "/api/v1/key/publicKey/infisical", {
|
||||
method: "GET",
|
||||
headers: {
|
||||
"Content-Type": "application/json",
|
||||
},
|
||||
});
|
||||
return fetch(PATH + "/api/v1/key/publicKey/infisical", {
|
||||
method: "GET",
|
||||
headers: {
|
||||
"Content-Type": "application/json",
|
||||
},
|
||||
});
|
||||
};
|
||||
|
||||
export default publicKeyInfisical;
|
||||
|
||||
@@ -1,6 +1,6 @@
|
||||
import SecurityClient from "~/utilities/SecurityClient.js";
|
||||
|
||||
import { PATH } from "../../../const.js";
|
||||
import { PATH } from "~/const";
|
||||
|
||||
/**
|
||||
* This function fetches the encrypted secrets from the .env file
|
||||
@@ -9,28 +9,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",
|
||||
}),
|
||||
{
|
||||
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");
|
||||
}
|
||||
});
|
||||
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;
|
||||
|
||||
@@ -1,6 +1,6 @@
|
||||
import SecurityClient from "~/utilities/SecurityClient";
|
||||
|
||||
import { PATH } from "../../../const";
|
||||
import { PATH } from "~/const";
|
||||
|
||||
/**
|
||||
* This function uploads the encrypted .env file
|
||||
@@ -9,24 +9,24 @@ import { PATH } from "../../../const";
|
||||
* @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");
|
||||
}
|
||||
});
|
||||
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;
|
||||
|
||||
@@ -1,27 +1,27 @@
|
||||
import SecurityClient from "~/utilities/SecurityClient";
|
||||
|
||||
import { PATH } from "../../../const";
|
||||
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");
|
||||
}
|
||||
});
|
||||
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;
|
||||
|
||||
@@ -1,6 +1,6 @@
|
||||
import SecurityClient from "~/utilities/SecurityClient";
|
||||
|
||||
import { PATH } from "../../../const";
|
||||
import { PATH } from "~/const";
|
||||
|
||||
/**
|
||||
* This route deletes an integration from a certain project
|
||||
@@ -8,21 +8,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) => {
|
||||
if (res.status == 200) {
|
||||
return (await res.json()).workspace;
|
||||
} else {
|
||||
console.log("Failed to delete an integration");
|
||||
}
|
||||
});
|
||||
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;
|
||||
|
||||
@@ -1,6 +1,6 @@
|
||||
import SecurityClient from "~/utilities/SecurityClient";
|
||||
|
||||
import { PATH } from "../../../const";
|
||||
import { PATH } from "~/const";
|
||||
|
||||
/**
|
||||
* This route deletes an integration authorization from a certain project
|
||||
@@ -8,21 +8,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) => {
|
||||
if (res.status == 200) {
|
||||
return res;
|
||||
} else {
|
||||
console.log("Failed to delete an integration authorization");
|
||||
}
|
||||
});
|
||||
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;
|
||||
|
||||
@@ -1,23 +1,23 @@
|
||||
import SecurityClient from "~/utilities/SecurityClient";
|
||||
|
||||
import { PATH } from "../../../const";
|
||||
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");
|
||||
}
|
||||
});
|
||||
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;
|
||||
|
||||
@@ -1,20 +1,20 @@
|
||||
import SecurityClient from "~/utilities/SecurityClient";
|
||||
|
||||
import { PATH } from "../../../const";
|
||||
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");
|
||||
}
|
||||
});
|
||||
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;
|
||||
|
||||
@@ -1,6 +1,6 @@
|
||||
import SecurityClient from "~/utilities/SecurityClient";
|
||||
|
||||
import { PATH } from "../../../const";
|
||||
import { PATH } from "~/const";
|
||||
|
||||
/**
|
||||
* This route starts the integration after teh default one if gonna set up.
|
||||
@@ -8,28 +8,28 @@ import { PATH } from "../../../const";
|
||||
* @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");
|
||||
}
|
||||
});
|
||||
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;
|
||||
|
||||
@@ -1,6 +1,6 @@
|
||||
import SecurityClient from "~/utilities/SecurityClient";
|
||||
|
||||
import { PATH } from "../../../const";
|
||||
import { PATH } from "~/const";
|
||||
|
||||
/**
|
||||
* This is the first step of the change password process (pake)
|
||||
@@ -8,26 +8,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) => {
|
||||
if (res.status == 200) {
|
||||
return res;
|
||||
} else {
|
||||
console.log("Failed to authorize the 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;
|
||||
|
||||
@@ -1,6 +1,6 @@
|
||||
import SecurityClient from "~/utilities/SecurityClient";
|
||||
|
||||
import { PATH } from "../../../const";
|
||||
import { PATH } from "~/const";
|
||||
|
||||
/**
|
||||
* This route gets authorizations of a certain project (Heroku, etc.)
|
||||
@@ -8,21 +8,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) => {
|
||||
if (res.status == 200) {
|
||||
return (await res.json()).authorizations;
|
||||
} else {
|
||||
console.log("Failed to get project authorizations");
|
||||
}
|
||||
});
|
||||
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;
|
||||
|
||||
@@ -1,6 +1,6 @@
|
||||
import SecurityClient from "~/utilities/SecurityClient";
|
||||
|
||||
import { PATH } from "../../../const";
|
||||
import { PATH } from "~/const";
|
||||
|
||||
/**
|
||||
* This route gets integrations of a certain project (Heroku, etc.)
|
||||
@@ -8,21 +8,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) => {
|
||||
if (res.status == 200) {
|
||||
return (await res.json()).integrations;
|
||||
} else {
|
||||
console.log("Failed to get the project integrations");
|
||||
}
|
||||
});
|
||||
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;
|
||||
|
||||
@@ -1,6 +1,6 @@
|
||||
import SecurityClient from "~/utilities/SecurityClient";
|
||||
|
||||
import { PATH } from "../../../const";
|
||||
import { PATH } from "~/const";
|
||||
|
||||
/**
|
||||
* This route lets us get info about a certain org
|
||||
@@ -9,21 +9,18 @@ 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) => {
|
||||
if (res.status == 200) {
|
||||
return (await res.json()).organization;
|
||||
} else {
|
||||
console.log("Failed to get org info");
|
||||
}
|
||||
});
|
||||
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;
|
||||
|
||||
@@ -1,6 +1,6 @@
|
||||
import SecurityClient from "~/utilities/SecurityClient";
|
||||
|
||||
import { PATH } from "../../../const";
|
||||
import { PATH } from "~/const";
|
||||
|
||||
/**
|
||||
* This route lets us get all the users in an org.
|
||||
@@ -9,21 +9,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) => {
|
||||
if (res.status == 200) {
|
||||
return (await res.json()).workspaces;
|
||||
} else {
|
||||
console.log("Failed to get projects for an org");
|
||||
}
|
||||
});
|
||||
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;
|
||||
|
||||
@@ -1,6 +1,6 @@
|
||||
import SecurityClient from "~/utilities/SecurityClient";
|
||||
|
||||
import { PATH } from "../../../const";
|
||||
import { PATH } from "~/const";
|
||||
|
||||
/**
|
||||
* This route lets us get the current subscription of an org.
|
||||
@@ -9,21 +9,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) => {
|
||||
if (res.status == 200) {
|
||||
return (await res.json()).subscriptions;
|
||||
} else {
|
||||
console.log("Failed to get org subscriptions");
|
||||
}
|
||||
});
|
||||
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;
|
||||
|
||||
@@ -1,6 +1,6 @@
|
||||
import SecurityClient from "~/utilities/SecurityClient";
|
||||
|
||||
import { PATH } from "../../../const";
|
||||
import { PATH } from "~/const";
|
||||
|
||||
/**
|
||||
* This route lets us get all the projects of a certain user in an org.
|
||||
@@ -9,21 +9,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) => {
|
||||
if (res.status == 200) {
|
||||
return (await res.json()).workspaces;
|
||||
} else {
|
||||
console.log("Failed to get projects of a user in an org");
|
||||
}
|
||||
});
|
||||
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;
|
||||
|
||||
@@ -1,6 +1,6 @@
|
||||
import SecurityClient from "~/utilities/SecurityClient";
|
||||
|
||||
import { PATH } from "../../../const";
|
||||
import { PATH } from "~/const";
|
||||
|
||||
/**
|
||||
* This route lets us get all the users in an org.
|
||||
@@ -9,21 +9,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) => {
|
||||
if (res.status == 200) {
|
||||
return (await res.json()).users;
|
||||
} else {
|
||||
console.log("Failed to get org users");
|
||||
}
|
||||
});
|
||||
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;
|
||||
|
||||
@@ -1,6 +1,6 @@
|
||||
import SecurityClient from "~/utilities/SecurityClient";
|
||||
|
||||
import { PATH } from "../../../const";
|
||||
import { PATH } from "~/const";
|
||||
|
||||
/**
|
||||
* This route redirects the user to the right stripe billing page.
|
||||
@@ -9,21 +9,21 @@ import { PATH } from "../../../const";
|
||||
* @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");
|
||||
}
|
||||
});
|
||||
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,6 +1,6 @@
|
||||
import SecurityClient from "~/utilities/SecurityClient";
|
||||
|
||||
import { PATH } from "../../../const";
|
||||
import { PATH } from "~/const";
|
||||
|
||||
/**
|
||||
* This route add an incident contact email to a certain organization
|
||||
@@ -8,24 +8,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) => {
|
||||
if (res.status == 200) {
|
||||
return res;
|
||||
} else {
|
||||
console.log("Failed to add an incident contact");
|
||||
}
|
||||
});
|
||||
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;
|
||||
|
||||
@@ -1,6 +1,6 @@
|
||||
import SecurityClient from "~/utilities/SecurityClient";
|
||||
|
||||
import { PATH } from "../../../const";
|
||||
import { PATH } from "~/const";
|
||||
|
||||
/**
|
||||
* This function sends an email invite to a user to join an org
|
||||
@@ -9,22 +9,22 @@ import { PATH } from "../../../const";
|
||||
* @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");
|
||||
}
|
||||
});
|
||||
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;
|
||||
|
||||
@@ -1,6 +1,6 @@
|
||||
import SecurityClient from "~/utilities/SecurityClient";
|
||||
|
||||
import { PATH } from "../../../const";
|
||||
import { PATH } from "~/const";
|
||||
|
||||
/**
|
||||
* This route deletes an incident Contact from a certain organization
|
||||
@@ -8,24 +8,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) => {
|
||||
if (res.status == 200) {
|
||||
return res;
|
||||
} else {
|
||||
console.log("Failed to delete an incident contact");
|
||||
}
|
||||
});
|
||||
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;
|
||||
|
||||
@@ -1,6 +1,6 @@
|
||||
import SecurityClient from "~/utilities/SecurityClient";
|
||||
|
||||
import { PATH } from "../../../const";
|
||||
import { PATH } from "~/const";
|
||||
|
||||
/**
|
||||
* This function removes a certain member from a certain organization
|
||||
@@ -8,21 +8,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) => {
|
||||
if (res.status == 200) {
|
||||
return res;
|
||||
} else {
|
||||
console.log("Failed to delete a user from an org");
|
||||
}
|
||||
});
|
||||
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;
|
||||
|
||||
@@ -1,6 +1,6 @@
|
||||
import SecurityClient from "~/utilities/SecurityClient";
|
||||
|
||||
import { PATH } from "../../../const";
|
||||
import { PATH } from "~/const";
|
||||
|
||||
/**
|
||||
* This routes gets all the incident contacts of a certain organization
|
||||
@@ -8,21 +8,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) => {
|
||||
if (res.status == 200) {
|
||||
return (await res.json()).incidentContactsOrg;
|
||||
} else {
|
||||
console.log("Failed to get incident contacts");
|
||||
}
|
||||
});
|
||||
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;
|
||||
|
||||
@@ -1,6 +1,6 @@
|
||||
import SecurityClient from "~/utilities/SecurityClient";
|
||||
|
||||
import { PATH } from "../../../const";
|
||||
import { PATH } from "~/const";
|
||||
|
||||
/**
|
||||
* This route lets us get the all the orgs of a certain user.
|
||||
@@ -9,18 +9,18 @@ import { PATH } from "../../../const";
|
||||
* @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");
|
||||
}
|
||||
});
|
||||
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;
|
||||
|
||||
@@ -1,6 +1,6 @@
|
||||
import SecurityClient from "~/utilities/SecurityClient";
|
||||
|
||||
import { PATH } from "../../../const";
|
||||
import { PATH } from "~/const";
|
||||
|
||||
/**
|
||||
* This route lets us rename a certain org.
|
||||
@@ -9,24 +9,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) => {
|
||||
if (res.status == 200) {
|
||||
return res;
|
||||
} else {
|
||||
console.log("Failed to rename an organization");
|
||||
}
|
||||
});
|
||||
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;
|
||||
|
||||
@@ -1,6 +1,6 @@
|
||||
import SecurityClient from "~/utilities/SecurityClient";
|
||||
|
||||
import { PATH } from "../../../const";
|
||||
import { PATH } from "~/const";
|
||||
|
||||
/**
|
||||
* This route gets service tokens for a specific user in a project
|
||||
@@ -8,35 +8,35 @@ import { PATH } from "../../../const";
|
||||
* @returns
|
||||
*/
|
||||
const addServiceToken = ({
|
||||
name,
|
||||
workspaceId,
|
||||
environment,
|
||||
expiresIn,
|
||||
publicKey,
|
||||
encryptedKey,
|
||||
nonce,
|
||||
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");
|
||||
}
|
||||
});
|
||||
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;
|
||||
|
||||
@@ -1,6 +1,6 @@
|
||||
import SecurityClient from "~/utilities/SecurityClient";
|
||||
|
||||
import { PATH } from "../../../const";
|
||||
import { PATH } from "~/const";
|
||||
|
||||
/**
|
||||
* This route gets service tokens for a specific user in a project
|
||||
@@ -8,21 +8,21 @@ import { PATH } from "../../../const";
|
||||
* @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");
|
||||
}
|
||||
});
|
||||
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;
|
||||
|
||||
@@ -1,6 +1,6 @@
|
||||
import SecurityClient from "~/utilities/SecurityClient";
|
||||
|
||||
import { PATH } from "../../../const";
|
||||
import { PATH } from "~/const";
|
||||
|
||||
/**
|
||||
* This route gets the information about a specific user.
|
||||
@@ -9,18 +9,18 @@ import { PATH } from "../../../const";
|
||||
* @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");
|
||||
}
|
||||
});
|
||||
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;
|
||||
|
||||
@@ -1,6 +1,6 @@
|
||||
import SecurityClient from "~/utilities/SecurityClient";
|
||||
|
||||
import { PATH } from "../../../const";
|
||||
import { PATH } from "~/const";
|
||||
|
||||
/**
|
||||
* This route registers a certain action for a user
|
||||
@@ -9,26 +9,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) => {
|
||||
if (res.status == 200) {
|
||||
return (await res.json()).userAction;
|
||||
} else {
|
||||
console.log("Failed to check a user 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;
|
||||
|
||||
@@ -1,6 +1,6 @@
|
||||
import SecurityClient from "~/utilities/SecurityClient";
|
||||
|
||||
import { PATH } from "../../../const";
|
||||
import { PATH } from "~/const";
|
||||
|
||||
/**
|
||||
* This route registers a certain action for a user
|
||||
@@ -8,21 +8,21 @@ import { PATH } from "../../../const";
|
||||
* @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");
|
||||
}
|
||||
});
|
||||
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;
|
||||
|
||||
@@ -1,6 +1,6 @@
|
||||
import SecurityClient from "~/utilities/SecurityClient";
|
||||
|
||||
import { PATH } from "../../../const";
|
||||
import { PATH } from "~/const";
|
||||
|
||||
/**
|
||||
* This function adds a user to a project
|
||||
@@ -9,24 +9,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,6 +1,6 @@
|
||||
import SecurityClient from "~/utilities/SecurityClient";
|
||||
|
||||
import { PATH } from "../../../const";
|
||||
import { PATH } from "~/const";
|
||||
|
||||
/**
|
||||
* This function change the access of a user in a certain workspace
|
||||
@@ -9,24 +9,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) => {
|
||||
if (res.status == 200) {
|
||||
return res;
|
||||
} else {
|
||||
console.log("Failed to change the user role in a project");
|
||||
}
|
||||
});
|
||||
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;
|
||||
|
||||
@@ -1,6 +1,6 @@
|
||||
import SecurityClient from "~/utilities/SecurityClient";
|
||||
|
||||
import { PATH } from "../../../const";
|
||||
import { PATH } from "~/const";
|
||||
|
||||
/**
|
||||
* This route creates a new workspace for a user.
|
||||
@@ -8,22 +8,22 @@ import { PATH } from "../../../const";
|
||||
* @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");
|
||||
}
|
||||
});
|
||||
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;
|
||||
|
||||
@@ -1,6 +1,6 @@
|
||||
import SecurityClient from "~/utilities/SecurityClient";
|
||||
|
||||
import { PATH } from "../../../const";
|
||||
import { PATH } from "~/const";
|
||||
|
||||
/**
|
||||
* This function removes a certain member from a certain workspace
|
||||
@@ -8,21 +8,18 @@ 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) => {
|
||||
if (res.status == 200) {
|
||||
return res;
|
||||
} else {
|
||||
console.log("Failed to delete a user from a project");
|
||||
}
|
||||
});
|
||||
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;
|
||||
|
||||
@@ -1,6 +1,6 @@
|
||||
import SecurityClient from "~/utilities/SecurityClient";
|
||||
|
||||
import { PATH } from "../../../const";
|
||||
import { PATH } from "~/const";
|
||||
|
||||
/**
|
||||
* This route deletes a specified workspace.
|
||||
@@ -8,18 +8,18 @@ import { PATH } from "../../../const";
|
||||
* @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");
|
||||
}
|
||||
});
|
||||
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;
|
||||
|
||||
@@ -1,6 +1,6 @@
|
||||
import SecurityClient from "~/utilities/SecurityClient";
|
||||
|
||||
import { PATH } from "../../../const";
|
||||
import { PATH } from "~/const";
|
||||
|
||||
/**
|
||||
* Get the latest key pairs from a certain workspace
|
||||
@@ -8,23 +8,21 @@ 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,6 +1,6 @@
|
||||
import SecurityClient from "~/utilities/SecurityClient";
|
||||
|
||||
import { PATH } from "../../../const";
|
||||
import { PATH } from "~/const";
|
||||
|
||||
/**
|
||||
* This route lets us get the information of a certain project.
|
||||
@@ -9,21 +9,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) => {
|
||||
if (res.status == 200) {
|
||||
return (await res.json()).workspace;
|
||||
} else {
|
||||
console.log("Failed to get project info");
|
||||
}
|
||||
});
|
||||
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;
|
||||
|
||||
@@ -1,6 +1,6 @@
|
||||
import SecurityClient from "~/utilities/SecurityClient";
|
||||
|
||||
import { PATH } from "../../../const";
|
||||
import { PATH } from "~/const";
|
||||
|
||||
/**
|
||||
* This route lets us get the public keys of everyone in your workspace.
|
||||
@@ -9,23 +9,21 @@ 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) => {
|
||||
if (res.status == 200) {
|
||||
return (await res.json()).publicKeys;
|
||||
} else {
|
||||
console.log(
|
||||
"Failed to get the public keys of everyone in the workspace"
|
||||
);
|
||||
}
|
||||
});
|
||||
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;
|
||||
|
||||
@@ -1,6 +1,6 @@
|
||||
import SecurityClient from "~/utilities/SecurityClient";
|
||||
|
||||
import { PATH } from "../../../const";
|
||||
import { PATH } from "~/const";
|
||||
|
||||
/**
|
||||
* This route lets us get all the users in the workspace.
|
||||
@@ -9,21 +9,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) => {
|
||||
if (res.status == 200) {
|
||||
return (await res.json()).users;
|
||||
} else {
|
||||
console.log("Failed to get Project Users");
|
||||
}
|
||||
});
|
||||
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;
|
||||
|
||||
@@ -1,6 +1,6 @@
|
||||
import SecurityClient from "~/utilities/SecurityClient";
|
||||
|
||||
import { PATH } from "../../../const";
|
||||
import { PATH } from "~/const";
|
||||
|
||||
/**
|
||||
* This route lets us get the public keys of everyone in your workspace.
|
||||
@@ -9,18 +9,18 @@ import { PATH } from "../../../const";
|
||||
* @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");
|
||||
}
|
||||
});
|
||||
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;
|
||||
|
||||
@@ -1,6 +1,6 @@
|
||||
import SecurityClient from "~/utilities/SecurityClient";
|
||||
|
||||
import { PATH } from "../../../const";
|
||||
import { PATH } from "~/const";
|
||||
|
||||
/**
|
||||
* This route lets us rename a certain workspace.
|
||||
@@ -9,24 +9,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) => {
|
||||
if (res.status == 200) {
|
||||
return res;
|
||||
} else {
|
||||
console.log("Failed to rename a project");
|
||||
}
|
||||
});
|
||||
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;
|
||||
|
||||
@@ -1,6 +1,6 @@
|
||||
import SecurityClient from "~/utilities/SecurityClient";
|
||||
|
||||
import { PATH } from "../../../const";
|
||||
import { PATH } from "~/const";
|
||||
|
||||
/**
|
||||
* This route uplods the keys in an encrypted format.
|
||||
@@ -11,25 +11,25 @@ import { PATH } from "../../../const";
|
||||
* @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");
|
||||
}
|
||||
});
|
||||
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