From 1211a79da40ff6bef1d3d978f3fbb487b289dc4f Mon Sep 17 00:00:00 2001 From: indexzero Date: Sat, 23 Jan 2016 01:41:55 -0800 Subject: [PATCH] [fix] Update to minimum of joyent@7.0 --- lib/pkgcloud/joyent/client.js | 20 ++++++++------------ 1 file changed, 8 insertions(+), 12 deletions(-) diff --git a/lib/pkgcloud/joyent/client.js b/lib/pkgcloud/joyent/client.js index 7e3785d94..d80ba2059 100644 --- a/lib/pkgcloud/joyent/client.js +++ b/lib/pkgcloud/joyent/client.js @@ -36,14 +36,14 @@ var Client = exports.Client = function (opts) { opts.key = fs.readFileSync(opts.identity, 'ascii'); } - if (!(opts.username && opts.password) && - !(opts.keyId && opts.key)) { - throw new TypeError('Either username/password or keyId/key are required'); - } - // default values opts.account = opts.account || opts.username || 'my'; - opts.apiVersion = opts.apiVersion || '~6.5'; + opts.keyId = opts.keyId || opts.key; + opts.apiVersion = opts.apiVersion || '~7.0'; + + if (!opts.account || !opts.keyId) { + throw new TypeError('acccount and keyId are required'); + } // if a person gives a key id by name that doesn't work in joyent // keys are fully qualified. so we check for `/` in the keyId, if it's not @@ -65,14 +65,10 @@ var Client = exports.Client = function (opts) { if (!this.before) { this.before = []; } - if (opts.key && opts.keyId) { - this.before.push(auth.httpSignature); - } else { - this.before.push(auth.basic); - } - + this.before.push(auth.httpSignature); this.before.push(function setReqHeaders(req) { req.json = true; + req.headers = req.headers || {}; if (typeof req.headers['X-Api-Version'] === 'undefined') { req.headers['x-api-version'] = opts.apiVersion; req.headers.Accept = 'application/json';