node/deps/npm/node_modules/npm-registry-client/lib/whoami.js
Forrest L Norvell e79ccee168 npm: upgrade to v2.1.18
PR-URL: https://github.com/iojs/io.js/pull/266
Reviewed-By: Ben Noordhuis <info@bnoordhuis.nl>
2015-01-08 23:49:03 +01:00

20 lines
582 B
JavaScript

module.exports = whoami
var url = require("url")
, assert = require("assert")
function whoami (uri, params, cb) {
assert(typeof uri === "string", "must pass registry URI to whoami")
assert(params && typeof params === "object", "must pass params to whoami")
assert(typeof cb === "function", "must pass callback to whoami")
var auth = params.auth
assert(auth && typeof auth === "object", "must pass auth to whoami")
this.request(url.resolve(uri, "whoami"), { auth : auth }, function (er, userdata) {
if (er) return cb(er)
cb(null, userdata.username)
})
}