Comparing version 0.1.1 to 0.1.2
@@ -1,53 +0,1 @@ | ||
var request = require('request'); | ||
var api = require('./api'); | ||
function Client(options) { | ||
['clientID', 'clientSecret'].forEach(function (k) { | ||
if(!options[k]){ | ||
throw new Error(k + ' is required'); | ||
} | ||
}); | ||
options.namespace = options.namespace || 'app.auth0.com'; | ||
this.apiUrl = 'https://' + options.namespace + '/api'; | ||
this.tokenUrl = 'https://' + options.namespace + '/oauth/token'; | ||
this.options = options; | ||
} | ||
Client.prototype._getAccessToken = function(done){ | ||
var body = { | ||
'client_id': this.options.clientID, | ||
'client_secret': this.options.clientSecret, | ||
'grant_type': 'client_credentials' | ||
}; | ||
request.post({ | ||
url: this.tokenUrl, | ||
form: body | ||
}, function (err, resp, body) { | ||
if(err) return done(err); | ||
if (resp.statusCode === 404) return done(new Error('unknown client')); | ||
var accessToken = JSON.parse(body)['access_token']; | ||
done(null, accessToken); | ||
}); | ||
}; | ||
Object.keys(api).forEach(function (m) { | ||
Client.prototype[m] = function (){ | ||
var args = [].slice.call(arguments), | ||
callback = args[args.length - 1]; | ||
this._getAccessToken(function (err, accessToken) { | ||
if (err) return callback(err); | ||
api[m].apply(this, [accessToken].concat(args)); | ||
}.bind(this)); | ||
}; | ||
}); | ||
module.exports = Client; | ||
module.exports = require('./Client'); |
{ | ||
"name": "auth0", | ||
"version": "0.1.1", | ||
"version": "0.1.2", | ||
"description": "Client library for the Auth0 platform", | ||
@@ -5,0 +5,0 @@ "main": "lib/index.js", |
@@ -14,3 +14,4 @@ Node.js client library for the Auth0 platform. | ||
clientID: 'your-client-id', | ||
clientSecret: 'your-client-secret' | ||
clientSecret: 'your-client-secret', | ||
domain: '' | ||
}); | ||
@@ -17,0 +18,0 @@ ~~~ |
License Policy Violation
LicenseThis package is not allowed per your license policy. Review the package's license to ensure compliance.
Found 1 instance in 1 package
New author
Supply chain riskA new npm collaborator published a version of the package for the first time. New collaborators are usually benign additions to a project, but do indicate a change to the security surface area of a package.
Found 1 instance in 1 package
License Policy Violation
LicenseThis package is not allowed per your license policy. Review the package's license to ensure compliance.
Found 1 instance in 1 package
Non-existent author
Supply chain riskThe package was published by an npm account that no longer exists.
Found 1 instance in 1 package
8310
8
84
0
175
1