1 module.exports = whoami
3 var url = require('url')
4 var assert = require('assert')
6 function whoami (uri, params, cb) {
7 assert(typeof uri === 'string', 'must pass registry URI to whoami')
8 assert(params && typeof params === 'object', 'must pass params to whoami')
9 assert(typeof cb === 'function', 'must pass callback to whoami')
11 var auth = params.auth
12 assert(auth && typeof auth === 'object', 'must pass auth to whoami')
14 if (auth.username) return process.nextTick(cb.bind(this, null, auth.username))
16 this.request(url.resolve(uri, '-/whoami'), { auth: auth }, function (er, userdata) {
19 cb(null, userdata.username)