diff --git a/packages/bruno-app/src/components/CollectionSettings/ClientCertSettings/index.js b/packages/bruno-app/src/components/CollectionSettings/ClientCertSettings/index.js index 3f62fc23e..a9d7255ea 100644 --- a/packages/bruno-app/src/components/CollectionSettings/ClientCertSettings/index.js +++ b/packages/bruno-app/src/components/CollectionSettings/ClientCertSettings/index.js @@ -1,19 +1,20 @@ import React from 'react'; import { IconCertificate, IconTrash, IconWorld } from '@tabler/icons'; import { useFormik } from 'formik'; -import { uuid } from 'utils/common'; import * as Yup from 'yup'; -import { IconEye, IconEyeOff } from '@tabler/icons'; -import { useState } from 'react'; - import StyledWrapper from './StyledWrapper'; import { useRef } from 'react'; import path from 'utils/common/path'; +import SensitiveFieldWarning from 'components/SensitiveFieldWarning/index'; +import SingleLineEditor from 'components/SingleLineEditor/index'; +import { useDetectSensitiveField } from 'hooks/useDetectSensitiveField/index'; +import { useTheme } from 'styled-components'; -const ClientCertSettings = ({ root, clientCertConfig, onUpdate, onRemove }) => { +const ClientCertSettings = ({ collection, clientCertConfig, onUpdate, onRemove }) => { const certFilePathInputRef = useRef(); const keyFilePathInputRef = useRef(); const pfxFilePathInputRef = useRef(); + const { storedTheme } = useTheme(); const formik = useFormik({ initialValues: { @@ -68,10 +69,13 @@ const ClientCertSettings = ({ root, clientCertConfig, onUpdate, onRemove }) => { } }); + const { isSensitive } = useDetectSensitiveField(collection); + const { showWarning, warningMessage } = isSensitive(formik.values.passphrase); + const getFile = (e) => { const filePath = window?.ipcRenderer?.getFilePath(e?.files?.[0]); if (filePath) { - let relativePath = path.relative(root, filePath); + let relativePath = path.relative(collection.pathname, filePath); formik.setFieldValue(e.name, relativePath); } }; @@ -82,8 +86,6 @@ const ClientCertSettings = ({ root, clientCertConfig, onUpdate, onRemove }) => { pfxFilePathInputRef.current.value = ''; }; - const [passwordVisible, setPasswordVisible] = useState(false); - const handleTypeChange = (e) => { formik.setFieldValue('type', e.target.value); if (e.target.value === 'cert') { @@ -314,21 +316,14 @@ const ClientCertSettings = ({ root, clientCertConfig, onUpdate, onRemove }) => { Passphrase
- formik.setFieldValue('passphrase', val)} + collection={collection} + isSecret={true} /> - + {showWarning && }
{formik.touched.passphrase && formik.errors.passphrase ? (
{formik.errors.passphrase}
diff --git a/packages/bruno-app/src/components/CollectionSettings/index.js b/packages/bruno-app/src/components/CollectionSettings/index.js index 333ed69b8..beb4f040e 100644 --- a/packages/bruno-app/src/components/CollectionSettings/index.js +++ b/packages/bruno-app/src/components/CollectionSettings/index.js @@ -120,7 +120,7 @@ const CollectionSettings = ({ collection }) => { case 'clientCert': { return ( { return isSecret === true ? ( -