@npmcli/config 4.1.0 → 4.2.0

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (2) hide show
  1. package/lib/index.js +17 -2
  2. package/package.json +3 -3
package/lib/index.js CHANGED
@@ -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`) ||
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@npmcli/config",
3
- "version": "4.1.0",
3
+ "version": "4.2.0",
4
4
  "files": [
5
5
  "bin/",
6
6
  "lib/"
@@ -31,7 +31,7 @@
31
31
  },
32
32
  "devDependencies": {
33
33
  "@npmcli/eslint-config": "^3.0.1",
34
- "@npmcli/template-oss": "3.3.2",
34
+ "@npmcli/template-oss": "3.5.0",
35
35
  "tap": "^16.0.1"
36
36
  },
37
37
  "dependencies": {
@@ -49,6 +49,6 @@
49
49
  },
50
50
  "templateOSS": {
51
51
  "//@npmcli/template-oss": "This file is partially managed by @npmcli/template-oss. Edits may be overwritten.",
52
- "version": "3.3.2"
52
+ "version": "3.5.0"
53
53
  }
54
54
  }