Welcome to mirror list, hosted at ThFree Co, Russian Federation.

access.js « lib « npm-registry-client « node_modules « npm « deps - github.com/nodejs/node.git - Unnamed repository; edit this file 'description' to name the repository.
summaryrefslogtreecommitdiff
blob: b671f6b5f219c1c1359bd1dee02ab5eb79073549 (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
module.exports = access

var assert = require('assert')

function access (uri, params, cb) {
  assert(typeof uri === 'string', 'must pass registry URI to access')
  assert(params && typeof params === 'object', 'must pass params to access')
  assert(typeof cb === 'function', 'muss pass callback to access')

  assert(typeof params.level === 'string', 'must pass level to access')
  assert(
    ['public', 'restricted'].indexOf(params.level) !== -1,
    "access level must be either 'public' or 'restricted'"
  )
  assert(
    params.auth && typeof params.auth === 'object',
    'must pass auth to access'
  )

  var body = {
    access: params.level
  }

  var options = {
    method: 'POST',
    body: JSON.stringify(body),
    auth: params.auth
  }
  this.request(uri, options, cb)
}