blob: 4c099ebec6fe731b28631677369b919f459b38b2 (
plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
|
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)
})
}
|