mirror of
https://github.com/awatertrevi/infisical.git
synced 2026-10-16 17:30:06 +00:00
chore(frontend): fixed all eslint errors
This commit is contained in:
@@ -1,4 +1,4 @@
|
||||
import SecurityClient from '~/utilities/SecurityClient';
|
||||
import SecurityClient from '@app/components/utilities/SecurityClient';
|
||||
|
||||
interface Props {
|
||||
name: string;
|
||||
@@ -12,11 +12,8 @@ interface Props {
|
||||
* @param {string} obj.expiresIn - how soon the API key expires in ms
|
||||
* @returns
|
||||
*/
|
||||
const addAPIKey = ({
|
||||
name,
|
||||
expiresIn,
|
||||
}: Props) => {
|
||||
return SecurityClient.fetchCall('/api/v2/api-key/', {
|
||||
const addAPIKey = ({ name, expiresIn }: Props) =>
|
||||
SecurityClient.fetchCall('/api/v2/api-key/', {
|
||||
method: 'POST',
|
||||
headers: {
|
||||
'Content-Type': 'application/json'
|
||||
@@ -26,12 +23,11 @@ const addAPIKey = ({
|
||||
expiresIn
|
||||
})
|
||||
}).then(async (res) => {
|
||||
if (res && res.status == 200) {
|
||||
return (await res.json());
|
||||
} else {
|
||||
console.log('Failed to add API key');
|
||||
if (res && res.status === 200) {
|
||||
return res.json();
|
||||
}
|
||||
console.log('Failed to add API key');
|
||||
return undefined;
|
||||
});
|
||||
};
|
||||
|
||||
export default addAPIKey;
|
||||
|
||||
@@ -1,4 +1,4 @@
|
||||
import SecurityClient from '~/utilities/SecurityClient';
|
||||
import SecurityClient from '@app/components/utilities/SecurityClient';
|
||||
|
||||
interface Props {
|
||||
apiKeyId: string;
|
||||
@@ -10,21 +10,18 @@ interface Props {
|
||||
* @param {string} obj.apiKeyId - id of the API key to delete
|
||||
* @returns
|
||||
*/
|
||||
const deleteAPIKey = ({
|
||||
apiKeyId
|
||||
}: Props) => {
|
||||
return SecurityClient.fetchCall('/api/v2/api-key/' + apiKeyId, {
|
||||
const deleteAPIKey = ({ apiKeyId }: Props) =>
|
||||
SecurityClient.fetchCall(`/api/v2/api-key/${apiKeyId}`, {
|
||||
method: 'DELETE',
|
||||
headers: {
|
||||
'Content-Type': 'application/json'
|
||||
},
|
||||
}).then(async (res) => {
|
||||
if (res && res.status == 200) {
|
||||
return (await res.json());
|
||||
} else {
|
||||
console.log('Failed to delete API key');
|
||||
}
|
||||
}).then(async (res) => {
|
||||
if (res && res.status === 200) {
|
||||
return res.json();
|
||||
}
|
||||
console.log('Failed to delete API key');
|
||||
return undefined;
|
||||
});
|
||||
};
|
||||
|
||||
export default deleteAPIKey;
|
||||
|
||||
@@ -1,26 +1,22 @@
|
||||
import SecurityClient from '~/utilities/SecurityClient';
|
||||
import SecurityClient from '@app/components/utilities/SecurityClient';
|
||||
|
||||
/**
|
||||
* This route gets API keys for the user
|
||||
* @param {*} param0
|
||||
* @returns
|
||||
*/
|
||||
const getAPIKeys = () => {
|
||||
return SecurityClient.fetchCall(
|
||||
'/api/v2/api-key',
|
||||
{
|
||||
method: 'GET',
|
||||
headers: {
|
||||
'Content-Type': 'application/json'
|
||||
}
|
||||
const getAPIKeys = () =>
|
||||
SecurityClient.fetchCall('/api/v2/api-key', {
|
||||
method: 'GET',
|
||||
headers: {
|
||||
'Content-Type': 'application/json'
|
||||
}
|
||||
).then(async (res) => {
|
||||
if (res && res.status == 200) {
|
||||
return (await res.json()).apiKeyData;
|
||||
} else {
|
||||
console.log('Failed to get API keys');
|
||||
}).then(async (res) => {
|
||||
if (res && res.status === 200) {
|
||||
return (await res.json()).apiKeyData;
|
||||
}
|
||||
console.log('Failed to get API keys');
|
||||
return undefined;
|
||||
});
|
||||
};
|
||||
|
||||
export default getAPIKeys;
|
||||
|
||||
@@ -1,4 +1,4 @@
|
||||
import SecurityClient from '~/utilities/SecurityClient';
|
||||
import SecurityClient from '@app/components/utilities/SecurityClient';
|
||||
|
||||
interface Props {
|
||||
encryptedPrivateKey: string;
|
||||
@@ -14,34 +14,26 @@ interface Props {
|
||||
* @param {*} clientPublicKey
|
||||
* @returns
|
||||
*/
|
||||
const changePassword2 = ({
|
||||
encryptedPrivateKey,
|
||||
iv,
|
||||
tag,
|
||||
salt,
|
||||
verifier,
|
||||
clientProof
|
||||
}: Props) => {
|
||||
return SecurityClient.fetchCall('/api/v1/password/change-password', {
|
||||
const changePassword2 = ({ encryptedPrivateKey, iv, tag, salt, verifier, clientProof }: Props) =>
|
||||
SecurityClient.fetchCall('/api/v1/password/change-password', {
|
||||
method: 'POST',
|
||||
headers: {
|
||||
'Content-Type': 'application/json'
|
||||
},
|
||||
body: JSON.stringify({
|
||||
clientProof: clientProof,
|
||||
encryptedPrivateKey: encryptedPrivateKey,
|
||||
iv: iv,
|
||||
tag: tag,
|
||||
salt: salt,
|
||||
verifier: verifier
|
||||
clientProof,
|
||||
encryptedPrivateKey,
|
||||
iv,
|
||||
tag,
|
||||
salt,
|
||||
verifier
|
||||
})
|
||||
}).then(async (res) => {
|
||||
if (res && 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');
|
||||
return undefined;
|
||||
});
|
||||
};
|
||||
|
||||
export default changePassword2;
|
||||
|
||||
@@ -1,16 +1,15 @@
|
||||
import SecurityClient from '~/utilities/SecurityClient';
|
||||
import SecurityClient from '@app/components/utilities/SecurityClient';
|
||||
|
||||
/**
|
||||
* This function is used to check if the user is authenticated.
|
||||
* To do that, we get their tokens from cookies, and verify if they are good.
|
||||
*/
|
||||
const checkAuth = async () => {
|
||||
return SecurityClient.fetchCall('/api/v1/auth/checkAuth', {
|
||||
const checkAuth = async () =>
|
||||
SecurityClient.fetchCall('/api/v1/auth/checkAuth', {
|
||||
method: 'POST',
|
||||
headers: {
|
||||
'Content-Type': 'application/json'
|
||||
}
|
||||
}).then((res) => res);
|
||||
};
|
||||
|
||||
export default checkAuth;
|
||||
|
||||
@@ -10,17 +10,15 @@ interface Props {
|
||||
* @param {string} obj.code
|
||||
* @returns
|
||||
*/
|
||||
const checkEmailVerificationCode = ({ email, code }: Props) => {
|
||||
return fetch('/api/v1/signup/email/verify', {
|
||||
const checkEmailVerificationCode = ({ email, code }: Props) => fetch('/api/v1/signup/email/verify', {
|
||||
method: 'POST',
|
||||
headers: {
|
||||
'Content-Type': 'application/json'
|
||||
},
|
||||
body: JSON.stringify({
|
||||
email: email,
|
||||
code: code
|
||||
email,
|
||||
code
|
||||
})
|
||||
});
|
||||
};
|
||||
|
||||
export default checkEmailVerificationCode;
|
||||
|
||||
@@ -41,12 +41,11 @@ const completeAccountInformationSignup = ({
|
||||
salt,
|
||||
verifier,
|
||||
token
|
||||
}: Props) => {
|
||||
return fetch('/api/v1/signup/complete-account/signup', {
|
||||
}: Props) => fetch('/api/v1/signup/complete-account/signup', {
|
||||
method: 'POST',
|
||||
headers: {
|
||||
'Content-Type': 'application/json',
|
||||
Authorization: 'Bearer ' + token
|
||||
Authorization: `Bearer ${ token}`
|
||||
},
|
||||
body: JSON.stringify({
|
||||
email,
|
||||
@@ -61,6 +60,5 @@ const completeAccountInformationSignup = ({
|
||||
verifier
|
||||
})
|
||||
});
|
||||
};
|
||||
|
||||
export default completeAccountInformationSignup;
|
||||
|
||||
@@ -38,25 +38,23 @@ const completeAccountInformationSignupInvite = ({
|
||||
salt,
|
||||
verifier,
|
||||
token
|
||||
}: Props) => {
|
||||
return fetch('/api/v1/signup/complete-account/invite', {
|
||||
}: Props) => fetch('/api/v1/signup/complete-account/invite', {
|
||||
method: 'POST',
|
||||
headers: {
|
||||
'Content-Type': 'application/json',
|
||||
Authorization: 'Bearer ' + token
|
||||
Authorization: `Bearer ${ token}`
|
||||
},
|
||||
body: JSON.stringify({
|
||||
email: email,
|
||||
firstName: firstName,
|
||||
lastName: lastName,
|
||||
publicKey: publicKey,
|
||||
email,
|
||||
firstName,
|
||||
lastName,
|
||||
publicKey,
|
||||
encryptedPrivateKey: ciphertext,
|
||||
iv: iv,
|
||||
tag: tag,
|
||||
salt: salt,
|
||||
verifier: verifier
|
||||
iv,
|
||||
tag,
|
||||
salt,
|
||||
verifier
|
||||
})
|
||||
});
|
||||
};
|
||||
|
||||
export default completeAccountInformationSignupInvite;
|
||||
|
||||
@@ -18,8 +18,8 @@ const EmailVerifyOnPasswordReset = async ({ email, code }: Props) => {
|
||||
'Content-Type': 'application/json'
|
||||
},
|
||||
body: JSON.stringify({
|
||||
email: email,
|
||||
code: code
|
||||
email,
|
||||
code
|
||||
})
|
||||
});
|
||||
if (response?.status === 200) {
|
||||
|
||||
@@ -1,4 +1,4 @@
|
||||
import SecurityClient from '~/utilities/SecurityClient';
|
||||
import SecurityClient from '@app/components/utilities/SecurityClient';
|
||||
|
||||
interface Props {
|
||||
encryptedPrivateKey: string;
|
||||
@@ -27,19 +27,19 @@ const issueBackupPrivateKey = ({
|
||||
salt,
|
||||
verifier,
|
||||
clientProof
|
||||
}: Props) => {
|
||||
return SecurityClient.fetchCall('/api/v1/password/backup-private-key', {
|
||||
}: Props) =>
|
||||
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
|
||||
clientProof,
|
||||
encryptedPrivateKey,
|
||||
iv,
|
||||
tag,
|
||||
salt,
|
||||
verifier
|
||||
})
|
||||
}).then((res) => {
|
||||
if (res?.status !== 200) {
|
||||
@@ -47,6 +47,5 @@ const issueBackupPrivateKey = ({
|
||||
}
|
||||
return res;
|
||||
});
|
||||
};
|
||||
|
||||
export default issueBackupPrivateKey;
|
||||
|
||||
@@ -16,7 +16,7 @@ const login1 = async (email: string, clientPublicKey: string) => {
|
||||
"Content-Type": "application/json",
|
||||
},
|
||||
body: JSON.stringify({
|
||||
email: email,
|
||||
email,
|
||||
clientPublicKey,
|
||||
}),
|
||||
});
|
||||
|
||||
@@ -13,24 +13,24 @@ interface Login2Response {
|
||||
* @returns
|
||||
*/
|
||||
const login2 = async (email: string, clientProof: string) => {
|
||||
const response = await fetch("/api/v1/auth/login2", {
|
||||
method: "POST",
|
||||
const response = await fetch('/api/v1/auth/login2', {
|
||||
method: 'POST',
|
||||
headers: {
|
||||
"Content-Type": "application/json",
|
||||
'Content-Type': 'application/json'
|
||||
},
|
||||
body: JSON.stringify({
|
||||
email: email,
|
||||
clientProof,
|
||||
email,
|
||||
clientProof
|
||||
}),
|
||||
credentials: "include",
|
||||
credentials: 'include'
|
||||
});
|
||||
// need precise error handling about the status code
|
||||
if (response.status == 200) {
|
||||
if (response.status === 200) {
|
||||
const data = (await response.json()) as unknown as Login2Response;
|
||||
return data;
|
||||
}
|
||||
|
||||
throw new Error("Password verification failed");
|
||||
throw new Error('Password verification failed');
|
||||
};
|
||||
|
||||
export default login2;
|
||||
|
||||
@@ -1,18 +1,18 @@
|
||||
import SecurityClient from '~/utilities/SecurityClient';
|
||||
import SecurityClient from '@app/components/utilities/SecurityClient';
|
||||
|
||||
/**
|
||||
* This route logs the user out. Note: the user should authorized to do this.
|
||||
* We first try to log out - if the authorization fails (response.status = 401), we refetch the new token, and then retry
|
||||
*/
|
||||
const logout = async () => {
|
||||
return SecurityClient.fetchCall('/api/v1/auth/logout', {
|
||||
const logout = async () =>
|
||||
SecurityClient.fetchCall('/api/v1/auth/logout', {
|
||||
method: 'POST',
|
||||
headers: {
|
||||
'Content-Type': 'application/json'
|
||||
},
|
||||
credentials: 'include'
|
||||
}).then((res) => {
|
||||
if (res?.status == 200) {
|
||||
if (res?.status === 200) {
|
||||
SecurityClient.setToken('');
|
||||
// Delete the cookie by not setting a value; Alternatively clear the local storage
|
||||
localStorage.setItem('publicKey', '');
|
||||
@@ -22,10 +22,9 @@ const logout = async () => {
|
||||
localStorage.setItem('PRIVATE_KEY', '');
|
||||
console.log('User logged out', res);
|
||||
return res;
|
||||
} else {
|
||||
console.log('Failed to log out');
|
||||
}
|
||||
console.log('Failed to log out');
|
||||
return undefined;
|
||||
});
|
||||
};
|
||||
|
||||
export default logout;
|
||||
|
||||
@@ -1,4 +1,4 @@
|
||||
import SecurityClient from '~/utilities/SecurityClient';
|
||||
import SecurityClient from '@app/components/utilities/SecurityClient';
|
||||
|
||||
interface Props {
|
||||
clientPublicKey: string;
|
||||
@@ -9,8 +9,8 @@ interface Props {
|
||||
* @param {string} clientPublicKey
|
||||
* @returns
|
||||
*/
|
||||
const SRP1 = ({ clientPublicKey }: Props) => {
|
||||
return SecurityClient.fetchCall('/api/v1/password/srp1', {
|
||||
const SRP1 = ({ clientPublicKey }: Props) =>
|
||||
SecurityClient.fetchCall('/api/v1/password/srp1', {
|
||||
method: 'POST',
|
||||
headers: {
|
||||
'Content-Type': 'application/json'
|
||||
@@ -19,12 +19,11 @@ const SRP1 = ({ clientPublicKey }: Props) => {
|
||||
clientPublicKey
|
||||
})
|
||||
}).then(async (res) => {
|
||||
if (res && res.status == 200) {
|
||||
return await res.json();
|
||||
} else {
|
||||
console.log('Failed to do the first step of SRP');
|
||||
if (res && res.status === 200) {
|
||||
return res.json();
|
||||
}
|
||||
console.log('Failed to do the first step of SRP');
|
||||
return undefined;
|
||||
});
|
||||
};
|
||||
|
||||
export default SRP1;
|
||||
|
||||
@@ -16,7 +16,7 @@ const SendEmailOnPasswordReset = async ({ email }: Props) => {
|
||||
'Content-Type': 'application/json'
|
||||
},
|
||||
body: JSON.stringify({
|
||||
email: email
|
||||
email
|
||||
})
|
||||
});
|
||||
// need precise error handling about the status code
|
||||
|
||||
@@ -9,7 +9,7 @@ const sendVerificationEmail = (email: string) => {
|
||||
'Content-Type': 'application/json'
|
||||
},
|
||||
body: JSON.stringify({
|
||||
email: email
|
||||
email
|
||||
})
|
||||
});
|
||||
};
|
||||
|
||||
@@ -1,17 +1,16 @@
|
||||
const token = async () => {
|
||||
return fetch('/api/v1/auth/token', {
|
||||
const token = async () =>
|
||||
fetch('/api/v1/auth/token', {
|
||||
method: 'POST',
|
||||
headers: {
|
||||
'Content-Type': 'application/json'
|
||||
},
|
||||
credentials: 'include'
|
||||
}).then(async (res) => {
|
||||
if (res.status == 200) {
|
||||
if (res.status === 200) {
|
||||
return (await res.json()).token;
|
||||
} else {
|
||||
console.log('Getting a new token failed');
|
||||
}
|
||||
console.log('Getting a new token failed');
|
||||
return undefined;
|
||||
});
|
||||
};
|
||||
|
||||
export default token;
|
||||
|
||||
@@ -10,8 +10,7 @@ interface Props {
|
||||
* @param {string} obj.code - code that a user received to the abovementioned email
|
||||
* @returns
|
||||
*/
|
||||
const verifySignupInvite = ({ email, code }: Props) => {
|
||||
return fetch('/api/v1/invite-org/verify', {
|
||||
const verifySignupInvite = ({ email, code }: Props) => fetch('/api/v1/invite-org/verify', {
|
||||
method: 'POST',
|
||||
headers: {
|
||||
'Content-Type': 'application/json'
|
||||
@@ -21,6 +20,5 @@ const verifySignupInvite = ({ email, code }: Props) => {
|
||||
code
|
||||
})
|
||||
});
|
||||
};
|
||||
|
||||
export default verifySignupInvite;
|
||||
|
||||
@@ -8,12 +8,11 @@ const getBackupEncryptedPrivateKey = ({
|
||||
verificationToken
|
||||
}: {
|
||||
verificationToken: string;
|
||||
}) => {
|
||||
return fetch('/api/v1/password/backup-private-key', {
|
||||
}) => fetch('/api/v1/password/backup-private-key', {
|
||||
method: 'GET',
|
||||
headers: {
|
||||
'Content-Type': 'application/json',
|
||||
Authorization: 'Bearer ' + verificationToken
|
||||
Authorization: `Bearer ${ verificationToken}`
|
||||
}
|
||||
}).then(async (res) => {
|
||||
if (res?.status !== 200) {
|
||||
@@ -21,6 +20,5 @@ const getBackupEncryptedPrivateKey = ({
|
||||
}
|
||||
return (await res?.json())?.backupPrivateKey;
|
||||
});
|
||||
};
|
||||
|
||||
export default getBackupEncryptedPrivateKey;
|
||||
|
||||
@@ -1,10 +1,8 @@
|
||||
const publicKeyInfisical = () => {
|
||||
return fetch('/api/v1/key/publicKey/infisical', {
|
||||
const publicKeyInfisical = () => fetch('/api/v1/key/publicKey/infisical', {
|
||||
method: 'GET',
|
||||
headers: {
|
||||
'Content-Type': 'application/json'
|
||||
}
|
||||
});
|
||||
};
|
||||
|
||||
export default publicKeyInfisical;
|
||||
|
||||
@@ -25,19 +25,18 @@ const resetPasswordOnAccountRecovery = ({
|
||||
tag,
|
||||
salt,
|
||||
verifier
|
||||
}: Props) => {
|
||||
return fetch('/api/v1/password/password-reset', {
|
||||
}: Props) => fetch('/api/v1/password/password-reset', {
|
||||
method: 'POST',
|
||||
headers: {
|
||||
'Content-Type': 'application/json',
|
||||
Authorization: 'Bearer ' + verificationToken
|
||||
Authorization: `Bearer ${ verificationToken}`
|
||||
},
|
||||
body: JSON.stringify({
|
||||
encryptedPrivateKey: encryptedPrivateKey,
|
||||
iv: iv,
|
||||
tag: tag,
|
||||
salt: salt,
|
||||
verifier: verifier
|
||||
encryptedPrivateKey,
|
||||
iv,
|
||||
tag,
|
||||
salt,
|
||||
verifier
|
||||
})
|
||||
}).then(async (res) => {
|
||||
if (res?.status !== 200) {
|
||||
@@ -45,6 +44,5 @@ const resetPasswordOnAccountRecovery = ({
|
||||
}
|
||||
return res;
|
||||
});
|
||||
};
|
||||
|
||||
export default resetPasswordOnAccountRecovery;
|
||||
|
||||
@@ -1,4 +1,4 @@
|
||||
import SecurityClient from "~/utilities/SecurityClient";
|
||||
import SecurityClient from '@app/components/utilities/SecurityClient';
|
||||
|
||||
interface Props {
|
||||
workspaceId: string;
|
||||
@@ -10,22 +10,18 @@ interface Props {
|
||||
* @param {String} obj.workspaceId
|
||||
* @returns
|
||||
*/
|
||||
const getBot = async ({ workspaceId }: Props) => {
|
||||
return SecurityClient.fetchCall(
|
||||
"/api/v1/bot/" + workspaceId,
|
||||
{
|
||||
method: "GET",
|
||||
headers: {
|
||||
"Content-Type": "application/json",
|
||||
}
|
||||
const getBot = async ({ workspaceId }: Props) =>
|
||||
SecurityClient.fetchCall(`/api/v1/bot/${workspaceId}`, {
|
||||
method: 'GET',
|
||||
headers: {
|
||||
'Content-Type': 'application/json'
|
||||
}
|
||||
).then(async (res) => {
|
||||
if (res && res.status == 200) {
|
||||
}).then(async (res) => {
|
||||
if (res && res.status === 200) {
|
||||
return (await res.json()).bot;
|
||||
} else {
|
||||
console.log("Failed to get bot for project");
|
||||
}
|
||||
console.log('Failed to get bot for project');
|
||||
return undefined;
|
||||
});
|
||||
};
|
||||
|
||||
export default getBot;
|
||||
export default getBot;
|
||||
|
||||
@@ -1,4 +1,4 @@
|
||||
import SecurityClient from "~/utilities/SecurityClient";
|
||||
import SecurityClient from '@app/components/utilities/SecurityClient';
|
||||
|
||||
interface BotKey {
|
||||
encryptedKey: string;
|
||||
@@ -10,10 +10,10 @@ interface Props {
|
||||
isActive: boolean;
|
||||
botKey: BotKey;
|
||||
}
|
||||
|
||||
|
||||
/**
|
||||
* This function sets the active status of a bot and shares a copy of
|
||||
* the project key (encrypted under the bot's public key) with the
|
||||
* the project key (encrypted under the bot's public key) with the
|
||||
* project's bot
|
||||
* @param {Object} obj
|
||||
* @param {String} obj.botId
|
||||
@@ -21,26 +21,22 @@ interface Props {
|
||||
* @param {Object} obj.botKey
|
||||
* @returns
|
||||
*/
|
||||
const setBotActiveStatus = async ({ botId, isActive, botKey }: Props) => {
|
||||
return SecurityClient.fetchCall(
|
||||
"/api/v1/bot/" + botId + "/active",
|
||||
{
|
||||
method: "PATCH",
|
||||
headers: {
|
||||
"Content-Type": "application/json",
|
||||
},
|
||||
body: JSON.stringify({
|
||||
isActive,
|
||||
botKey
|
||||
})
|
||||
}
|
||||
).then(async (res) => {
|
||||
if (res && res.status == 200) {
|
||||
return await res.json();
|
||||
} else {
|
||||
console.log("Failed to get bot for project");
|
||||
const setBotActiveStatus = async ({ botId, isActive, botKey }: Props) =>
|
||||
SecurityClient.fetchCall(`/api/v1/bot/${botId}/active`, {
|
||||
method: 'PATCH',
|
||||
headers: {
|
||||
'Content-Type': 'application/json'
|
||||
},
|
||||
body: JSON.stringify({
|
||||
isActive,
|
||||
botKey
|
||||
})
|
||||
}).then(async (res) => {
|
||||
if (res && res.status === 200) {
|
||||
return res.json();
|
||||
}
|
||||
console.log('Failed to get bot for project');
|
||||
return undefined;
|
||||
});
|
||||
};
|
||||
|
||||
export default setBotActiveStatus;
|
||||
export default setBotActiveStatus;
|
||||
|
||||
@@ -1,4 +1,4 @@
|
||||
import SecurityClient from '~/utilities/SecurityClient';
|
||||
import SecurityClient from '@app/components/utilities/SecurityClient';
|
||||
|
||||
type NewEnvironmentInfo = {
|
||||
environmentSlug: string;
|
||||
@@ -10,20 +10,19 @@ type NewEnvironmentInfo = {
|
||||
* @param {*} workspaceId
|
||||
* @returns
|
||||
*/
|
||||
const createEnvironment = (workspaceId:string, newEnv: NewEnvironmentInfo) => {
|
||||
return SecurityClient.fetchCall(`/api/v2/workspace/${workspaceId}/environments`, {
|
||||
const createEnvironment = (workspaceId: string, newEnv: NewEnvironmentInfo) =>
|
||||
SecurityClient.fetchCall(`/api/v2/workspace/${workspaceId}/environments`, {
|
||||
method: 'POST',
|
||||
headers: {
|
||||
'Content-Type': 'application/json',
|
||||
'Content-Type': 'application/json'
|
||||
},
|
||||
body: JSON.stringify(newEnv)
|
||||
}).then(async (res) => {
|
||||
if (res && res.status == 200) {
|
||||
if (res && res.status === 200) {
|
||||
return res;
|
||||
} else {
|
||||
console.log('Failed to create environment');
|
||||
}
|
||||
console.log('Failed to create environment');
|
||||
return undefined;
|
||||
});
|
||||
};
|
||||
|
||||
export default createEnvironment;
|
||||
|
||||
@@ -1,26 +1,22 @@
|
||||
import SecurityClient from '~/utilities/SecurityClient';
|
||||
import SecurityClient from '@app/components/utilities/SecurityClient';
|
||||
/**
|
||||
* This route deletes a specified env.
|
||||
* @param {*} workspaceId
|
||||
* @returns
|
||||
*/
|
||||
const deleteEnvironment = (workspaceId: string, environmentSlug: string) => {
|
||||
return SecurityClient.fetchCall(
|
||||
`/api/v2/workspace/${workspaceId}/environments`,
|
||||
{
|
||||
method: 'DELETE',
|
||||
headers: {
|
||||
'Content-Type': 'application/json',
|
||||
},
|
||||
body: JSON.stringify({ environmentSlug }),
|
||||
}
|
||||
).then(async (res) => {
|
||||
if (res && res.status == 200) {
|
||||
const deleteEnvironment = (workspaceId: string, environmentSlug: string) =>
|
||||
SecurityClient.fetchCall(`/api/v2/workspace/${workspaceId}/environments`, {
|
||||
method: 'DELETE',
|
||||
headers: {
|
||||
'Content-Type': 'application/json'
|
||||
},
|
||||
body: JSON.stringify({ environmentSlug })
|
||||
}).then(async (res) => {
|
||||
if (res && res.status === 200) {
|
||||
return res;
|
||||
} else {
|
||||
console.log('Failed to delete environment');
|
||||
}
|
||||
console.log('Failed to delete environment');
|
||||
return undefined;
|
||||
});
|
||||
};
|
||||
|
||||
export default deleteEnvironment;
|
||||
|
||||
@@ -1,4 +1,4 @@
|
||||
import SecurityClient from '~/utilities/SecurityClient';
|
||||
import SecurityClient from '@app/components/utilities/SecurityClient';
|
||||
|
||||
type EnvironmentInfo = {
|
||||
oldEnvironmentSlug: string;
|
||||
@@ -11,23 +11,19 @@ type EnvironmentInfo = {
|
||||
* @param {*} workspaceId
|
||||
* @returns
|
||||
*/
|
||||
const updateEnvironment = (workspaceId: string, env: EnvironmentInfo) => {
|
||||
return SecurityClient.fetchCall(
|
||||
`/api/v2/workspace/${workspaceId}/environments`,
|
||||
{
|
||||
method: 'PUT',
|
||||
headers: {
|
||||
'Content-Type': 'application/json',
|
||||
},
|
||||
body: JSON.stringify(env),
|
||||
}
|
||||
).then(async (res) => {
|
||||
if (res && res.status == 200) {
|
||||
const updateEnvironment = (workspaceId: string, env: EnvironmentInfo) =>
|
||||
SecurityClient.fetchCall(`/api/v2/workspace/${workspaceId}/environments`, {
|
||||
method: 'PUT',
|
||||
headers: {
|
||||
'Content-Type': 'application/json'
|
||||
},
|
||||
body: JSON.stringify(env)
|
||||
}).then(async (res) => {
|
||||
if (res && res.status === 200) {
|
||||
return res;
|
||||
} else {
|
||||
console.log('Failed to update environment');
|
||||
}
|
||||
console.log('Failed to update environment');
|
||||
return undefined;
|
||||
});
|
||||
};
|
||||
|
||||
export default updateEnvironment;
|
||||
|
||||
@@ -1,4 +1,4 @@
|
||||
import SecurityClient from '~/utilities/SecurityClient';
|
||||
import SecurityClient from '@app/components/utilities/SecurityClient';
|
||||
|
||||
interface EncryptedSecretProps {
|
||||
id: string;
|
||||
@@ -13,7 +13,7 @@ interface EncryptedSecretProps {
|
||||
secretValueCiphertext: string;
|
||||
secretValueIV: string;
|
||||
secretValueTag: string;
|
||||
type: "personal" | "shared";
|
||||
type: 'personal' | 'shared';
|
||||
}
|
||||
|
||||
/**
|
||||
@@ -24,25 +24,31 @@ interface EncryptedSecretProps {
|
||||
* @param {string} obj.workspaceId - the project to which we are adding secrets
|
||||
* @returns
|
||||
*/
|
||||
const addSecrets = async ({ secrets, env, workspaceId }: { secrets: EncryptedSecretProps[]; env: string; workspaceId: string; }) => {
|
||||
return SecurityClient.fetchCall('/api/v2/secrets', {
|
||||
method: 'POST',
|
||||
headers: {
|
||||
'Content-Type': 'application/json'
|
||||
},
|
||||
body: JSON.stringify({
|
||||
environment: env,
|
||||
workspaceId,
|
||||
secrets
|
||||
})
|
||||
}
|
||||
).then(async (res) => {
|
||||
if (res && res.status == 200) {
|
||||
return await res.json();
|
||||
} else {
|
||||
console.log('Failed to add certain project secrets');
|
||||
const addSecrets = async ({
|
||||
secrets,
|
||||
env,
|
||||
workspaceId
|
||||
}: {
|
||||
secrets: EncryptedSecretProps[];
|
||||
env: string;
|
||||
workspaceId: string;
|
||||
}) =>
|
||||
SecurityClient.fetchCall('/api/v2/secrets', {
|
||||
method: 'POST',
|
||||
headers: {
|
||||
'Content-Type': 'application/json'
|
||||
},
|
||||
body: JSON.stringify({
|
||||
environment: env,
|
||||
workspaceId,
|
||||
secrets
|
||||
})
|
||||
}).then(async (res) => {
|
||||
if (res && res.status === 200) {
|
||||
return res.json();
|
||||
}
|
||||
console.log('Failed to add certain project secrets');
|
||||
return undefined;
|
||||
});
|
||||
};
|
||||
|
||||
export default addSecrets;
|
||||
|
||||
@@ -1,27 +1,25 @@
|
||||
import SecurityClient from '~/utilities/SecurityClient';
|
||||
import SecurityClient from '@app/components/utilities/SecurityClient';
|
||||
|
||||
/**
|
||||
* This function deletes certain secrets from a certain project
|
||||
* @param {string[]} secretIds - the ids of secrets that we want to be deleted
|
||||
* @returns
|
||||
*/
|
||||
const deleteSecrets = async ({ secretIds }: { secretIds: string[] }) => {
|
||||
return SecurityClient.fetchCall('/api/v2/secrets', {
|
||||
method: 'DELETE',
|
||||
headers: {
|
||||
'Content-Type': 'application/json'
|
||||
},
|
||||
body: JSON.stringify({
|
||||
secretIds
|
||||
})
|
||||
}
|
||||
).then(async (res) => {
|
||||
if (res && res.status == 200) {
|
||||
return await res.json();
|
||||
} else {
|
||||
console.log('Failed to delete certain project secrets');
|
||||
const deleteSecrets = async ({ secretIds }: { secretIds: string[] }) =>
|
||||
SecurityClient.fetchCall('/api/v2/secrets', {
|
||||
method: 'DELETE',
|
||||
headers: {
|
||||
'Content-Type': 'application/json'
|
||||
},
|
||||
body: JSON.stringify({
|
||||
secretIds
|
||||
})
|
||||
}).then(async (res) => {
|
||||
if (res && res.status === 200) {
|
||||
return res.json();
|
||||
}
|
||||
console.log('Failed to delete certain project secrets');
|
||||
return undefined;
|
||||
});
|
||||
};
|
||||
|
||||
export default deleteSecrets;
|
||||
|
||||
@@ -1,4 +1,4 @@
|
||||
import SecurityClient from '~/utilities/SecurityClient';
|
||||
import SecurityClient from '@app/components/utilities/SecurityClient';
|
||||
|
||||
/**
|
||||
* This function fetches the encrypted secrets for a certain project
|
||||
@@ -6,13 +6,12 @@ import SecurityClient from '~/utilities/SecurityClient';
|
||||
* @param {string} env - environment of a project for which a user is trying ot get secrets
|
||||
* @returns
|
||||
*/
|
||||
const getSecrets = async (workspaceId: string, env: string) => {
|
||||
return SecurityClient.fetchCall(
|
||||
'/api/v2/secrets?' +
|
||||
new URLSearchParams({
|
||||
environment: env,
|
||||
workspaceId
|
||||
}),
|
||||
const getSecrets = async (workspaceId: string, env: string) =>
|
||||
SecurityClient.fetchCall(
|
||||
`/api/v2/secrets?${new URLSearchParams({
|
||||
environment: env,
|
||||
workspaceId
|
||||
})}`,
|
||||
{
|
||||
method: 'GET',
|
||||
headers: {
|
||||
@@ -20,12 +19,11 @@ const getSecrets = async (workspaceId: string, env: string) => {
|
||||
}
|
||||
}
|
||||
).then(async (res) => {
|
||||
if (res && res.status == 200) {
|
||||
if (res && res.status === 200) {
|
||||
return (await res.json()).secrets;
|
||||
} else {
|
||||
console.log('Failed to get project secrets');
|
||||
}
|
||||
console.log('Failed to get project secrets');
|
||||
return undefined;
|
||||
});
|
||||
};
|
||||
|
||||
export default getSecrets;
|
||||
|
||||
@@ -1,4 +1,4 @@
|
||||
import SecurityClient from '~/utilities/SecurityClient';
|
||||
import SecurityClient from '@app/components/utilities/SecurityClient';
|
||||
|
||||
interface EncryptedSecretProps {
|
||||
id: string;
|
||||
@@ -13,7 +13,7 @@ interface EncryptedSecretProps {
|
||||
secretValueCiphertext: string;
|
||||
secretValueIV: string;
|
||||
secretValueTag: string;
|
||||
type: "personal" | "shared";
|
||||
type: 'personal' | 'shared';
|
||||
}
|
||||
|
||||
/**
|
||||
@@ -22,23 +22,21 @@ interface EncryptedSecretProps {
|
||||
* @param {EncryptedSecretProps[]} obj.secrets - the ids of secrets that we want to update
|
||||
* @returns
|
||||
*/
|
||||
const updateSecrets = async ({ secrets }: { secrets: EncryptedSecretProps[] }) => {
|
||||
return SecurityClient.fetchCall('/api/v2/secrets', {
|
||||
method: 'PATCH',
|
||||
headers: {
|
||||
'Content-Type': 'application/json'
|
||||
},
|
||||
body: JSON.stringify({
|
||||
secrets
|
||||
})
|
||||
}
|
||||
).then(async (res) => {
|
||||
if (res && res.status == 200) {
|
||||
return await res.json();
|
||||
} else {
|
||||
console.log('Failed to update certain project secrets');
|
||||
const updateSecrets = async ({ secrets }: { secrets: EncryptedSecretProps[] }) =>
|
||||
SecurityClient.fetchCall('/api/v2/secrets', {
|
||||
method: 'PATCH',
|
||||
headers: {
|
||||
'Content-Type': 'application/json'
|
||||
},
|
||||
body: JSON.stringify({
|
||||
secrets
|
||||
})
|
||||
}).then(async (res) => {
|
||||
if (res && res.status === 200) {
|
||||
return res.json();
|
||||
}
|
||||
console.log('Failed to update certain project secrets');
|
||||
return undefined;
|
||||
});
|
||||
};
|
||||
|
||||
export default updateSecrets;
|
||||
|
||||
@@ -1,4 +1,4 @@
|
||||
import SecurityClient from '~/utilities/SecurityClient';
|
||||
import SecurityClient from '@app/components/utilities/SecurityClient';
|
||||
|
||||
interface Props {
|
||||
workspaceId: string;
|
||||
@@ -16,13 +16,8 @@ interface Props {
|
||||
* @param {string} obj.environment
|
||||
* @returns
|
||||
*/
|
||||
const uploadSecrets = async ({
|
||||
workspaceId,
|
||||
secrets,
|
||||
keys,
|
||||
environment
|
||||
}: Props) => {
|
||||
return SecurityClient.fetchCall('/api/v2/workspace/' + workspaceId + '/secrets', {
|
||||
const uploadSecrets = async ({ workspaceId, secrets, keys, environment }: Props) =>
|
||||
SecurityClient.fetchCall(`/api/v2/workspace/${workspaceId}/secrets`, {
|
||||
method: 'POST',
|
||||
headers: {
|
||||
'Content-Type': 'application/json'
|
||||
@@ -34,12 +29,11 @@ const uploadSecrets = async ({
|
||||
channel: 'web'
|
||||
})
|
||||
}).then(async (res) => {
|
||||
if (res && res.status == 200) {
|
||||
if (res && res.status === 200) {
|
||||
return res;
|
||||
} else {
|
||||
console.log('Failed to push secrets');
|
||||
}
|
||||
console.log('Failed to push secrets');
|
||||
return undefined;
|
||||
});
|
||||
};
|
||||
|
||||
export default uploadSecrets;
|
||||
|
||||
@@ -1,4 +1,4 @@
|
||||
import SecurityClient from '~/utilities/SecurityClient';
|
||||
import SecurityClient from '@app/components/utilities/SecurityClient';
|
||||
|
||||
interface Props {
|
||||
integrationId: string;
|
||||
@@ -16,26 +16,22 @@ interface Props {
|
||||
}[];
|
||||
}
|
||||
|
||||
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) {
|
||||
const changeHerokuConfigVars = ({ integrationId, key, secrets }: Props) =>
|
||||
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');
|
||||
}
|
||||
console.log('Failed to sync secrets to Heroku');
|
||||
return undefined;
|
||||
});
|
||||
};
|
||||
|
||||
export default changeHerokuConfigVars;
|
||||
|
||||
@@ -1,4 +1,4 @@
|
||||
import SecurityClient from '~/utilities/SecurityClient';
|
||||
import SecurityClient from '@app/components/utilities/SecurityClient';
|
||||
|
||||
interface Props {
|
||||
integrationId: string;
|
||||
@@ -9,19 +9,18 @@ interface Props {
|
||||
* @param {*} integrationId
|
||||
* @returns
|
||||
*/
|
||||
const deleteIntegration = ({ integrationId }: Props) => {
|
||||
return SecurityClient.fetchCall('/api/v1/integration/' + integrationId, {
|
||||
const deleteIntegration = ({ integrationId }: Props) =>
|
||||
SecurityClient.fetchCall(`/api/v1/integration/${integrationId}`, {
|
||||
method: 'DELETE',
|
||||
headers: {
|
||||
'Content-Type': 'application/json'
|
||||
}
|
||||
}).then(async (res) => {
|
||||
if (res && res.status == 200) {
|
||||
if (res && res.status === 200) {
|
||||
return (await res.json()).workspace;
|
||||
} else {
|
||||
console.log('Failed to delete an integration');
|
||||
}
|
||||
console.log('Failed to delete an integration');
|
||||
return undefined;
|
||||
});
|
||||
};
|
||||
|
||||
export default deleteIntegration;
|
||||
|
||||
@@ -1,4 +1,4 @@
|
||||
import SecurityClient from '~/utilities/SecurityClient';
|
||||
import SecurityClient from '@app/components/utilities/SecurityClient';
|
||||
|
||||
interface Props {
|
||||
integrationAuthId: string;
|
||||
@@ -9,22 +9,18 @@ interface Props {
|
||||
* @param {*} integrationAuthId
|
||||
* @returns
|
||||
*/
|
||||
const deleteIntegrationAuth = ({ integrationAuthId }: Props) => {
|
||||
return SecurityClient.fetchCall(
|
||||
'/api/v1/integration-auth/' + integrationAuthId,
|
||||
{
|
||||
method: 'DELETE',
|
||||
headers: {
|
||||
'Content-Type': 'application/json'
|
||||
}
|
||||
const deleteIntegrationAuth = ({ integrationAuthId }: Props) =>
|
||||
SecurityClient.fetchCall(`/api/v1/integration-auth/${integrationAuthId}`, {
|
||||
method: 'DELETE',
|
||||
headers: {
|
||||
'Content-Type': 'application/json'
|
||||
}
|
||||
).then(async (res) => {
|
||||
if (res && res.status == 200) {
|
||||
}).then(async (res) => {
|
||||
if (res && res.status === 200) {
|
||||
return res;
|
||||
} else {
|
||||
console.log('Failed to delete an integration authorization');
|
||||
}
|
||||
console.log('Failed to delete an integration authorization');
|
||||
return undefined;
|
||||
});
|
||||
};
|
||||
|
||||
export default deleteIntegrationAuth;
|
||||
|
||||
@@ -1,25 +1,21 @@
|
||||
import SecurityClient from '~/utilities/SecurityClient';
|
||||
import SecurityClient from '@app/components/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'
|
||||
}
|
||||
const getIntegrationApps = ({ integrationAuthId }: Props) =>
|
||||
SecurityClient.fetchCall(`/api/v1/integration-auth/${integrationAuthId}/apps`, {
|
||||
method: 'GET',
|
||||
headers: {
|
||||
'Content-Type': 'application/json'
|
||||
}
|
||||
).then(async (res) => {
|
||||
if (res && res.status == 200) {
|
||||
}).then(async (res) => {
|
||||
if (res && res.status === 200) {
|
||||
return (await res.json()).apps;
|
||||
} else {
|
||||
console.log('Failed to get available apps for an integration');
|
||||
}
|
||||
console.log('Failed to get available apps for an integration');
|
||||
return undefined;
|
||||
});
|
||||
};
|
||||
|
||||
export default getIntegrationApps;
|
||||
|
||||
@@ -1,21 +1,17 @@
|
||||
import SecurityClient from '~/utilities/SecurityClient';
|
||||
import SecurityClient from '@app/components/utilities/SecurityClient';
|
||||
|
||||
const getIntegrationOptions = () => {
|
||||
return SecurityClient.fetchCall(
|
||||
'/api/v1/integration-auth/integration-options',
|
||||
{
|
||||
method: 'GET',
|
||||
headers: {
|
||||
'Content-Type': 'application/json'
|
||||
}
|
||||
const getIntegrationOptions = () =>
|
||||
SecurityClient.fetchCall('/api/v1/integration-auth/integration-options', {
|
||||
method: 'GET',
|
||||
headers: {
|
||||
'Content-Type': 'application/json'
|
||||
}
|
||||
).then(async (res) => {
|
||||
if (res && res.status == 200) {
|
||||
}).then(async (res) => {
|
||||
if (res && res.status === 200) {
|
||||
return (await res.json()).integrationOptions;
|
||||
} else {
|
||||
console.log('Failed to get (cloud) integration options');
|
||||
}
|
||||
console.log('Failed to get (cloud) integration options');
|
||||
return undefined;
|
||||
});
|
||||
};
|
||||
|
||||
export default getIntegrationOptions;
|
||||
|
||||
@@ -1,4 +1,4 @@
|
||||
import SecurityClient from '~/utilities/SecurityClient';
|
||||
import SecurityClient from '@app/components/utilities/SecurityClient';
|
||||
|
||||
interface Props {
|
||||
integrationId: string;
|
||||
@@ -11,8 +11,8 @@ interface Props {
|
||||
* @param {*} integrationId
|
||||
* @returns
|
||||
*/
|
||||
const startIntegration = ({ integrationId, appName, environment }: Props) => {
|
||||
return SecurityClient.fetchCall('/api/v1/integration/' + integrationId, {
|
||||
const startIntegration = ({ integrationId, appName, environment }: Props) =>
|
||||
SecurityClient.fetchCall(`/api/v1/integration/${integrationId}`, {
|
||||
method: 'PATCH',
|
||||
headers: {
|
||||
'Content-Type': 'application/json'
|
||||
@@ -25,12 +25,11 @@ const startIntegration = ({ integrationId, appName, environment }: Props) => {
|
||||
}
|
||||
})
|
||||
}).then(async (res) => {
|
||||
if (res && res.status == 200) {
|
||||
if (res && res.status === 200) {
|
||||
return res;
|
||||
} else {
|
||||
console.log('Failed to start an integration');
|
||||
}
|
||||
console.log('Failed to start an integration');
|
||||
return undefined;
|
||||
});
|
||||
};
|
||||
|
||||
export default startIntegration;
|
||||
|
||||
@@ -1,4 +1,4 @@
|
||||
import SecurityClient from '~/utilities/SecurityClient';
|
||||
import SecurityClient from '@app/components/utilities/SecurityClient';
|
||||
|
||||
interface Props {
|
||||
workspaceId: string;
|
||||
@@ -13,8 +13,8 @@ interface Props {
|
||||
* @param {object} obj.integration - integration which a user is trying to turn on
|
||||
* @returns
|
||||
*/
|
||||
const AuthorizeIntegration = ({ workspaceId, code, integration }: Props) => {
|
||||
return SecurityClient.fetchCall('/api/v1/integration-auth/oauth-token', {
|
||||
const AuthorizeIntegration = ({ workspaceId, code, integration }: Props) =>
|
||||
SecurityClient.fetchCall('/api/v1/integration-auth/oauth-token', {
|
||||
method: 'POST',
|
||||
headers: {
|
||||
'Content-Type': 'application/json'
|
||||
@@ -25,12 +25,11 @@ const AuthorizeIntegration = ({ workspaceId, code, integration }: Props) => {
|
||||
integration
|
||||
})
|
||||
}).then(async (res) => {
|
||||
if (res && res.status == 200) {
|
||||
if (res && res.status === 200) {
|
||||
return res;
|
||||
} else {
|
||||
console.log('Failed to authorize the integration');
|
||||
}
|
||||
console.log('Failed to authorize the integration');
|
||||
return undefined;
|
||||
});
|
||||
};
|
||||
|
||||
export default AuthorizeIntegration;
|
||||
|
||||
@@ -1,4 +1,4 @@
|
||||
import SecurityClient from '~/utilities/SecurityClient';
|
||||
import SecurityClient from '@app/components/utilities/SecurityClient';
|
||||
|
||||
interface Props {
|
||||
workspaceId: string;
|
||||
@@ -9,22 +9,18 @@ interface Props {
|
||||
* @param {*} workspaceId
|
||||
* @returns
|
||||
*/
|
||||
const getWorkspaceAuthorizations = ({ workspaceId }: Props) => {
|
||||
return SecurityClient.fetchCall(
|
||||
'/api/v1/workspace/' + workspaceId + '/authorizations',
|
||||
{
|
||||
method: 'GET',
|
||||
headers: {
|
||||
'Content-Type': 'application/json'
|
||||
}
|
||||
const getWorkspaceAuthorizations = ({ workspaceId }: Props) =>
|
||||
SecurityClient.fetchCall(`/api/v1/workspace/${workspaceId}/authorizations`, {
|
||||
method: 'GET',
|
||||
headers: {
|
||||
'Content-Type': 'application/json'
|
||||
}
|
||||
).then(async (res) => {
|
||||
if (res && res.status == 200) {
|
||||
}).then(async (res) => {
|
||||
if (res && res.status === 200) {
|
||||
return (await res.json()).authorizations;
|
||||
} else {
|
||||
console.log('Failed to get project authorizations');
|
||||
}
|
||||
console.log('Failed to get project authorizations');
|
||||
return undefined;
|
||||
});
|
||||
};
|
||||
|
||||
export default getWorkspaceAuthorizations;
|
||||
|
||||
@@ -1,4 +1,4 @@
|
||||
import SecurityClient from '~/utilities/SecurityClient';
|
||||
import SecurityClient from '@app/components/utilities/SecurityClient';
|
||||
|
||||
interface Props {
|
||||
workspaceId: string;
|
||||
@@ -9,22 +9,18 @@ interface Props {
|
||||
* @param {*} workspaceId
|
||||
* @returns
|
||||
*/
|
||||
const getWorkspaceIntegrations = ({ workspaceId }: Props) => {
|
||||
return SecurityClient.fetchCall(
|
||||
'/api/v1/workspace/' + workspaceId + '/integrations',
|
||||
{
|
||||
method: 'GET',
|
||||
headers: {
|
||||
'Content-Type': 'application/json'
|
||||
}
|
||||
const getWorkspaceIntegrations = ({ workspaceId }: Props) =>
|
||||
SecurityClient.fetchCall(`/api/v1/workspace/${workspaceId}/integrations`, {
|
||||
method: 'GET',
|
||||
headers: {
|
||||
'Content-Type': 'application/json'
|
||||
}
|
||||
).then(async (res) => {
|
||||
if (res && res.status == 200) {
|
||||
}).then(async (res) => {
|
||||
if (res && res.status === 200) {
|
||||
return (await res.json()).integrations;
|
||||
} else {
|
||||
console.log('Failed to get the project integrations');
|
||||
}
|
||||
console.log('Failed to get the project integrations');
|
||||
return undefined;
|
||||
});
|
||||
};
|
||||
|
||||
export default getWorkspaceIntegrations;
|
||||
|
||||
@@ -1,4 +1,4 @@
|
||||
import SecurityClient from "~/utilities/SecurityClient";
|
||||
import SecurityClient from '@app/components/utilities/SecurityClient';
|
||||
|
||||
/**
|
||||
* This route starts the integration after teh default one if gonna set up.
|
||||
@@ -6,7 +6,7 @@ import SecurityClient from "~/utilities/SecurityClient";
|
||||
* [environment] to the integration [app] with active state [isActive]
|
||||
* @param {Object} obj
|
||||
* @param {String} obj.integrationId - id of integration
|
||||
* @param {String} obj.app - name of app
|
||||
* @param {String} obj.app - name of app
|
||||
* @param {String} obj.environment - project environment to push secrets from
|
||||
* @param {Boolean} obj.isActive - active state
|
||||
* @param {String} obj.target - (optional) target (environment) for Vercel integration
|
||||
@@ -14,47 +14,42 @@ import SecurityClient from "~/utilities/SecurityClient";
|
||||
* @param {String} obj.siteId - (optional) app (site_id) for Netlify integration
|
||||
* @returns
|
||||
*/
|
||||
const updateIntegration = ({
|
||||
integrationId,
|
||||
app,
|
||||
const updateIntegration = ({
|
||||
integrationId,
|
||||
app,
|
||||
environment,
|
||||
isActive,
|
||||
target,
|
||||
context,
|
||||
siteId
|
||||
}: {
|
||||
integrationId: string,
|
||||
app: string,
|
||||
environment: string,
|
||||
isActive: boolean,
|
||||
target: string | null,
|
||||
context: string | null,
|
||||
siteId: string | null
|
||||
|
||||
}) => {
|
||||
return SecurityClient.fetchCall(
|
||||
"/api/v1/integration/" + integrationId,
|
||||
{
|
||||
method: "PATCH",
|
||||
headers: {
|
||||
"Content-Type": "application/json",
|
||||
},
|
||||
body: JSON.stringify({
|
||||
app,
|
||||
environment,
|
||||
isActive,
|
||||
target,
|
||||
context,
|
||||
siteId
|
||||
}),
|
||||
}
|
||||
).then(async (res) => {
|
||||
if (res && res.status == 200) {
|
||||
integrationId: string;
|
||||
app: string;
|
||||
environment: string;
|
||||
isActive: boolean;
|
||||
target: string | null;
|
||||
context: string | null;
|
||||
siteId: string | null;
|
||||
}) =>
|
||||
SecurityClient.fetchCall(`/api/v1/integration/${integrationId}`, {
|
||||
method: 'PATCH',
|
||||
headers: {
|
||||
'Content-Type': 'application/json'
|
||||
},
|
||||
body: JSON.stringify({
|
||||
app,
|
||||
environment,
|
||||
isActive,
|
||||
target,
|
||||
context,
|
||||
siteId
|
||||
})
|
||||
}).then(async (res) => {
|
||||
if (res && res.status === 200) {
|
||||
return res;
|
||||
} else {
|
||||
console.log("Failed to start an integration");
|
||||
}
|
||||
console.log('Failed to start an integration');
|
||||
return undefined;
|
||||
});
|
||||
};
|
||||
|
||||
export default updateIntegration;
|
||||
|
||||
@@ -1,23 +1,22 @@
|
||||
import SecurityClient from '~/utilities/SecurityClient';
|
||||
import SecurityClient from '@app/components/utilities/SecurityClient';
|
||||
|
||||
/**
|
||||
* This route lets us get info about a certain org
|
||||
* @param {string} orgId - the organization ID
|
||||
* @returns
|
||||
*/
|
||||
const getOrganization = ({ orgId }: { orgId: string }) => {
|
||||
return SecurityClient.fetchCall('/api/v1/organization/' + orgId, {
|
||||
const getOrganization = ({ orgId }: { orgId: string }) =>
|
||||
SecurityClient.fetchCall(`/api/v1/organization/${orgId}`, {
|
||||
method: 'GET',
|
||||
headers: {
|
||||
'Content-Type': 'application/json'
|
||||
}
|
||||
}).then(async (res) => {
|
||||
if (res?.status == 200) {
|
||||
if (res?.status === 200) {
|
||||
return (await res.json()).organization;
|
||||
} else {
|
||||
console.log('Failed to get org info');
|
||||
}
|
||||
console.log('Failed to get org info');
|
||||
return undefined;
|
||||
});
|
||||
};
|
||||
|
||||
export default getOrganization;
|
||||
|
||||
@@ -1,4 +1,4 @@
|
||||
import SecurityClient from '~/utilities/SecurityClient';
|
||||
import SecurityClient from '@app/components/utilities/SecurityClient';
|
||||
|
||||
/**
|
||||
* This route lets us get all the users in an org.
|
||||
@@ -8,22 +8,18 @@ import SecurityClient from '~/utilities/SecurityClient';
|
||||
*/
|
||||
|
||||
// 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'
|
||||
}
|
||||
const getOrganizationProjects = (req: { orgId: string }) =>
|
||||
SecurityClient.fetchCall(`/api/organization/${req.orgId}/workspaces`, {
|
||||
method: 'GET',
|
||||
headers: {
|
||||
'Content-Type': 'application/json'
|
||||
}
|
||||
).then(async (res) => {
|
||||
if (res && res.status == 200) {
|
||||
}).then(async (res) => {
|
||||
if (res && res.status === 200) {
|
||||
return (await res.json()).workspaces;
|
||||
} else {
|
||||
console.log('Failed to get projects for an org');
|
||||
}
|
||||
console.log('Failed to get projects for an org');
|
||||
return undefined;
|
||||
});
|
||||
};
|
||||
|
||||
export default getOrganizationProjects;
|
||||
|
||||
@@ -1,4 +1,4 @@
|
||||
import SecurityClient from '~/utilities/SecurityClient';
|
||||
import SecurityClient from '@app/components/utilities/SecurityClient';
|
||||
|
||||
/**
|
||||
* This route lets us get the current subscription of an org.
|
||||
@@ -6,22 +6,18 @@ import SecurityClient from '~/utilities/SecurityClient';
|
||||
* @param {*} res
|
||||
* @returns
|
||||
*/
|
||||
const getOrganizationSubscriptions = (req: { orgId: string }) => {
|
||||
return SecurityClient.fetchCall(
|
||||
'/api/v1/organization/' + req.orgId + '/subscriptions',
|
||||
{
|
||||
method: 'GET',
|
||||
headers: {
|
||||
'Content-Type': 'application/json'
|
||||
}
|
||||
const getOrganizationSubscriptions = (req: { orgId: string }) =>
|
||||
SecurityClient.fetchCall(`/api/v1/organization/${req.orgId}/subscriptions`, {
|
||||
method: 'GET',
|
||||
headers: {
|
||||
'Content-Type': 'application/json'
|
||||
}
|
||||
).then(async (res) => {
|
||||
if (res && res.status == 200) {
|
||||
}).then(async (res) => {
|
||||
if (res && res.status === 200) {
|
||||
return (await res.json()).subscriptions;
|
||||
} else {
|
||||
console.log('Failed to get org subscriptions');
|
||||
}
|
||||
console.log('Failed to get org subscriptions');
|
||||
return undefined;
|
||||
});
|
||||
};
|
||||
|
||||
export default getOrganizationSubscriptions;
|
||||
|
||||
@@ -1,4 +1,4 @@
|
||||
import SecurityClient from '~/utilities/SecurityClient';
|
||||
import SecurityClient from '@app/components/utilities/SecurityClient';
|
||||
|
||||
/**
|
||||
* This route lets us get all the projects of a certain user in an org.
|
||||
@@ -6,22 +6,18 @@ import SecurityClient from '~/utilities/SecurityClient';
|
||||
* @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'
|
||||
}
|
||||
const getOrganizationUserProjects = (req: { orgId: string }) =>
|
||||
SecurityClient.fetchCall(`/api/v1/organization/${req.orgId}/my-workspaces`, {
|
||||
method: 'GET',
|
||||
headers: {
|
||||
'Content-Type': 'application/json'
|
||||
}
|
||||
).then(async (res) => {
|
||||
if (res && res.status == 200) {
|
||||
}).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');
|
||||
}
|
||||
console.log('Failed to get projects of a user in an org');
|
||||
return undefined;
|
||||
});
|
||||
};
|
||||
|
||||
export default getOrganizationUserProjects;
|
||||
|
||||
@@ -1,4 +1,4 @@
|
||||
import SecurityClient from '~/utilities/SecurityClient';
|
||||
import SecurityClient from '@app/components/utilities/SecurityClient';
|
||||
|
||||
export interface IMembershipOrg {
|
||||
_id: string;
|
||||
@@ -20,23 +20,18 @@ export interface IMembershipOrg {
|
||||
* @param {string} obj.orgId - organization Id
|
||||
* @returns
|
||||
*/
|
||||
const getOrganizationUsers = ({
|
||||
orgId,
|
||||
}: {
|
||||
orgId: string;
|
||||
}): Promise<IMembershipOrg[]> => {
|
||||
return SecurityClient.fetchCall('/api/v1/organization/' + orgId + '/users', {
|
||||
const getOrganizationUsers = ({ orgId }: { orgId: string }): Promise<IMembershipOrg[]> =>
|
||||
SecurityClient.fetchCall(`/api/v1/organization/${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');
|
||||
'Content-Type': 'application/json'
|
||||
}
|
||||
}).then(async (res) => {
|
||||
if (res?.status === 200) {
|
||||
return (await res.json()).users;
|
||||
}
|
||||
console.log('Failed to get org users');
|
||||
return undefined;
|
||||
});
|
||||
};
|
||||
|
||||
export default getOrganizationUsers;
|
||||
|
||||
@@ -1,4 +1,4 @@
|
||||
import SecurityClient from '~/utilities/SecurityClient';
|
||||
import SecurityClient from '@app/components/utilities/SecurityClient';
|
||||
|
||||
/**
|
||||
* This route redirects the user to the right stripe billing page.
|
||||
@@ -6,22 +6,18 @@ import SecurityClient from '~/utilities/SecurityClient';
|
||||
* @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'
|
||||
}
|
||||
const StripeRedirect = ({ orgId }: { orgId: string }) =>
|
||||
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');
|
||||
}).then(async (res) => {
|
||||
if (res && res.status === 200) {
|
||||
window.location.href = (await res.json()).url;
|
||||
return;
|
||||
}
|
||||
console.log('Failed to redirect to Stripe');
|
||||
});
|
||||
};
|
||||
|
||||
export default StripeRedirect;
|
||||
|
||||
@@ -1,29 +1,25 @@
|
||||
import SecurityClient from '~/utilities/SecurityClient';
|
||||
import SecurityClient from '@app/components/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) {
|
||||
const addIncidentContact = (organizationId: string, email: string) =>
|
||||
SecurityClient.fetchCall(`/api/v1/organization/${organizationId}/incidentContactOrg`, {
|
||||
method: 'POST',
|
||||
headers: {
|
||||
'Content-Type': 'application/json'
|
||||
},
|
||||
body: JSON.stringify({
|
||||
email
|
||||
})
|
||||
}).then(async (res) => {
|
||||
if (res && res.status === 200) {
|
||||
return res;
|
||||
} else {
|
||||
console.log('Failed to add an incident contact');
|
||||
}
|
||||
console.log('Failed to add an incident contact');
|
||||
return undefined;
|
||||
});
|
||||
};
|
||||
|
||||
export default addIncidentContact;
|
||||
|
||||
@@ -1,4 +1,4 @@
|
||||
import SecurityClient from '~/utilities/SecurityClient';
|
||||
import SecurityClient from '@app/components/utilities/SecurityClient';
|
||||
|
||||
/**
|
||||
* This function sends an email invite to a user to join an org
|
||||
@@ -6,8 +6,8 @@ import SecurityClient from '~/utilities/SecurityClient';
|
||||
* @param {*} orgId
|
||||
* @returns
|
||||
*/
|
||||
const addUserToOrg = (email: string, orgId: string) => {
|
||||
return SecurityClient.fetchCall('/api/v1/invite-org/signup', {
|
||||
const addUserToOrg = (email: string, orgId: string) =>
|
||||
SecurityClient.fetchCall('/api/v1/invite-org/signup', {
|
||||
method: 'POST',
|
||||
headers: {
|
||||
'Content-Type': 'application/json'
|
||||
@@ -17,12 +17,11 @@ const addUserToOrg = (email: string, orgId: string) => {
|
||||
organizationId: orgId
|
||||
})
|
||||
}).then(async (res) => {
|
||||
if (res && res.status == 200) {
|
||||
if (res && res.status === 200) {
|
||||
return res;
|
||||
} else {
|
||||
console.log('Failed to add a user to an org');
|
||||
}
|
||||
console.log('Failed to add a user to an org');
|
||||
return undefined;
|
||||
});
|
||||
};
|
||||
|
||||
export default addUserToOrg;
|
||||
|
||||
@@ -1,29 +1,25 @@
|
||||
import SecurityClient from '~/utilities/SecurityClient';
|
||||
import SecurityClient from '@app/components/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) {
|
||||
const deleteIncidentContact = (organizationId: string, email: string) =>
|
||||
SecurityClient.fetchCall(`/api/v1/organization/${organizationId}/incidentContactOrg`, {
|
||||
method: 'DELETE',
|
||||
headers: {
|
||||
'Content-Type': 'application/json'
|
||||
},
|
||||
body: JSON.stringify({
|
||||
email
|
||||
})
|
||||
}).then(async (res) => {
|
||||
if (res && res.status === 200) {
|
||||
return res;
|
||||
} else {
|
||||
console.log('Failed to delete an incident contact');
|
||||
}
|
||||
console.log('Failed to delete an incident contact');
|
||||
return undefined;
|
||||
});
|
||||
};
|
||||
|
||||
export default deleteIncidentContact;
|
||||
|
||||
@@ -1,23 +1,22 @@
|
||||
import SecurityClient from '~/utilities/SecurityClient';
|
||||
import SecurityClient from '@app/components/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, {
|
||||
const deleteUserFromOrganization = (membershipId: string) =>
|
||||
SecurityClient.fetchCall(`/api/v1/membership-org/${membershipId}`, {
|
||||
method: 'DELETE',
|
||||
headers: {
|
||||
'Content-Type': 'application/json'
|
||||
}
|
||||
}).then(async (res) => {
|
||||
if (res && res.status == 200) {
|
||||
if (res && res.status === 200) {
|
||||
return res;
|
||||
} else {
|
||||
console.log('Failed to delete a user from an org');
|
||||
}
|
||||
console.log('Failed to delete a user from an org');
|
||||
return undefined;
|
||||
});
|
||||
};
|
||||
|
||||
export default deleteUserFromOrganization;
|
||||
|
||||
@@ -1,4 +1,4 @@
|
||||
import SecurityClient from '~/utilities/SecurityClient';
|
||||
import SecurityClient from '@app/components/utilities/SecurityClient';
|
||||
|
||||
export interface IIncidentContactOrg {
|
||||
_id: string;
|
||||
@@ -10,24 +10,18 @@ export interface IIncidentContactOrg {
|
||||
* @param {*} workspaceId
|
||||
* @returns
|
||||
*/
|
||||
const getIncidentContacts = (
|
||||
organizationId: string
|
||||
): Promise<IIncidentContactOrg[]> => {
|
||||
return SecurityClient.fetchCall(
|
||||
'/api/v1/organization/' + organizationId + '/incidentContactOrg',
|
||||
{
|
||||
method: 'GET',
|
||||
headers: {
|
||||
'Content-Type': 'application/json',
|
||||
},
|
||||
const getIncidentContacts = (organizationId: string): Promise<IIncidentContactOrg[]> =>
|
||||
SecurityClient.fetchCall(`/api/v1/organization/${organizationId}/incidentContactOrg`, {
|
||||
method: 'GET',
|
||||
headers: {
|
||||
'Content-Type': 'application/json'
|
||||
}
|
||||
).then(async (res) => {
|
||||
if (res && res.status == 200) {
|
||||
}).then(async (res) => {
|
||||
if (res && res.status === 200) {
|
||||
return (await res.json()).incidentContactsOrg;
|
||||
} else {
|
||||
console.log('Failed to get incident contacts');
|
||||
}
|
||||
console.log('Failed to get incident contacts');
|
||||
return undefined;
|
||||
});
|
||||
};
|
||||
|
||||
export default getIncidentContacts;
|
||||
|
||||
@@ -1,22 +1,21 @@
|
||||
import SecurityClient from '~/utilities/SecurityClient';
|
||||
import SecurityClient from '@app/components/utilities/SecurityClient';
|
||||
|
||||
/**
|
||||
* This route lets us get the all the orgs of a certain user.
|
||||
* @returns
|
||||
*/
|
||||
const getOrganizations = () => {
|
||||
return SecurityClient.fetchCall('/api/v1/organization', {
|
||||
const getOrganizations = () =>
|
||||
SecurityClient.fetchCall('/api/v1/organization', {
|
||||
method: 'GET',
|
||||
headers: {
|
||||
'Content-Type': 'application/json'
|
||||
}
|
||||
}).then(async (res) => {
|
||||
if (res?.status == 200) {
|
||||
if (res?.status === 200) {
|
||||
return (await res.json()).organizations;
|
||||
} else {
|
||||
console.log('Failed to get orgs of a user');
|
||||
}
|
||||
console.log('Failed to get orgs of a user');
|
||||
return undefined;
|
||||
});
|
||||
};
|
||||
|
||||
export default getOrganizations;
|
||||
|
||||
@@ -1,4 +1,4 @@
|
||||
import SecurityClient from '~/utilities/SecurityClient';
|
||||
import SecurityClient from '@app/components/utilities/SecurityClient';
|
||||
|
||||
/**
|
||||
* This route lets us rename a certain org.
|
||||
@@ -6,8 +6,8 @@ import SecurityClient from '~/utilities/SecurityClient';
|
||||
* @param {*} res
|
||||
* @returns
|
||||
*/
|
||||
const renameOrg = (orgId: string, newOrgName: string) => {
|
||||
return SecurityClient.fetchCall('/api/v1/organization/' + orgId + '/name', {
|
||||
const renameOrg = (orgId: string, newOrgName: string) =>
|
||||
SecurityClient.fetchCall(`/api/v1/organization/${orgId}/name`, {
|
||||
method: 'PATCH',
|
||||
headers: {
|
||||
'Content-Type': 'application/json'
|
||||
@@ -16,12 +16,11 @@ const renameOrg = (orgId: string, newOrgName: string) => {
|
||||
name: newOrgName
|
||||
})
|
||||
}).then(async (res) => {
|
||||
if (res && res.status == 200) {
|
||||
if (res && res.status === 200) {
|
||||
return res;
|
||||
} else {
|
||||
console.log('Failed to rename an organization');
|
||||
}
|
||||
console.log('Failed to rename an organization');
|
||||
return undefined;
|
||||
});
|
||||
};
|
||||
|
||||
export default renameOrg;
|
||||
|
||||
@@ -1,4 +1,4 @@
|
||||
import SecurityClient from '~/utilities/SecurityClient';
|
||||
import SecurityClient from '@app/components/utilities/SecurityClient';
|
||||
|
||||
interface Props {
|
||||
name: string;
|
||||
@@ -28,10 +28,10 @@ const addServiceToken = ({
|
||||
environment,
|
||||
expiresIn,
|
||||
encryptedKey,
|
||||
iv,
|
||||
iv,
|
||||
tag
|
||||
}: Props) => {
|
||||
return SecurityClient.fetchCall('/api/v2/service-token/', {
|
||||
}: Props) =>
|
||||
SecurityClient.fetchCall('/api/v2/service-token/', {
|
||||
method: 'POST',
|
||||
headers: {
|
||||
'Content-Type': 'application/json'
|
||||
@@ -42,16 +42,15 @@ const addServiceToken = ({
|
||||
environment,
|
||||
expiresIn,
|
||||
encryptedKey,
|
||||
iv,
|
||||
iv,
|
||||
tag
|
||||
})
|
||||
}).then(async (res) => {
|
||||
if (res && res.status == 200) {
|
||||
return (await res.json());
|
||||
} else {
|
||||
console.log('Failed to add service tokens');
|
||||
if (res && res.status === 200) {
|
||||
return res.json();
|
||||
}
|
||||
console.log('Failed to add service tokens');
|
||||
return undefined;
|
||||
});
|
||||
};
|
||||
|
||||
export default addServiceToken;
|
||||
|
||||
@@ -1,4 +1,4 @@
|
||||
import SecurityClient from '~/utilities/SecurityClient';
|
||||
import SecurityClient from '@app/components/utilities/SecurityClient';
|
||||
|
||||
interface Props {
|
||||
serviceTokenId: string;
|
||||
@@ -10,21 +10,18 @@ interface Props {
|
||||
* @param {string} obj.serviceTokenId - id of a cervice token that we want to delete
|
||||
* @returns
|
||||
*/
|
||||
const deleteServiceToken = ({
|
||||
serviceTokenId,
|
||||
}: Props) => {
|
||||
return SecurityClient.fetchCall('/api/v2/service-token/' + serviceTokenId, {
|
||||
const deleteServiceToken = ({ serviceTokenId }: Props) =>
|
||||
SecurityClient.fetchCall(`/api/v2/service-token/${serviceTokenId}`, {
|
||||
method: 'DELETE',
|
||||
headers: {
|
||||
'Content-Type': 'application/json'
|
||||
},
|
||||
}).then(async (res) => {
|
||||
if (res && res.status == 200) {
|
||||
return (await res.json());
|
||||
} else {
|
||||
console.log('Failed to delete a service token');
|
||||
}
|
||||
}).then(async (res) => {
|
||||
if (res && res.status === 200) {
|
||||
return res.json();
|
||||
}
|
||||
console.log('Failed to delete a service token');
|
||||
return undefined;
|
||||
});
|
||||
};
|
||||
|
||||
export default deleteServiceToken;
|
||||
|
||||
@@ -1,26 +1,22 @@
|
||||
import SecurityClient from '~/utilities/SecurityClient';
|
||||
import SecurityClient from '@app/components/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/v2/workspace/' + workspaceId + '/service-token-data',
|
||||
{
|
||||
method: 'GET',
|
||||
headers: {
|
||||
'Content-Type': 'application/json'
|
||||
}
|
||||
const getServiceTokens = ({ workspaceId }: { workspaceId: string }) =>
|
||||
SecurityClient.fetchCall(`/api/v2/workspace/${workspaceId}/service-token-data`, {
|
||||
method: 'GET',
|
||||
headers: {
|
||||
'Content-Type': 'application/json'
|
||||
}
|
||||
).then(async (res) => {
|
||||
if (res && res.status == 200) {
|
||||
}).then(async (res) => {
|
||||
if (res && res.status === 200) {
|
||||
return (await res.json()).serviceTokenData;
|
||||
} else {
|
||||
console.log('Failed to get service tokens');
|
||||
}
|
||||
console.log('Failed to get service tokens');
|
||||
return undefined;
|
||||
});
|
||||
};
|
||||
|
||||
export default getServiceTokens;
|
||||
|
||||
@@ -1,21 +1,20 @@
|
||||
import SecurityClient from '~/utilities/SecurityClient';
|
||||
import SecurityClient from '@app/components/utilities/SecurityClient';
|
||||
|
||||
/**
|
||||
* This route gets the information about a specific user.
|
||||
*/
|
||||
const getUser = () => {
|
||||
return SecurityClient.fetchCall('/api/v1/user', {
|
||||
const getUser = () =>
|
||||
SecurityClient.fetchCall('/api/v1/user', {
|
||||
method: 'GET',
|
||||
headers: {
|
||||
'Content-Type': 'application/json'
|
||||
}
|
||||
}).then(async (res) => {
|
||||
if (res?.status == 200) {
|
||||
if (res?.status === 200) {
|
||||
return (await res.json()).user;
|
||||
} else {
|
||||
console.log('Failed to get user info');
|
||||
}
|
||||
console.log('Failed to get user info');
|
||||
return undefined;
|
||||
});
|
||||
};
|
||||
|
||||
export default getUser;
|
||||
|
||||
@@ -1,4 +1,4 @@
|
||||
import SecurityClient from '~/utilities/SecurityClient';
|
||||
import SecurityClient from '@app/components/utilities/SecurityClient';
|
||||
|
||||
/**
|
||||
* This route registers a certain action for a user
|
||||
@@ -6,13 +6,12 @@ import SecurityClient from '~/utilities/SecurityClient';
|
||||
* @param {*} workspaceId
|
||||
* @returns
|
||||
*/
|
||||
const checkUserAction = ({ action }: { action: string }) => {
|
||||
return SecurityClient.fetchCall(
|
||||
'/api/v1/user-action' +
|
||||
'?' +
|
||||
new URLSearchParams({
|
||||
const checkUserAction = ({ action }: { action: string }) =>
|
||||
SecurityClient.fetchCall(
|
||||
`/api/v1/user-action` +
|
||||
`?${new URLSearchParams({
|
||||
action
|
||||
}),
|
||||
})}`,
|
||||
{
|
||||
method: 'GET',
|
||||
headers: {
|
||||
@@ -20,12 +19,11 @@ const checkUserAction = ({ action }: { action: string }) => {
|
||||
}
|
||||
}
|
||||
).then(async (res) => {
|
||||
if (res && 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');
|
||||
return undefined;
|
||||
});
|
||||
};
|
||||
|
||||
export default checkUserAction;
|
||||
|
||||
@@ -1,12 +1,12 @@
|
||||
import SecurityClient from '~/utilities/SecurityClient';
|
||||
import SecurityClient from '@app/components/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', {
|
||||
const registerUserAction = ({ action }: { action: string }) =>
|
||||
SecurityClient.fetchCall('/api/v1/user-action', {
|
||||
method: 'POST',
|
||||
headers: {
|
||||
'Content-Type': 'application/json'
|
||||
@@ -15,12 +15,11 @@ const registerUserAction = ({ action }: { action: string }) => {
|
||||
action
|
||||
})
|
||||
}).then(async (res) => {
|
||||
if (res && res.status == 200) {
|
||||
if (res && res.status === 200) {
|
||||
return res;
|
||||
} else {
|
||||
console.log('Failed to register a user action');
|
||||
}
|
||||
console.log('Failed to register a user action');
|
||||
return undefined;
|
||||
});
|
||||
};
|
||||
|
||||
export default registerUserAction;
|
||||
|
||||
@@ -1,4 +1,4 @@
|
||||
import SecurityClient from '~/utilities/SecurityClient';
|
||||
import SecurityClient from '@app/components/utilities/SecurityClient';
|
||||
|
||||
/**
|
||||
* This function adds a user to a project
|
||||
@@ -6,25 +6,21 @@ import SecurityClient from '~/utilities/SecurityClient';
|
||||
* @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');
|
||||
const addUserToWorkspace = (email: string, workspaceId: string) =>
|
||||
SecurityClient.fetchCall(`/api/v1/workspace/${workspaceId}/invite-signup`, {
|
||||
method: 'POST',
|
||||
headers: {
|
||||
'Content-Type': 'application/json'
|
||||
},
|
||||
body: JSON.stringify({
|
||||
email
|
||||
})
|
||||
}).then(async (res) => {
|
||||
if (res && res.status === 200) {
|
||||
return res.json();
|
||||
}
|
||||
console.log('Failed to add a user to project');
|
||||
return undefined;
|
||||
});
|
||||
};
|
||||
|
||||
export default addUserToWorkspace;
|
||||
|
||||
@@ -1,4 +1,4 @@
|
||||
import SecurityClient from '~/utilities/SecurityClient';
|
||||
import SecurityClient from '@app/components/utilities/SecurityClient';
|
||||
|
||||
/**
|
||||
* This function change the access of a user in a certain workspace
|
||||
@@ -6,25 +6,21 @@ import SecurityClient from '~/utilities/SecurityClient';
|
||||
* @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) {
|
||||
const changeUserRoleInWorkspace = (membershipId: string, role: string) =>
|
||||
SecurityClient.fetchCall(`/api/v1/membership/${membershipId}/change-role`, {
|
||||
method: 'POST',
|
||||
headers: {
|
||||
'Content-Type': 'application/json'
|
||||
},
|
||||
body: JSON.stringify({
|
||||
role
|
||||
})
|
||||
}).then(async (res) => {
|
||||
if (res && res.status === 200) {
|
||||
return res;
|
||||
} else {
|
||||
console.log('Failed to change the user role in a project');
|
||||
}
|
||||
console.log('Failed to change the user role in a project');
|
||||
return undefined;
|
||||
});
|
||||
};
|
||||
|
||||
export default changeUserRoleInWorkspace;
|
||||
|
||||
@@ -1,4 +1,4 @@
|
||||
import SecurityClient from '~/utilities/SecurityClient';
|
||||
import SecurityClient from '@app/components/utilities/SecurityClient';
|
||||
|
||||
/**
|
||||
* This route creates a new workspace for a user within a certain organization.
|
||||
@@ -12,23 +12,22 @@ const createWorkspace = ({
|
||||
}: {
|
||||
workspaceName: string;
|
||||
organizationId: string;
|
||||
}) => {
|
||||
return SecurityClient.fetchCall('/api/v1/workspace', {
|
||||
}) =>
|
||||
SecurityClient.fetchCall('/api/v1/workspace', {
|
||||
method: 'POST',
|
||||
headers: {
|
||||
'Content-Type': 'application/json'
|
||||
},
|
||||
body: JSON.stringify({
|
||||
workspaceName: workspaceName,
|
||||
organizationId: organizationId
|
||||
workspaceName,
|
||||
organizationId
|
||||
})
|
||||
}).then(async (res) => {
|
||||
if (res?.status == 200) {
|
||||
if (res?.status === 200) {
|
||||
return (await res.json()).workspace;
|
||||
} else {
|
||||
console.log('Failed to create a project');
|
||||
}
|
||||
console.log('Failed to create a project');
|
||||
return undefined;
|
||||
});
|
||||
};
|
||||
|
||||
export default createWorkspace;
|
||||
|
||||
@@ -1,23 +1,22 @@
|
||||
import SecurityClient from '~/utilities/SecurityClient';
|
||||
import SecurityClient from '@app/components/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, {
|
||||
const deleteUserFromWorkspace = (membershipId: string) =>
|
||||
SecurityClient.fetchCall(`/api/v1/membership/${membershipId}`, {
|
||||
method: 'DELETE',
|
||||
headers: {
|
||||
'Content-Type': 'application/json'
|
||||
}
|
||||
}).then(async (res) => {
|
||||
if (res && res.status == 200) {
|
||||
if (res && res.status === 200) {
|
||||
return res;
|
||||
} else {
|
||||
console.log('Failed to delete a user from a project');
|
||||
}
|
||||
console.log('Failed to delete a user from a project');
|
||||
return undefined;
|
||||
});
|
||||
};
|
||||
|
||||
export default deleteUserFromWorkspace;
|
||||
|
||||
@@ -1,23 +1,22 @@
|
||||
import SecurityClient from '~/utilities/SecurityClient';
|
||||
import SecurityClient from '@app/components/utilities/SecurityClient';
|
||||
|
||||
/**
|
||||
* This route deletes a specified workspace.
|
||||
* @param {*} workspaceId
|
||||
* @returns
|
||||
*/
|
||||
const deleteWorkspace = (workspaceId: string) => {
|
||||
return SecurityClient.fetchCall('/api/v1/workspace/' + workspaceId, {
|
||||
const deleteWorkspace = (workspaceId: string) =>
|
||||
SecurityClient.fetchCall(`/api/v1/workspace/${workspaceId}`, {
|
||||
method: 'DELETE',
|
||||
headers: {
|
||||
'Content-Type': 'application/json'
|
||||
}
|
||||
}).then(async (res) => {
|
||||
if (res && res.status == 200) {
|
||||
if (res && res.status === 200) {
|
||||
return res;
|
||||
} else {
|
||||
console.log('Failed to delete a project');
|
||||
}
|
||||
console.log('Failed to delete a project');
|
||||
return undefined;
|
||||
});
|
||||
};
|
||||
|
||||
export default deleteWorkspace;
|
||||
|
||||
@@ -1,4 +1,4 @@
|
||||
import SecurityClient from '~/utilities/SecurityClient';
|
||||
import SecurityClient from '@app/components/utilities/SecurityClient';
|
||||
|
||||
interface Workspace {
|
||||
__v: number;
|
||||
@@ -12,20 +12,19 @@ interface Workspace {
|
||||
* This route lets us get the workspaces of a certain user
|
||||
* @returns
|
||||
*/
|
||||
const getAWorkspace = (workspaceID:string) => {
|
||||
return SecurityClient.fetchCall(`/api/v1/workspace/${workspaceID}`, {
|
||||
const getAWorkspace = (workspaceID: string) =>
|
||||
SecurityClient.fetchCall(`/api/v1/workspace/${workspaceID}`, {
|
||||
method: 'GET',
|
||||
headers: {
|
||||
'Content-Type': 'application/json',
|
||||
},
|
||||
'Content-Type': 'application/json'
|
||||
}
|
||||
}).then(async (res) => {
|
||||
if (res?.status == 200) {
|
||||
if (res?.status === 200) {
|
||||
const data = (await res.json()) as unknown as { workspace: Workspace };
|
||||
return data.workspace;
|
||||
}
|
||||
|
||||
throw new Error('Failed to get workspace');
|
||||
});
|
||||
};
|
||||
|
||||
export default getAWorkspace;
|
||||
|
||||
@@ -1,23 +1,22 @@
|
||||
import SecurityClient from '~/utilities/SecurityClient';
|
||||
import SecurityClient from '@app/components/utilities/SecurityClient';
|
||||
|
||||
/**
|
||||
* Get the latest key pairs from a certain workspace
|
||||
* @param {string} workspaceId
|
||||
* @returns
|
||||
*/
|
||||
const getLatestFileKey = ({ workspaceId }: { workspaceId: string }) => {
|
||||
return SecurityClient.fetchCall('/api/v1/key/' + workspaceId + '/latest', {
|
||||
const getLatestFileKey = ({ workspaceId }: { workspaceId: string }) =>
|
||||
SecurityClient.fetchCall(`/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');
|
||||
if (res?.status === 200) {
|
||||
return res.json();
|
||||
}
|
||||
console.log('Failed to get the latest key pairs for a certain project');
|
||||
return undefined;
|
||||
});
|
||||
};
|
||||
|
||||
export default getLatestFileKey;
|
||||
|
||||
@@ -1,23 +1,22 @@
|
||||
import SecurityClient from '~/utilities/SecurityClient';
|
||||
import SecurityClient from '@app/components/utilities/SecurityClient';
|
||||
|
||||
/**
|
||||
* This route lets us get the information of a certain project.
|
||||
* @param {*} projectId - project ID (we renamed workspaces to projects in the app)
|
||||
* @returns
|
||||
*/
|
||||
const getProjectInfo = ({ projectId }: { projectId: string }) => {
|
||||
return SecurityClient.fetchCall('/api/v1/workspace/' + projectId, {
|
||||
const getProjectInfo = ({ projectId }: { projectId: string }) =>
|
||||
SecurityClient.fetchCall(`/api/v1/workspace/${projectId}`, {
|
||||
method: 'GET',
|
||||
headers: {
|
||||
'Content-Type': 'application/json'
|
||||
}
|
||||
}).then(async (res) => {
|
||||
if (res?.status == 200) {
|
||||
if (res?.status === 200) {
|
||||
return (await res.json()).workspace;
|
||||
} else {
|
||||
console.log('Failed to get project info');
|
||||
}
|
||||
console.log('Failed to get project info');
|
||||
return undefined;
|
||||
});
|
||||
};
|
||||
|
||||
export default getProjectInfo;
|
||||
|
||||
@@ -1,26 +1,22 @@
|
||||
import SecurityClient from "~/utilities/SecurityClient";
|
||||
import SecurityClient from '@app/components/utilities/SecurityClient';
|
||||
|
||||
/**
|
||||
* This route lets us get the public keys of everyone in your workspace.
|
||||
* @param {string} workspaceId
|
||||
* @returns
|
||||
*/
|
||||
const getWorkspaceKeys = ({ workspaceId }: { workspaceId: string; }) => {
|
||||
return SecurityClient.fetchCall(
|
||||
"/api/v1/workspace/" + workspaceId + "/keys",
|
||||
{
|
||||
method: "GET",
|
||||
headers: {
|
||||
"Content-Type": "application/json",
|
||||
},
|
||||
const getWorkspaceKeys = ({ workspaceId }: { workspaceId: string }) =>
|
||||
SecurityClient.fetchCall(`/api/v1/workspace/${workspaceId}/keys`, {
|
||||
method: 'GET',
|
||||
headers: {
|
||||
'Content-Type': 'application/json'
|
||||
}
|
||||
).then(async (res) => {
|
||||
if (res?.status == 200) {
|
||||
}).then(async (res) => {
|
||||
if (res?.status === 200) {
|
||||
return (await res.json()).publicKeys;
|
||||
} else {
|
||||
console.log("Failed to get the public keys of everyone in the workspace");
|
||||
}
|
||||
console.log('Failed to get the public keys of everyone in the workspace');
|
||||
return undefined;
|
||||
});
|
||||
};
|
||||
|
||||
export default getWorkspaceKeys;
|
||||
|
||||
@@ -1,26 +1,22 @@
|
||||
import SecurityClient from '~/utilities/SecurityClient';
|
||||
import SecurityClient from '@app/components/utilities/SecurityClient';
|
||||
|
||||
/**
|
||||
* This route lets us get all the users in the workspace.
|
||||
* @param {string} workspaceId - workspace ID
|
||||
* @returns
|
||||
*/
|
||||
const getWorkspaceUsers = ({ workspaceId }: { workspaceId: string }) => {
|
||||
return SecurityClient.fetchCall(
|
||||
'/api/v1/workspace/' + workspaceId + '/users',
|
||||
{
|
||||
method: 'GET',
|
||||
headers: {
|
||||
'Content-Type': 'application/json'
|
||||
}
|
||||
const getWorkspaceUsers = ({ workspaceId }: { workspaceId: string }) =>
|
||||
SecurityClient.fetchCall(`/api/v1/workspace/${workspaceId}/users`, {
|
||||
method: 'GET',
|
||||
headers: {
|
||||
'Content-Type': 'application/json'
|
||||
}
|
||||
).then(async (res) => {
|
||||
if (res?.status == 200) {
|
||||
}).then(async (res) => {
|
||||
if (res?.status === 200) {
|
||||
return (await res.json()).users;
|
||||
} else {
|
||||
console.log('Failed to get Project Users');
|
||||
}
|
||||
console.log('Failed to get Project Users');
|
||||
return undefined;
|
||||
});
|
||||
};
|
||||
|
||||
export default getWorkspaceUsers;
|
||||
|
||||
@@ -1,31 +1,30 @@
|
||||
import SecurityClient from '~/utilities/SecurityClient';
|
||||
import SecurityClient from '@app/components/utilities/SecurityClient';
|
||||
|
||||
interface Workspace {
|
||||
__v: number;
|
||||
_id: string;
|
||||
name: string;
|
||||
organization: string;
|
||||
environments: Array<{name:string, slug:string}>
|
||||
environments: Array<{ name: string; slug: string }>;
|
||||
}
|
||||
|
||||
/**
|
||||
* This route lets us get the workspaces of a certain user
|
||||
* @returns
|
||||
*/
|
||||
const getWorkspaces = () => {
|
||||
return SecurityClient.fetchCall('/api/v1/workspace', {
|
||||
const getWorkspaces = () =>
|
||||
SecurityClient.fetchCall('/api/v1/workspace', {
|
||||
method: 'GET',
|
||||
headers: {
|
||||
'Content-Type': 'application/json'
|
||||
}
|
||||
}).then(async (res) => {
|
||||
if (res?.status == 200) {
|
||||
if (res?.status === 200) {
|
||||
const data = (await res.json()) as unknown as { workspaces: Workspace[] };
|
||||
return data.workspaces;
|
||||
}
|
||||
|
||||
throw new Error('Failed to get projects');
|
||||
});
|
||||
};
|
||||
|
||||
export default getWorkspaces;
|
||||
|
||||
@@ -1,4 +1,4 @@
|
||||
import SecurityClient from '~/utilities/SecurityClient';
|
||||
import SecurityClient from '@app/components/utilities/SecurityClient';
|
||||
|
||||
/**
|
||||
* This route lets us rename a certain workspace.
|
||||
@@ -6,25 +6,21 @@ import SecurityClient from '~/utilities/SecurityClient';
|
||||
* @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) {
|
||||
const renameWorkspace = (workspaceId: string, newWorkspaceName: string) =>
|
||||
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');
|
||||
}
|
||||
console.log('Failed to rename a project');
|
||||
return undefined;
|
||||
});
|
||||
};
|
||||
|
||||
export default renameWorkspace;
|
||||
|
||||
@@ -1,4 +1,4 @@
|
||||
import SecurityClient from '~/utilities/SecurityClient';
|
||||
import SecurityClient from '@app/components/utilities/SecurityClient';
|
||||
|
||||
/**
|
||||
* This route uplods the keys in an encrypted format.
|
||||
@@ -8,31 +8,25 @@ import SecurityClient from '~/utilities/SecurityClient';
|
||||
* @param {*} nonce
|
||||
* @returns
|
||||
*/
|
||||
const uploadKeys = (
|
||||
workspaceId: string,
|
||||
userId: string,
|
||||
encryptedKey: string,
|
||||
nonce: string
|
||||
) => {
|
||||
return SecurityClient.fetchCall('/api/v1/key/' + workspaceId, {
|
||||
const uploadKeys = (workspaceId: string, userId: string, encryptedKey: string, nonce: string) =>
|
||||
SecurityClient.fetchCall(`/api/v1/key/${workspaceId}`, {
|
||||
method: 'POST',
|
||||
headers: {
|
||||
'Content-Type': 'application/json'
|
||||
},
|
||||
body: JSON.stringify({
|
||||
key: {
|
||||
userId: userId,
|
||||
encryptedKey: encryptedKey,
|
||||
nonce: nonce
|
||||
userId,
|
||||
encryptedKey,
|
||||
nonce
|
||||
}
|
||||
})
|
||||
}).then(async (res) => {
|
||||
if (res && res.status == 200) {
|
||||
if (res && res.status === 200) {
|
||||
return res;
|
||||
} else {
|
||||
console.log('Failed to upload keys for a new user');
|
||||
}
|
||||
console.log('Failed to upload keys for a new user');
|
||||
return undefined;
|
||||
});
|
||||
};
|
||||
|
||||
export default uploadKeys;
|
||||
|
||||
Reference in New Issue
Block a user