Huge News!Announcing our $40M Series B led by Abstract Ventures.Learn More
Socket
Sign inDemoInstall
Socket

auth0

Package Overview
Dependencies
Maintainers
5
Versions
156
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

auth0 - npm Package Compare versions

Comparing version 0.6.5 to 0.7.0

23

lib/api.js

@@ -358,2 +358,25 @@ var request = require('request');

api.impersonateUser = function(accessToken, userId, options, cb) {
var req = {
method: 'POST',
url: this.apiUrl + '/users/' + userId + '/impersonate',
headers: {
'Authorization': 'Bearer ' + accessToken,
},
json: options
};
request(req, function(err, res, data) {
if (err) {
return cb(err);
}
if (res.statusCode.toString().substr(0, 1) !== '2') {
return cb(new ApiError(data, res.statusCode));
}
return cb(null, data);
});
};
api.getUsers = function(accessToken, options, done) {

@@ -360,0 +383,0 @@ var nextPageLink, req, connection;

2

package.json
{
"name": "auth0",
"version": "0.6.5",
"version": "0.7.0",
"description": "Client library for the Auth0 platform",

@@ -5,0 +5,0 @@ "main": "lib/index.js",

@@ -99,2 +99,21 @@ Node.js client library for the [Auth0](https://auth0.com) platform.

### api.impersonateUser(userId, options, callback)
Returns the impersonation link:
~~~js
api.impersonateUser('github|123', {
protocol: 'oauth2',
impersonator_id: 'gonto',
client_id: 'client',
additionalParameters: {
response_type: 'code'
}
}, function (err, result){
//.....
});
~~~
Check it on the [API Explorer](https://docs.auth0.com/auth-api#!#post--users--user_id--impersonate);
### api.getAccessToken(callback)

@@ -101,0 +120,0 @@

@@ -122,2 +122,40 @@ var expect = require('chai').expect;

describe('impersonateUser', function () {
it('should work on request success', function (done) {
var reqData = {
protocol: 'oauth2',
impersonator_id: 'gonto',
client_id: 'client',
additionalParameters: {
response_type: 'code'
}
};
var reqUserId = 'userid';
var resData = {some: 'data'};
var scope = nock('https://' + domain)
.post('/oauth/token', qs)
.reply(200, {
'access_token': accessToken,
'token_type': 'bearer'
})
.post('/api/users/' + reqUserId + '/impersonate', reqData)
.matchHeader('Authorization', 'Bearer ' + accessToken)
.reply(200, resData);
api.impersonateUser(reqUserId, reqData, function (err, userData) {
expect(err).to.not.exist;
expect(userData).to.be.deep.equal(resData);
expect(scope.isDone()).to.be.equal(true);
nock.cleanAll();
done();
});
});
});
describe('updateUserEmail', function () {

@@ -242,3 +280,3 @@ it('should work on request success', function (done) {

var resUserData = {foo: 'bar'};
var qs = querystring.stringify({

@@ -266,3 +304,3 @@ access_token: userAccessToken

var resError = 'Invalid access token';
var qs = querystring.stringify({

@@ -287,4 +325,4 @@ access_token: userAccessToken

});
});
});
SocketSocket SOC 2 Logo

Product

  • Package Alerts
  • Integrations
  • Docs
  • Pricing
  • FAQ
  • Roadmap
  • Changelog

Packages

npm

Stay in touch

Get open source security insights delivered straight into your inbox.


  • Terms
  • Privacy
  • Security

Made with ⚡️ by Socket Inc