@@ -25,6 +25,7 @@ export class NpmRegistry implements INpmRegistry {
2525 this . authOnly = authOnly || false ;
2626 }
2727
28+ /** Return NpmRegistry with masked auth from Service Endpoint. */
2829 public static async FromServiceEndpoint ( endpointId : string , authOnly ?: boolean ) : Promise < NpmRegistry > {
2930 const lineEnd = os . EOL ;
3031 let endpointAuth : tl . EndpointAuthorization ;
@@ -59,31 +60,32 @@ export class NpmRegistry implements INpmRegistry {
5960 username = endpointAuth . parameters [ 'username' ] ;
6061 password = endpointAuth . parameters [ 'password' ] ;
6162 email = username ; // npm needs an email to be set in order to publish, this is ignored on npmjs
62- password64 = ( new Buffer ( password ) . toString ( 'base64' ) ) ;
63- tl . setSecret ( password64 ) ;
63+ password64 = Buffer . from ( password ) . toString ( 'base64' ) ;
6464
6565 auth = nerfed + ':username=' + username + lineEnd ;
6666 auth += nerfed + ':_password=' + password64 + lineEnd ;
6767 auth += nerfed + ':email=' + email + lineEnd ;
6868 break ;
6969 case 'Token' :
7070 const apitoken = endpointAuth . parameters [ 'apitoken' ] ;
71+ tl . setSecret ( apitoken ) ;
7172 if ( ! isVstsTokenAuth ) {
7273 // Use Bearer auth as it was intended.
7374 auth = nerfed + ':_authToken=' + apitoken + lineEnd ;
7475 } else {
7576 // Azure DevOps does not support PATs+Bearer only JWTs+Bearer
7677 email = 'VssEmail' ;
7778 username = 'VssToken' ;
78- password64 = ( new Buffer ( apitoken ) . toString ( 'base64' ) ) ;
79- tl . setSecret ( password64 ) ;
79+ password64 = Buffer . from ( apitoken ) . toString ( 'base64' ) ;
8080
8181 auth = nerfed + ':username=' + username + lineEnd ;
8282 auth += nerfed + ':_password=' + password64 + lineEnd ;
8383 auth += nerfed + ':email=' + email + lineEnd ;
8484 }
8585 break ;
8686 }
87+ tl . setSecret ( password ) ;
88+ tl . setSecret ( password64 ) ;
8789
8890 auth += nerfed + ':always-auth=true' ;
8991 return new NpmRegistry ( url , auth , authOnly ) ;
0 commit comments