Infisical is the open-source platform for securing secrets, certificates, access, and AI Agents.
TypeScript acmeagentsai-agentscertificate-managementdevsecopsenvironment-variableskubernetesopen-sourcepampkipostgresprivate-caprivileged-access-managementsecret-managementsecret-managersecretssecrets-managementsecuritysecurity-toolsvault
Convert TS to JS
seunghyunOh4a14753b8ce8
diff --git a/frontend/components/analytics/posthog.ts b/frontend/components/analytics/posthog.tsnew file mode 100644index 0000000000..e0d6e7c09a--- /dev/null+++ b/frontend/components/analytics/posthog.ts@@ -0,0 +1,18 @@+/* eslint-disable @typescript-eslint/ban-ts-comment */+/* eslint-disable no-undef */+import posthog from 'posthog-js';++import { ENV, POSTHOG_API_KEY, POSTHOG_HOST } from '../utilities/config';++export const initPostHog = () => {+ if (typeof window !== 'undefined') {+ // @ts-ignore+ if (ENV == 'production' && TELEMETRY_CAPTURING_ENABLED) {+ posthog.init(POSTHOG_API_KEY, {+ api_host: POSTHOG_HOST+ });+ }+ }++ return posthog;+};diff --git a/frontend/components/billing/Plan.js b/frontend/components/billing/Plan.tsxsimilarity index 66%rename from frontend/components/billing/Plan.jsrename to frontend/components/billing/Plan.tsxindex 4274696353..b051e7435d 100644--- a/frontend/components/billing/Plan.js+++ b/frontend/components/billing/Plan.tsx@@ -1,14 +1,27 @@-import React from "react";+import React from 'react';-import StripeRedirect from "~/pages/api/organization/StripeRedirect";+import StripeRedirect from '~/pages/api/organization/StripeRedirect';-export default function Plan({ plan }) {+interface Props {+ plan: {+ name: string;+ price: string;+ priceExplanation: string;+ text: string;+ subtext: string;+ buttonTextMain: string;+ buttonTextSecondary: string;+ current: boolean;+ };+}++export default function Plan({ plan }: Props) {return (<div- className={`relative flex flex-col justify-between border border-2 min-w-fit w-96 rounded-lg h-68 mr-4 bg-mineshaft-800 ${- (plan.name != "Starter") & (plan.current == true)- ? "border-primary"- : "border-chicago-700"+ className={`relative flex flex-col justify-between border-2 min-w-fit w-96 rounded-lg h-68 mr-4 bg-mineshaft-800 ${+ plan.name != 'Starter' && plan.current == true+ ? 'border-primary'+ : 'border-chicago-700'}`}>@@ -36,7 +49,7 @@ export default function Plan({ plan }) {<div className="flex flex-row items-center">{plan.current == false ? (<>- {plan.buttonTextMain == "Schedule a Demo" ? (+ {plan.buttonTextMain == 'Schedule a Demo' ? (<a href="/scheduledemo" target='_blank rel="noopener"'><div className="relative z-10 mx-5 mt-3 mb-4 py-2 px-4 border border-1 border-gray-600 hover:text-black hover:border-primary text-gray-400 font-semibold hover:bg-primary bg-bunker duration-200 cursor-pointer rounded-md flex w-max">{plan.buttonTextMain}@@ -45,15 +58,15 @@ export default function Plan({ plan }) {) : (<divclassName={`relative z-10 mx-5 mt-3 mb-4 py-2 px-4 border border-1 border-gray-600 text-gray-400 font-semibold ${- plan.buttonTextMain == "Downgrade"- ? "hover:bg-red hover:text-white hover:border-red"- : "hover:bg-primary hover:text-black hover:border-primary"+ plan.buttonTextMain == 'Downgrade'+ ? 'hover:bg-red hover:text-white hover:border-red'+ : 'hover:bg-primary hover:text-black hover:border-primary'} bg-bunker duration-200 cursor-pointer rounded-md flex w-max`}><buttononClick={() =>StripeRedirect({- orgId: localStorage.getItem("orgData.id"),+ orgId: localStorage.getItem('orgData.id')})}>@@ -61,7 +74,10 @@ export default function Plan({ plan }) {</button></div>)}- <a href="https://infisical.com/pricing" target='_blank rel="noopener"'>+ <a+ href="https://infisical.com/pricing"+ target='_blank rel="noopener"'+ ><div className="relative z-10 text-gray-400 font-semibold hover:text-primary duration-200 cursor-pointer mb-0.5">{plan.buttonTextSecondary}</div>@@ -70,9 +86,9 @@ export default function Plan({ plan }) {) : (<divclassName={`h-8 w-full rounded-b-md flex justify-center items-center z-10 ${- (plan.name != "Starter") & (plan.current == true)- ? "bg-primary"- : "bg-chicago-700"+ plan.name != 'Starter' && plan.current == true+ ? 'bg-primary'+ : 'bg-chicago-700'}`}><p className="text-xs text-black font-semibold">CURRENT PLAN</p>diff --git a/frontend/components/utilities/SecurityClient.js b/frontend/components/utilities/SecurityClient.jsdeleted file mode 100644index 78eebdebef..0000000000--- a/frontend/components/utilities/SecurityClient.js+++ /dev/null@@ -1,24 +0,0 @@-import token from "~/pages/api/auth/Token";--export default class SecurityClient {- static #token = "";-- constructor() {}-- static setToken(token) {- this.#token = token;- }-- static async fetchCall(resource, options) {- let req = new Request(resource, options);-- if (this.#token == "") {- this.setToken(await token());- }-- if (this.#token) {- req.headers.set("Authorization", "Bearer " + this.#token);- return fetch(req);- }- }-}diff --git a/frontend/components/utilities/SecurityClient.ts b/frontend/components/utilities/SecurityClient.tsnew file mode 100644index 0000000000..ea2664c70b--- /dev/null+++ b/frontend/components/utilities/SecurityClient.ts@@ -0,0 +1,27 @@+import token from '~/pages/api/auth/Token';++export default class SecurityClient {+ static #token = '';++ constructor() {}++ static setToken(token: string) {+ this.#token = token;+ }++ static async fetchCall(+ resource: RequestInfo,+ options?: RequestInit | undefined+ ) {+ const req = new Request(resource, options);++ if (this.#token == '') {+ this.setToken(await token());+ }++ if (this.#token) {+ req.headers.set('Authorization', 'Bearer ' + this.#token);+ return fetch(req);+ }+ }+}diff --git a/frontend/components/utilities/cryptography/issueBackupKey.js b/frontend/components/utilities/cryptography/issueBackupKey.jsdeleted file mode 100644index 19d7ebefa8..0000000000--- a/frontend/components/utilities/cryptography/issueBackupKey.js+++ /dev/null@@ -1,98 +0,0 @@-import issueBackupPrivateKey from "~/pages/api/auth/IssueBackupPrivateKey";-import SRP1 from "~/pages/api/auth/SRP1";--import generateBackupPDF from "../generateBackupPDF";-import Aes256Gcm from "./aes-256-gcm";--const nacl = require("tweetnacl");-nacl.util = require("tweetnacl-util");-const jsrp = require("jsrp");-const clientPassword = new jsrp.client();-const clientKey = new jsrp.client();-const crypto = require("crypto");--/**- * This function loggs in the user (whether it's right after signup, or a normal login)- * @param {*} email- * @param {*} password- * @param {*} setErrorLogin- * @param {*} router- * @param {*} isSignUp- * @returns- */-const issueBackupKey = async ({- email,- password,- personalName,- setBackupKeyError,- setBackupKeyIssued,-}) => {- try {- setBackupKeyError(false);- setBackupKeyIssued(false);- clientPassword.init(- {- username: email,- password: password,- },- async () => {- const clientPublicKey = clientPassword.getPublicKey();-- let serverPublicKey, salt;- try {- const res = await SRP1({- clientPublicKey: clientPublicKey,- });- serverPublicKey = res.serverPublicKey;- salt = res.salt;- } catch (err) {- setBackupKeyError(true);- console.log("Wrong current password", err, 1);- }-- clientPassword.setSalt(salt);- clientPassword.setServerPublicKey(serverPublicKey);- const clientProof = clientPassword.getProof(); // called M1-- const generatedKey = crypto.randomBytes(16).toString("hex");-- clientKey.init(- {- username: email,- password: generatedKey,- },- async () => {- clientKey.createVerifier(async (err, result) => {- let { ciphertext, iv, tag } = Aes256Gcm.encrypt(- localStorage.getItem("PRIVATE_KEY"),- generatedKey- );-- const res = await issueBackupPrivateKey({- encryptedPrivateKey: ciphertext,- iv,- tag,- salt: result.salt,- verifier: result.verifier,- clientProof,- });-- if (res.status == 400) {- setBackupKeyError(true);- } else if (res.status == 200) {- generateBackupPDF(personalName, email, generatedKey);- setBackupKeyIssued(true);- }- });- }- );- }- );- } catch (error) {- setBackupKeyError(true);- console.log("Failed to issue a backup key");- }- return true;-};--export default issueBackupKey;diff --git a/frontend/components/utilities/cryptography/issueBackupKey.ts b/frontend/components/utilities/cryptography/issueBackupKey.tsnew file mode 100644index 0000000000..518186406c--- /dev/null+++ b/frontend/components/utilities/cryptography/issueBackupKey.ts@@ -0,0 +1,112 @@+import issueBackupPrivateKey from '~/pages/api/auth/IssueBackupPrivateKey';+import SRP1 from '~/pages/api/auth/SRP1';++import { tempLocalStorage } from '../checks/tempLocalStorage';+import generateBackupPDF from '../generateBackupPDF';+import Aes256Gcm from './aes-256-gcm';++const nacl = require('tweetnacl');+nacl.util = require('tweetnacl-util');+const jsrp = require('jsrp');+const clientPassword = new jsrp.client();+const clientKey = new jsrp.client();+const crypto = require('crypto');++interface Props {+ email: string;+ password: string;+ personalName: string;+ setBackupKeyError: any;+ setBackupKeyIssued: any;+}++/**+ * This function loggs in the user (whether it's right after signup, or a normal login)+ * @param {*} email+ * @param {*} password+ * @param {*} setErrorLogin+ * @param {*} router+ * @param {*} isSignUp+ * @returns+ */+const issueBackupKey = async ({+ email,+ password,+ personalName,+ setBackupKeyError,+ setBackupKeyIssued+}: Props) => {+ try {+ setBackupKeyError(false);+ setBackupKeyIssued(false);+ clientPassword.init(+ {+ username: email,+ password: password+ },+ async () => {+ const clientPublicKey = clientPassword.getPublicKey();++ let serverPublicKey, salt;+ try {+ const res = await SRP1({+ clientPublicKey: clientPublicKey+ });+ serverPublicKey = res.serverPublicKey;+ salt = res.salt;+ } catch (err) {+ setBackupKeyError(true);+ console.log('Wrong current password', err, 1);+ }++ clientPassword.setSalt(salt);+ clientPassword.setServerPublicKey(serverPublicKey);+ const clientProof = clientPassword.getProof(); // called M1++ const generatedKey = crypto.randomBytes(16).toString('hex');++ clientKey.init(+ {+ username: email,+ password: generatedKey+ },+ async () => {+ clientKey.createVerifier(+ async (_: any, result: { salt: string; verifier: string }) => {+ // TODO: Fix this+ // eslint-disable-next-line @typescript-eslint/ban-ts-comment+ // @ts-ignore+ const { ciphertext, iv, tag } = Aes256Gcm.encrypt(+ tempLocalStorage('PRIVATE_KEY'),+ generatedKey+ );++ const res = await issueBackupPrivateKey({+ encryptedPrivateKey: ciphertext,+ iv,+ tag,+ salt: result.salt,+ verifier: result.verifier,+ clientProof+ });++ if (res && res.status == 400) {+ setBackupKeyError(true);+ } else if (res && res.status == 200) {+ generateBackupPDF(personalName, email, generatedKey);+ setBackupKeyIssued(true);+ }+ }+ );+ }+ );+ }+ );+ } catch (error) {+ setBackupKeyError(true);+ console.log('Failed to issue a backup key');+ }+ return true;+};++export default issueBackupKey;diff --git a/frontend/components/utilities/file.js b/frontend/components/utilities/file.tssimilarity index 74%rename from frontend/components/utilities/file.jsrename to frontend/components/utilities/file.tsindex 96d1820eb1..3784405f91 100644--- a/frontend/components/utilities/file.js+++ b/frontend/components/utilities/file.ts@@ -6,21 +6,21 @@ const LINE =* @param {Buffer} src - source buffer* @returns {String} text - text of buffer*/-function parse(src) {- const obj = {};+function parse(src: Buffer) {+ const obj: Record<string, string> = {};// Convert buffer to stringlet lines = src.toString();// Convert line breaks to same format- lines = lines.replace(/\r\n?/gm, "\n");+ lines = lines.replace(/\r\n?/gm, '\n');let match;while ((match = LINE.exec(lines)) != null) {const key = match[1];// Default undefined or null to empty string- let value = match[2] || "";+ let value = match[2] || '';// Remove whitespacevalue = value.trim();@@ -29,12 +29,12 @@ function parse(src) {const maybeQuote = value[0];// Remove surrounding quotes- value = value.replace(/^(['"`])([\s\S]*)\1$/gm, "$2");+ value = value.replace(/^(['"`])([\s\S]*)\1$/gm, '$2');// Expand newlines if double quotedif (maybeQuote === '"') {- value = value.replace(/\\n/g, "\n");- value = value.replace(/\\r/g, "\r");+ value = value.replace(/\\n/g, '\n');+ value = value.replace(/\\r/g, '\r');}// Add to objectdiff --git a/frontend/components/utilities/randomId.js b/frontend/components/utilities/randomId.tssimilarity index 82%rename from frontend/components/utilities/randomId.jsrename to frontend/components/utilities/randomId.tsindex 7d1c0859bd..8e1c7f9723 100644--- a/frontend/components/utilities/randomId.js+++ b/frontend/components/utilities/randomId.ts@@ -3,19 +3,19 @@* @returns*/const guidGenerator = () => {- var S4 = function () {+ const S4 = function () {return (((1 + Math.random()) * 0x10000) | 0).toString(16).substring(1);};return (S4() +S4() +- "-" ++ '-' +S4() +- "-" ++ '-' +S4() +- "-" ++ '-' +S4() +- "-" ++ '-' +S4() +S4() +S4()diff --git a/frontend/components/utilities/secrets/getSecretsForProject.js b/frontend/components/utilities/secrets/getSecretsForProject.tssimilarity index 60%rename from frontend/components/utilities/secrets/getSecretsForProject.jsrename to frontend/components/utilities/secrets/getSecretsForProject.tsindex 7bdac922ff..284b8bee1d 100644--- a/frontend/components/utilities/secrets/getSecretsForProject.js+++ b/frontend/components/utilities/secrets/getSecretsForProject.ts@@ -1,22 +1,30 @@-import getSecrets from "~/pages/api/files/GetSecrets";+import getSecrets from '~/pages/api/files/GetSecrets';-import { envMapping } from "../../../public/data/frequentConstants";-import guidGenerator from "../randomId";+import { envMapping } from '../../../public/data/frequentConstants';+import guidGenerator from '../randomId';const {decryptAssymmetric,- decryptSymmetric,-} = require("../cryptography/crypto");-const nacl = require("tweetnacl");-nacl.util = require("tweetnacl-util");+ decryptSymmetric+} = require('../cryptography/crypto');+const nacl = require('tweetnacl');+nacl.util = require('tweetnacl-util');++interface Props {+ env: keyof typeof envMapping;+ setFileState: any;+ setIsKeyAvailable: any;+ setData: any;+ workspaceId: string;+}const getSecretsForProject = async ({env,setFileState,setIsKeyAvailable,setData,- workspaceId,-}) => {+ workspaceId+}: Props) => {try {let file;try {@@ -24,44 +32,42 @@ const getSecretsForProject = async ({setFileState(file);} catch (error) {- console.log("ERROR: Not able to access the latest file");+ console.log('ERROR: Not able to access the latest file');}// This is called isKeyAvilable but what it really means is if a person is able to create new key pairs- setIsKeyAvailable(- !file.key ? (file.secrets.length == 0 ? true : false) : true- );+ setIsKeyAvailable(!file.key ? file.secrets.length == 0 : true);- const PRIVATE_KEY = localStorage.getItem("PRIVATE_KEY");+ const PRIVATE_KEY = localStorage.getItem('PRIVATE_KEY');- let tempFileState = [];+ const tempFileState: { key: string; value: string; type: string }[] = [];if (file.key) {// assymmetrically decrypt symmetric key with local private keyconst key = decryptAssymmetric({ciphertext: file.key.encryptedKey,nonce: file.key.nonce,publicKey: file.key.sender.publicKey,- privateKey: PRIVATE_KEY,+ privateKey: PRIVATE_KEY});- file.secrets.map((secretPair) => {+ file.secrets.map((secretPair: any) => {// decrypt .env file with symmetric keyconst plainTextKey = decryptSymmetric({ciphertext: secretPair.secretKey.ciphertext,iv: secretPair.secretKey.iv,tag: secretPair.secretKey.tag,- key,+ key});const plainTextValue = decryptSymmetric({ciphertext: secretPair.secretValue.ciphertext,iv: secretPair.secretValue.iv,tag: secretPair.secretValue.tag,- key,+ key});tempFileState.push({key: plainTextKey,value: plainTextValue,- type: secretPair.type,+ type: secretPair.type});});}@@ -71,9 +77,9 @@ const getSecretsForProject = async ({tempFileState.map((line, index) => [guidGenerator(),index,- line["key"],- line["value"],- line["type"],+ line['key'],+ line['value'],+ line['type']])// .sort((a, b) =>// sortMethod == "alphabetical"@@ -84,12 +90,12 @@ const getSecretsForProject = async ({return tempFileState.map((line, index) => [guidGenerator(),index,- line["key"],- line["value"],- line["type"],+ line['key'],+ line['value'],+ line['type']]);} catch (error) {- console.log("Something went wrong during accessing or decripting secrets.");+ console.log('Something went wrong during accessing or decripting secrets.');}return true;};diff --git a/frontend/components/utilities/secrets/pushKeysIntegration.js b/frontend/components/utilities/secrets/pushKeysIntegration.jsdeleted file mode 100644index 5b08748e72..0000000000--- a/frontend/components/utilities/secrets/pushKeysIntegration.js+++ /dev/null@@ -1,74 +0,0 @@-import publicKeyInfical from "~/pages/api/auth/publicKeyInfisical";-import changeHerokuConfigVars from "~/pages/api/integrations/ChangeHerokuConfigVars";--const crypto = require("crypto");-const {- encryptSymmetric,- encryptAssymmetric,-} = require("../cryptography/crypto");-const nacl = require("tweetnacl");-nacl.util = require("tweetnacl-util");--const pushKeysIntegration = async ({ obj, integrationId }) => {- const PRIVATE_KEY = localStorage.getItem("PRIVATE_KEY");-- let randomBytes = crypto.randomBytes(16).toString("hex");-- const secrets = Object.keys(obj).map((key) => {- // encrypt key- const {- ciphertext: ciphertextKey,- iv: ivKey,- tag: tagKey,- } = encryptSymmetric({- plaintext: key,- key: randomBytes,- });-- // encrypt value- const {- ciphertext: ciphertextValue,- iv: ivValue,- tag: tagValue,- } = encryptSymmetric({- plaintext: obj[key],- key: randomBytes,- });-- const visibility = "shared";-- return {- ciphertextKey,- ivKey,- tagKey,- hashKey: crypto.createHash("sha256").update(key).digest("hex"),- ciphertextValue,- ivValue,- tagValue,- hashValue: crypto.createHash("sha256").update(obj[key]).digest("hex"),- type: visibility,- };- });-- // obtain public keys of all receivers (i.e. members in workspace)- let publicKeyInfisical = await publicKeyInfical();-- publicKeyInfisical = (await publicKeyInfisical.json()).publicKey;-- // assymmetrically encrypt key with each receiver public keys-- const { ciphertext, nonce } = encryptAssymmetric({- plaintext: randomBytes,- publicKey: publicKeyInfisical,- privateKey: PRIVATE_KEY,- });-- const key = {- encryptedKey: ciphertext,- nonce,- };-- changeHerokuConfigVars({ integrationId, key, secrets });-};--export default pushKeysIntegration;diff --git a/frontend/components/utilities/secrets/pushKeysIntegration.ts b/frontend/components/utilities/secrets/pushKeysIntegration.tsnew file mode 100644index 0000000000..9497789275--- /dev/null+++ b/frontend/components/utilities/secrets/pushKeysIntegration.ts@@ -0,0 +1,79 @@+import publicKeyInfical from '~/pages/api/auth/publicKeyInfisical';+import changeHerokuConfigVars from '~/pages/api/integrations/ChangeHerokuConfigVars';++const crypto = require('crypto');+const {+ encryptSymmetric,+ encryptAssymmetric+} = require('../cryptography/crypto');+const nacl = require('tweetnacl');+nacl.util = require('tweetnacl-util');++interface Props {+ obj: Record<string, string>;+ integrationId: string;+}++const pushKeysIntegration = async ({ obj, integrationId }: Props) => {+ const PRIVATE_KEY = localStorage.getItem('PRIVATE_KEY');++ const randomBytes = crypto.randomBytes(16).toString('hex');++ const secrets = Object.keys(obj).map((key) => {+ // encrypt key+ const {+ ciphertext: ciphertextKey,+ iv: ivKey,+ tag: tagKey+ } = encryptSymmetric({+ plaintext: key,+ key: randomBytes+ });++ // encrypt value+ const {+ ciphertext: ciphertextValue,+ iv: ivValue,+ tag: tagValue+ } = encryptSymmetric({+ plaintext: obj[key],+ key: randomBytes+ });++ const visibility = 'shared';++ return {+ ciphertextKey,+ ivKey,+ tagKey,+ hashKey: crypto.createHash('sha256').update(key).digest('hex'),+ ciphertextValue,+ ivValue,+ tagValue,+ hashValue: crypto.createHash('sha256').update(obj[key]).digest('hex'),+ type: visibility+ };+ });++ // obtain public keys of all receivers (i.e. members in workspace)+ const publicKeyInfisical = await publicKeyInfical();++ const publicKey = (await publicKeyInfisical.json()).publicKey;++ // assymmetrically encrypt key with each receiver public keys++ const { ciphertext, nonce } = encryptAssymmetric({+ plaintext: randomBytes,+ publicKey,+ privateKey: PRIVATE_KEY+ });++ const key = {+ encryptedKey: ciphertext,+ nonce+ };++ changeHerokuConfigVars({ integrationId, key, secrets });+};++export default pushKeysIntegration;diff --git a/frontend/pages/api/auth/ChangePassword2.js b/frontend/pages/api/auth/ChangePassword2.tssimilarity index 50%rename from frontend/pages/api/auth/ChangePassword2.jsrename to frontend/pages/api/auth/ChangePassword2.tsindex b764e60677..132eeddf43 100644--- a/frontend/pages/api/auth/ChangePassword2.js+++ b/frontend/pages/api/auth/ChangePassword2.ts@@ -1,4 +1,13 @@-import SecurityClient from "~/utilities/SecurityClient";+import SecurityClient from '~/utilities/SecurityClient';++interface Props {+ encryptedPrivateKey: string;+ iv: string;+ tag: string;+ salt: string;+ verifier: string;+ clientProof: string;+}/*** This is the second step of the change password process (pake)@@ -11,12 +20,12 @@ const changePassword2 = ({tag,salt,verifier,- clientProof,-}) => {- return SecurityClient.fetchCall("/api/v1/password/change-password", {- method: "POST",+ clientProof+}: Props) => {+ return SecurityClient.fetchCall('/api/v1/password/change-password', {+ method: 'POST',headers: {- "Content-Type": "application/json",+ 'Content-Type': 'application/json'},body: JSON.stringify({clientProof: clientProof,@@ -24,13 +33,13 @@ const changePassword2 = ({iv: iv,tag: tag,salt: salt,- verifier: verifier,- }),+ verifier: verifier+ })}).then(async (res) => {- if (res.status == 200) {+ if (res && res.status == 200) {return res;} else {- console.log("Failed to change the password");+ console.log('Failed to change the password');}});};diff --git a/frontend/pages/api/auth/CheckAuth.js b/frontend/pages/api/auth/CheckAuth.tssimilarity index 50%rename from frontend/pages/api/auth/CheckAuth.jsrename to frontend/pages/api/auth/CheckAuth.tsindex edd3736144..6d9c92c545 100644--- a/frontend/pages/api/auth/CheckAuth.js+++ b/frontend/pages/api/auth/CheckAuth.ts@@ -1,4 +1,4 @@-import SecurityClient from "~/utilities/SecurityClient.js";+import SecurityClient from '~/utilities/SecurityClient.js';/*** This function is used to check if the user is authenticated.@@ -7,17 +7,17 @@ import SecurityClient from "~/utilities/SecurityClient.js";* @param {*} res* @returns*/-const checkAuth = async (req, res) => {- return SecurityClient.fetchCall("/api/v1/auth/checkAuth", {- method: "POST",+const checkAuth = async () => {+ return SecurityClient.fetchCall('/api/v1/auth/checkAuth', {+ method: 'POST',headers: {- "Content-Type": "application/json",- },+ 'Content-Type': 'application/json'+ }}).then((res) => {- if (res.status == 200) {+ if (res && res.status == 200) {return res;} else {- console.log("Not authorized");+ console.log('Not authorized');}});};diff --git a/frontend/pages/api/auth/CheckEmailVerificationCode.js b/frontend/pages/api/auth/CheckEmailVerificationCode.tssimilarity index 50%rename from frontend/pages/api/auth/CheckEmailVerificationCode.jsrename to frontend/pages/api/auth/CheckEmailVerificationCode.tsindex 83a64602a7..08fb6b3911 100644--- a/frontend/pages/api/auth/CheckEmailVerificationCode.js+++ b/frontend/pages/api/auth/CheckEmailVerificationCode.ts@@ -1,19 +1,24 @@+interface Props {+ email: string;+ code: string;+}+/*** This route check the verification code from the email that user just recieved* @param {*} email* @param {*} code* @returns*/-const checkEmailVerificationCode = (email, code) => {- return fetch("/api/v1/signup/email/verify", {- method: "POST",+const checkEmailVerificationCode = ({ email, code }: Props) => {+ return fetch('/api/v1/signup/email/verify', {+ method: 'POST',headers: {- "Content-Type": "application/json",+ 'Content-Type': 'application/json'},body: JSON.stringify({email: email,- code: code,- }),+ code: code+ })});};diff --git a/frontend/pages/api/auth/CompleteAccountInformationSignup.js b/frontend/pages/api/auth/CompleteAccountInformationSignup.tssimilarity index 64%rename from frontend/pages/api/auth/CompleteAccountInformationSignup.jsrename to frontend/pages/api/auth/CompleteAccountInformationSignup.tsindex 21406e381e..98e78dec9d 100644--- a/frontend/pages/api/auth/CompleteAccountInformationSignup.js+++ b/frontend/pages/api/auth/CompleteAccountInformationSignup.ts@@ -1,3 +1,17 @@+interface Props {+ email: string;+ firstName: string;+ lastName: string;+ publicKey: string;+ ciphertext: string;+ organizationName: string;+ iv: string;+ tag: string;+ salt: string;+ verifier: string;+ token: string;+}+/*** This function is called in the end of the signup process.* It sends all the necessary nformation to the server.@@ -24,13 +38,13 @@ const completeAccountInformationSignup = ({tag,salt,verifier,- token,-}) => {- return fetch("/api/v1/signup/complete-account/signup", {- method: "POST",+ token+}: Props) => {+ return fetch('/api/v1/signup/complete-account/signup', {+ method: 'POST',headers: {- "Content-Type": "application/json",- Authorization: "Bearer " + token,+ 'Content-Type': 'application/json',+ Authorization: 'Bearer ' + token},body: JSON.stringify({email,@@ -42,8 +56,8 @@ const completeAccountInformationSignup = ({iv,tag,salt,- verifier,- }),+ verifier+ })});};diff --git a/frontend/pages/api/auth/CompleteAccountInformationSignupInvite.js b/frontend/pages/api/auth/CompleteAccountInformationSignupInvite.tssimilarity index 64%rename from frontend/pages/api/auth/CompleteAccountInformationSignupInvite.jsrename to frontend/pages/api/auth/CompleteAccountInformationSignupInvite.tsindex a205e6f59f..1e5abdc459 100644--- a/frontend/pages/api/auth/CompleteAccountInformationSignupInvite.js+++ b/frontend/pages/api/auth/CompleteAccountInformationSignupInvite.ts@@ -1,3 +1,16 @@+interface Props {+ email: string;+ firstName: string;+ lastName: string;+ publicKey: string;+ ciphertext: string;+ iv: string;+ tag: string;+ salt: string;+ verifier: string;+ token: string;+}+/*** This function is called in the end of the signup process.* It sends all the necessary nformation to the server.@@ -22,13 +35,13 @@ const completeAccountInformationSignupInvite = ({tag,salt,verifier,- token,-}) => {- return fetch("/api/v1/signup/complete-account/invite", {- method: "POST",+ token+}: Props) => {+ return fetch('/api/v1/signup/complete-account/invite', {+ method: 'POST',headers: {- "Content-Type": "application/json",- Authorization: "Bearer " + token,+ 'Content-Type': 'application/json',+ Authorization: 'Bearer ' + token},body: JSON.stringify({email: email,@@ -39,8 +52,8 @@ const completeAccountInformationSignupInvite = ({iv: iv,tag: tag,salt: salt,- verifier: verifier,- }),+ verifier: verifier+ })});};diff --git a/frontend/pages/api/auth/IssueBackupPrivateKey.js b/frontend/pages/api/auth/IssueBackupPrivateKey.jsdeleted file mode 100644index 9a31f7b008..0000000000--- a/frontend/pages/api/auth/IssueBackupPrivateKey.js+++ /dev/null@@ -1,40 +0,0 @@-import SecurityClient from "~/utilities/SecurityClient";--/**- * 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(- "/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 {- console.log("Failed to issue the backup key");- return res;- }- });-};--export default issueBackupPrivateKey;diff --git a/frontend/pages/api/auth/IssueBackupPrivateKey.ts b/frontend/pages/api/auth/IssueBackupPrivateKey.tsnew file mode 100644index 0000000000..9b300f55bd--- /dev/null+++ b/frontend/pages/api/auth/IssueBackupPrivateKey.ts@@ -0,0 +1,44 @@+import SecurityClient from '~/utilities/SecurityClient';++interface Props {+ encryptedPrivateKey: string;+ iv: string;+ tag: string;+ salt: string;+ verifier: string;+ clientProof: string;+}++/**+ * 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+}: Props) => {+ return SecurityClient.fetchCall('/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) {+ console.log('Failed to issue the backup key');+ }+ return res;+ });+};++export default issueBackupPrivateKey;diff --git a/frontend/pages/api/auth/SRP1.js b/frontend/pages/api/auth/SRP1.jsdeleted file mode 100644index b0fefb857b..0000000000--- a/frontend/pages/api/auth/SRP1.js+++ /dev/null@@ -1,26 +0,0 @@-import SecurityClient from "~/utilities/SecurityClient";--/**- * This is the first step of the change password process (pake)- * @param {*} clientPublicKey- * @returns- */-const SRP1 = ({ clientPublicKey }) => {- return SecurityClient.fetchCall("/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;diff --git a/frontend/pages/api/auth/SRP1.ts b/frontend/pages/api/auth/SRP1.tsnew file mode 100644index 0000000000..292dcbdd1a--- /dev/null+++ b/frontend/pages/api/auth/SRP1.ts@@ -0,0 +1,30 @@+import SecurityClient from '~/utilities/SecurityClient';++interface Props {+ clientPublicKey: string;+}++/**+ * This is the first step of the change password process (pake)+ * @param {*} clientPublicKey+ * @returns+ */+const SRP1 = ({ clientPublicKey }: Props) => {+ return SecurityClient.fetchCall('/api/v1/password/srp1', {+ method: 'POST',+ headers: {+ 'Content-Type': 'application/json'+ },+ body: JSON.stringify({+ clientPublicKey+ })+ }).then(async (res) => {+ if (res && res.status == 200) {+ return await res.json();+ } else {+ console.log('Failed to do the first step of SRP');+ }+ });+};++export default SRP1;diff --git a/frontend/pages/api/auth/SendVerificationEmail.js b/frontend/pages/api/auth/SendVerificationEmail.tssimilarity index 55%rename from frontend/pages/api/auth/SendVerificationEmail.jsrename to frontend/pages/api/auth/SendVerificationEmail.tsindex ae952852d0..4f3b063c6a 100644--- a/frontend/pages/api/auth/SendVerificationEmail.js+++ b/frontend/pages/api/auth/SendVerificationEmail.ts@@ -2,15 +2,15 @@* This route send the verification email to the user's email (contains a 6-digit verification code)* @param {*} email*/-const sendVerificationEmail = (email) => {- fetch("/api/v1/signup/email/signup", {- method: "POST",+const sendVerificationEmail = (email: string) => {+ fetch('/api/v1/signup/email/signup', {+ method: 'POST',headers: {- "Content-Type": "application/json",+ 'Content-Type': 'application/json'},body: JSON.stringify({- email: email,- }),+ email: email+ })});};diff --git a/frontend/pages/api/auth/Token.js b/frontend/pages/api/auth/Token.jsdeleted file mode 100644index c3e5fd9587..0000000000--- a/frontend/pages/api/auth/Token.js+++ /dev/null@@ -1,17 +0,0 @@-const token = async (req, res) => {- return fetch("/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;diff --git a/frontend/pages/api/auth/Token.ts b/frontend/pages/api/auth/Token.tsnew file mode 100644index 0000000000..ed347ba4b8--- /dev/null+++ b/frontend/pages/api/auth/Token.ts@@ -0,0 +1,17 @@+const token = async () => {+ return fetch('/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;diff --git a/frontend/pages/api/auth/VerifySignupInvite.js b/frontend/pages/api/auth/VerifySignupInvite.jsdeleted file mode 100644index 2a9ba4dcd9..0000000000--- a/frontend/pages/api/auth/VerifySignupInvite.js+++ /dev/null@@ -1,20 +0,0 @@-/**- * This route verifies the signup invite link- * @param {*} email- * @param {*} code- * @returns- */-const verifySignupInvite = ({ email, code }) => {- return fetch("/api/v1/invite-org/verify", {- method: "POST",- headers: {- "Content-Type": "application/json",- },- body: JSON.stringify({- email,- code,- }),- });-};--export default verifySignupInvite;diff --git a/frontend/pages/api/auth/VerifySignupInvite.ts b/frontend/pages/api/auth/VerifySignupInvite.tsnew file mode 100644index 0000000000..20e52dfd12--- /dev/null+++ b/frontend/pages/api/auth/VerifySignupInvite.ts@@ -0,0 +1,25 @@+interface Props {+ email: string;+ code: string;+}++/**+ * This route verifies the signup invite link+ * @param {*} email+ * @param {*} code+ * @returns+ */+const verifySignupInvite = ({ email, code }: Props) => {+ return fetch('/api/v1/invite-org/verify', {+ method: 'POST',+ headers: {+ 'Content-Type': 'application/json'+ },+ body: JSON.stringify({+ email,+ code+ })+ });+};++export default verifySignupInvite;diff --git a/frontend/pages/api/auth/publicKeyInfisical.js b/frontend/pages/api/auth/publicKeyInfisical.jsdeleted file mode 100644index 76cad17260..0000000000--- a/frontend/pages/api/auth/publicKeyInfisical.js+++ /dev/null@@ -1,16 +0,0 @@-/**- * 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("/api/v1/key/publicKey/infisical", {- method: "GET",- headers: {- "Content-Type": "application/json",- },- });-};--export default publicKeyInfisical;diff --git a/frontend/pages/api/auth/publicKeyInfisical.ts b/frontend/pages/api/auth/publicKeyInfisical.tsnew file mode 100644index 0000000000..d3e0f646c8--- /dev/null+++ b/frontend/pages/api/auth/publicKeyInfisical.ts@@ -0,0 +1,10 @@+const publicKeyInfisical = () => {+ return fetch('/api/v1/key/publicKey/infisical', {+ method: 'GET',+ headers: {+ 'Content-Type': 'application/json'+ }+ });+};++export default publicKeyInfisical;diff --git a/frontend/pages/api/files/GetSecrets.js b/frontend/pages/api/files/GetSecrets.tssimilarity index 53%rename from frontend/pages/api/files/GetSecrets.jsrename to frontend/pages/api/files/GetSecrets.tsindex fa91d09621..4e33e19f25 100644--- a/frontend/pages/api/files/GetSecrets.js+++ b/frontend/pages/api/files/GetSecrets.ts@@ -1,4 +1,4 @@-import SecurityClient from "~/utilities/SecurityClient.js";+import SecurityClient from '~/utilities/SecurityClient.js';/*** This function fetches the encrypted secrets from the .env file@@ -6,26 +6,26 @@ import SecurityClient from "~/utilities/SecurityClient.js";* @param {*} env* @returns*/-const getSecrets = async (workspaceId, env) => {+const getSecrets = async (workspaceId: string, env: string) => {return SecurityClient.fetchCall(- "/api/v1/secret/" ++ '/api/v1/secret/' +workspaceId +- "?" ++ '?' +new URLSearchParams({environment: env,- channel: "web",+ channel: 'web'}),{- method: "GET",+ method: 'GET',headers: {- "Content-Type": "application/json",- },+ 'Content-Type': 'application/json'+ }}).then(async (res) => {- if (res.status == 200) {+ if (res && res.status == 200) {return await res.json();} else {- console.log("Failed to get project secrets");+ console.log('Failed to get project secrets');}});};diff --git a/frontend/pages/api/files/UploadSecrets.js b/frontend/pages/api/files/UploadSecrets.jsdeleted file mode 100644index c2f94e64d0..0000000000--- a/frontend/pages/api/files/UploadSecrets.js+++ /dev/null@@ -1,30 +0,0 @@-import SecurityClient from "~/utilities/SecurityClient";--/**- * This function uploads the encrypted .env file- * @param {*} req- * @param {*} res- * @returns- */-const uploadSecrets = async ({ workspaceId, secrets, keys, environment }) => {- return SecurityClient.fetchCall("/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;diff --git a/frontend/pages/api/files/UploadSecrets.ts b/frontend/pages/api/files/UploadSecrets.tsnew file mode 100644index 0000000000..53b87d62f5--- /dev/null+++ b/frontend/pages/api/files/UploadSecrets.ts@@ -0,0 +1,42 @@+import SecurityClient from '~/utilities/SecurityClient';++interface Props {+ workspaceId: string;+ secrets: string;+ keys: string;+ environment: string;+}++/**+ * This function uploads the encrypted .env file+ * @param {*} req+ * @param {*} res+ * @returns+ */+const uploadSecrets = async ({+ workspaceId,+ secrets,+ keys,+ environment+}: Props) => {+ return SecurityClient.fetchCall('/api/v1/secret/' + workspaceId, {+ method: 'POST',+ headers: {+ 'Content-Type': 'application/json'+ },+ body: JSON.stringify({+ secrets,+ keys,+ environment,+ channel: 'web'+ })+ }).then(async (res) => {+ if (res && res.status == 200) {+ return res;+ } else {+ console.log('Failed to push secrets');+ }+ });+};++export default uploadSecrets;diff --git a/frontend/pages/api/integrations/ChangeHerokuConfigVars.js b/frontend/pages/api/integrations/ChangeHerokuConfigVars.jsdeleted file mode 100644index 118848ae6a..0000000000--- a/frontend/pages/api/integrations/ChangeHerokuConfigVars.js+++ /dev/null@@ -1,25 +0,0 @@-import SecurityClient from "~/utilities/SecurityClient";--const changeHerokuConfigVars = ({ integrationId, key, secrets }) => {- return SecurityClient.fetchCall(- "/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;diff --git a/frontend/pages/api/integrations/ChangeHerokuConfigVars.ts b/frontend/pages/api/integrations/ChangeHerokuConfigVars.tsnew file mode 100644index 0000000000..854e614e0a--- /dev/null+++ b/frontend/pages/api/integrations/ChangeHerokuConfigVars.ts@@ -0,0 +1,31 @@+import SecurityClient from '~/utilities/SecurityClient';++interface Props {+ integrationId: string;+ key: string;+ secrets: string;+}++const changeHerokuConfigVars = ({ integrationId, key, secrets }: Props) => {+ return SecurityClient.fetchCall(+ '/api/v1/integration/' + integrationId + '/sync',+ {+ method: 'POST',+ headers: {+ 'Content-Type': 'application/json'+ },+ body: JSON.stringify({+ key,+ secrets+ })+ }+ ).then(async (res) => {+ if (res && res.status == 200) {+ return res;+ } else {+ console.log('Failed to sync secrets to Heroku');+ }+ });+};++export default changeHerokuConfigVars;diff --git a/frontend/pages/api/integrations/DeleteIntegration.js b/frontend/pages/api/integrations/DeleteIntegration.jsdeleted file mode 100644index 7698d7eae8..0000000000--- a/frontend/pages/api/integrations/DeleteIntegration.js+++ /dev/null@@ -1,26 +0,0 @@-import SecurityClient from "~/utilities/SecurityClient";--/**- * This route deletes an integration from a certain project- * @param {*} integrationId- * @returns- */-const deleteIntegration = ({ integrationId }) => {- return SecurityClient.fetchCall(- "/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;diff --git a/frontend/pages/api/integrations/DeleteIntegration.ts b/frontend/pages/api/integrations/DeleteIntegration.tsnew file mode 100644index 0000000000..89aa0ab0c5--- /dev/null+++ b/frontend/pages/api/integrations/DeleteIntegration.ts@@ -0,0 +1,27 @@+import SecurityClient from '~/utilities/SecurityClient';++interface Props {+ integrationId: string;+}++/**+ * This route deletes an integration from a certain project+ * @param {*} integrationId+ * @returns+ */+const deleteIntegration = ({ integrationId }: Props) => {+ return SecurityClient.fetchCall('/api/v1/integration/' + integrationId, {+ method: 'DELETE',+ headers: {+ 'Content-Type': 'application/json'+ }+ }).then(async (res) => {+ if (res && res.status == 200) {+ return (await res.json()).workspace;+ } else {+ console.log('Failed to delete an integration');+ }+ });+};++export default deleteIntegration;diff --git a/frontend/pages/api/integrations/DeleteIntegrationAuth.js b/frontend/pages/api/integrations/DeleteIntegrationAuth.jsdeleted file mode 100644index eb6106e8ef..0000000000--- a/frontend/pages/api/integrations/DeleteIntegrationAuth.js+++ /dev/null@@ -1,26 +0,0 @@-import SecurityClient from "~/utilities/SecurityClient";--/**- * This route deletes an integration authorization from a certain project- * @param {*} integrationAuthId- * @returns- */-const deleteIntegrationAuth = ({ integrationAuthId }) => {- return SecurityClient.fetchCall(- "/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;diff --git a/frontend/pages/api/integrations/DeleteIntegrationAuth.ts b/frontend/pages/api/integrations/DeleteIntegrationAuth.tsnew file mode 100644index 0000000000..3a2da2cbf3--- /dev/null+++ b/frontend/pages/api/integrations/DeleteIntegrationAuth.ts@@ -0,0 +1,30 @@+import SecurityClient from '~/utilities/SecurityClient';++interface Props {+ integrationAuthId: string;+}++/**+ * This route deletes an integration authorization from a certain project+ * @param {*} integrationAuthId+ * @returns+ */+const deleteIntegrationAuth = ({ integrationAuthId }: Props) => {+ return SecurityClient.fetchCall(+ '/api/v1/integration-auth/' + integrationAuthId,+ {+ method: 'DELETE',+ headers: {+ 'Content-Type': 'application/json'+ }+ }+ ).then(async (res) => {+ if (res && res.status == 200) {+ return res;+ } else {+ console.log('Failed to delete an integration authorization');+ }+ });+};++export default deleteIntegrationAuth;diff --git a/frontend/pages/api/integrations/GetIntegrationApps.js b/frontend/pages/api/integrations/GetIntegrationApps.jsdeleted file mode 100644index dc0bfb4b69..0000000000--- a/frontend/pages/api/integrations/GetIntegrationApps.js+++ /dev/null@@ -1,21 +0,0 @@-import SecurityClient from "~/utilities/SecurityClient";--const getIntegrationApps = ({ integrationAuthId }) => {- return SecurityClient.fetchCall(- "/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;diff --git a/frontend/pages/api/integrations/GetIntegrationApps.ts b/frontend/pages/api/integrations/GetIntegrationApps.tsnew file mode 100644index 0000000000..5597c24b15--- /dev/null+++ b/frontend/pages/api/integrations/GetIntegrationApps.ts@@ -0,0 +1,25 @@+import SecurityClient from '~/utilities/SecurityClient';++interface Props {+ integrationAuthId: string;+}++const getIntegrationApps = ({ integrationAuthId }: Props) => {+ return SecurityClient.fetchCall(+ '/api/v1/integration-auth/' + integrationAuthId + '/apps',+ {+ method: 'GET',+ headers: {+ 'Content-Type': 'application/json'+ }+ }+ ).then(async (res) => {+ if (res && res.status == 200) {+ return (await res.json()).apps;+ } else {+ console.log('Failed to get available apps for an integration');+ }+ });+};++export default getIntegrationApps;diff --git a/frontend/pages/api/integrations/GetIntegrations.js b/frontend/pages/api/integrations/GetIntegrations.jsdeleted file mode 100644index 401c80d3b3..0000000000--- a/frontend/pages/api/integrations/GetIntegrations.js+++ /dev/null@@ -1,18 +0,0 @@-import SecurityClient from "~/utilities/SecurityClient";--const getIntegrations = () => {- return SecurityClient.fetchCall("/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;diff --git a/frontend/pages/api/integrations/GetIntegrations.ts b/frontend/pages/api/integrations/GetIntegrations.tsnew file mode 100644index 0000000000..c189010a4d--- /dev/null+++ b/frontend/pages/api/integrations/GetIntegrations.ts@@ -0,0 +1,18 @@+import SecurityClient from '~/utilities/SecurityClient';++const getIntegrations = () => {+ return SecurityClient.fetchCall('/api/v1/integration/integrations', {+ method: 'GET',+ headers: {+ 'Content-Type': 'application/json'+ }+ }).then(async (res) => {+ if (res && res.status == 200) {+ return (await res.json()).integrations;+ } else {+ console.log('Failed to get project integrations');+ }+ });+};++export default getIntegrations;diff --git a/frontend/pages/api/integrations/StartIntegration.js b/frontend/pages/api/integrations/StartIntegration.jsdeleted file mode 100644index a4e8b0b02d..0000000000--- a/frontend/pages/api/integrations/StartIntegration.js+++ /dev/null@@ -1,33 +0,0 @@-import SecurityClient from "~/utilities/SecurityClient";--/**- * This route starts the integration after teh default one if gonna set up.- * @param {*} integrationId- * @returns- */-const startIntegration = ({ integrationId, appName, environment }) => {- return SecurityClient.fetchCall(- "/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;diff --git a/frontend/pages/api/integrations/StartIntegration.ts b/frontend/pages/api/integrations/StartIntegration.tsnew file mode 100644index 0000000000..bef82e7e17--- /dev/null+++ b/frontend/pages/api/integrations/StartIntegration.ts@@ -0,0 +1,36 @@+import SecurityClient from '~/utilities/SecurityClient';++interface Props {+ integrationId: string;+ appName: string;+ environment: string;+}++/**+ * This route starts the integration after teh default one if gonna set up.+ * @param {*} integrationId+ * @returns+ */+const startIntegration = ({ integrationId, appName, environment }: Props) => {+ return SecurityClient.fetchCall('/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 && res.status == 200) {+ return res;+ } else {+ console.log('Failed to start an integration');+ }+ });+};++export default startIntegration;diff --git a/frontend/pages/api/integrations/authorizeIntegration.js b/frontend/pages/api/integrations/authorizeIntegration.jsdeleted file mode 100644index b9a1d3995d..0000000000--- a/frontend/pages/api/integrations/authorizeIntegration.js+++ /dev/null@@ -1,31 +0,0 @@-import SecurityClient from "~/utilities/SecurityClient";--/**- * This is the first step of the change password process (pake)- * @param {*} clientPublicKey- * @returns- */-const AuthorizeIntegration = ({ workspaceId, code, integration }) => {- return SecurityClient.fetchCall(- "/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;diff --git a/frontend/pages/api/integrations/authorizeIntegration.ts b/frontend/pages/api/integrations/authorizeIntegration.tsnew file mode 100644index 0000000000..83158f594a--- /dev/null+++ b/frontend/pages/api/integrations/authorizeIntegration.ts@@ -0,0 +1,33 @@+import SecurityClient from '~/utilities/SecurityClient';++interface Props {+ workspaceId: string;+ code: string;+ integration: string;+}+/**+ * This is the first step of the change password process (pake)+ * @param {*} clientPublicKey+ * @returns+ */+const AuthorizeIntegration = ({ workspaceId, code, integration }: Props) => {+ return SecurityClient.fetchCall('/api/v1/integration-auth/oauth-token', {+ method: 'POST',+ headers: {+ 'Content-Type': 'application/json'+ },+ body: JSON.stringify({+ workspaceId,+ code,+ integration+ })+ }).then(async (res) => {+ if (res && res.status == 200) {+ return res;+ } else {+ console.log('Failed to authorize the integration');+ }+ });+};++export default AuthorizeIntegration;diff --git a/frontend/pages/api/integrations/getWorkspaceAuthorizations.js b/frontend/pages/api/integrations/getWorkspaceAuthorizations.jsdeleted file mode 100644index ad8c4732b9..0000000000--- a/frontend/pages/api/integrations/getWorkspaceAuthorizations.js+++ /dev/null@@ -1,26 +0,0 @@-import SecurityClient from "~/utilities/SecurityClient";--/**- * This route gets authorizations of a certain project (Heroku, etc.)- * @param {*} workspaceId- * @returns- */-const getWorkspaceAuthorizations = ({ workspaceId }) => {- return SecurityClient.fetchCall(- "/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;diff --git a/frontend/pages/api/integrations/getWorkspaceAuthorizations.ts b/frontend/pages/api/integrations/getWorkspaceAuthorizations.tsnew file mode 100644index 0000000000..f1b4065550--- /dev/null+++ b/frontend/pages/api/integrations/getWorkspaceAuthorizations.ts@@ -0,0 +1,30 @@+import SecurityClient from '~/utilities/SecurityClient';++interface Props {+ workspaceId: string;+}++/**+ * This route gets authorizations of a certain project (Heroku, etc.)+ * @param {*} workspaceId+ * @returns+ */+const getWorkspaceAuthorizations = ({ workspaceId }: Props) => {+ return SecurityClient.fetchCall(+ '/api/v1/workspace/' + workspaceId + '/authorizations',+ {+ method: 'GET',+ headers: {+ 'Content-Type': 'application/json'+ }+ }+ ).then(async (res) => {+ if (res && res.status == 200) {+ return (await res.json()).authorizations;+ } else {+ console.log('Failed to get project authorizations');+ }+ });+};++export default getWorkspaceAuthorizations;diff --git a/frontend/pages/api/integrations/getWorkspaceIntegrations.js b/frontend/pages/api/integrations/getWorkspaceIntegrations.jsdeleted file mode 100644index 22470e4bea..0000000000--- a/frontend/pages/api/integrations/getWorkspaceIntegrations.js+++ /dev/null@@ -1,26 +0,0 @@-import SecurityClient from "~/utilities/SecurityClient";--/**- * This route gets integrations of a certain project (Heroku, etc.)- * @param {*} workspaceId- * @returns- */-const getWorkspaceIntegrations = ({ workspaceId }) => {- return SecurityClient.fetchCall(- "/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;diff --git a/frontend/pages/api/integrations/getWorkspaceIntegrations.ts b/frontend/pages/api/integrations/getWorkspaceIntegrations.tsnew file mode 100644index 0000000000..a33256749d--- /dev/null+++ b/frontend/pages/api/integrations/getWorkspaceIntegrations.ts@@ -0,0 +1,30 @@+import SecurityClient from '~/utilities/SecurityClient';++interface Props {+ workspaceId: string;+}++/**+ * This route gets integrations of a certain project (Heroku, etc.)+ * @param {*} workspaceId+ * @returns+ */+const getWorkspaceIntegrations = ({ workspaceId }: Props) => {+ return SecurityClient.fetchCall(+ '/api/v1/workspace/' + workspaceId + '/integrations',+ {+ method: 'GET',+ headers: {+ 'Content-Type': 'application/json'+ }+ }+ ).then(async (res) => {+ if (res && res.status == 200) {+ return (await res.json()).integrations;+ } else {+ console.log('Failed to get the project integrations');+ }+ });+};++export default getWorkspaceIntegrations;diff --git a/frontend/pages/api/organization/GetOrgProjects.js b/frontend/pages/api/organization/GetOrgProjects.jsdeleted file mode 100644index 656fea18f9..0000000000--- a/frontend/pages/api/organization/GetOrgProjects.js+++ /dev/null@@ -1,27 +0,0 @@-import SecurityClient from "~/utilities/SecurityClient";--/**- * This route lets us get all the users in an org.- * @param {*} req- * @param {*} res- * @returns- */-const getOrganizationProjects = (req, res) => {- return SecurityClient.fetchCall(- "/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;diff --git a/frontend/pages/api/organization/GetOrgProjects.ts b/frontend/pages/api/organization/GetOrgProjects.tsnew file mode 100644index 0000000000..9546944863--- /dev/null+++ b/frontend/pages/api/organization/GetOrgProjects.ts@@ -0,0 +1,29 @@+import SecurityClient from '~/utilities/SecurityClient';++/**+ * This route lets us get all the users in an org.+ * @param {*} req+ * @param {*} res+ * @returns+ */++// TODO: this file is not used anywhere+const getOrganizationProjects = (req: { orgId: string }) => {+ return SecurityClient.fetchCall(+ '/api/organization/' + req.orgId + '/workspaces',+ {+ method: 'GET',+ headers: {+ 'Content-Type': 'application/json'+ }+ }+ ).then(async (res) => {+ if (res && res.status == 200) {+ return (await res.json()).workspaces;+ } else {+ console.log('Failed to get projects for an org');+ }+ });+};++export default getOrganizationProjects;diff --git a/frontend/pages/api/organization/GetOrgSubscription.js b/frontend/pages/api/organization/GetOrgSubscription.jsdeleted file mode 100644index 97c6f4e5ce..0000000000--- a/frontend/pages/api/organization/GetOrgSubscription.js+++ /dev/null@@ -1,27 +0,0 @@-import SecurityClient from "~/utilities/SecurityClient";--/**- * This route lets us get the current subscription of an org.- * @param {*} req- * @param {*} res- * @returns- */-const getOrganizationSubscriptions = (req, res) => {- return SecurityClient.fetchCall(- "/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;diff --git a/frontend/pages/api/organization/GetOrgSubscription.ts b/frontend/pages/api/organization/GetOrgSubscription.tsnew file mode 100644index 0000000000..c93679cdc8--- /dev/null+++ b/frontend/pages/api/organization/GetOrgSubscription.ts@@ -0,0 +1,27 @@+import SecurityClient from '~/utilities/SecurityClient';++/**+ * This route lets us get the current subscription of an org.+ * @param {*} req+ * @param {*} res+ * @returns+ */+const getOrganizationSubscriptions = (req: { orgId: string }) => {+ return SecurityClient.fetchCall(+ '/api/v1/organization/' + req.orgId + '/subscriptions',+ {+ method: 'GET',+ headers: {+ 'Content-Type': 'application/json'+ }+ }+ ).then(async (res) => {+ if (res && res.status == 200) {+ return (await res.json()).subscriptions;+ } else {+ console.log('Failed to get org subscriptions');+ }+ });+};++export default getOrganizationSubscriptions;diff --git a/frontend/pages/api/organization/GetOrgUserProjects.js b/frontend/pages/api/organization/GetOrgUserProjects.jsdeleted file mode 100644index c2d751f64d..0000000000--- a/frontend/pages/api/organization/GetOrgUserProjects.js+++ /dev/null@@ -1,27 +0,0 @@-import SecurityClient from "~/utilities/SecurityClient";--/**- * This route lets us get all the projects of a certain user in an org.- * @param {*} req- * @param {*} res- * @returns- */-const getOrganizationUserProjects = (req) => {- return SecurityClient.fetchCall(- "/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;diff --git a/frontend/pages/api/organization/GetOrgUserProjects.ts b/frontend/pages/api/organization/GetOrgUserProjects.tsnew file mode 100644index 0000000000..872b8d7818--- /dev/null+++ b/frontend/pages/api/organization/GetOrgUserProjects.ts@@ -0,0 +1,27 @@+import SecurityClient from '~/utilities/SecurityClient';++/**+ * This route lets us get all the projects of a certain user in an org.+ * @param {*} req+ * @param {*} res+ * @returns+ */+const getOrganizationUserProjects = (req: { orgId: string }) => {+ return SecurityClient.fetchCall(+ '/api/v1/organization/' + req.orgId + '/my-workspaces',+ {+ method: 'GET',+ headers: {+ 'Content-Type': 'application/json'+ }+ }+ ).then(async (res) => {+ if (res && res.status == 200) {+ return (await res.json()).workspaces;+ } else {+ console.log('Failed to get projects of a user in an org');+ }+ });+};++export default getOrganizationUserProjects;diff --git a/frontend/pages/api/organization/StripeRedirect.js b/frontend/pages/api/organization/StripeRedirect.jsdeleted file mode 100644index e8911cf53c..0000000000--- a/frontend/pages/api/organization/StripeRedirect.js+++ /dev/null@@ -1,27 +0,0 @@-import SecurityClient from "~/utilities/SecurityClient";--/**- * This route redirects the user to the right stripe billing page.- * @param {*} req- * @param {*} res- * @returns- */-const StripeRedirect = ({ orgId }) => {- return SecurityClient.fetchCall(- "/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;diff --git a/frontend/pages/api/organization/StripeRedirect.ts b/frontend/pages/api/organization/StripeRedirect.tsnew file mode 100644index 0000000000..a9fe1f066d--- /dev/null+++ b/frontend/pages/api/organization/StripeRedirect.ts@@ -0,0 +1,27 @@+import SecurityClient from '~/utilities/SecurityClient';++/**+ * This route redirects the user to the right stripe billing page.+ * @param {*} req+ * @param {*} res+ * @returns+ */+const StripeRedirect = ({ orgId }: { orgId: string }) => {+ return SecurityClient.fetchCall(+ '/api/v1/organization/' + orgId + '/customer-portal-session',+ {+ method: 'POST',+ headers: {+ 'Content-Type': 'application/json'+ }+ }+ ).then(async (res) => {+ if (res && res.status == 200) {+ return (window.location.href = (await res.json()).url);+ } else {+ console.log('Failed to redirect to Stripe');+ }+ });+};++export default StripeRedirect;diff --git a/frontend/pages/api/organization/addIncidentContact.js b/frontend/pages/api/organization/addIncidentContact.jsdeleted file mode 100644index 0e6068a1a1..0000000000--- a/frontend/pages/api/organization/addIncidentContact.js+++ /dev/null@@ -1,29 +0,0 @@-import SecurityClient from "~/utilities/SecurityClient";--/**- * This route add an incident contact email to a certain organization- * @param {*} param0- * @returns- */-const addIncidentContact = (organizationId, email) => {- return SecurityClient.fetchCall(- "/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;diff --git a/frontend/pages/api/organization/addIncidentContact.ts b/frontend/pages/api/organization/addIncidentContact.tsnew file mode 100644index 0000000000..d3676e6419--- /dev/null+++ b/frontend/pages/api/organization/addIncidentContact.ts@@ -0,0 +1,29 @@+import SecurityClient from '~/utilities/SecurityClient';++/**+ * This route add an incident contact email to a certain organization+ * @param {*} param0+ * @returns+ */+const addIncidentContact = (organizationId: string, email: string) => {+ return SecurityClient.fetchCall(+ '/api/v1/organization/' + organizationId + '/incidentContactOrg',+ {+ method: 'POST',+ headers: {+ 'Content-Type': 'application/json'+ },+ body: JSON.stringify({+ email: email+ })+ }+ ).then(async (res) => {+ if (res && res.status == 200) {+ return res;+ } else {+ console.log('Failed to add an incident contact');+ }+ });+};++export default addIncidentContact;diff --git a/frontend/pages/api/organization/addUserToOrg.js b/frontend/pages/api/organization/addUserToOrg.jsdeleted file mode 100644index 15f22cff93..0000000000--- a/frontend/pages/api/organization/addUserToOrg.js+++ /dev/null@@ -1,28 +0,0 @@-import SecurityClient from "~/utilities/SecurityClient";--/**- * 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("/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;diff --git a/frontend/pages/api/organization/addUserToOrg.ts b/frontend/pages/api/organization/addUserToOrg.tsnew file mode 100644index 0000000000..70dbad56cc--- /dev/null+++ b/frontend/pages/api/organization/addUserToOrg.ts@@ -0,0 +1,28 @@+import SecurityClient from '~/utilities/SecurityClient';++/**+ * This function sends an email invite to a user to join an org+ * @param {*} email+ * @param {*} orgId+ * @returns+ */+const addUserToOrg = (email: string, orgId: string) => {+ return SecurityClient.fetchCall('/api/v1/invite-org/signup', {+ method: 'POST',+ headers: {+ 'Content-Type': 'application/json'+ },+ body: JSON.stringify({+ inviteeEmail: email,+ organizationId: orgId+ })+ }).then(async (res) => {+ if (res && res.status == 200) {+ return res;+ } else {+ console.log('Failed to add a user to an org');+ }+ });+};++export default addUserToOrg;diff --git a/frontend/pages/api/organization/deleteIncidentContact.js b/frontend/pages/api/organization/deleteIncidentContact.jsdeleted file mode 100644index f6e57c5905..0000000000--- a/frontend/pages/api/organization/deleteIncidentContact.js+++ /dev/null@@ -1,29 +0,0 @@-import SecurityClient from "~/utilities/SecurityClient";--/**- * This route deletes an incident Contact from a certain organization- * @param {*} param0- * @returns- */-const deleteIncidentContact = (organizaionId, email) => {- return SecurityClient.fetchCall(- "/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;diff --git a/frontend/pages/api/organization/deleteIncidentContact.ts b/frontend/pages/api/organization/deleteIncidentContact.tsnew file mode 100644index 0000000000..fd6374e9b6--- /dev/null+++ b/frontend/pages/api/organization/deleteIncidentContact.ts@@ -0,0 +1,29 @@+import SecurityClient from '~/utilities/SecurityClient';++/**+ * This route deletes an incident Contact from a certain organization+ * @param {*} param0+ * @returns+ */+const deleteIncidentContact = (organizationId: string, email: string) => {+ return SecurityClient.fetchCall(+ '/api/v1/organization/' + organizationId + '/incidentContactOrg',+ {+ method: 'DELETE',+ headers: {+ 'Content-Type': 'application/json'+ },+ body: JSON.stringify({+ email: email+ })+ }+ ).then(async (res) => {+ if (res && res.status == 200) {+ return res;+ } else {+ console.log('Failed to delete an incident contact');+ }+ });+};++export default deleteIncidentContact;diff --git a/frontend/pages/api/organization/deleteUserFromOrganization.js b/frontend/pages/api/organization/deleteUserFromOrganization.jsdeleted file mode 100644index 66ea847939..0000000000--- a/frontend/pages/api/organization/deleteUserFromOrganization.js+++ /dev/null@@ -1,26 +0,0 @@-import SecurityClient from "~/utilities/SecurityClient";--/**- * This function removes a certain member from a certain organization- * @param {*} membershipId- * @returns- */-const deleteUserFromOrganization = (membershipId) => {- return SecurityClient.fetchCall(- "/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;diff --git a/frontend/pages/api/organization/deleteUserFromOrganization.ts b/frontend/pages/api/organization/deleteUserFromOrganization.tsnew file mode 100644index 0000000000..988a09485a--- /dev/null+++ b/frontend/pages/api/organization/deleteUserFromOrganization.ts@@ -0,0 +1,23 @@+import SecurityClient from '~/utilities/SecurityClient';++/**+ * This function removes a certain member from a certain organization+ * @param {*} membershipId+ * @returns+ */+const deleteUserFromOrganization = (membershipId: string) => {+ return SecurityClient.fetchCall('/api/v1/membership-org/' + membershipId, {+ method: 'DELETE',+ headers: {+ 'Content-Type': 'application/json'+ }+ }).then(async (res) => {+ if (res && res.status == 200) {+ return res;+ } else {+ console.log('Failed to delete a user from an org');+ }+ });+};++export default deleteUserFromOrganization;diff --git a/frontend/pages/api/organization/getIncidentContacts.js b/frontend/pages/api/organization/getIncidentContacts.jsdeleted file mode 100644index 4f3f61a487..0000000000--- a/frontend/pages/api/organization/getIncidentContacts.js+++ /dev/null@@ -1,26 +0,0 @@-import SecurityClient from "~/utilities/SecurityClient";--/**- * This routes gets all the incident contacts of a certain organization- * @param {*} workspaceId- * @returns- */-const getIncidentContacts = (organizationId) => {- return SecurityClient.fetchCall(- "/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;diff --git a/frontend/pages/api/organization/getIncidentContacts.ts b/frontend/pages/api/organization/getIncidentContacts.tsnew file mode 100644index 0000000000..bb9c3613a7--- /dev/null+++ b/frontend/pages/api/organization/getIncidentContacts.ts@@ -0,0 +1,26 @@+import SecurityClient from '~/utilities/SecurityClient';++/**+ * This routes gets all the incident contacts of a certain organization+ * @param {*} workspaceId+ * @returns+ */+const getIncidentContacts = (organizationId: string) => {+ return SecurityClient.fetchCall(+ '/api/v1/organization/' + organizationId + '/incidentContactOrg',+ {+ method: 'GET',+ headers: {+ 'Content-Type': 'application/json'+ }+ }+ ).then(async (res) => {+ if (res && res.status == 200) {+ return (await res.json()).incidentContactsOrg;+ } else {+ console.log('Failed to get incident contacts');+ }+ });+};++export default getIncidentContacts;diff --git a/frontend/pages/api/organization/renameOrg.js b/frontend/pages/api/organization/renameOrg.jsdeleted file mode 100644index a9d80a3a53..0000000000--- a/frontend/pages/api/organization/renameOrg.js+++ /dev/null@@ -1,30 +0,0 @@-import SecurityClient from "~/utilities/SecurityClient";--/**- * This route lets us rename a certain org.- * @param {*} req- * @param {*} res- * @returns- */-const renameOrg = (orgId, newOrgName) => {- return SecurityClient.fetchCall(- "/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;diff --git a/frontend/pages/api/organization/renameOrg.ts b/frontend/pages/api/organization/renameOrg.tsnew file mode 100644index 0000000000..c5c0b4d65b--- /dev/null+++ b/frontend/pages/api/organization/renameOrg.ts@@ -0,0 +1,27 @@+import SecurityClient from '~/utilities/SecurityClient';++/**+ * This route lets us rename a certain org.+ * @param {*} req+ * @param {*} res+ * @returns+ */+const renameOrg = (orgId: string, newOrgName: string) => {+ return SecurityClient.fetchCall('/api/v1/organization/' + orgId + '/name', {+ method: 'PATCH',+ headers: {+ 'Content-Type': 'application/json'+ },+ body: JSON.stringify({+ name: newOrgName+ })+ }).then(async (res) => {+ if (res && res.status == 200) {+ return res;+ } else {+ console.log('Failed to rename an organization');+ }+ });+};++export default renameOrg;diff --git a/frontend/pages/api/serviceToken/addServiceToken.js b/frontend/pages/api/serviceToken/addServiceToken.tssimilarity index 51%rename from frontend/pages/api/serviceToken/addServiceToken.jsrename to frontend/pages/api/serviceToken/addServiceToken.tsindex 4c6031db84..5dad69f69c 100644--- a/frontend/pages/api/serviceToken/addServiceToken.js+++ b/frontend/pages/api/serviceToken/addServiceToken.ts@@ -1,4 +1,14 @@-import SecurityClient from "~/utilities/SecurityClient";+import SecurityClient from '~/utilities/SecurityClient';++interface Props {+ name: string;+ workspaceId: string;+ environment: string;+ expiresIn: number;+ publicKey: string;+ encryptedKey: string;+ nonce: string;+}/*** This route gets service tokens for a specific user in a project@@ -12,12 +22,12 @@ const addServiceToken = ({expiresIn,publicKey,encryptedKey,- nonce,-}) => {- return SecurityClient.fetchCall("/api/v1/service-token/", {- method: "POST",+ nonce+}: Props) => {+ return SecurityClient.fetchCall('/api/v1/service-token/', {+ method: 'POST',headers: {- "Content-Type": "application/json",+ 'Content-Type': 'application/json'},body: JSON.stringify({name,@@ -26,13 +36,13 @@ const addServiceToken = ({expiresIn,publicKey,encryptedKey,- nonce,- }),+ nonce+ })}).then(async (res) => {- if (res.status == 200) {+ if (res && res.status == 200) {return (await res.json()).token;} else {- console.log("Failed to add service tokens");+ console.log('Failed to add service tokens');}});};diff --git a/frontend/pages/api/serviceToken/getServiceTokens.js b/frontend/pages/api/serviceToken/getServiceTokens.jsdeleted file mode 100644index 79c6a7fc06..0000000000--- a/frontend/pages/api/serviceToken/getServiceTokens.js+++ /dev/null@@ -1,26 +0,0 @@-import SecurityClient from "~/utilities/SecurityClient";--/**- * This route gets service tokens for a specific user in a project- * @param {*} param0- * @returns- */-const getServiceTokens = ({ workspaceId }) => {- return SecurityClient.fetchCall(- "/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;diff --git a/frontend/pages/api/serviceToken/getServiceTokens.ts b/frontend/pages/api/serviceToken/getServiceTokens.tsnew file mode 100644index 0000000000..d2577cc831--- /dev/null+++ b/frontend/pages/api/serviceToken/getServiceTokens.ts@@ -0,0 +1,26 @@+import SecurityClient from '~/utilities/SecurityClient';++/**+ * This route gets service tokens for a specific user in a project+ * @param {*} param0+ * @returns+ */+const getServiceTokens = ({ workspaceId }: { workspaceId: string }) => {+ return SecurityClient.fetchCall(+ '/api/v1/workspace/' + workspaceId + '/service-tokens',+ {+ method: 'GET',+ headers: {+ 'Content-Type': 'application/json'+ }+ }+ ).then(async (res) => {+ if (res && res.status == 200) {+ return (await res.json()).serviceTokens;+ } else {+ console.log('Failed to get service tokens');+ }+ });+};++export default getServiceTokens;diff --git a/frontend/pages/api/userActions/checkUserAction.js b/frontend/pages/api/userActions/checkUserAction.tssimilarity index 51%rename from frontend/pages/api/userActions/checkUserAction.jsrename to frontend/pages/api/userActions/checkUserAction.tsindex dfe2178563..9941ae85a9 100644--- a/frontend/pages/api/userActions/checkUserAction.js+++ b/frontend/pages/api/userActions/checkUserAction.ts@@ -1,4 +1,4 @@-import SecurityClient from "~/utilities/SecurityClient";+import SecurityClient from '~/utilities/SecurityClient';/*** This route registers a certain action for a user@@ -6,24 +6,24 @@ import SecurityClient from "~/utilities/SecurityClient";* @param {*} workspaceId* @returns*/-const checkUserAction = ({ action }) => {+const checkUserAction = ({ action }: { action: string }) => {return SecurityClient.fetchCall(- "/api/v1/user-action" +- "?" ++ '/api/v1/user-action' ++ '?' +new URLSearchParams({- action,+ action}),{- method: "GET",+ method: 'GET',headers: {- "Content-Type": "application/json",- },+ 'Content-Type': 'application/json'+ }}).then(async (res) => {- if (res.status == 200) {+ if (res && res.status == 200) {return (await res.json()).userAction;} else {- console.log("Failed to check a user action");+ console.log('Failed to check a user action');}});};diff --git a/frontend/pages/api/userActions/registerUserAction.js b/frontend/pages/api/userActions/registerUserAction.jsdeleted file mode 100644index 619886d897..0000000000--- a/frontend/pages/api/userActions/registerUserAction.js+++ /dev/null@@ -1,26 +0,0 @@-import SecurityClient from "~/utilities/SecurityClient";--/**- * This route registers a certain action for a user- * @param {*} action- * @returns- */-const registerUserAction = ({ action }) => {- return SecurityClient.fetchCall("/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;diff --git a/frontend/pages/api/userActions/registerUserAction.ts b/frontend/pages/api/userActions/registerUserAction.tsnew file mode 100644index 0000000000..d8f4d41e6e--- /dev/null+++ b/frontend/pages/api/userActions/registerUserAction.ts@@ -0,0 +1,26 @@+import SecurityClient from '~/utilities/SecurityClient';++/**+ * This route registers a certain action for a user+ * @param {*} action+ * @returns+ */+const registerUserAction = ({ action }: { action: string }) => {+ return SecurityClient.fetchCall('/api/v1/user-action', {+ method: 'POST',+ headers: {+ 'Content-Type': 'application/json'+ },+ body: JSON.stringify({+ action+ })+ }).then(async (res) => {+ if (res && res.status == 200) {+ return res;+ } else {+ console.log('Failed to register a user action');+ }+ });+};++export default registerUserAction;diff --git a/frontend/pages/api/workspace/addUserToWorkspace.js b/frontend/pages/api/workspace/addUserToWorkspace.jsdeleted file mode 100644index 86e991389f..0000000000--- a/frontend/pages/api/workspace/addUserToWorkspace.js+++ /dev/null@@ -1,30 +0,0 @@-import SecurityClient from "~/utilities/SecurityClient";--/**- * This function adds a user to a project- * @param {*} email- * @param {*} workspaceId- * @returns- */-const addUserToWorkspace = (email, workspaceId) => {- return SecurityClient.fetchCall(- "/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;diff --git a/frontend/pages/api/workspace/addUserToWorkspace.ts b/frontend/pages/api/workspace/addUserToWorkspace.tsnew file mode 100644index 0000000000..e1efa51a1a--- /dev/null+++ b/frontend/pages/api/workspace/addUserToWorkspace.ts@@ -0,0 +1,30 @@+import SecurityClient from '~/utilities/SecurityClient';++/**+ * This function adds a user to a project+ * @param {*} email+ * @param {*} workspaceId+ * @returns+ */+const addUserToWorkspace = (email: string, workspaceId: string) => {+ return SecurityClient.fetchCall(+ '/api/v1/workspace/' + workspaceId + '/invite-signup',+ {+ method: 'POST',+ headers: {+ 'Content-Type': 'application/json'+ },+ body: JSON.stringify({+ email: email+ })+ }+ ).then(async (res) => {+ if (res && res.status == 200) {+ return await res.json();+ } else {+ console.log('Failed to add a user to project');+ }+ });+};++export default addUserToWorkspace;diff --git a/frontend/pages/api/workspace/changeUserRoleInWorkspace.js b/frontend/pages/api/workspace/changeUserRoleInWorkspace.jsdeleted file mode 100644index a93e22181a..0000000000--- a/frontend/pages/api/workspace/changeUserRoleInWorkspace.js+++ /dev/null@@ -1,30 +0,0 @@-import SecurityClient from "~/utilities/SecurityClient";--/**- * This function change the access of a user in a certain workspace- * @param {*} membershipId- * @param {*} role- * @returns- */-const changeUserRoleInWorkspace = (membershipId, role) => {- return SecurityClient.fetchCall(- "/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;diff --git a/frontend/pages/api/workspace/changeUserRoleInWorkspace.ts b/frontend/pages/api/workspace/changeUserRoleInWorkspace.tsnew file mode 100644index 0000000000..9ac49440a7--- /dev/null+++ b/frontend/pages/api/workspace/changeUserRoleInWorkspace.ts@@ -0,0 +1,30 @@+import SecurityClient from '~/utilities/SecurityClient';++/**+ * This function change the access of a user in a certain workspace+ * @param {*} membershipId+ * @param {*} role+ * @returns+ */+const changeUserRoleInWorkspace = (membershipId: string, role: string) => {+ return SecurityClient.fetchCall(+ '/api/v1/membership/' + membershipId + '/change-role',+ {+ method: 'POST',+ headers: {+ 'Content-Type': 'application/json'+ },+ body: JSON.stringify({+ role: role+ })+ }+ ).then(async (res) => {+ if (res && res.status == 200) {+ return res;+ } else {+ console.log('Failed to change the user role in a project');+ }+ });+};++export default changeUserRoleInWorkspace;diff --git a/frontend/pages/api/workspace/deleteUserFromWorkspace.js b/frontend/pages/api/workspace/deleteUserFromWorkspace.jsdeleted file mode 100644index bad8beced1..0000000000--- a/frontend/pages/api/workspace/deleteUserFromWorkspace.js+++ /dev/null@@ -1,23 +0,0 @@-import SecurityClient from "~/utilities/SecurityClient";--/**- * This function removes a certain member from a certain workspace- * @param {*} membershipId- * @returns- */-const deleteUserFromWorkspace = (membershipId) => {- return SecurityClient.fetchCall("/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;diff --git a/frontend/pages/api/workspace/deleteUserFromWorkspace.ts b/frontend/pages/api/workspace/deleteUserFromWorkspace.tsnew file mode 100644index 0000000000..ea02f96d44--- /dev/null+++ b/frontend/pages/api/workspace/deleteUserFromWorkspace.ts@@ -0,0 +1,23 @@+import SecurityClient from '~/utilities/SecurityClient';++/**+ * This function removes a certain member from a certain workspace+ * @param {*} membershipId+ * @returns+ */+const deleteUserFromWorkspace = (membershipId: string) => {+ return SecurityClient.fetchCall('/api/v1/membership/' + membershipId, {+ method: 'DELETE',+ headers: {+ 'Content-Type': 'application/json'+ }+ }).then(async (res) => {+ if (res && res.status == 200) {+ return res;+ } else {+ console.log('Failed to delete a user from a project');+ }+ });+};++export default deleteUserFromWorkspace;diff --git a/frontend/pages/api/workspace/deleteWorkspace.js b/frontend/pages/api/workspace/deleteWorkspace.jsdeleted file mode 100644index 33d34844d6..0000000000--- a/frontend/pages/api/workspace/deleteWorkspace.js+++ /dev/null@@ -1,23 +0,0 @@-import SecurityClient from "~/utilities/SecurityClient";--/**- * This route deletes a specified workspace.- * @param {*} workspaceId- * @returns- */-const deleteWorkspace = (workspaceId) => {- return SecurityClient.fetchCall("/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;diff --git a/frontend/pages/api/workspace/deleteWorkspace.ts b/frontend/pages/api/workspace/deleteWorkspace.tsnew file mode 100644index 0000000000..2bdb64cd31--- /dev/null+++ b/frontend/pages/api/workspace/deleteWorkspace.ts@@ -0,0 +1,23 @@+import SecurityClient from '~/utilities/SecurityClient';++/**+ * This route deletes a specified workspace.+ * @param {*} workspaceId+ * @returns+ */+const deleteWorkspace = (workspaceId: string) => {+ return SecurityClient.fetchCall('/api/v1/workspace/' + workspaceId, {+ method: 'DELETE',+ headers: {+ 'Content-Type': 'application/json'+ }+ }).then(async (res) => {+ if (res && res.status == 200) {+ return res;+ } else {+ console.log('Failed to delete a project');+ }+ });+};++export default deleteWorkspace;diff --git a/frontend/pages/api/workspace/renameWorkspace.js b/frontend/pages/api/workspace/renameWorkspace.jsdeleted file mode 100644index 6dd297f820..0000000000--- a/frontend/pages/api/workspace/renameWorkspace.js+++ /dev/null@@ -1,30 +0,0 @@-import SecurityClient from "~/utilities/SecurityClient";--/**- * This route lets us rename a certain workspace.- * @param {*} req- * @param {*} res- * @returns- */-const renameWorkspace = (workspaceId, newWorkspaceName) => {- return SecurityClient.fetchCall(- "/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;diff --git a/frontend/pages/api/workspace/renameWorkspace.ts b/frontend/pages/api/workspace/renameWorkspace.tsnew file mode 100644index 0000000000..a25d2068c1--- /dev/null+++ b/frontend/pages/api/workspace/renameWorkspace.ts@@ -0,0 +1,30 @@+import SecurityClient from '~/utilities/SecurityClient';++/**+ * This route lets us rename a certain workspace.+ * @param {*} req+ * @param {*} res+ * @returns+ */+const renameWorkspace = (workspaceId: string, newWorkspaceName: string) => {+ return SecurityClient.fetchCall(+ '/api/v1/workspace/' + workspaceId + '/name',+ {+ method: 'POST',+ headers: {+ 'Content-Type': 'application/json'+ },+ body: JSON.stringify({+ name: newWorkspaceName+ })+ }+ ).then(async (res) => {+ if (res && res.status == 200) {+ return res;+ } else {+ console.log('Failed to rename a project');+ }+ });+};++export default renameWorkspace;diff --git a/frontend/pages/api/workspace/uploadKeys.js b/frontend/pages/api/workspace/uploadKeys.jsdeleted file mode 100644index 37b384f304..0000000000--- a/frontend/pages/api/workspace/uploadKeys.js+++ /dev/null@@ -1,33 +0,0 @@-import SecurityClient from "~/utilities/SecurityClient";--/**- * 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("/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;diff --git a/frontend/pages/api/workspace/uploadKeys.ts b/frontend/pages/api/workspace/uploadKeys.tsnew file mode 100644index 0000000000..2f791735d9--- /dev/null+++ b/frontend/pages/api/workspace/uploadKeys.ts@@ -0,0 +1,38 @@+import SecurityClient from '~/utilities/SecurityClient';++/**+ * This route uplods the keys in an encrypted format.+ * @param {*} workspaceId+ * @param {*} userId+ * @param {*} encryptedKey+ * @param {*} nonce+ * @returns+ */+const uploadKeys = (+ workspaceId: string,+ userId: string,+ encryptedKey: string,+ nonce: string+) => {+ return SecurityClient.fetchCall('/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 && res.status == 200) {+ return res;+ } else {+ console.log('Failed to upload keys for a new user');+ }+ });+};++export default uploadKeys;