chore: mask the debug key

pull/12372/head
Joel 2 years ago
parent a059660ed8
commit d4c9c76454

@ -15,6 +15,7 @@ type Props = {
label: string label: string
labelWidthClassName?: string labelWidthClassName?: string
value: string value: string
maskedValue?: string
valueMaxWidthClassName?: string valueMaxWidthClassName?: string
} }
@ -22,6 +23,7 @@ const KeyValueItem: FC<Props> = ({
label, label,
labelWidthClassName = 'w-10', labelWidthClassName = 'w-10',
value, value,
maskedValue,
valueMaxWidthClassName = 'max-w-[162px]', valueMaxWidthClassName = 'max-w-[162px]',
}) => { }) => {
const { t } = useTranslation() const { t } = useTranslation()
@ -49,7 +51,7 @@ const KeyValueItem: FC<Props> = ({
<span className={cn('flex flex-col justify-center items-start text-text-tertiary system-xs-medium', labelWidthClassName)}>{label}</span> <span className={cn('flex flex-col justify-center items-start text-text-tertiary system-xs-medium', labelWidthClassName)}>{label}</span>
<div className='flex justify-center items-center gap-0.5'> <div className='flex justify-center items-center gap-0.5'>
<span className={cn(valueMaxWidthClassName, ' truncate system-xs-medium text-text-secondary')}> <span className={cn(valueMaxWidthClassName, ' truncate system-xs-medium text-text-secondary')}>
{value} {maskedValue || value}
</span> </span>
<Tooltip popupContent={t(`common.operation.${isCopied ? 'copied' : 'copy'}`)} position='top'> <Tooltip popupContent={t(`common.operation.${isCopied ? 'copied' : 'copy'}`)} position='top'>
<ActionButton onClick={handleCopy}> <ActionButton onClick={handleCopy}>

@ -17,6 +17,9 @@ const DebugInfo: FC = () => {
const { t } = useTranslation() const { t } = useTranslation()
const { data: info, isLoading } = useDebugKey() const { data: info, isLoading } = useDebugKey()
// info.key likes 4580bdb7-b878-471c-a8a4-bfd760263a53 mask the middle part using *.
const maskedKey = info?.key?.replace(/(.{8})(.*)(.{8})/, '$1********$3')
if (isLoading) return null if (isLoading) return null
return ( return (
@ -40,6 +43,7 @@ const DebugInfo: FC = () => {
<KeyValueItem <KeyValueItem
label={'Key'} label={'Key'}
value={info?.key || ''} value={info?.key || ''}
maskedValue={maskedKey}
/> />
</div> </div>
</> </>

Loading…
Cancel
Save