File tree Expand file tree Collapse file tree 3 files changed +74
-14
lines changed
shared/components/TextSelectCopy
teleport/src/services/integrations Expand file tree Collapse file tree 3 files changed +74
-14
lines changed Original file line number Diff line number Diff line change @@ -29,3 +29,9 @@ export const BashCommand = () => {
29
29
export const NonBash = ( ) => {
30
30
return < Component text = "some text to be copied" bash = { false } /> ;
31
31
} ;
32
+
33
+ export const Obfuscated = ( ) => {
34
+ return (
35
+ < Component text = "Super-secret-donot-tell-anyone" bash = { false } obfuscate />
36
+ ) ;
37
+ } ;
Original file line number Diff line number Diff line change @@ -30,12 +30,17 @@ export function TextSelectCopy({
30
30
allowMultiline,
31
31
onCopy,
32
32
bash = true ,
33
+ obfuscate = false ,
33
34
...styles
34
35
} : Props ) {
35
36
const font = fontFamily || useTheme ( ) . fonts . mono ;
36
37
const ref = useRef ( undefined ) ;
37
38
const abortControllerRef = useRef < AbortController > ( undefined ) ;
38
39
const [ copyCmd , setCopyCmd ] = useState ( ( ) => 'Copy' ) ;
40
+ const [ isObfuscated , setIsObfuscated ] = useState ( false ) ;
41
+
42
+ const displayText =
43
+ obfuscate && ! bash && ! isObfuscated ? obfuscateText ( text ) : text ;
39
44
40
45
function onCopyClick ( ) {
41
46
abortControllerRef . current ?. abort ( ) ;
@@ -84,20 +89,36 @@ export function TextSelectCopy({
84
89
>
85
90
< Flex mr = "2" style = { boxStyles } >
86
91
{ bash && < Box mr = "1" style = { { userSelect : 'none' } } > { `$` } </ Box > }
87
- < div ref = { ref } > { text } </ div >
92
+ < div ref = { ref } > { displayText } </ div >
93
+ </ Flex >
94
+ < Flex gap = { 2 } alignItems = "center" >
95
+ { obfuscate && (
96
+ < ButtonPrimary
97
+ onClick = { ( ) => setIsObfuscated ( ! isObfuscated ) }
98
+ style = { {
99
+ maxWidth : '48px' ,
100
+ width : '100%' ,
101
+ padding : '4px 8px' ,
102
+ minHeight : '10px' ,
103
+ fontSize : '10px' ,
104
+ } }
105
+ >
106
+ { isObfuscated ? 'Hide' : 'Show' }
107
+ </ ButtonPrimary >
108
+ ) }
109
+ < ButtonPrimary
110
+ onClick = { onCopyClick }
111
+ style = { {
112
+ maxWidth : '48px' ,
113
+ width : '100%' ,
114
+ padding : '4px 8px' ,
115
+ minHeight : '10px' ,
116
+ fontSize : '10px' ,
117
+ } }
118
+ >
119
+ { copyCmd }
120
+ </ ButtonPrimary >
88
121
</ Flex >
89
- < ButtonPrimary
90
- onClick = { onCopyClick }
91
- style = { {
92
- maxWidth : '48px' ,
93
- width : '100%' ,
94
- padding : '4px 8px' ,
95
- minHeight : '10px' ,
96
- fontSize : '10px' ,
97
- } }
98
- >
99
- { copyCmd }
100
- </ ButtonPrimary >
101
122
</ Flex >
102
123
) ;
103
124
}
@@ -109,4 +130,16 @@ type Props = {
109
130
allowMultiline ?: boolean ;
110
131
// handles styles
111
132
[ key : string ] : any ;
112
- } ;
133
+ // only one of `bash`/`obfuscate` should be set at a time
134
+ } & (
135
+ | {
136
+ bash : false ;
137
+ obfuscate ?: true ;
138
+ }
139
+ | {
140
+ bash ?: true ;
141
+ obfuscate ?: false ;
142
+ }
143
+ ) ;
144
+
145
+ const obfuscateText = ( value : string ) : string => '•' . repeat ( value . length ) ;
Original file line number Diff line number Diff line change @@ -70,6 +70,7 @@ export type IntegrationTemplate<
70
70
details ?: string ;
71
71
statusCode : IntegrationStatusCode ;
72
72
status ?: SD ;
73
+ credentials ?: PluginCredentials ;
73
74
} ;
74
75
// IntegrationKind string values should be in sync
75
76
// with the backend value for defining the integration
@@ -228,6 +229,26 @@ export type PluginStatus<D = any> = {
228
229
* contains provider-specific status information
229
230
*/
230
231
details ?: D ;
232
+ /**
233
+ * credentials contains information about the plugin's credentials,
234
+ * if applicable, only on creation.
235
+ */
236
+ credentials ?: PluginCredentials ;
237
+ } ;
238
+
239
+ export type PluginCredentials = {
240
+ OAuthCredentials ?: PluginOAuthCredentials ;
241
+ } ;
242
+
243
+ type PluginOAuthCredentials = {
244
+ /**
245
+ * clientId is the OAuth client ID
246
+ */
247
+ clientId : string ;
248
+ /**
249
+ * clientSecret is the OAuth client secret
250
+ */
251
+ clientSecret : string ;
231
252
} ;
232
253
233
254
/**
You can’t perform that action at this time.
0 commit comments