@@ -25,6 +25,7 @@ export class NpmRegistry implements INpmRegistry {
25
25
this . authOnly = authOnly || false ;
26
26
}
27
27
28
+ /** Return NpmRegistry with masked auth from Service Endpoint. */
28
29
public static async FromServiceEndpoint ( endpointId : string , authOnly ?: boolean ) : Promise < NpmRegistry > {
29
30
const lineEnd = os . EOL ;
30
31
let endpointAuth : tl . EndpointAuthorization ;
@@ -59,31 +60,32 @@ export class NpmRegistry implements INpmRegistry {
59
60
username = endpointAuth . parameters [ 'username' ] ;
60
61
password = endpointAuth . parameters [ 'password' ] ;
61
62
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' ) ;
64
64
65
65
auth = nerfed + ':username=' + username + lineEnd ;
66
66
auth += nerfed + ':_password=' + password64 + lineEnd ;
67
67
auth += nerfed + ':email=' + email + lineEnd ;
68
68
break ;
69
69
case 'Token' :
70
70
const apitoken = endpointAuth . parameters [ 'apitoken' ] ;
71
+ tl . setSecret ( apitoken ) ;
71
72
if ( ! isVstsTokenAuth ) {
72
73
// Use Bearer auth as it was intended.
73
74
auth = nerfed + ':_authToken=' + apitoken + lineEnd ;
74
75
} else {
75
76
// Azure DevOps does not support PATs+Bearer only JWTs+Bearer
76
77
email = 'VssEmail' ;
77
78
username = 'VssToken' ;
78
- password64 = ( new Buffer ( apitoken ) . toString ( 'base64' ) ) ;
79
- tl . setSecret ( password64 ) ;
79
+ password64 = Buffer . from ( apitoken ) . toString ( 'base64' ) ;
80
80
81
81
auth = nerfed + ':username=' + username + lineEnd ;
82
82
auth += nerfed + ':_password=' + password64 + lineEnd ;
83
83
auth += nerfed + ':email=' + email + lineEnd ;
84
84
}
85
85
break ;
86
86
}
87
+ tl . setSecret ( password ) ;
88
+ tl . setSecret ( password64 ) ;
87
89
88
90
auth += nerfed + ':always-auth=true' ;
89
91
return new NpmRegistry ( url , auth , authOnly ) ;
0 commit comments