File tree 5 files changed +77
-1
lines changed
5 files changed +77
-1
lines changed Original file line number Diff line number Diff line change 57
57
"@types/node" : " ^11.13.2" ,
58
58
"@types/recursive-readdir" : " ^2.2.0" ,
59
59
"debug" : " ^4.1.1" ,
60
+ "fast-redact" : " ^1.5.0" ,
60
61
"file-type" : " ^10.10.0" ,
61
62
"got" : " ^9.6.0" ,
62
63
"mime-types" : " ^2.1.22" ,
Original file line number Diff line number Diff line change @@ -460,7 +460,7 @@ export class TwilioServerlessApiClient extends events.EventEmitter {
460
460
message : 'Gathering Functions and Assets to deploy' ,
461
461
} ) ;
462
462
463
- log ( 'Deploy config %O ' , deployConfig ) ;
463
+ log ( 'Deploy config %P ' , deployConfig ) ;
464
464
465
465
const searchConfig : SearchConfig = { } ;
466
466
if ( deployConfig . functionsFolderName ) {
Original file line number Diff line number Diff line change
1
+ declare module 'fast-redact' {
2
+ function createRedactor ( options : { } ) : < T > ( val : T ) => string ;
3
+
4
+ export = createRedactor ;
5
+ }
Original file line number Diff line number Diff line change 4
4
*
5
5
* Main entry point of the project
6
6
*/
7
+
8
+ import './utils/debug' ;
9
+
7
10
export * from './api' ;
8
11
export * from './client' ;
9
12
export * from './types/index' ;
Original file line number Diff line number Diff line change
1
+ import debug from 'debug' ;
2
+ import fastRedact from 'fast-redact' ;
3
+
4
+ type RedactorFunction < T extends object > = ( val : T ) => T ;
5
+
6
+ function prefixAllEntriesWithWildcard ( values : string [ ] ) : string [ ] {
7
+ const result = [ ] ;
8
+
9
+ for ( let val of values ) {
10
+ result . push ( val ) ;
11
+ result . push ( `*.${ val } ` ) ;
12
+ }
13
+
14
+ return result ;
15
+ }
16
+
17
+ export const generalRedactor = fastRedact ( {
18
+ paths : [
19
+ 'env.*' ,
20
+ 'pkgJson.*' ,
21
+ ...prefixAllEntriesWithWildcard ( [
22
+ 'authToken' ,
23
+ 'apiSecret' ,
24
+ 'username' ,
25
+ 'password' ,
26
+ 'cookies' ,
27
+ 'AUTH_TOKEN' ,
28
+ 'API_SECRET' ,
29
+ 'TWILIO_AUTH_TOKEN' ,
30
+ 'TWILIO_API_SECRET' ,
31
+ ] ) ,
32
+ ] ,
33
+ } ) ;
34
+
35
+ export const allPropertiesRedactor = fastRedact ( {
36
+ paths : [ '*' ] ,
37
+ } ) ;
38
+
39
+ debug . formatters . P = function protectedFormatterMultiline ( v : any ) : string {
40
+ if ( typeof v === 'object' ) {
41
+ v = JSON . parse ( generalRedactor ( v ) ) ;
42
+ }
43
+
44
+ return debug . formatters . O . bind ( debug ) ( v ) ;
45
+ } ;
46
+
47
+ debug . formatters . p = function protectedFormatterSameline ( v : any ) : string {
48
+ if ( typeof v === 'object' ) {
49
+ v = JSON . parse ( generalRedactor ( v ) ) ;
50
+ }
51
+
52
+ return debug . formatters . o . bind ( debug ) ( v ) ;
53
+ } ;
54
+
55
+ debug . formatters . R = function redactedFormatterMultiline ( v : any ) : string {
56
+ if ( typeof v === 'object' ) {
57
+ v = JSON . parse ( allPropertiesRedactor ( v ) ) ;
58
+ }
59
+ return debug . formatters . O . bind ( debug ) ( v ) ;
60
+ } ;
61
+
62
+ debug . formatters . r = function redactedFormatterSameline ( v : any ) : string {
63
+ if ( typeof v === 'object' ) {
64
+ v = JSON . parse ( allPropertiesRedactor ( v ) ) ;
65
+ }
66
+ return debug . formatters . o . bind ( debug ) ( v ) ;
67
+ } ;
You can’t perform that action at this time.
0 commit comments