Comparing version 0.6.5 to 0.7.0
@@ -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; |
{ | ||
"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 | ||
}); | ||
}); | ||
}); |
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
74815
1313
371
3