auth0 2.36.1 → 2.38.1
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/CHANGELOG.md +557 -0
- package/README.md +33 -11
- package/package.json +22 -15
- package/src/Auth0RestClient.js +72 -71
- package/src/RetryRestClient.js +78 -81
- package/src/auth/DatabaseAuthenticator.js +242 -259
- package/src/auth/OAUthWithIDTokenValidation.js +99 -103
- package/src/auth/OAuthAuthenticator.js +325 -344
- package/src/auth/PasswordlessAuthenticator.js +238 -252
- package/src/auth/TokensManager.js +231 -246
- package/src/auth/UsersManager.js +149 -160
- package/src/auth/idToken.js +22 -19
- package/src/auth/index.js +510 -581
- package/src/errors.js +23 -23
- package/src/index.js +3 -2
- package/src/management/ActionsManager.js +503 -585
- package/src/management/BlacklistedTokensManager.js +77 -84
- package/src/management/BrandingManager.js +141 -163
- package/src/management/ClientGrantsManager.js +132 -145
- package/src/management/ClientsManager.js +145 -161
- package/src/management/ConnectionsManager.js +215 -204
- package/src/management/CustomDomainsManager.js +140 -157
- package/src/management/DeviceCredentialsManager.js +95 -111
- package/src/management/EmailProviderManager.js +110 -128
- package/src/management/EmailTemplatesManager.js +96 -112
- package/src/management/GrantsManager.js +94 -101
- package/src/management/GuardianManager.js +381 -455
- package/src/management/HooksManager.js +283 -325
- package/src/management/JobsManager.js +310 -343
- package/src/management/LogStreamsManager.js +142 -158
- package/src/management/LogsManager.js +92 -99
- package/src/management/ManagementTokenProvider.js +112 -120
- package/src/management/MigrationsManager.js +81 -90
- package/src/management/OrganizationsManager.js +686 -761
- package/src/management/PromptsManager.js +160 -182
- package/src/management/ResourceServersManager.js +143 -160
- package/src/management/RolesManager.js +323 -369
- package/src/management/RulesConfigsManager.js +94 -110
- package/src/management/RulesManager.js +154 -176
- package/src/management/StatsManager.js +87 -103
- package/src/management/TenantManager.js +81 -97
- package/src/management/TicketsManager.js +107 -115
- package/src/management/UserBlocksManager.js +135 -162
- package/src/management/UsersManager.js +729 -852
- package/src/management/index.js +3094 -3619
- package/src/utils.js +31 -60
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "auth0",
|
|
3
|
-
"version": "2.
|
|
3
|
+
"version": "2.38.1",
|
|
4
4
|
"description": "SDK for Auth0 API v2",
|
|
5
5
|
"main": "src/index.js",
|
|
6
6
|
"sideEffects": false,
|
|
@@ -8,18 +8,21 @@
|
|
|
8
8
|
"src"
|
|
9
9
|
],
|
|
10
10
|
"scripts": {
|
|
11
|
-
"test": "mocha --reporter spec ./test/**/*.tests.js
|
|
11
|
+
"test": "mocha --reporter spec './test/**/*.tests.js'",
|
|
12
12
|
"test:ci": "nyc npm run test -- --forbid-only --reporter mocha-junit-reporter",
|
|
13
13
|
"test:coverage": "codecov",
|
|
14
|
-
"test:watch": "cross-env NODE_ENV=test mocha --timeout 5000 ./test/**/*.tests.js ./test/*.tests.js --watch",
|
|
14
|
+
"test:watch": "cross-env NODE_ENV=test mocha --timeout 5000 './test/**/*.tests.js' './test/*.tests.js' --watch",
|
|
15
15
|
"jsdoc:generate": "jsdoc --configure .jsdoc.json --verbose",
|
|
16
|
-
"
|
|
17
|
-
"
|
|
16
|
+
"precommit": "pretty-quick --staged",
|
|
17
|
+
"lint": "eslint ."
|
|
18
18
|
},
|
|
19
19
|
"repository": {
|
|
20
20
|
"type": "git",
|
|
21
21
|
"url": "https://github.com/auth0/node-auth0"
|
|
22
22
|
},
|
|
23
|
+
"engines": {
|
|
24
|
+
"node": ">=8.3.0"
|
|
25
|
+
},
|
|
23
26
|
"keywords": [
|
|
24
27
|
"auth0",
|
|
25
28
|
"api"
|
|
@@ -31,34 +34,38 @@
|
|
|
31
34
|
},
|
|
32
35
|
"homepage": "https://github.com/auth0/node-auth0",
|
|
33
36
|
"dependencies": {
|
|
34
|
-
"axios": "^0.
|
|
35
|
-
"es6-promisify": "^6.1.1",
|
|
37
|
+
"axios": "^0.24.0",
|
|
36
38
|
"form-data": "^3.0.1",
|
|
37
39
|
"jsonwebtoken": "^8.5.1",
|
|
38
40
|
"jwks-rsa": "^1.12.1",
|
|
39
41
|
"lru-memoizer": "^2.1.4",
|
|
40
|
-
"rest-facade": "^1.
|
|
42
|
+
"rest-facade": "^1.16.3",
|
|
41
43
|
"retry": "^0.13.1"
|
|
42
44
|
},
|
|
43
45
|
"devDependencies": {
|
|
44
46
|
"chai": "^4.2.0",
|
|
45
47
|
"codecov": "^3.7.2",
|
|
46
48
|
"cross-env": "^5.2.0",
|
|
49
|
+
"eslint": "^8.1.0",
|
|
50
|
+
"eslint-config-prettier": "^8.3.0",
|
|
51
|
+
"eslint-plugin-jsdoc": "^37.0.3",
|
|
52
|
+
"eslint-plugin-node": "^11.1.0",
|
|
53
|
+
"eslint-plugin-prettier": "^4.0.0",
|
|
54
|
+
"eslint-plugin-promise": "^5.1.1",
|
|
47
55
|
"husky": "^3.0.1",
|
|
48
|
-
"jsdoc": "^3.6.
|
|
56
|
+
"jsdoc": "^3.6.7",
|
|
49
57
|
"json-loader": "^0.5.7",
|
|
50
58
|
"jws": "^3.2.2",
|
|
51
59
|
"minami": "^1.2.3",
|
|
52
|
-
"mocha": "^
|
|
53
|
-
"mocha-junit-reporter": "^
|
|
54
|
-
"moment": "^2.24.0",
|
|
60
|
+
"mocha": "^8.4.0",
|
|
61
|
+
"mocha-junit-reporter": "^2.0.0",
|
|
55
62
|
"nock": "^10.0.6",
|
|
56
63
|
"nyc": "^14.1.1",
|
|
57
64
|
"pem": "^1.14.2",
|
|
58
|
-
"prettier": "
|
|
65
|
+
"prettier": "2.4.1",
|
|
59
66
|
"pretty-quick": "^1.11.1",
|
|
60
|
-
"proxyquire": "^2.1.
|
|
61
|
-
"sinon": "^
|
|
67
|
+
"proxyquire": "^2.1.3",
|
|
68
|
+
"sinon": "^11.1.2",
|
|
62
69
|
"string-replace-webpack-plugin": "0.1.3",
|
|
63
70
|
"webpack": "^4.36.1"
|
|
64
71
|
}
|
package/src/Auth0RestClient.js
CHANGED
|
@@ -1,89 +1,90 @@
|
|
|
1
|
-
|
|
2
|
-
|
|
1
|
+
const RestClient = require('rest-facade').Client;
|
|
2
|
+
const { ArgumentError } = require('rest-facade');
|
|
3
3
|
|
|
4
|
-
|
|
5
|
-
|
|
4
|
+
const utils = require('./utils');
|
|
5
|
+
const { SanitizedError } = require('./errors');
|
|
6
6
|
|
|
7
|
-
|
|
8
|
-
|
|
9
|
-
|
|
10
|
-
|
|
11
|
-
|
|
12
|
-
if ('string' !== typeof resourceUrl || resourceUrl.length === 0) {
|
|
13
|
-
throw new ArgumentError('The provided Resource Url is invalid');
|
|
14
|
-
}
|
|
7
|
+
class Auth0RestClient {
|
|
8
|
+
constructor(resourceUrl, options, provider) {
|
|
9
|
+
if (resourceUrl === null || resourceUrl === undefined) {
|
|
10
|
+
throw new ArgumentError('Must provide a Resource Url');
|
|
11
|
+
}
|
|
15
12
|
|
|
16
|
-
|
|
17
|
-
|
|
18
|
-
|
|
13
|
+
if ('string' !== typeof resourceUrl || resourceUrl.length === 0) {
|
|
14
|
+
throw new ArgumentError('The provided Resource Url is invalid');
|
|
15
|
+
}
|
|
19
16
|
|
|
20
|
-
|
|
21
|
-
|
|
17
|
+
if (options === null || typeof options !== 'object') {
|
|
18
|
+
throw new ArgumentError('Must provide options');
|
|
19
|
+
}
|
|
22
20
|
|
|
23
|
-
|
|
24
|
-
|
|
25
|
-
|
|
21
|
+
options.errorCustomizer = options.errorCustomizer || SanitizedError;
|
|
22
|
+
options.errorFormatter = options.errorFormatter || { message: 'message', name: 'error' };
|
|
23
|
+
|
|
24
|
+
this.options = options;
|
|
25
|
+
this.provider = provider;
|
|
26
|
+
this.restClient = new RestClient(resourceUrl, options);
|
|
27
|
+
|
|
28
|
+
this.wrappedProvider = function (method, args) {
|
|
29
|
+
if (!this.provider) {
|
|
30
|
+
return this.restClient[method](...args);
|
|
31
|
+
}
|
|
32
|
+
|
|
33
|
+
let callback;
|
|
34
|
+
if (args && args[args.length - 1] instanceof Function) {
|
|
35
|
+
callback = args[args.length - 1];
|
|
36
|
+
}
|
|
37
|
+
|
|
38
|
+
return this.provider
|
|
39
|
+
.getAccessToken()
|
|
40
|
+
.then((access_token) => {
|
|
41
|
+
this.restClient.options.headers['Authorization'] = `Bearer ${access_token}`;
|
|
42
|
+
return this.restClient[method](...args);
|
|
43
|
+
})
|
|
44
|
+
.catch((err) => {
|
|
45
|
+
if (callback) {
|
|
46
|
+
return callback(err);
|
|
47
|
+
}
|
|
48
|
+
throw err;
|
|
49
|
+
});
|
|
50
|
+
};
|
|
51
|
+
}
|
|
26
52
|
|
|
27
|
-
|
|
28
|
-
|
|
29
|
-
|
|
30
|
-
}
|
|
53
|
+
getAll(...args) {
|
|
54
|
+
return this.wrappedProvider('getAll', args);
|
|
55
|
+
}
|
|
31
56
|
|
|
32
|
-
|
|
33
|
-
if (
|
|
34
|
-
|
|
57
|
+
get(params, callback) {
|
|
58
|
+
if (typeof params === 'object' && params.id) {
|
|
59
|
+
params.id = utils.maybeDecode(`${params.id}`);
|
|
35
60
|
}
|
|
36
|
-
|
|
37
|
-
var self = this;
|
|
38
|
-
return this.provider
|
|
39
|
-
.getAccessToken()
|
|
40
|
-
.then(function(access_token) {
|
|
41
|
-
self.restClient.options.headers['Authorization'] = 'Bearer ' + access_token;
|
|
42
|
-
return self.restClient[method].apply(self.restClient, args);
|
|
43
|
-
})
|
|
44
|
-
.catch(function(err) {
|
|
45
|
-
if (callback) {
|
|
46
|
-
return callback(err);
|
|
47
|
-
}
|
|
48
|
-
return Promise.reject(err);
|
|
49
|
-
});
|
|
50
|
-
};
|
|
51
|
-
};
|
|
52
|
-
|
|
53
|
-
Auth0RestClient.prototype.getAll = function(params, callback) {
|
|
54
|
-
return this.wrappedProvider('getAll', arguments);
|
|
55
|
-
};
|
|
56
|
-
|
|
57
|
-
Auth0RestClient.prototype.get = function(params, callback) {
|
|
58
|
-
if (typeof params === 'object' && params.id) {
|
|
59
|
-
params.id = utils.maybeDecode(`${params.id}`);
|
|
61
|
+
return this.wrappedProvider('get', [...[params, callback].filter(Boolean)]);
|
|
60
62
|
}
|
|
61
|
-
return this.wrappedProvider('get', [...[params, callback].filter(Boolean)]);
|
|
62
|
-
};
|
|
63
63
|
|
|
64
|
-
|
|
65
|
-
|
|
66
|
-
}
|
|
64
|
+
create(...args) {
|
|
65
|
+
return this.wrappedProvider('create', args);
|
|
66
|
+
}
|
|
67
67
|
|
|
68
|
-
|
|
69
|
-
|
|
70
|
-
|
|
68
|
+
patch(params, ...restOfArgs) {
|
|
69
|
+
if (typeof params === 'object' && params.id) {
|
|
70
|
+
params.id = utils.maybeDecode(`${params.id}`);
|
|
71
|
+
}
|
|
72
|
+
return this.wrappedProvider('patch', [params, ...restOfArgs]);
|
|
71
73
|
}
|
|
72
|
-
return this.wrappedProvider('patch', arguments);
|
|
73
|
-
};
|
|
74
74
|
|
|
75
|
-
|
|
76
|
-
|
|
77
|
-
|
|
75
|
+
update(params, ...restOfArgs) {
|
|
76
|
+
if (typeof params === 'object' && params.id) {
|
|
77
|
+
params.id = utils.maybeDecode(`${params.id}`);
|
|
78
|
+
}
|
|
79
|
+
return this.wrappedProvider('update', [params, ...restOfArgs]);
|
|
78
80
|
}
|
|
79
|
-
return this.wrappedProvider('update', arguments);
|
|
80
|
-
};
|
|
81
81
|
|
|
82
|
-
|
|
83
|
-
|
|
84
|
-
|
|
82
|
+
delete(params, ...restOfArgs) {
|
|
83
|
+
if (typeof params === 'object' && params.id) {
|
|
84
|
+
params.id = utils.maybeDecode(`${params.id}`);
|
|
85
|
+
}
|
|
86
|
+
return this.wrappedProvider('delete', [params, ...restOfArgs]);
|
|
85
87
|
}
|
|
86
|
-
|
|
87
|
-
};
|
|
88
|
+
}
|
|
88
89
|
|
|
89
90
|
module.exports = Auth0RestClient;
|
package/src/RetryRestClient.js
CHANGED
|
@@ -1,108 +1,105 @@
|
|
|
1
|
-
|
|
2
|
-
|
|
1
|
+
const retry = require('retry');
|
|
2
|
+
const { ArgumentError } = require('rest-facade');
|
|
3
3
|
|
|
4
|
-
|
|
4
|
+
const DEFAULT_OPTIONS = {
|
|
5
5
|
maxRetries: 3,
|
|
6
6
|
enabled: true,
|
|
7
|
-
randomize: true
|
|
7
|
+
randomize: true,
|
|
8
8
|
};
|
|
9
9
|
|
|
10
10
|
/**
|
|
11
|
-
* @class RetryRestClient
|
|
12
11
|
* Wrapper Rest Client that adds Retry functionality when requests are failing due to rate limiting (status code 429).
|
|
13
|
-
* @constructor
|
|
14
|
-
* @memberOf module:management
|
|
15
|
-
* @param {Object} restClient RestClient.
|
|
16
|
-
* @param {Object} [options] Options for the RetryRestClient.
|
|
17
|
-
* @param {Object} [options.enabled:true] Enabled or Disable Retry Policy functionality.
|
|
18
|
-
* @param {Number} [options.maxRetries=3] The maximum amount of times to retry the operation. Default is 3.
|
|
19
|
-
* @param {*} [options.*] Any options that are available in https://github.com/tim-kos/node-retry#retryoperationoptions
|
|
20
12
|
*/
|
|
21
|
-
|
|
22
|
-
|
|
23
|
-
|
|
13
|
+
class RetryRestClient {
|
|
14
|
+
/**
|
|
15
|
+
* @param {object} restClient RestClient.
|
|
16
|
+
* @param {object} [options] Options for the RetryRestClient. It includes all properties from https://github.com/tim-kos/node-retry#retryoperationoptions
|
|
17
|
+
* @param {object} [options.enabled=true] Enabled or Disable Retry Policy functionality.
|
|
18
|
+
* @param {number} [options.maxRetries=3] The maximum amount of times to retry the operation.
|
|
19
|
+
*/
|
|
20
|
+
constructor(restClient, options) {
|
|
21
|
+
if (restClient === null || typeof restClient !== 'object') {
|
|
22
|
+
throw new ArgumentError('Must provide RestClient');
|
|
23
|
+
}
|
|
24
|
+
|
|
25
|
+
const params = Object.assign({}, DEFAULT_OPTIONS, options);
|
|
26
|
+
|
|
27
|
+
if (typeof params.enabled !== 'boolean') {
|
|
28
|
+
throw new ArgumentError('Must provide enabled boolean value');
|
|
29
|
+
}
|
|
30
|
+
|
|
31
|
+
if (typeof params.maxRetries !== 'number' || params.maxRetries <= 0) {
|
|
32
|
+
throw new ArgumentError('Must provide maxRetries as a positive number');
|
|
33
|
+
}
|
|
34
|
+
|
|
35
|
+
this.restClient = restClient;
|
|
36
|
+
this.enabled = params.enabled;
|
|
37
|
+
this.retryOptions = Object.assign({ retries: params.maxRetries }, params);
|
|
24
38
|
}
|
|
25
39
|
|
|
26
|
-
|
|
27
|
-
|
|
28
|
-
if (typeof params.enabled !== 'boolean') {
|
|
29
|
-
throw new ArgumentError('Must provide enabled boolean value');
|
|
40
|
+
getAll(...args) {
|
|
41
|
+
return this.invoke('getAll', args);
|
|
30
42
|
}
|
|
31
43
|
|
|
32
|
-
|
|
33
|
-
|
|
44
|
+
get(...args) {
|
|
45
|
+
return this.invoke('get', args);
|
|
34
46
|
}
|
|
35
47
|
|
|
36
|
-
|
|
37
|
-
|
|
38
|
-
|
|
39
|
-
};
|
|
40
|
-
|
|
41
|
-
RetryRestClient.prototype.getAll = function(/* [params], [callback] */) {
|
|
42
|
-
return this.invoke('getAll', arguments);
|
|
43
|
-
};
|
|
44
|
-
|
|
45
|
-
RetryRestClient.prototype.get = function(/* [params], [callback] */) {
|
|
46
|
-
return this.invoke('get', arguments);
|
|
47
|
-
};
|
|
48
|
-
|
|
49
|
-
RetryRestClient.prototype.create = function(/* [params], [callback] */) {
|
|
50
|
-
return this.invoke('create', arguments);
|
|
51
|
-
};
|
|
52
|
-
|
|
53
|
-
RetryRestClient.prototype.patch = function(/* [params], [callback] */) {
|
|
54
|
-
return this.invoke('patch', arguments);
|
|
55
|
-
};
|
|
48
|
+
create(...args) {
|
|
49
|
+
return this.invoke('create', args);
|
|
50
|
+
}
|
|
56
51
|
|
|
57
|
-
|
|
58
|
-
|
|
59
|
-
}
|
|
52
|
+
patch(...args) {
|
|
53
|
+
return this.invoke('patch', args);
|
|
54
|
+
}
|
|
60
55
|
|
|
61
|
-
|
|
62
|
-
|
|
63
|
-
}
|
|
56
|
+
update(...args) {
|
|
57
|
+
return this.invoke('update', args);
|
|
58
|
+
}
|
|
64
59
|
|
|
65
|
-
|
|
66
|
-
|
|
67
|
-
args = Array.prototype.slice.call(args); // convert array-like object to array.
|
|
68
|
-
if (args && args[args.length - 1] instanceof Function) {
|
|
69
|
-
cb = args[args.length - 1];
|
|
70
|
-
args.pop(); // Remove the callback
|
|
60
|
+
delete(...args) {
|
|
61
|
+
return this.invoke('delete', args);
|
|
71
62
|
}
|
|
72
63
|
|
|
73
|
-
|
|
64
|
+
invoke(method, args) {
|
|
65
|
+
let cb;
|
|
66
|
+
if (args && args[args.length - 1] instanceof Function) {
|
|
67
|
+
cb = args[args.length - 1];
|
|
68
|
+
args.pop(); // Remove the callback
|
|
69
|
+
}
|
|
74
70
|
|
|
75
|
-
|
|
76
|
-
promise.then(cb.bind(null, null)).catch(cb);
|
|
77
|
-
return;
|
|
78
|
-
}
|
|
71
|
+
const promise = this.handleRetry(method, args);
|
|
79
72
|
|
|
80
|
-
|
|
81
|
-
|
|
73
|
+
if (cb instanceof Function) {
|
|
74
|
+
promise.then(cb.bind(null, null)).catch(cb);
|
|
75
|
+
return;
|
|
76
|
+
}
|
|
82
77
|
|
|
83
|
-
|
|
84
|
-
if (!this.enabled) {
|
|
85
|
-
return this.restClient[method].apply(this.restClient, args);
|
|
78
|
+
return promise;
|
|
86
79
|
}
|
|
87
80
|
|
|
88
|
-
|
|
89
|
-
|
|
90
|
-
|
|
91
|
-
|
|
92
|
-
|
|
93
|
-
|
|
94
|
-
|
|
95
|
-
|
|
96
|
-
|
|
97
|
-
|
|
98
|
-
|
|
99
|
-
|
|
100
|
-
|
|
101
|
-
|
|
102
|
-
|
|
103
|
-
|
|
81
|
+
handleRetry(method, args) {
|
|
82
|
+
if (!this.enabled) {
|
|
83
|
+
return this.restClient[method](...args);
|
|
84
|
+
}
|
|
85
|
+
|
|
86
|
+
return new Promise((resolve, reject) => {
|
|
87
|
+
const operation = retry.operation(this.retryOptions);
|
|
88
|
+
|
|
89
|
+
operation.attempt(() => {
|
|
90
|
+
this.restClient[method](...args)
|
|
91
|
+
.then((body) => {
|
|
92
|
+
resolve(body);
|
|
93
|
+
})
|
|
94
|
+
.catch((err) => {
|
|
95
|
+
if (err && err.statusCode === 429 && operation.retry(err)) {
|
|
96
|
+
return;
|
|
97
|
+
}
|
|
98
|
+
reject(err);
|
|
99
|
+
});
|
|
100
|
+
});
|
|
104
101
|
});
|
|
105
|
-
}
|
|
106
|
-
}
|
|
102
|
+
}
|
|
103
|
+
}
|
|
107
104
|
|
|
108
105
|
module.exports = RetryRestClient;
|