@@ -5,14 +5,17 @@ export const AuthCodeBlock = ({
55 highlight,
66 children,
77} ) => {
8- const [ processedChildren , setProcessedChildren ] = useState ( children ) ;
8+ const [ displayText , setDisplayText ] = useState ( children ) ;
9+ const [ copyText , setCopyText ] = useState ( children ) ;
910
1011 useEffect ( ( ) => {
1112 let unsubscribe = null ;
1213
1314 function init ( ) {
1415 unsubscribe = window . autorun ( ( ) => {
15- let processedChildren = children ;
16+ let processedChildrenForDisplay = children ;
17+ let processedChildrenForCopy = children ;
18+
1619 for ( const [
1720 key ,
1821 value ,
@@ -21,12 +24,27 @@ export const AuthCodeBlock = ({
2124 / [ . * + ? ^ $ { } ( ) | [ \] \\ ] / g,
2225 String . raw `\$&`
2326 ) ;
24- processedChildren = processedChildren . replaceAll (
27+
28+ // For display: mask client secret if it's not the placeholder
29+ let displayValue = value ;
30+ if ( key === "{yourClientSecret}" && value !== "{yourClientSecret}" ) {
31+ displayValue = value . substring ( 0 , 3 ) + "*****MASKED*****" ;
32+ }
33+
34+ processedChildrenForDisplay = processedChildrenForDisplay . replaceAll (
35+ new RegExp ( escapedKey , "g" ) ,
36+ displayValue
37+ ) ;
38+
39+ // For copy: use the actual value (unmasked)
40+ processedChildrenForCopy = processedChildrenForCopy . replaceAll (
2541 new RegExp ( escapedKey , "g" ) ,
2642 value
2743 ) ;
2844 }
29- setProcessedChildren ( processedChildren ) ;
45+
46+ setDisplayText ( processedChildrenForDisplay ) ;
47+ setCopyText ( processedChildrenForCopy ) ;
3048 } ) ;
3149 }
3250
@@ -49,8 +67,9 @@ export const AuthCodeBlock = ({
4967 language = { language }
5068 lines
5169 highlight = { highlight }
70+ copyButtonProps = { { textToCopy : copyText , onCopied : ( ) => console . log ( 'onCopied' ) } }
5271 >
53- { processedChildren }
72+ { displayText }
5473 </ CodeBlock >
5574 ) ;
5675} ;
0 commit comments