Sha256: 36f1fa61827dd61aea10c5d42f4c2b06bfb757d0d89053d632992e3c3b4d93cb

Contents?: true

Size: 1.29 KB

Versions: 20

Compression:

Stored size: 1.29 KB

Contents

var assert = require("assert")

var toNerfDart = require("./nerf-dart.js")

module.exports = setCredentialsByURI

function setCredentialsByURI (uri, c) {
  assert(uri && typeof uri === "string", "registry URL is required")
  assert(c && typeof c === "object", "credentials are required")

  var nerfed = toNerfDart(uri)

  if (c.token) {
    this.set(nerfed + ":_authToken", c.token, "user")
    this.del(nerfed + ":_password",           "user")
    this.del(nerfed + ":username",            "user")
    this.del(nerfed + ":email",               "user")
    this.del(nerfed + ":always-auth",         "user")
  }
  else if (c.username || c.password || c.email) {
    assert(c.username, "must include username")
    assert(c.password, "must include password")
    assert(c.email, "must include email address")

    this.del(nerfed + ":_authToken", "user")

    var encoded = new Buffer(c.password, "utf8").toString("base64")
    this.set(nerfed + ":_password", encoded,   "user")
    this.set(nerfed + ":username", c.username, "user")
    this.set(nerfed + ":email", c.email,       "user")

    if (c.alwaysAuth !== undefined) {
      this.set(nerfed + ":always-auth", c.alwaysAuth, "user")
    }
    else {
      this.del(nerfed + ":always-auth", "user")
    }
  }
  else {
    throw new Error("No credentials to set.")
  }
}

Version data entries

20 entries across 20 versions & 3 rubygems

Version Path
hooch-0.4.2 jasmine/node_modules/karma-phantomjs-launcher/node_modules/phantomjs/node_modules/npmconf/lib/set-credentials-by-uri.js
hooch-0.4.1 jasmine/node_modules/karma-phantomjs-launcher/node_modules/phantomjs/node_modules/npmconf/lib/set-credentials-by-uri.js
hooch-0.4.0 jasmine/node_modules/karma-phantomjs-launcher/node_modules/phantomjs/node_modules/npmconf/lib/set-credentials-by-uri.js
gulp_assets-1.0.0.pre.5 template/node_modules/gulp-sass/node_modules/node-sass/node_modules/npmconf/lib/set-credentials-by-uri.js
gulp_assets-1.0.0.pre.4 template/node_modules/gulp-sass/node_modules/node-sass/node_modules/npmconf/lib/set-credentials-by-uri.js
gulp_assets-1.0.0.pre.3 template/node_modules/gulp-sass/node_modules/node-sass/node_modules/npmconf/lib/set-credentials-by-uri.js
hooch-0.3.0 jasmine/node_modules/karma-phantomjs-launcher/node_modules/phantomjs/node_modules/npmconf/lib/set-credentials-by-uri.js
hooch-0.2.1 jasmine/node_modules/karma-phantomjs-launcher/node_modules/phantomjs/node_modules/npmconf/lib/set-credentials-by-uri.js
hooch-0.2.0 jasmine/node_modules/karma-phantomjs-launcher/node_modules/phantomjs/node_modules/npmconf/lib/set-credentials-by-uri.js
hooch-0.1.0 jasmine/node_modules/karma-phantomjs-launcher/node_modules/phantomjs/node_modules/npmconf/lib/set-credentials-by-uri.js
hooch-0.0.8 jasmine/node_modules/karma-phantomjs-launcher/node_modules/phantomjs/node_modules/npmconf/lib/set-credentials-by-uri.js
hooch-0.0.7 jasmine/node_modules/karma-phantomjs-launcher/node_modules/phantomjs/node_modules/npmconf/lib/set-credentials-by-uri.js
hooch-0.0.6 jasmine/node_modules/karma-phantomjs-launcher/node_modules/phantomjs/node_modules/npmconf/lib/set-credentials-by-uri.js
entangled-0.0.16 spec/dummy/public/node_modules/bower/node_modules/update-notifier/node_modules/latest-version/node_modules/package-json/node_modules/registry-url/node_modules/npmconf/lib/set-credentials-by-uri.js
entangled-0.0.15 spec/dummy/public/node_modules/bower/node_modules/update-notifier/node_modules/latest-version/node_modules/package-json/node_modules/registry-url/node_modules/npmconf/lib/set-credentials-by-uri.js
entangled-0.0.14 spec/dummy/public/node_modules/bower/node_modules/update-notifier/node_modules/latest-version/node_modules/package-json/node_modules/registry-url/node_modules/npmconf/lib/set-credentials-by-uri.js
entangled-0.0.13 spec/dummy/public/node_modules/bower/node_modules/update-notifier/node_modules/latest-version/node_modules/package-json/node_modules/registry-url/node_modules/npmconf/lib/set-credentials-by-uri.js
entangled-0.0.12 spec/dummy/public/node_modules/bower/node_modules/update-notifier/node_modules/latest-version/node_modules/package-json/node_modules/registry-url/node_modules/npmconf/lib/set-credentials-by-uri.js
entangled-0.0.11 spec/dummy/public/node_modules/bower/node_modules/update-notifier/node_modules/latest-version/node_modules/package-json/node_modules/registry-url/node_modules/npmconf/lib/set-credentials-by-uri.js
entangled-0.0.10 spec/dummy/public/node_modules/bower/node_modules/update-notifier/node_modules/latest-version/node_modules/package-json/node_modules/registry-url/node_modules/npmconf/lib/set-credentials-by-uri.js