@npmcli/config 4.2.1 → 4.2.2

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 +12 -2
  2. package/package.json +3 -3
package/lib/index.js CHANGED
@@ -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()
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@npmcli/config",
3
- "version": "4.2.1",
3
+ "version": "4.2.2",
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.5.0",
34
+ "@npmcli/template-oss": "3.6.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.5.0"
52
+ "version": "3.6.0"
53
53
  }
54
54
  }