Comparing version 2.0.0 to 2.1.0
{ | ||
"name": "auth0", | ||
"version": "2.0.0", | ||
"version": "2.1.0", | ||
"description": "SDK for Auth0 API v2", | ||
@@ -36,7 +36,10 @@ "main": "src/index.js", | ||
"jsdoc": "^3.4.0", | ||
"json-loader": "^0.5.4", | ||
"latodoc": "smeijer/latodoc", | ||
"mocha": "^2.2.4", | ||
"nock": "^3.1.1", | ||
"sinon": "^1.17.1" | ||
"sinon": "^1.17.1", | ||
"string-replace-webpack-plugin": "0.0.3", | ||
"webpack": "^1.12.14" | ||
} | ||
} |
@@ -1,2 +0,2 @@ | ||
[![Coverage Status](https://coveralls.io/repos/sophilabs/node-auth0/badge.svg?branch=v2&service=github)](https://coveralls.io/github/sophilabs/node-auth0?branch=v2) [![Build Status](https://travis-ci.org/sophilabs/node-auth0.svg?branch=v2)](https://travis-ci.org/sophilabs/node-auth0) | ||
[![Coverage Status](https://coveralls.io/repos/github/auth0/node-auth0/badge.svg?branch=master)](https://coveralls.io/github/auth0/node-auth0?branch=master) [![Build Status](https://travis-ci.org/auth0/node-auth0.svg)](https://travis-ci.org/auth0/node-auth0) | ||
@@ -7,4 +7,11 @@ Node.js client library for the [Auth0](https://auth0.com) platform. | ||
npm install auth0 | ||
~~~ | ||
npm install auth0 | ||
~~~ | ||
## Documentation | ||
For more information on how to use this library you must build the docs. You can do so by running: `npm run docs-build`. | ||
The *docs-build* script will generate all the documentation in HTML format under the `docs` folder. Open `docs/index.html` in any web browser to see the documentation. | ||
## Management API Client | ||
@@ -25,4 +32,6 @@ The Auth0 Management API is meant to be used by back-end servers or trusted parties performing administrative tasks. Generally speaking, anything that can be done through the Auth0 dashboard (and more) can also be done through this API. | ||
Note: When using at browser you should use `telemetry: false`. | ||
## Authentication API Client | ||
This client must used to access Auth0's [Authentication API](https://auth0.com/docs/auth-api). | ||
This client must be used to access Auth0's [Authentication API](https://auth0.com/docs/auth-api). | ||
@@ -29,0 +38,0 @@ The **AuthenticationClient** constructor takes an *optional* client ID, if specified it will be used as default value for all endpoints that accept a client ID. |
@@ -166,3 +166,3 @@ var extend = require('util')._extend; | ||
/** | ||
* Change passwor using a database or active directory service. | ||
* Change password using a database or active directory service. | ||
* | ||
@@ -239,2 +239,67 @@ * @method changePassword | ||
/** | ||
* Request a change password email using a database or active directory service. | ||
* | ||
* @method requestChangePasswordEmail | ||
* @memberOf module:auth.DatabaseAuthenticator.prototype | ||
* | ||
* @example <caption> | ||
* Given the user email, the connection specified, Auth0 will send a change | ||
* password email. once the user clicks on the confirm password change link, | ||
* the new password specified in this POST will be set to this user. Find more | ||
* information in the <a href="https://auth0.com/docs/auth-api#!#post--dbconnections-change_password> | ||
* API Docs</a>. | ||
* </caption> | ||
* | ||
* var data = { | ||
* email: '{EMAIL}', | ||
* connection: 'Username-Password-Authentication' | ||
* }; | ||
* | ||
* auth0.database.requestChangePasswordEmail(data, function (err, message) { | ||
* if (err) { | ||
* // Handle error. | ||
* } | ||
* | ||
* console.log(message); | ||
* }); | ||
* | ||
* @param {Object} data User credentials object. | ||
* @param {String} data.email User email address. | ||
* @param {String} data.connection Identity provider in use. | ||
* @param {Function} [cb] Method callback. | ||
* | ||
* @return {Promise|undefined} | ||
*/ | ||
DatabaseAuthenticator.prototype.requestChangePasswordEmail = function (userData, cb) { | ||
var params = { | ||
type: 'change_password' | ||
}; | ||
var defaultFields = { | ||
client_id: this.clientId | ||
}; | ||
var data = extend(defaultFields, userData); | ||
if (!userData || typeof userData !== 'object') { | ||
throw new ArgumentError('Missing user data object'); | ||
} | ||
if (typeof data.email !== 'string' | ||
|| data.email.trim().length === 0) { | ||
throw new ArgumentError('email field is required'); | ||
} | ||
if (typeof data.connection !== 'string' | ||
|| data.connection.trim().length === 0) { | ||
throw new ArgumentError('connection field is required'); | ||
} | ||
if (cb && cb instanceof Function) { | ||
return this.dbConnections.create(params, data, cb); | ||
} | ||
return this.dbConnections.create(params, data); | ||
}; | ||
module.exports = DatabaseAuthenticator; |
@@ -363,3 +363,3 @@ /** @module auth **/ | ||
/** | ||
* Change passwor using a database or active directory service. | ||
* Change password using a database or active directory service. | ||
* | ||
@@ -411,2 +411,45 @@ * @method changePassword | ||
/** | ||
* Request a change password email using a database or active directory service. | ||
* | ||
* @method requestChangePasswordEmail | ||
* @memberOf module:auth.AuthenticationClient.prototype | ||
* | ||
* @example <caption> | ||
* Given the user email, the connection specified, Auth0 will send a change | ||
* password email. once the user clicks on the confirm password change link, | ||
* the new password specified in this POST will be set to this user. Find more | ||
* information in the <a href="https://auth0.com/docs/auth-api#!#post--dbconnections-change_password> | ||
* API Docs</a>. | ||
* </caption> | ||
* | ||
* var data = { | ||
* email: '{EMAIL}', | ||
* connection: 'Username-Password-Authentication' | ||
* }; | ||
* | ||
* auth0.requestChangePasswordEmail(data, function (err, message) { | ||
* if (err) { | ||
* // Handle error. | ||
* } | ||
* | ||
* console.log(message); | ||
* }); | ||
* | ||
* @param {Object} data User data object. | ||
* @param {String} data.email User email. | ||
* @param {String} data.connection Identity provider for the user. | ||
* | ||
* @return {Promise|undefined} | ||
*/ | ||
AuthenticationClient.prototype.requestChangePasswordEmail = function (data, cb) { | ||
var translatedData = { | ||
connection: data.connection, | ||
email: data.email || data.username | ||
}; | ||
return this.database.requestChangePasswordEmail(data, cb); | ||
}; | ||
/** | ||
* Given an access token get the user profile linked to it. | ||
@@ -413,0 +456,0 @@ * |
@@ -22,2 +22,3 @@ /** @module management */ | ||
var TicketsManager = require('./TicketsManager'); | ||
var LogsManager = require('./LogsManager'); | ||
@@ -163,2 +164,9 @@ var BASE_URL_FORMAT = 'https://%s/api/v2'; | ||
this.tickets = new TicketsManager(managerOptions); | ||
/** | ||
* Logs manager. | ||
* | ||
* @type {LogsManager} | ||
*/ | ||
this.logs = new LogsManager(managerOptions); | ||
}; | ||
@@ -1275,3 +1283,44 @@ | ||
/** | ||
* Get an Auth0 log. | ||
* | ||
* @method getLog | ||
* @memberOf module:management.ManagementClient.prototype | ||
* | ||
* @example | ||
* management.getLog({ id: EVENT_ID }, function (err, log) { | ||
* if (err) { | ||
* // Handle error. | ||
* } | ||
* | ||
* console.log(log); | ||
* }); | ||
* | ||
* @param {Object} params Log parameters. | ||
* @param {String} params.id Event ID. | ||
* @param {Function} [cb] Callback function. | ||
* | ||
* @return {Promise|undefined} | ||
*/ | ||
utils.wrapPropertyMethod(ManagementClient, 'getLog', 'logs.get'); | ||
/** | ||
* Get all logs. | ||
* | ||
* @method getLogs | ||
* @memberOf module:management.ManagementClient.prototype | ||
* | ||
* @example | ||
* management.getLogs(function (err, logs) { | ||
* console.log(logs.length); | ||
* }); | ||
* | ||
* @param {Object} data Log data object. | ||
* @param {Function} [cb] Callback function. | ||
* | ||
* @return {Promise|undefined} | ||
*/ | ||
utils.wrapPropertyMethod(ManagementClient, 'getLogs', 'logs.getAll'); | ||
module.exports = ManagementClient; |
@@ -43,3 +43,3 @@ var expect = require('chai').expect; | ||
describe('instance', function () { | ||
var methods = ['signIn', 'signUp', 'changePassword']; | ||
var methods = ['signIn', 'signUp', 'changePassword', 'requestChangePasswordEmail']; | ||
var oauth = new OAuth(validOptions); | ||
@@ -564,2 +564,126 @@ var authenticator = new Authenticator(validOptions, oauth); | ||
describe('#requestChangePasswordEmail', function () { | ||
var path = '/dbconnections/change_password'; | ||
var userData = { | ||
email: 'test@domain.com', | ||
connection: 'TEST_CONNECTION' | ||
}; | ||
beforeEach(function () { | ||
this.authenticator = new Authenticator(validOptions); | ||
this.request = nock(API_URL) | ||
.post(path) | ||
.reply(200); | ||
}); | ||
it('should require an object as first argument', function () { | ||
expect(this.authenticator.requestChangePasswordEmail) | ||
.to.throw(ArgumentError, 'Missing user data object'); | ||
}); | ||
it('should require an email', function () { | ||
var auth = this.authenticator; | ||
var userData = {}; | ||
var requestChangePasswordEmail = auth.requestChangePasswordEmail.bind(auth, userData); | ||
expect(requestChangePasswordEmail) | ||
.to.throw(ArgumentError, 'email field is required'); | ||
}); | ||
it('should require a connection', function () { | ||
var auth = this.authenticator; | ||
var userData = { email: 'email@domain.com' }; | ||
var requestChangePasswordEmail = auth.requestChangePasswordEmail.bind(auth, userData); | ||
expect(requestChangePasswordEmail) | ||
.to.throw(ArgumentError, 'connection field is required'); | ||
}); | ||
it('should accept a callback', function (done) { | ||
this | ||
.authenticator | ||
.requestChangePasswordEmail(userData, done.bind(null, null)); | ||
}); | ||
it('should return a promise when no callback is provided', function (done) { | ||
this | ||
.authenticator | ||
.requestChangePasswordEmail(userData) | ||
.then(done.bind(null, null)) | ||
.catch(done.bind(null, null)); | ||
}); | ||
it('should perform a POST request to ' + path, function (done) { | ||
var request = this.request; | ||
this | ||
.authenticator | ||
.requestChangePasswordEmail(userData) | ||
.then(function () { | ||
expect(request.isDone()) | ||
.to.be.true; | ||
done(); | ||
}) | ||
.catch(done); | ||
}); | ||
it('should include the user data in the request', function (done) { | ||
nock.cleanAll(); | ||
var request = nock(API_URL) | ||
.post(path, function (body) { | ||
for (var property in userData) { | ||
if (userData[property] !== body[property]) { | ||
return false; | ||
} | ||
} | ||
return true; | ||
}) | ||
.reply(200); | ||
this | ||
.authenticator | ||
.requestChangePasswordEmail(userData) | ||
.then(function () { | ||
expect(request.isDone()) | ||
.to.be.true; | ||
done(); | ||
}) | ||
.catch(done); | ||
}); | ||
it('should include the Auth0 client ID in the request', function (done) { | ||
nock.cleanAll(); | ||
var request = nock(API_URL) | ||
.post(path, function (body) { | ||
return body.client_id === CLIENT_ID; | ||
}) | ||
.reply(200); | ||
this | ||
.authenticator | ||
.requestChangePasswordEmail(userData) | ||
.then(function () { | ||
expect(request.isDone()) | ||
.to.be.true; | ||
done(); | ||
}) | ||
.catch(done); | ||
}); | ||
}); | ||
}); |
Sorry, the diff of this file is not supported yet
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
Network access
Supply chain riskThis module accesses the network.
Found 1 instance in 1 package
Dynamic require
Supply chain riskDynamic require can indicate the package is performing dangerous or unsafe dynamic code execution.
Found 1 instance in 1 package
Environment variable access
Supply chain riskPackage accesses environment variables, which may be a sign of credential stuffing or data theft.
Found 5 instances in 1 package
Filesystem access
Supply chain riskAccesses the file system, and could potentially read sensitive data.
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
373601
117
11207
108
11
61
1