mirror of
https://github.com/nodejs/node.git
synced 2025-05-15 03:29:46 +00:00

* Windows improvements: no more uid is undefined errors, use `%COMSPEC%` when set in preference to hardcoded `cmd`, improved handling of Git remotes. * Add caching based on Last-Modified / If-Modified-Since headers in addition to Etag-based cache validation. PR-URL: https://github.com/iojs/io.js/pull/573 Reviewed-By: Ben Noordhuis <info@bnoordhuis.nl> Reviewed-By: Colin Ihrig <cjihrig@gmail.com>
22 lines
666 B
JavaScript
22 lines
666 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")
|
|
|
|
if (auth.username) return process.nextTick(cb.bind(this, null, auth.username))
|
|
|
|
this.request(url.resolve(uri, "-/whoami"), { auth : auth }, function (er, userdata) {
|
|
if (er) return cb(er)
|
|
|
|
cb(null, userdata.username)
|
|
})
|
|
}
|