@@ -767,6 +767,11 @@ class Config {
767
767
const nerfed = nerfDart ( uri )
768
768
const creds = { }
769
769
770
+ const deprecatedAuthWarning = [
771
+ '`_auth`, `_authToken`, `username` and `_password` must be scoped to a registry.' ,
772
+ 'see `npm help npmrc` for more information.' ,
773
+ ] . join ( ' ' )
774
+
770
775
const email = this . get ( `${ nerfed } :email` ) || this . get ( 'email' )
771
776
if ( email ) {
772
777
creds . email = email
@@ -780,10 +785,13 @@ class Config {
780
785
// cert/key may be used in conjunction with other credentials, thus no `return`
781
786
}
782
787
783
- const tokenReg = this . get ( ` ${ nerfed } :_authToken` ) ||
784
- nerfed === nerfDart ( this . get ( 'registry' ) ) && this . get ( '_authToken' )
788
+ const defaultToken = nerfDart ( this . get ( 'registry' ) ) && this . get ( '_authToken' )
789
+ const tokenReg = this . get ( ` ${ nerfed } :_authToken` ) || defaultToken
785
790
786
791
if ( tokenReg ) {
792
+ if ( tokenReg === defaultToken ) {
793
+ log . warn ( 'config' , deprecatedAuthWarning )
794
+ }
787
795
creds . token = tokenReg
788
796
return creds
789
797
}
@@ -818,6 +826,7 @@ class Config {
818
826
const userDef = this . get ( 'username' )
819
827
const passDef = this . get ( '_password' )
820
828
if ( userDef && passDef ) {
829
+ log . warn ( 'config' , deprecatedAuthWarning )
821
830
creds . username = userDef
822
831
creds . password = Buffer . from ( passDef , 'base64' ) . toString ( 'utf8' )
823
832
const auth = `${ creds . username } :${ creds . password } `
@@ -832,6 +841,7 @@ class Config {
832
841
return creds
833
842
}
834
843
844
+ log . warn ( 'config' , deprecatedAuthWarning )
835
845
const authDecode = Buffer . from ( auth , 'base64' ) . toString ( 'utf8' )
836
846
const authSplit = authDecode . split ( ':' )
837
847
creds . username = authSplit . shift ( )
0 commit comments