From 1244716b9b6c511e39d8a12a8ccbe9bd471d6f35 Mon Sep 17 00:00:00 2001 From: Prem Kumar Easwaran Date: Mon, 16 Oct 2023 11:19:55 +0530 Subject: [PATCH 1/4] Change import icon --- .../Environments/EnvironmentSettings/EnvironmentList/index.js | 4 ++-- packages/bruno-app/src/components/Welcome/index.js | 4 ++-- 2 files changed, 4 insertions(+), 4 deletions(-) diff --git a/packages/bruno-app/src/components/Environments/EnvironmentSettings/EnvironmentList/index.js b/packages/bruno-app/src/components/Environments/EnvironmentSettings/EnvironmentList/index.js index 44e18455f..dd7ac4f79 100644 --- a/packages/bruno-app/src/components/Environments/EnvironmentSettings/EnvironmentList/index.js +++ b/packages/bruno-app/src/components/Environments/EnvironmentSettings/EnvironmentList/index.js @@ -5,7 +5,7 @@ import { toastError } from 'utils/common/error'; import usePrevious from 'hooks/usePrevious'; import EnvironmentDetails from './EnvironmentDetails'; import CreateEnvironment from '../CreateEnvironment'; -import { IconUpload } from '@tabler/icons'; +import { IconDownload } from '@tabler/icons'; import ImportEnvironment from '../ImportEnvironment'; import StyledWrapper from './StyledWrapper'; @@ -73,7 +73,7 @@ const EnvironmentList = ({ collection }) => {
setOpenImportModal(true)}> - + Import
diff --git a/packages/bruno-app/src/components/Welcome/index.js b/packages/bruno-app/src/components/Welcome/index.js index 278516538..adfce3dd8 100644 --- a/packages/bruno-app/src/components/Welcome/index.js +++ b/packages/bruno-app/src/components/Welcome/index.js @@ -2,7 +2,7 @@ import { useState } from 'react'; import toast from 'react-hot-toast'; import { useDispatch } from 'react-redux'; import { openCollection, importCollection } from 'providers/ReduxStore/slices/collections/actions'; -import { IconBrandGithub, IconPlus, IconUpload, IconFolders, IconSpeakerphone, IconBook } from '@tabler/icons'; +import { IconBrandGithub, IconPlus, IconDownload, IconFolders, IconSpeakerphone, IconBook } from '@tabler/icons'; import Bruno from 'components/Bruno'; import CreateCollection from 'components/Sidebar/CreateCollection'; @@ -69,7 +69,7 @@ const Welcome = () => { Open Collection
setImportCollectionModalOpen(true)}> - + Import Collection From 6e7fc2a9aae6a61163bf9a6eb86af79c3d2c2a42 Mon Sep 17 00:00:00 2001 From: "Donus(ADA)" Date: Mon, 16 Oct 2023 12:48:37 +0700 Subject: [PATCH 2/4] feat: add json body prettify --- .../RequestBody/RequestBodyMode/index.js | 28 ++++++++++++++++++- 1 file changed, 27 insertions(+), 1 deletion(-) diff --git a/packages/bruno-app/src/components/RequestPane/RequestBody/RequestBodyMode/index.js b/packages/bruno-app/src/components/RequestPane/RequestBody/RequestBodyMode/index.js index 0d3b63df6..407d42a0d 100644 --- a/packages/bruno-app/src/components/RequestPane/RequestBody/RequestBodyMode/index.js +++ b/packages/bruno-app/src/components/RequestPane/RequestBody/RequestBodyMode/index.js @@ -6,12 +6,15 @@ import { useDispatch } from 'react-redux'; import { updateRequestBodyMode } from 'providers/ReduxStore/slices/collections'; import { humanizeRequestBodyMode } from 'utils/collections'; import StyledWrapper from './StyledWrapper'; +import { updateRequestBody } from 'providers/ReduxStore/slices/collections/index'; +import { toastError } from 'utils/common/error'; const RequestBodyMode = ({ item, collection }) => { const dispatch = useDispatch(); const dropdownTippyRef = useRef(); const onDropdownCreate = (ref) => (dropdownTippyRef.current = ref); - const bodyMode = item.draft ? get(item, 'draft.request.body.mode') : get(item, 'request.body.mode'); + const body = item.draft ? get(item, 'draft.request.body') : get(item, 'request.body'); + const bodyMode = body?.mode; const Icon = forwardRef((props, ref) => { return ( @@ -31,6 +34,24 @@ const RequestBodyMode = ({ item, collection }) => { ); }; + const onPrettify = () => { + if (body?.json && bodyMode === 'json') { + try { + const bodyJson = JSON.parse(body.json); + const prettyBodyJson = JSON.stringify(bodyJson, null, 2); + dispatch( + updateRequestBody({ + content: prettyBodyJson, + itemUid: item.uid, + collectionUid: collection.uid + }) + ); + } catch (e) { + toastError(new Error('Unable to prettify. Invalid JSON format.')); + } + } + }; + return (
@@ -103,6 +124,11 @@ const RequestBodyMode = ({ item, collection }) => {
+ {bodyMode === 'json' && ( + + )} ); }; From 63e0df1640ba6dba180b42cf3aa1623862e93148 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Linhart=20Luk=C3=A1=C5=A1?= Date: Mon, 16 Oct 2023 14:11:01 +0200 Subject: [PATCH 3/4] fix collection client certs --- .../bruno-electron/src/ipc/network/index.js | 55 +++++++++++++++---- 1 file changed, 43 insertions(+), 12 deletions(-) diff --git a/packages/bruno-electron/src/ipc/network/index.js b/packages/bruno-electron/src/ipc/network/index.js index ebd780ece..89be40f36 100644 --- a/packages/bruno-electron/src/ipc/network/index.js +++ b/packages/bruno-electron/src/ipc/network/index.js @@ -662,6 +662,10 @@ const registerNetworkIpc = (mainWindow) => { const timeout = get(preferences, 'request.timeout', 0); request.timeout = timeout; const sslVerification = get(preferences, 'request.sslVerification', true); + const httpsAgentRequestFields = {}; + if (!sslVerification) { + httpsAgentRequestFields['rejectUnauthorized'] = false; + } // run pre-request script const requestScript = compact([get(collectionRoot, 'request.script.req'), get(request, 'script.req')]).join( @@ -704,17 +708,43 @@ const registerNetworkIpc = (mainWindow) => { ...eventData }); - // proxy configuration + const interpolationOptions = { + envVars, + collectionVariables, + processEnvVars + }; const brunoConfig = getBrunoConfig(collectionUid); + + // client certificate config + const clientCertConfig = get(brunoConfig, 'clientCertificates.certs', []); + + for (clientCert of clientCertConfig) { + const domain = interpolateString(clientCert.domain, interpolationOptions); + const certFilePath = interpolateString(clientCert.certFilePath, interpolationOptions); + const keyFilePath = interpolateString(clientCert.keyFilePath, interpolationOptions); + if (domain && certFilePath && keyFilePath) { + const hostRegex = '^https:\\/\\/' + domain.replaceAll('.', '\\.').replaceAll('*', '.*'); + + if (request.url.match(hostRegex)) { + try { + httpsAgentRequestFields['cert'] = fs.readFileSync(certFilePath); + httpsAgentRequestFields['key'] = fs.readFileSync(keyFilePath); + } catch (err) { + console.log('Error reading cert/key file', err); + } + httpsAgentRequestFields['passphrase'] = interpolateString( + clientCert.passphrase, + interpolationOptions + ); + break; + } + } + } + + // proxy configuration const proxyEnabled = get(brunoConfig, 'proxy.enabled', false); if (proxyEnabled) { let proxyUri; - const interpolationOptions = { - envVars, - collectionVariables, - processEnvVars - }; - const proxyProtocol = interpolateString(get(brunoConfig, 'proxy.protocol'), interpolationOptions); const proxyHostname = interpolateString(get(brunoConfig, 'proxy.hostname'), interpolationOptions); const proxyPort = interpolateString(get(brunoConfig, 'proxy.port'), interpolationOptions); @@ -743,15 +773,16 @@ const registerNetworkIpc = (mainWindow) => { request.httpsAgent = socksProxyAgent; request.httpAgent = socksProxyAgent; } else { - request.httpsAgent = new HttpsProxyAgent(proxyUri, { - rejectUnauthorized: sslVerification - }); + request.httpsAgent = new HttpsProxyAgent( + proxyUri, + Object.keys(httpsAgentRequestFields).length > 0 ? { ...httpsAgentRequestFields } : undefined + ); request.httpAgent = new HttpProxyAgent(proxyUri); } - } else if (!sslVerification) { + } else if (Object.keys(httpsAgentRequestFields).length > 0) { request.httpsAgent = new https.Agent({ - rejectUnauthorized: false + ...httpsAgentRequestFields }); } From b28f7625e42b14aa1982a4b9c18a37c3b17d382d Mon Sep 17 00:00:00 2001 From: Anoop M D Date: Tue, 17 Oct 2023 06:52:52 +0530 Subject: [PATCH 4/4] chore: update body selector styles --- .../RequestBody/RequestBodyMode/StyledWrapper.js | 6 +++++- .../RequestPane/RequestBody/RequestBodyMode/index.js | 2 +- 2 files changed, 6 insertions(+), 2 deletions(-) diff --git a/packages/bruno-app/src/components/RequestPane/RequestBody/RequestBodyMode/StyledWrapper.js b/packages/bruno-app/src/components/RequestPane/RequestBody/RequestBodyMode/StyledWrapper.js index e72774524..3d571b4bf 100644 --- a/packages/bruno-app/src/components/RequestPane/RequestBody/RequestBodyMode/StyledWrapper.js +++ b/packages/bruno-app/src/components/RequestPane/RequestBody/RequestBodyMode/StyledWrapper.js @@ -4,7 +4,7 @@ const Wrapper = styled.div` font-size: 0.8125rem; .body-mode-selector { - background: ${(props) => props.theme.requestTabPanel.bodyModeSelect.color}; + background: transparent; border-radius: 3px; .dropdown-item { @@ -15,6 +15,10 @@ const Wrapper = styled.div` .label-item { padding: 0.2rem 0.6rem !important; } + + .selected-body-mode { + color: ${(props) => props.theme.colors.text.yellow}; + } } .caret { diff --git a/packages/bruno-app/src/components/RequestPane/RequestBody/RequestBodyMode/index.js b/packages/bruno-app/src/components/RequestPane/RequestBody/RequestBodyMode/index.js index 407d42a0d..ef000431f 100644 --- a/packages/bruno-app/src/components/RequestPane/RequestBody/RequestBodyMode/index.js +++ b/packages/bruno-app/src/components/RequestPane/RequestBody/RequestBodyMode/index.js @@ -18,7 +18,7 @@ const RequestBodyMode = ({ item, collection }) => { const Icon = forwardRef((props, ref) => { return ( -
+
{humanizeRequestBodyMode(bodyMode)}
);