auth0 2.42.0 → 2.43.0
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 +8 -0
- package/package.json +4 -6
- package/src/Auth0RestClient.js +32 -2
- package/src/management/ActionsManager.js +12 -73
- package/src/management/AttackProtectionManager.js +8 -37
- package/src/management/BaseManager.js +40 -0
- package/src/management/BlacklistedTokensManager.js +4 -32
- package/src/management/BrandingManager.js +6 -39
- package/src/management/ClientGrantsManager.js +4 -32
- package/src/management/ClientsManager.js +5 -37
- package/src/management/ConnectionsManager.js +6 -42
- package/src/management/CustomDomainsManager.js +5 -37
- package/src/management/DeviceCredentialsManager.js +4 -26
- package/src/management/EmailProviderManager.js +4 -32
- package/src/management/EmailTemplatesManager.js +4 -27
- package/src/management/GrantsManager.js +4 -32
- package/src/management/GuardianManager.js +13 -86
- package/src/management/HooksManager.js +5 -36
- package/src/management/JobsManager.js +6 -38
- package/src/management/LogStreamsManager.js +4 -31
- package/src/management/LogsManager.js +4 -31
- package/src/management/MigrationsManager.js +4 -27
- package/src/management/OrganizationsManager.js +14 -65
- package/src/management/PromptsManager.js +5 -35
- package/src/management/ResourceServersManager.js +4 -31
- package/src/management/RolesManager.js +6 -42
- package/src/management/RulesConfigsManager.js +4 -31
- package/src/management/RulesManager.js +4 -31
- package/src/management/StatsManager.js +4 -27
- package/src/management/TenantManager.js +4 -27
- package/src/management/TicketsManager.js +4 -27
- package/src/management/UserBlocksManager.js +5 -35
- package/src/management/UsersManager.js +16 -91
- package/src/management/index.js +2 -0
package/CHANGELOG.md
CHANGED
|
@@ -1,5 +1,13 @@
|
|
|
1
1
|
# Change Log
|
|
2
2
|
|
|
3
|
+
## [v2.43.0](https://github.com/auth0/node-auth0/tree/v2.43.0) (2022-10-10)
|
|
4
|
+
|
|
5
|
+
[Full Changelog](https://github.com/auth0/node-auth0/compare/v2.42.0...v2.43.0)
|
|
6
|
+
|
|
7
|
+
**Added**
|
|
8
|
+
|
|
9
|
+
- Add option to include response headers in the result [\#744](https://github.com/auth0/node-auth0/pull/744) ([adamjmcgrath](https://github.com/adamjmcgrath))
|
|
10
|
+
|
|
3
11
|
## [v2.42.0](https://github.com/auth0/node-auth0/tree/v2.42.0) (2022-05-23)
|
|
4
12
|
|
|
5
13
|
[Full Changelog](https://github.com/auth0/node-auth0/compare/v2.41.0...v2.42.0)
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "auth0",
|
|
3
|
-
"version": "2.
|
|
3
|
+
"version": "2.43.0",
|
|
4
4
|
"description": "SDK for Auth0 API v2",
|
|
5
5
|
"main": "src/index.js",
|
|
6
6
|
"sideEffects": false,
|
|
@@ -10,7 +10,6 @@
|
|
|
10
10
|
"scripts": {
|
|
11
11
|
"test": "mocha --reporter spec './test/**/*.tests.js'",
|
|
12
12
|
"test:ci": "nyc npm run test -- --forbid-only --reporter mocha-junit-reporter",
|
|
13
|
-
"test:coverage": "codecov",
|
|
14
13
|
"test:watch": "cross-env NODE_ENV=test mocha --timeout 5000 './test/**/*.tests.js' './test/*.tests.js' --watch",
|
|
15
14
|
"jsdoc:generate": "jsdoc --configure .jsdoc.json --verbose",
|
|
16
15
|
"precommit": "pretty-quick --staged",
|
|
@@ -34,7 +33,7 @@
|
|
|
34
33
|
},
|
|
35
34
|
"homepage": "https://github.com/auth0/node-auth0",
|
|
36
35
|
"dependencies": {
|
|
37
|
-
"axios": "^0.
|
|
36
|
+
"axios": "^0.27.2",
|
|
38
37
|
"form-data": "^3.0.1",
|
|
39
38
|
"jsonwebtoken": "^8.5.1",
|
|
40
39
|
"jwks-rsa": "^1.12.1",
|
|
@@ -44,7 +43,6 @@
|
|
|
44
43
|
},
|
|
45
44
|
"devDependencies": {
|
|
46
45
|
"chai": "^4.2.0",
|
|
47
|
-
"codecov": "^3.7.2",
|
|
48
46
|
"cross-env": "^5.2.0",
|
|
49
47
|
"eslint": "^8.16.0",
|
|
50
48
|
"eslint-config-prettier": "^8.5.0",
|
|
@@ -59,13 +57,13 @@
|
|
|
59
57
|
"minami": "^1.2.3",
|
|
60
58
|
"mocha": "^8.4.0",
|
|
61
59
|
"mocha-junit-reporter": "^2.0.0",
|
|
62
|
-
"nock": "^
|
|
60
|
+
"nock": "^13.2.7",
|
|
63
61
|
"nyc": "^14.1.1",
|
|
64
62
|
"pem": "^1.14.2",
|
|
65
63
|
"prettier": "2.4.1",
|
|
66
64
|
"pretty-quick": "^1.11.1",
|
|
67
65
|
"proxyquire": "^2.1.3",
|
|
68
|
-
"sinon": "^
|
|
66
|
+
"sinon": "^14.0.0",
|
|
69
67
|
"string-replace-webpack-plugin": "0.1.3",
|
|
70
68
|
"webpack": "^4.36.1"
|
|
71
69
|
}
|
package/src/Auth0RestClient.js
CHANGED
|
@@ -27,7 +27,7 @@ class Auth0RestClient {
|
|
|
27
27
|
|
|
28
28
|
this.wrappedProvider = function (method, args) {
|
|
29
29
|
if (!this.provider) {
|
|
30
|
-
return this.
|
|
30
|
+
return this._request(method, args);
|
|
31
31
|
}
|
|
32
32
|
|
|
33
33
|
let callback;
|
|
@@ -39,7 +39,7 @@ class Auth0RestClient {
|
|
|
39
39
|
.getAccessToken()
|
|
40
40
|
.then((access_token) => {
|
|
41
41
|
this.restClient.options.headers['Authorization'] = `Bearer ${access_token}`;
|
|
42
|
-
return this.
|
|
42
|
+
return this._request(method, args);
|
|
43
43
|
})
|
|
44
44
|
.catch((err) => {
|
|
45
45
|
if (callback) {
|
|
@@ -50,6 +50,36 @@ class Auth0RestClient {
|
|
|
50
50
|
};
|
|
51
51
|
}
|
|
52
52
|
|
|
53
|
+
_request(method, args) {
|
|
54
|
+
if (!this.options.includeResponseHeaders) {
|
|
55
|
+
return this.restClient[method](...args);
|
|
56
|
+
}
|
|
57
|
+
|
|
58
|
+
let callback;
|
|
59
|
+
// Handle the case where the promise variant is called without any args
|
|
60
|
+
// client.get() -> client.get({}, callback)
|
|
61
|
+
if (!args || !args.length) {
|
|
62
|
+
args = [{}];
|
|
63
|
+
}
|
|
64
|
+
// Handle the case where an undefined placeholder is defined for callback
|
|
65
|
+
// client.get(params, undefined) -> client.get(params, callback)
|
|
66
|
+
if (typeof args[args.length - 1] === 'undefined') {
|
|
67
|
+
args.pop();
|
|
68
|
+
}
|
|
69
|
+
if (typeof args[args.length - 1] === 'function') {
|
|
70
|
+
callback = args.pop();
|
|
71
|
+
}
|
|
72
|
+
return new Promise((resolve, reject) => {
|
|
73
|
+
this.restClient[method](...args, (err, data, headers) => {
|
|
74
|
+
const payload = { data, headers };
|
|
75
|
+
if (err) {
|
|
76
|
+
(callback && callback(err)) || reject(err);
|
|
77
|
+
}
|
|
78
|
+
(callback && callback(null, payload)) || resolve(payload);
|
|
79
|
+
});
|
|
80
|
+
});
|
|
81
|
+
}
|
|
82
|
+
|
|
53
83
|
getAll(...args) {
|
|
54
84
|
return this.wrappedProvider('getAll', args);
|
|
55
85
|
}
|
|
@@ -1,13 +1,11 @@
|
|
|
1
|
-
const
|
|
2
|
-
const Auth0RestClient = require('../Auth0RestClient');
|
|
3
|
-
const RetryRestClient = require('../RetryRestClient');
|
|
1
|
+
const BaseManager = require('./BaseManager');
|
|
4
2
|
|
|
5
3
|
/**
|
|
6
4
|
* {@link https://auth0.com/docs/api/v2#!/Actions/get_actions Actions} provide a way to extend
|
|
7
5
|
* Auth0 flows with custom logic.
|
|
8
6
|
* See the {@link https://auth0.com/docs/actions Actions documentation} for more information.
|
|
9
7
|
*/
|
|
10
|
-
class ActionsManager {
|
|
8
|
+
class ActionsManager extends BaseManager {
|
|
11
9
|
/**
|
|
12
10
|
* @param {object} options The client options.
|
|
13
11
|
* @param {string} options.baseUrl The URL of the API.
|
|
@@ -15,28 +13,7 @@ class ActionsManager {
|
|
|
15
13
|
* @param {object} [options.retry] Retry Policy Config
|
|
16
14
|
*/
|
|
17
15
|
constructor(options) {
|
|
18
|
-
|
|
19
|
-
throw new ArgumentError('Must provide client options');
|
|
20
|
-
}
|
|
21
|
-
|
|
22
|
-
if (options.baseUrl === null || options.baseUrl === undefined) {
|
|
23
|
-
throw new ArgumentError('Must provide a base URL for the API');
|
|
24
|
-
}
|
|
25
|
-
|
|
26
|
-
if ('string' !== typeof options.baseUrl || options.baseUrl.length === 0) {
|
|
27
|
-
throw new ArgumentError('The provided base URL is invalid');
|
|
28
|
-
}
|
|
29
|
-
|
|
30
|
-
/**
|
|
31
|
-
* Options object for the Rest Client instance.
|
|
32
|
-
*
|
|
33
|
-
* @type {object}
|
|
34
|
-
*/
|
|
35
|
-
const clientOptions = {
|
|
36
|
-
errorFormatter: { message: 'message', name: 'error' },
|
|
37
|
-
headers: options.headers,
|
|
38
|
-
query: { repeatParams: false },
|
|
39
|
-
};
|
|
16
|
+
super(options);
|
|
40
17
|
|
|
41
18
|
/**
|
|
42
19
|
* Provides an abstraction layer for consuming the
|
|
@@ -44,61 +21,23 @@ class ActionsManager {
|
|
|
44
21
|
*
|
|
45
22
|
* @type {external:RestClient}
|
|
46
23
|
*/
|
|
47
|
-
|
|
48
|
-
`${options.baseUrl}/actions/actions/:id`,
|
|
49
|
-
clientOptions,
|
|
50
|
-
options.tokenProvider
|
|
51
|
-
);
|
|
52
|
-
this.resource = new RetryRestClient(auth0RestClient, options.retry);
|
|
24
|
+
this.resource = this._getRestClient('/actions/actions/:id');
|
|
53
25
|
|
|
54
|
-
|
|
55
|
-
`${options.baseUrl}/actions/actions/:id/deploy`,
|
|
56
|
-
clientOptions,
|
|
57
|
-
options.tokenProvider
|
|
58
|
-
);
|
|
59
|
-
this.actionsDeploy = new RetryRestClient(actionsDeployRestClient, options.retry);
|
|
26
|
+
this.actionsDeploy = this._getRestClient('/actions/actions/:id/deploy');
|
|
60
27
|
|
|
61
|
-
|
|
62
|
-
`${options.baseUrl}/actions/actions/:id/test`,
|
|
63
|
-
clientOptions,
|
|
64
|
-
options.tokenProvider
|
|
65
|
-
);
|
|
66
|
-
this.actionsTest = new RetryRestClient(actionsTestRestClient, options.retry);
|
|
28
|
+
this.actionsTest = this._getRestClient('/actions/actions/:id/test');
|
|
67
29
|
|
|
68
|
-
|
|
69
|
-
`${options.baseUrl}/actions/triggers/:trigger_id`,
|
|
70
|
-
clientOptions,
|
|
71
|
-
options.tokenProvider
|
|
72
|
-
);
|
|
73
|
-
this.triggers = new RetryRestClient(triggersRestClient, options.retry);
|
|
30
|
+
this.triggers = this._getRestClient('/actions/triggers/:trigger_id');
|
|
74
31
|
|
|
75
|
-
|
|
76
|
-
`${options.baseUrl}/actions/triggers/:trigger_id/bindings`,
|
|
77
|
-
clientOptions,
|
|
78
|
-
options.tokenProvider
|
|
79
|
-
);
|
|
80
|
-
this.triggerBindings = new RetryRestClient(triggerBindingsRestClient, options.retry);
|
|
32
|
+
this.triggerBindings = this._getRestClient('/actions/triggers/:trigger_id/bindings');
|
|
81
33
|
|
|
82
|
-
|
|
83
|
-
`${options.baseUrl}/actions/executions/:execution_id`,
|
|
84
|
-
clientOptions,
|
|
85
|
-
options.tokenProvider
|
|
86
|
-
);
|
|
87
|
-
this.executions = new RetryRestClient(executionsRestClient, options.retry);
|
|
34
|
+
this.executions = this._getRestClient('/actions/executions/:execution_id');
|
|
88
35
|
|
|
89
|
-
|
|
90
|
-
`${options.baseUrl}/actions/actions/:id/versions/:version_id`,
|
|
91
|
-
clientOptions,
|
|
92
|
-
options.tokenProvider
|
|
93
|
-
);
|
|
94
|
-
this.actionVersions = new RetryRestClient(actionVersionRestClient, options.retry);
|
|
36
|
+
this.actionVersions = this._getRestClient('/actions/actions/:id/versions/:version_id');
|
|
95
37
|
|
|
96
|
-
|
|
97
|
-
|
|
98
|
-
clientOptions,
|
|
99
|
-
options.tokenProvider
|
|
38
|
+
this.actionVersionDeploy = this._getRestClient(
|
|
39
|
+
'/actions/actions/:id/versions/:version_id/deploy'
|
|
100
40
|
);
|
|
101
|
-
this.actionVersionDeploy = new RetryRestClient(deployActionVersionRestClient, options.retry);
|
|
102
41
|
}
|
|
103
42
|
|
|
104
43
|
/**
|
|
@@ -1,6 +1,4 @@
|
|
|
1
|
-
const
|
|
2
|
-
const Auth0RestClient = require('../Auth0RestClient');
|
|
3
|
-
const RetryRestClient = require('../RetryRestClient');
|
|
1
|
+
const BaseManager = require('./BaseManager');
|
|
4
2
|
|
|
5
3
|
/**
|
|
6
4
|
* Simple facade for consuming a REST API endpoint.
|
|
@@ -9,7 +7,7 @@ const RetryRestClient = require('../RetryRestClient');
|
|
|
9
7
|
* @see https://github.com/ngonzalvez/rest-facade
|
|
10
8
|
*/
|
|
11
9
|
|
|
12
|
-
class AttackProtectionManager {
|
|
10
|
+
class AttackProtectionManager extends BaseManager {
|
|
13
11
|
/**
|
|
14
12
|
* @class
|
|
15
13
|
* Abstracts interaction with the attack-protection endpoints.
|
|
@@ -21,44 +19,17 @@ class AttackProtectionManager {
|
|
|
21
19
|
* @param {object} [options.tokenProvider] Management API Token Provider
|
|
22
20
|
*/
|
|
23
21
|
constructor(options) {
|
|
24
|
-
|
|
25
|
-
throw new ArgumentError('Must provide manager options');
|
|
26
|
-
}
|
|
22
|
+
super(options);
|
|
27
23
|
|
|
28
|
-
|
|
29
|
-
throw new ArgumentError('Must provide a base URL for the API');
|
|
30
|
-
}
|
|
24
|
+
this.bruteForceProtection = this._getRestClient('/attack-protection/brute-force-protection');
|
|
31
25
|
|
|
32
|
-
|
|
33
|
-
|
|
34
|
-
}
|
|
35
|
-
|
|
36
|
-
const clientOptions = {
|
|
37
|
-
errorFormatter: { message: 'message', name: 'error' },
|
|
38
|
-
headers: options.headers,
|
|
39
|
-
query: { repeatParams: false },
|
|
40
|
-
};
|
|
41
|
-
|
|
42
|
-
const bruteForceProtection = new Auth0RestClient(
|
|
43
|
-
`${options.baseUrl}/attack-protection/brute-force-protection`,
|
|
44
|
-
clientOptions,
|
|
45
|
-
options.tokenProvider
|
|
46
|
-
);
|
|
47
|
-
this.bruteForceProtection = new RetryRestClient(bruteForceProtection, options.retry);
|
|
48
|
-
|
|
49
|
-
const suspiciousIpThrottling = new Auth0RestClient(
|
|
50
|
-
`${options.baseUrl}/attack-protection/suspicious-ip-throttling`,
|
|
51
|
-
clientOptions,
|
|
52
|
-
options.tokenProvider
|
|
26
|
+
this.suspiciousIpThrottling = this._getRestClient(
|
|
27
|
+
'/attack-protection/suspicious-ip-throttling'
|
|
53
28
|
);
|
|
54
|
-
this.suspiciousIpThrottling = new RetryRestClient(suspiciousIpThrottling, options.retry);
|
|
55
29
|
|
|
56
|
-
|
|
57
|
-
|
|
58
|
-
clientOptions,
|
|
59
|
-
options.tokenProvider
|
|
30
|
+
this.breachedPasswordDetection = this._getRestClient(
|
|
31
|
+
'/attack-protection/breached-password-detection'
|
|
60
32
|
);
|
|
61
|
-
this.breachedPasswordDetection = new RetryRestClient(breachedPasswordDetection, options.retry);
|
|
62
33
|
}
|
|
63
34
|
|
|
64
35
|
/**
|
|
@@ -0,0 +1,40 @@
|
|
|
1
|
+
const { ArgumentError } = require('rest-facade');
|
|
2
|
+
const Auth0RestClient = require('../Auth0RestClient');
|
|
3
|
+
const RetryRestClient = require('../RetryRestClient');
|
|
4
|
+
|
|
5
|
+
class BaseManager {
|
|
6
|
+
constructor(options) {
|
|
7
|
+
if (options === null || typeof options !== 'object') {
|
|
8
|
+
throw new ArgumentError('Must provide manager options');
|
|
9
|
+
}
|
|
10
|
+
|
|
11
|
+
if (options.baseUrl === null || options.baseUrl === undefined) {
|
|
12
|
+
throw new ArgumentError('Must provide a base URL for the API');
|
|
13
|
+
}
|
|
14
|
+
|
|
15
|
+
if ('string' !== typeof options.baseUrl || options.baseUrl.length === 0) {
|
|
16
|
+
throw new ArgumentError('The provided base URL is invalid');
|
|
17
|
+
}
|
|
18
|
+
|
|
19
|
+
this._options = options;
|
|
20
|
+
}
|
|
21
|
+
|
|
22
|
+
_getRestClient(path) {
|
|
23
|
+
const options = this._options;
|
|
24
|
+
const clientOptions = {
|
|
25
|
+
errorFormatter: { message: 'message', name: 'error' },
|
|
26
|
+
headers: options.headers,
|
|
27
|
+
query: { repeatParams: false },
|
|
28
|
+
includeResponseHeaders: options.includeResponseHeaders,
|
|
29
|
+
};
|
|
30
|
+
|
|
31
|
+
const usersAuth0RestClient = new Auth0RestClient(
|
|
32
|
+
`${options.baseUrl}${path}`,
|
|
33
|
+
clientOptions,
|
|
34
|
+
options.tokenProvider
|
|
35
|
+
);
|
|
36
|
+
return new RetryRestClient(usersAuth0RestClient, options.retry);
|
|
37
|
+
}
|
|
38
|
+
}
|
|
39
|
+
|
|
40
|
+
module.exports = BaseManager;
|
|
@@ -1,12 +1,10 @@
|
|
|
1
|
-
const
|
|
2
|
-
const Auth0RestClient = require('../Auth0RestClient');
|
|
3
|
-
const RetryRestClient = require('../RetryRestClient');
|
|
1
|
+
const BaseManager = require('./BaseManager');
|
|
4
2
|
|
|
5
3
|
/**
|
|
6
4
|
* The BlacklistedTokensManager class provides methods to retrieve the list of
|
|
7
5
|
* blacklisted tokens and blacklist new ones..
|
|
8
6
|
*/
|
|
9
|
-
class BlacklistedTokensManager {
|
|
7
|
+
class BlacklistedTokensManager extends BaseManager {
|
|
10
8
|
/**
|
|
11
9
|
* @param {object} options The client options.
|
|
12
10
|
* @param {string} options.baseUrl The URL of the API.
|
|
@@ -14,28 +12,7 @@ class BlacklistedTokensManager {
|
|
|
14
12
|
* @param {object} [options.retry] Retry Policy Config
|
|
15
13
|
*/
|
|
16
14
|
constructor(options) {
|
|
17
|
-
|
|
18
|
-
throw new ArgumentError('Must provide client options');
|
|
19
|
-
}
|
|
20
|
-
|
|
21
|
-
if (options.baseUrl === null || options.baseUrl === undefined) {
|
|
22
|
-
throw new ArgumentError('Must provide a base URL for the API');
|
|
23
|
-
}
|
|
24
|
-
|
|
25
|
-
if ('string' !== typeof options.baseUrl || options.baseUrl.length === 0) {
|
|
26
|
-
throw new ArgumentError('The provided base URL is invalid');
|
|
27
|
-
}
|
|
28
|
-
|
|
29
|
-
/**
|
|
30
|
-
* Options object for the Rest Client instance.
|
|
31
|
-
*
|
|
32
|
-
* @type {object}
|
|
33
|
-
*/
|
|
34
|
-
const clientOptions = {
|
|
35
|
-
errorFormatter: { message: 'message', name: 'error' },
|
|
36
|
-
headers: options.headers,
|
|
37
|
-
query: { repeatParams: false },
|
|
38
|
-
};
|
|
15
|
+
super(options);
|
|
39
16
|
|
|
40
17
|
/**
|
|
41
18
|
* Provides an abstraction layer for consuming the
|
|
@@ -43,12 +20,7 @@ class BlacklistedTokensManager {
|
|
|
43
20
|
*
|
|
44
21
|
* @type {external:RestClient}
|
|
45
22
|
*/
|
|
46
|
-
|
|
47
|
-
`${options.baseUrl}/blacklists/tokens`,
|
|
48
|
-
clientOptions,
|
|
49
|
-
options.tokenProvider
|
|
50
|
-
);
|
|
51
|
-
this.resource = new RetryRestClient(auth0RestClient, options.retry);
|
|
23
|
+
this.resource = this._getRestClient('/blacklists/tokens');
|
|
52
24
|
}
|
|
53
25
|
|
|
54
26
|
/**
|
|
@@ -1,11 +1,9 @@
|
|
|
1
|
-
const
|
|
2
|
-
const Auth0RestClient = require('../Auth0RestClient');
|
|
3
|
-
const RetryRestClient = require('../RetryRestClient');
|
|
1
|
+
const BaseManager = require('./BaseManager');
|
|
4
2
|
|
|
5
3
|
/**
|
|
6
4
|
* Manages settings related to branding.
|
|
7
5
|
*/
|
|
8
|
-
class BrandingManager {
|
|
6
|
+
class BrandingManager extends BaseManager {
|
|
9
7
|
/**
|
|
10
8
|
* @param {object} options The client options.
|
|
11
9
|
* @param {string} options.baseUrl The URL of the API.
|
|
@@ -13,23 +11,7 @@ class BrandingManager {
|
|
|
13
11
|
* @param {object} [options.retry] Retry Policy Config
|
|
14
12
|
*/
|
|
15
13
|
constructor(options) {
|
|
16
|
-
|
|
17
|
-
throw new ArgumentError('Must provide manager options');
|
|
18
|
-
}
|
|
19
|
-
|
|
20
|
-
if (options.baseUrl === null || options.baseUrl === undefined) {
|
|
21
|
-
throw new ArgumentError('Must provide a base URL for the API');
|
|
22
|
-
}
|
|
23
|
-
|
|
24
|
-
if ('string' !== typeof options.baseUrl || options.baseUrl.length === 0) {
|
|
25
|
-
throw new ArgumentError('The provided base URL is invalid');
|
|
26
|
-
}
|
|
27
|
-
|
|
28
|
-
const clientOptions = {
|
|
29
|
-
errorFormatter: { message: 'message', name: 'error' },
|
|
30
|
-
headers: options.headers,
|
|
31
|
-
query: { repeatParams: false },
|
|
32
|
-
};
|
|
14
|
+
super(options);
|
|
33
15
|
|
|
34
16
|
/**
|
|
35
17
|
* Provides an abstraction layer for consuming the
|
|
@@ -37,12 +19,7 @@ class BrandingManager {
|
|
|
37
19
|
*
|
|
38
20
|
* @type {external:RestClient}
|
|
39
21
|
*/
|
|
40
|
-
|
|
41
|
-
`${options.baseUrl}/branding`,
|
|
42
|
-
clientOptions,
|
|
43
|
-
options.tokenProvider
|
|
44
|
-
);
|
|
45
|
-
this.resource = new RetryRestClient(auth0RestClient, options.retry);
|
|
22
|
+
this.resource = this._getRestClient('/branding');
|
|
46
23
|
|
|
47
24
|
/**
|
|
48
25
|
* Provides an abstraction layer for consuming the
|
|
@@ -50,12 +27,7 @@ class BrandingManager {
|
|
|
50
27
|
*
|
|
51
28
|
* @type {external:RestClient}
|
|
52
29
|
*/
|
|
53
|
-
|
|
54
|
-
`${options.baseUrl}/branding/templates/universal-login`,
|
|
55
|
-
clientOptions,
|
|
56
|
-
options.tokenProvider
|
|
57
|
-
);
|
|
58
|
-
this.brandingTemplates = new RetryRestClient(brandingTemplateAuth0RestClient, options.retry);
|
|
30
|
+
this.brandingTemplates = this._getRestClient('/branding/templates/universal-login');
|
|
59
31
|
|
|
60
32
|
/**
|
|
61
33
|
* Provides an abstraction layer for consuming the
|
|
@@ -63,12 +35,7 @@ class BrandingManager {
|
|
|
63
35
|
*
|
|
64
36
|
* @type {external:RestClient}
|
|
65
37
|
*/
|
|
66
|
-
|
|
67
|
-
`${options.baseUrl}/branding/themes/:id`,
|
|
68
|
-
clientOptions,
|
|
69
|
-
options.tokenProvider
|
|
70
|
-
);
|
|
71
|
-
this.brandingThemes = new RetryRestClient(brandingThemesAuth0RestClient, options.retry);
|
|
38
|
+
this.brandingThemes = this._getRestClient('/branding/themes/:id');
|
|
72
39
|
}
|
|
73
40
|
|
|
74
41
|
/**
|
|
@@ -1,13 +1,11 @@
|
|
|
1
|
-
const
|
|
2
|
-
const Auth0RestClient = require('../Auth0RestClient');
|
|
3
|
-
const RetryRestClient = require('../RetryRestClient');
|
|
1
|
+
const BaseManager = require('./BaseManager');
|
|
4
2
|
|
|
5
3
|
/**
|
|
6
4
|
* Auth0 Client Grants Manager.
|
|
7
5
|
*
|
|
8
6
|
* See {@link https://auth0.com/docs/api/v2#!/Client_Grants Client Grants}
|
|
9
7
|
*/
|
|
10
|
-
class ClientGrantsManager {
|
|
8
|
+
class ClientGrantsManager extends BaseManager {
|
|
11
9
|
/**
|
|
12
10
|
* @param {object} options The client options.
|
|
13
11
|
* @param {string} options.baseUrl The URL of the API.
|
|
@@ -15,28 +13,7 @@ class ClientGrantsManager {
|
|
|
15
13
|
* @param {object} [options.retry] Retry Policy Config
|
|
16
14
|
*/
|
|
17
15
|
constructor(options) {
|
|
18
|
-
|
|
19
|
-
throw new ArgumentError('Must provide client options');
|
|
20
|
-
}
|
|
21
|
-
|
|
22
|
-
if (options.baseUrl === null || options.baseUrl === undefined) {
|
|
23
|
-
throw new ArgumentError('Must provide a base URL for the API');
|
|
24
|
-
}
|
|
25
|
-
|
|
26
|
-
if ('string' !== typeof options.baseUrl || options.baseUrl.length === 0) {
|
|
27
|
-
throw new ArgumentError('The provided base URL is invalid');
|
|
28
|
-
}
|
|
29
|
-
|
|
30
|
-
/**
|
|
31
|
-
* Options object for the Rest Client instance.
|
|
32
|
-
*
|
|
33
|
-
* @type {object}
|
|
34
|
-
*/
|
|
35
|
-
const clientOptions = {
|
|
36
|
-
errorFormatter: { message: 'message', name: 'error' },
|
|
37
|
-
headers: options.headers,
|
|
38
|
-
query: { repeatParams: false },
|
|
39
|
-
};
|
|
16
|
+
super(options);
|
|
40
17
|
|
|
41
18
|
/**
|
|
42
19
|
* Provides an abstraction layer for consuming the
|
|
@@ -44,12 +21,7 @@ class ClientGrantsManager {
|
|
|
44
21
|
*
|
|
45
22
|
* @type {external:RestClient}
|
|
46
23
|
*/
|
|
47
|
-
|
|
48
|
-
`${options.baseUrl}/client-grants/:id`,
|
|
49
|
-
clientOptions,
|
|
50
|
-
options.tokenProvider
|
|
51
|
-
);
|
|
52
|
-
this.resource = new RetryRestClient(auth0RestClient, options.retry);
|
|
24
|
+
this.resource = this._getRestClient('/client-grants/:id');
|
|
53
25
|
}
|
|
54
26
|
|
|
55
27
|
/**
|
|
@@ -1,6 +1,5 @@
|
|
|
1
1
|
const { ArgumentError } = require('rest-facade');
|
|
2
|
-
const
|
|
3
|
-
const RetryRestClient = require('../RetryRestClient');
|
|
2
|
+
const BaseManager = require('./BaseManager');
|
|
4
3
|
|
|
5
4
|
/**
|
|
6
5
|
* Auth0 Clients Manager.
|
|
@@ -11,7 +10,7 @@ const RetryRestClient = require('../RetryRestClient');
|
|
|
11
10
|
* {@link https://auth0.com/docs/applications Applications} section of the
|
|
12
11
|
* documentation.
|
|
13
12
|
*/
|
|
14
|
-
class ClientsManager {
|
|
13
|
+
class ClientsManager extends BaseManager {
|
|
15
14
|
/**
|
|
16
15
|
* @param {object} options The client options.
|
|
17
16
|
* @param {string} options.baseUrl The URL of the API.
|
|
@@ -19,28 +18,7 @@ class ClientsManager {
|
|
|
19
18
|
* @param {object} [options.retry] Retry Policy Config
|
|
20
19
|
*/
|
|
21
20
|
constructor(options) {
|
|
22
|
-
|
|
23
|
-
throw new ArgumentError('Must provide client options');
|
|
24
|
-
}
|
|
25
|
-
|
|
26
|
-
if (options.baseUrl === null || options.baseUrl === undefined) {
|
|
27
|
-
throw new ArgumentError('Must provide a base URL for the API');
|
|
28
|
-
}
|
|
29
|
-
|
|
30
|
-
if ('string' !== typeof options.baseUrl || options.baseUrl.length === 0) {
|
|
31
|
-
throw new ArgumentError('The provided base URL is invalid');
|
|
32
|
-
}
|
|
33
|
-
|
|
34
|
-
/**
|
|
35
|
-
* Options object for the Rest Client instance.
|
|
36
|
-
*
|
|
37
|
-
* @type {object}
|
|
38
|
-
*/
|
|
39
|
-
const clientOptions = {
|
|
40
|
-
errorFormatter: { message: 'message', name: 'error' },
|
|
41
|
-
headers: options.headers,
|
|
42
|
-
query: { repeatParams: false },
|
|
43
|
-
};
|
|
21
|
+
super(options);
|
|
44
22
|
|
|
45
23
|
/**
|
|
46
24
|
* Provides an abstraction layer for consuming the
|
|
@@ -48,12 +26,7 @@ class ClientsManager {
|
|
|
48
26
|
*
|
|
49
27
|
* @type {external:RestClient}
|
|
50
28
|
*/
|
|
51
|
-
|
|
52
|
-
`${options.baseUrl}/clients/:client_id`,
|
|
53
|
-
clientOptions,
|
|
54
|
-
options.tokenProvider
|
|
55
|
-
);
|
|
56
|
-
this.resource = new RetryRestClient(auth0RestClient, options.retry);
|
|
29
|
+
this.resource = this._getRestClient('/clients/:client_id');
|
|
57
30
|
|
|
58
31
|
/**
|
|
59
32
|
* Provides an abstraction layer for consuming the
|
|
@@ -61,12 +34,7 @@ class ClientsManager {
|
|
|
61
34
|
*
|
|
62
35
|
* @type {external:RestClient}
|
|
63
36
|
*/
|
|
64
|
-
|
|
65
|
-
`${options.baseUrl}/clients/:client_id/rotate-secret`,
|
|
66
|
-
clientOptions,
|
|
67
|
-
options.tokenProvider
|
|
68
|
-
);
|
|
69
|
-
this.rotateSecretResource = new RetryRestClient(auth0RotateSecretClient, options.retry);
|
|
37
|
+
this.rotateSecretResource = this._getRestClient('/clients/:client_id/rotate-secret');
|
|
70
38
|
}
|
|
71
39
|
|
|
72
40
|
/**
|