@@ -698,9 +698,11 @@ class Config {
698
698
this . delete ( `${ nerfed } :_password` , 'user' )
699
699
this . delete ( `${ nerfed } :username` , 'user' )
700
700
this . delete ( `${ nerfed } :email` , 'user' )
701
+ this . delete ( `${ nerfed } :certfile` , 'user' )
702
+ this . delete ( `${ nerfed } :keyfile` , 'user' )
701
703
}
702
704
703
- setCredentialsByURI ( uri , { token, username, password, email } ) {
705
+ setCredentialsByURI ( uri , { token, username, password, email, certfile , keyfile } ) {
704
706
const nerfed = nerfDart ( uri )
705
707
const def = nerfDart ( this . get ( 'registry' ) )
706
708
@@ -733,6 +735,11 @@ class Config {
733
735
this . delete ( `${ nerfed } :-authtoken` , 'user' )
734
736
this . delete ( `${ nerfed } :_authtoken` , 'user' )
735
737
this . delete ( `${ nerfed } :email` , 'user' )
738
+ if ( certfile && keyfile ) {
739
+ this . set ( `${ nerfed } :certfile` , certfile , 'user' )
740
+ this . set ( `${ nerfed } :keyfile` , keyfile , 'user' )
741
+ // cert/key may be used in conjunction with other credentials, thus no `else`
742
+ }
736
743
if ( token ) {
737
744
this . set ( `${ nerfed } :_authToken` , token , 'user' )
738
745
this . delete ( `${ nerfed } :_password` , 'user' )
@@ -750,7 +757,7 @@ class Config {
750
757
// protects against shoulder-hacks if password is memorable, I guess?
751
758
const encoded = Buffer . from ( password , 'utf8' ) . toString ( 'base64' )
752
759
this . set ( `${ nerfed } :_password` , encoded , 'user' )
753
- } else {
760
+ } else if ( ! certfile || ! keyfile ) {
754
761
throw new Error ( 'No credentials to set.' )
755
762
}
756
763
}
@@ -765,6 +772,14 @@ class Config {
765
772
creds . email = email
766
773
}
767
774
775
+ const certfileReg = this . get ( `${ nerfed } :certfile` )
776
+ const keyfileReg = this . get ( `${ nerfed } :keyfile` )
777
+ if ( certfileReg && keyfileReg ) {
778
+ creds . certfile = certfileReg
779
+ creds . keyfile = keyfileReg
780
+ // cert/key may be used in conjunction with other credentials, thus no `return`
781
+ }
782
+
768
783
const tokenReg = this . get ( `${ nerfed } :_authToken` ) ||
769
784
this . get ( `${ nerfed } :_authtoken` ) ||
770
785
this . get ( `${ nerfed } :-authtoken` ) ||
0 commit comments