Comparing version 2.0.9 to 2.1.0
@@ -12,3 +12,12 @@ var assert = require("assert") | ||
var c = {scope : nerfed} | ||
// hidden class micro-optimization | ||
var c = { | ||
scope : nerfed, | ||
token : undefined, | ||
password : undefined, | ||
username : undefined, | ||
email : undefined, | ||
auth : undefined, | ||
alwaysAuth : undefined | ||
} | ||
@@ -53,2 +62,9 @@ if (this.get(nerfed + ":_authToken")) { | ||
if (this.get(nerfed + ":always-auth") !== undefined) { | ||
var val = this.get(nerfed + ":always-auth") | ||
c.alwaysAuth = val === "false" ? false : !!val | ||
} else if (this.get("always-auth") !== undefined) { | ||
c.alwaysAuth = this.get("always-auth") | ||
} | ||
if (c.username && c.password) { | ||
@@ -55,0 +71,0 @@ c.auth = new Buffer(c.username + ":" + c.password).toString("base64") |
@@ -15,5 +15,6 @@ var assert = require("assert") | ||
this.set(nerfed + ":_authToken", c.token, "user") | ||
this.del(nerfed + ":_password", "user") | ||
this.del(nerfed + ":username", "user") | ||
this.del(nerfed + ":email", "user") | ||
this.del(nerfed + ":_password", "user") | ||
this.del(nerfed + ":username", "user") | ||
this.del(nerfed + ":email", "user") | ||
this.del(nerfed + ":always-auth", "user") | ||
} | ||
@@ -28,5 +29,12 @@ else if (c.username || c.password || c.email) { | ||
var encoded = new Buffer(c.password, "utf8").toString("base64") | ||
this.set(nerfed + ":_password", encoded, "user") | ||
this.set(nerfed + ":_password", encoded, "user") | ||
this.set(nerfed + ":username", c.username, "user") | ||
this.set(nerfed + ":email", c.email, "user") | ||
this.set(nerfed + ":email", c.email, "user") | ||
if (c.alwaysAuth !== undefined) { | ||
this.set(nerfed + ":always-auth", c.alwaysAuth, "user") | ||
} | ||
else { | ||
this.del(nerfed + ":always-auth", "user") | ||
} | ||
} | ||
@@ -33,0 +41,0 @@ else { |
@@ -7,2 +7,3 @@ module.exports = setUser | ||
var fs = require('fs') | ||
var mkdirp = require('mkdirp') | ||
@@ -23,6 +24,9 @@ function setUser (cb) { | ||
var prefix = path.resolve(this.get("prefix")) | ||
fs.stat(prefix, function (er, st) { | ||
defaultConf.user = st && st.uid | ||
return cb(er) | ||
mkdirp(prefix, function (er) { | ||
if (er) return cb(er) | ||
fs.stat(prefix, function (er, st) { | ||
defaultConf.user = st && st.uid | ||
return cb(er) | ||
}) | ||
}) | ||
} |
{ | ||
"name": "npmconf", | ||
"version": "2.0.9", | ||
"version": "2.1.0", | ||
"description": "The config thing npm uses", | ||
@@ -5,0 +5,0 @@ "main": "npmconf.js", |
@@ -64,4 +64,9 @@ var test = require("tap").test | ||
var expected = { | ||
scope : "//registry.lvh.me:8661/", | ||
token : "simple-token" | ||
scope : "//registry.lvh.me:8661/", | ||
token : "simple-token", | ||
username : undefined, | ||
password : undefined, | ||
email : undefined, | ||
auth : undefined, | ||
alwaysAuth : undefined | ||
} | ||
@@ -141,7 +146,9 @@ | ||
var expected = { | ||
scope : "//registry.lvh.me:8661/", | ||
username : "username", | ||
password : "password", | ||
email : "ogd@aoaioxxysz.net", | ||
auth : "dXNlcm5hbWU6cGFzc3dvcmQ=" | ||
scope : "//registry.lvh.me:8661/", | ||
token : undefined, | ||
username : "username", | ||
password : "password", | ||
email : "ogd@aoaioxxysz.net", | ||
auth : "dXNlcm5hbWU6cGFzc3dvcmQ=", | ||
alwaysAuth : false | ||
} | ||
@@ -159,7 +166,9 @@ | ||
var expected = { | ||
scope: '//registry.npmjs.org/', | ||
password: 'password', | ||
username: 'username', | ||
email: 'i@izs.me', | ||
auth: 'dXNlcm5hbWU6cGFzc3dvcmQ=' | ||
scope : '//registry.npmjs.org/', | ||
token : undefined, | ||
password : 'password', | ||
username : 'username', | ||
email : 'i@izs.me', | ||
auth : 'dXNlcm5hbWU6cGFzc3dvcmQ=', | ||
alwaysAuth : false | ||
} | ||
@@ -170,1 +179,121 @@ t.same(actual, expected) | ||
}) | ||
test("set with always-auth enabled", function (t) { | ||
npmconf.load(common.builtin, function (er, conf) { | ||
t.ifError(er, "configuration loaded") | ||
var credentials = { | ||
username : "username", | ||
password : "password", | ||
email : "ogd@aoaioxxysz.net", | ||
alwaysAuth : true | ||
} | ||
conf.setCredentialsByURI(URI, credentials) | ||
var expected = { | ||
scope : "//registry.lvh.me:8661/", | ||
token : undefined, | ||
username : "username", | ||
password : "password", | ||
email : "ogd@aoaioxxysz.net", | ||
auth : "dXNlcm5hbWU6cGFzc3dvcmQ=", | ||
alwaysAuth : true | ||
} | ||
t.same(conf.getCredentialsByURI(URI), expected, "got credentials") | ||
t.end() | ||
}) | ||
}) | ||
test("set with always-auth disabled", function (t) { | ||
npmconf.load(common.builtin, function (er, conf) { | ||
t.ifError(er, "configuration loaded") | ||
var credentials = { | ||
username : "username", | ||
password : "password", | ||
email : "ogd@aoaioxxysz.net", | ||
alwaysAuth : false | ||
} | ||
conf.setCredentialsByURI(URI, credentials) | ||
var expected = { | ||
scope : "//registry.lvh.me:8661/", | ||
token : undefined, | ||
username : "username", | ||
password : "password", | ||
email : "ogd@aoaioxxysz.net", | ||
auth : "dXNlcm5hbWU6cGFzc3dvcmQ=", | ||
alwaysAuth : false | ||
} | ||
t.same(conf.getCredentialsByURI(URI), expected, "got credentials") | ||
t.end() | ||
}) | ||
}) | ||
test("set with global always-auth enabled", function (t) { | ||
npmconf.load(common.builtin, function (er, conf) { | ||
t.ifError(er, "configuration loaded") | ||
var original = conf.get("always-auth") | ||
conf.set("always-auth", true) | ||
var credentials = { | ||
username : "username", | ||
password : "password", | ||
email : "ogd@aoaioxxysz.net" | ||
} | ||
conf.setCredentialsByURI(URI, credentials) | ||
var expected = { | ||
scope : "//registry.lvh.me:8661/", | ||
token : undefined, | ||
username : "username", | ||
password : "password", | ||
email : "ogd@aoaioxxysz.net", | ||
auth : "dXNlcm5hbWU6cGFzc3dvcmQ=", | ||
alwaysAuth : true | ||
} | ||
t.same(conf.getCredentialsByURI(URI), expected, "got credentials") | ||
conf.set("always-auth", original) | ||
t.end() | ||
}) | ||
}) | ||
test("set with global always-auth disabled", function (t) { | ||
npmconf.load(common.builtin, function (er, conf) { | ||
t.ifError(er, "configuration loaded") | ||
var original = conf.get("always-auth") | ||
conf.set("always-auth", false) | ||
var credentials = { | ||
username : "username", | ||
password : "password", | ||
email : "ogd@aoaioxxysz.net" | ||
} | ||
conf.setCredentialsByURI(URI, credentials) | ||
var expected = { | ||
scope : "//registry.lvh.me:8661/", | ||
token : undefined, | ||
username : "username", | ||
password : "password", | ||
email : "ogd@aoaioxxysz.net", | ||
auth : "dXNlcm5hbWU6cGFzc3dvcmQ=", | ||
alwaysAuth : false | ||
} | ||
t.same(conf.getCredentialsByURI(URI), expected, "got credentials") | ||
conf.set("always-auth", original) | ||
t.end() | ||
}) | ||
}) |
License Policy Violation
LicenseThis package is not allowed per your license policy. Review the package's license to ensure compliance.
Found 1 instance in 1 package
License Policy Violation
LicenseThis package is not allowed per your license policy. Review the package's license to ensure compliance.
Found 1 instance in 1 package
52606
1553