File tree Expand file tree Collapse file tree 1 file changed +20
-1
lines changed
Expand file tree Collapse file tree 1 file changed +20
-1
lines changed Original file line number Diff line number Diff line change @@ -1139,8 +1139,27 @@ function applyHeadersMut(targetHeaders: Headers, newHeaders: Headers): void {
11391139}
11401140
11411141export function debug ( action : string , ...args : any [ ] ) {
1142+ const sensitiveHeaders = [ "authorization" , "api-key" ] ;
11421143 if ( typeof process !== 'undefined' && process ?. env ?. [ 'DEBUG' ] === 'true' ) {
1143- console . log ( `OpenAI:DEBUG:${ action } ` , ...args ) ;
1144+ for ( const arg of args ) {
1145+ if ( ! arg ) {
1146+ break ;
1147+ }
1148+ // Check for sensitive headers in request body "headers"
1149+ if ( arg [ "headers" ] ) {
1150+ for ( const header in arg [ "headers" ] ) {
1151+ if ( sensitiveHeaders . includes ( header . toLowerCase ( ) ) ) {
1152+ arg [ "headers" ] [ header ] = "REDACTED" ;
1153+ }
1154+ }
1155+ }
1156+ // Check for sensitive headers in headers object
1157+ for ( const header in arg ) {
1158+ if ( sensitiveHeaders . includes ( header . toLowerCase ( ) ) ) {
1159+ arg [ header ] = "REDACTED" ;
1160+ }
1161+ }
1162+ }
11441163 }
11451164}
11461165
You can’t perform that action at this time.
0 commit comments