auth0 2.42.0 → 2.44.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.
Files changed (34) hide show
  1. package/CHANGELOG.md +16 -0
  2. package/package.json +5 -6
  3. package/src/Auth0RestClient.js +32 -2
  4. package/src/management/ActionsManager.js +12 -73
  5. package/src/management/AttackProtectionManager.js +8 -37
  6. package/src/management/BaseManager.js +41 -0
  7. package/src/management/BlacklistedTokensManager.js +4 -32
  8. package/src/management/BrandingManager.js +6 -39
  9. package/src/management/ClientGrantsManager.js +4 -32
  10. package/src/management/ClientsManager.js +7 -37
  11. package/src/management/ConnectionsManager.js +6 -42
  12. package/src/management/CustomDomainsManager.js +5 -37
  13. package/src/management/DeviceCredentialsManager.js +4 -26
  14. package/src/management/EmailProviderManager.js +4 -32
  15. package/src/management/EmailTemplatesManager.js +4 -27
  16. package/src/management/GrantsManager.js +4 -32
  17. package/src/management/GuardianManager.js +13 -86
  18. package/src/management/HooksManager.js +5 -36
  19. package/src/management/JobsManager.js +6 -38
  20. package/src/management/LogStreamsManager.js +4 -31
  21. package/src/management/LogsManager.js +4 -31
  22. package/src/management/MigrationsManager.js +4 -27
  23. package/src/management/OrganizationsManager.js +14 -65
  24. package/src/management/PromptsManager.js +5 -35
  25. package/src/management/ResourceServersManager.js +4 -31
  26. package/src/management/RolesManager.js +6 -42
  27. package/src/management/RulesConfigsManager.js +4 -31
  28. package/src/management/RulesManager.js +4 -31
  29. package/src/management/StatsManager.js +4 -27
  30. package/src/management/TenantManager.js +4 -27
  31. package/src/management/TicketsManager.js +4 -27
  32. package/src/management/UserBlocksManager.js +5 -35
  33. package/src/management/UsersManager.js +16 -91
  34. package/src/management/index.js +6 -0
package/CHANGELOG.md CHANGED
@@ -1,5 +1,21 @@
1
1
  # Change Log
2
2
 
3
+ ## [v2.44.0](https://github.com/auth0/node-auth0/tree/v2.44.0) (2022-10-11)
4
+
5
+ [Full Changelog](https://github.com/auth0/node-auth0/compare/v2.43.0...v2.44.0)
6
+
7
+ **Added**
8
+
9
+ - [SDK-3653] Add proxy support to Management Client [\#747](https://github.com/auth0/node-auth0/pull/747) ([adamjmcgrath](https://github.com/adamjmcgrath))
10
+
11
+ ## [v2.43.0](https://github.com/auth0/node-auth0/tree/v2.43.0) (2022-10-10)
12
+
13
+ [Full Changelog](https://github.com/auth0/node-auth0/compare/v2.42.0...v2.43.0)
14
+
15
+ **Added**
16
+
17
+ - Add option to include response headers in the result [\#744](https://github.com/auth0/node-auth0/pull/744) ([adamjmcgrath](https://github.com/adamjmcgrath))
18
+
3
19
  ## [v2.42.0](https://github.com/auth0/node-auth0/tree/v2.42.0) (2022-05-23)
4
20
 
5
21
  [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.42.0",
3
+ "version": "2.44.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.26.1",
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,14 +57,15 @@
59
57
  "minami": "^1.2.3",
60
58
  "mocha": "^8.4.0",
61
59
  "mocha-junit-reporter": "^2.0.0",
62
- "nock": "^10.0.6",
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": "^11.1.2",
66
+ "sinon": "^14.0.0",
69
67
  "string-replace-webpack-plugin": "0.1.3",
68
+ "superagent-proxy": "^3.0.0",
70
69
  "webpack": "^4.36.1"
71
70
  }
72
71
  }
@@ -27,7 +27,7 @@ class Auth0RestClient {
27
27
 
28
28
  this.wrappedProvider = function (method, args) {
29
29
  if (!this.provider) {
30
- return this.restClient[method](...args);
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.restClient[method](...args);
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 { ArgumentError } = require('rest-facade');
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
- if (options === null || typeof options !== 'object') {
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
- const auth0RestClient = new Auth0RestClient(
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
- const actionsDeployRestClient = new Auth0RestClient(
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
- const actionsTestRestClient = new Auth0RestClient(
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
- const triggersRestClient = new Auth0RestClient(
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
- const triggerBindingsRestClient = new Auth0RestClient(
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
- const executionsRestClient = new Auth0RestClient(
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
- const actionVersionRestClient = new Auth0RestClient(
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
- const deployActionVersionRestClient = new Auth0RestClient(
97
- `${options.baseUrl}/actions/actions/:id/versions/:version_id/deploy`,
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 { ArgumentError } = require('rest-facade');
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
- if (options === null || typeof options !== 'object') {
25
- throw new ArgumentError('Must provide manager options');
26
- }
22
+ super(options);
27
23
 
28
- if (options.baseUrl === null || options.baseUrl === undefined) {
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
- if ('string' !== typeof options.baseUrl || options.baseUrl.length === 0) {
33
- throw new ArgumentError('The provided base URL is invalid');
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
- const breachedPasswordDetection = new Auth0RestClient(
57
- `${options.baseUrl}/attack-protection/breached-password-detection`,
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,41 @@
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
+ proxy: options.proxy,
28
+ query: { repeatParams: false },
29
+ includeResponseHeaders: options.includeResponseHeaders,
30
+ };
31
+
32
+ const usersAuth0RestClient = new Auth0RestClient(
33
+ `${options.baseUrl}${path}`,
34
+ clientOptions,
35
+ options.tokenProvider
36
+ );
37
+ return new RetryRestClient(usersAuth0RestClient, options.retry);
38
+ }
39
+ }
40
+
41
+ module.exports = BaseManager;
@@ -1,12 +1,10 @@
1
- const { ArgumentError } = require('rest-facade');
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
- if (options === null || typeof options !== 'object') {
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
- const auth0RestClient = new Auth0RestClient(
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 { ArgumentError } = require('rest-facade');
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
- if (options === null || typeof options !== 'object') {
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
- const auth0RestClient = new Auth0RestClient(
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
- const brandingTemplateAuth0RestClient = new Auth0RestClient(
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
- const brandingThemesAuth0RestClient = new Auth0RestClient(
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 { ArgumentError } = require('rest-facade');
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
- if (options === null || typeof options !== 'object') {
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
- const auth0RestClient = new Auth0RestClient(
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 Auth0RestClient = require('../Auth0RestClient');
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
- if (options === null || typeof options !== 'object') {
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
- const auth0RestClient = new Auth0RestClient(
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
- const auth0RotateSecretClient = new Auth0RestClient(
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
  /**
@@ -129,6 +97,8 @@ class ClientsManager {
129
97
  * });
130
98
  * @param {object} params Client parameters.
131
99
  * @param {string} params.client_id Application client ID.
100
+ * @param {string} params.fields Comma-separated list of fields to include or exclude (based on value provided for include_fields).
101
+ * @param {string} params.include_fields Whether specified fields are to be included (true) or excluded (false).
132
102
  * @param {Function} [cb] Callback function.
133
103
  * @returns {Promise|undefined}
134
104
  */