File tree 3 files changed +13
-3
lines changed
3 files changed +13
-3
lines changed Original file line number Diff line number Diff line change @@ -34,4 +34,11 @@ export class ResponseError extends Error {
34
34
responseCode : number ;
35
35
}
36
36
37
- export class OneTimePasswordError extends Error { }
37
+ export class OneTimePasswordError extends Error {
38
+ constructor ( notice : string ) {
39
+ super ( ) ;
40
+ this . notice = notice ;
41
+ }
42
+
43
+ notice : string ;
44
+ }
Original file line number Diff line number Diff line change @@ -191,6 +191,10 @@ export default class NpmRegistry extends Registry {
191
191
}
192
192
193
193
this . reporter . info ( this . reporter . lang ( 'twoFactorAuthenticationEnabled' ) ) ;
194
+ if ( error . notice ) {
195
+ this . reporter . info ( error . notice ) ;
196
+ }
197
+
194
198
this . otp = await getOneTimePassword ( this . reporter ) ;
195
199
196
200
this . requestManager . clearCache ( ) ;
Original file line number Diff line number Diff line change @@ -440,9 +440,8 @@ export default class RequestManager {
440
440
441
441
if ( res . statusCode === 401 && res . headers [ 'www-authenticate' ] ) {
442
442
const authMethods = res . headers [ 'www-authenticate' ] . split ( / , \s * / ) . map ( s => s . toLowerCase ( ) ) ;
443
-
444
443
if ( authMethods . indexOf ( 'otp' ) !== - 1 ) {
445
- reject ( new OneTimePasswordError ( ) ) ;
444
+ reject ( new OneTimePasswordError ( res . headers [ 'npm-notice' ] ) ) ;
446
445
return ;
447
446
}
448
447
}
You can’t perform that action at this time.
0 commit comments