auth0 2.41.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.
Files changed (34) hide show
  1. package/CHANGELOG.md +16 -0
  2. package/package.json +7 -9
  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 +40 -0
  7. package/src/management/BlacklistedTokensManager.js +4 -32
  8. package/src/management/BrandingManager.js +122 -33
  9. package/src/management/ClientGrantsManager.js +4 -32
  10. package/src/management/ClientsManager.js +5 -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 +2 -0
package/CHANGELOG.md CHANGED
@@ -1,5 +1,21 @@
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
+
11
+ ## [v2.42.0](https://github.com/auth0/node-auth0/tree/v2.42.0) (2022-05-23)
12
+
13
+ [Full Changelog](https://github.com/auth0/node-auth0/compare/v2.41.0...v2.42.0)
14
+
15
+ **Added**
16
+
17
+ - chore: add branding theme routes [\#725](https://github.com/auth0/node-auth0/pull/725) ([alejofernandez](https://github.com/alejofernandez))
18
+
3
19
  ## [v2.41.0](https://github.com/auth0/node-auth0/tree/v2.41.0) (2022-05-20)
4
20
 
5
21
  [Full Changelog](https://github.com/auth0/node-auth0/compare/v2.40.0...v2.41.0)
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "auth0",
3
- "version": "2.41.0",
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.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,14 +43,13 @@
44
43
  },
45
44
  "devDependencies": {
46
45
  "chai": "^4.2.0",
47
- "codecov": "^3.7.2",
48
46
  "cross-env": "^5.2.0",
49
- "eslint": "^8.1.0",
50
- "eslint-config-prettier": "^8.3.0",
47
+ "eslint": "^8.16.0",
48
+ "eslint-config-prettier": "^8.5.0",
51
49
  "eslint-plugin-jsdoc": "^37.0.3",
52
50
  "eslint-plugin-node": "^11.1.0",
53
51
  "eslint-plugin-prettier": "^4.0.0",
54
- "eslint-plugin-promise": "^5.1.1",
52
+ "eslint-plugin-promise": "^6.0.0",
55
53
  "husky": "^3.0.1",
56
54
  "jsdoc": "^3.6.7",
57
55
  "json-loader": "^0.5.7",
@@ -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": "^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",
70
68
  "webpack": "^4.36.1"
71
69
  }
@@ -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,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 { 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,15 @@ 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');
31
+
32
+ /**
33
+ * Provides an abstraction layer for consuming the
34
+ * {@link https://auth0.com/docs/api/management/v2#!/Branding/get_branding_theme Branding theme endpoint}.
35
+ *
36
+ * @type {external:RestClient}
37
+ */
38
+ this.brandingThemes = this._getRestClient('/branding/themes/:id');
59
39
  }
60
40
 
61
41
  /**
@@ -156,6 +136,115 @@ class BrandingManager {
156
136
  deleteUniversalLoginTemplate(...args) {
157
137
  return this.brandingTemplates.delete(...args);
158
138
  }
139
+
140
+ /**
141
+ * Get the new universal login theme by id.
142
+ *
143
+ * @example
144
+ * var params = { id: THEME_ID };
145
+ *
146
+ * management.branding.getTheme(params, function (err, theme) {
147
+ * if (err) {
148
+ * // Handle error.
149
+ * }
150
+ *
151
+ * // Theme
152
+ * console.log(theme);
153
+ * });
154
+ * @param {object} params Theme params
155
+ * @param {object} params.id Theme identifier.
156
+ * @param {Function} [cb] Callback function.
157
+ * @returns {Promise|undefined}
158
+ */
159
+ getTheme(...args) {
160
+ return this.brandingThemes.get(...args);
161
+ }
162
+
163
+ /**
164
+ * Get the default new universal login theme.
165
+ *
166
+ * @example
167
+ * management.branding.getDefaultTheme(function (err, theme) {
168
+ * if (err) {
169
+ * // Handle error.
170
+ * }
171
+ *
172
+ * // Theme
173
+ * console.log(theme);
174
+ * });
175
+ * @param {Function} [cb] Callback function.
176
+ * @returns {Promise|undefined}
177
+ */
178
+ getDefaultTheme(...args) {
179
+ return this.brandingThemes.get(...[{ id: 'default' }].concat(args));
180
+ }
181
+
182
+ /**
183
+ * Create a new theme.
184
+ *
185
+ * @example
186
+ * management.branding.createTheme(data, function (err, theme) {
187
+ * if (err) {
188
+ * // Handle error.
189
+ * }
190
+ *
191
+ * // Theme created.
192
+ * console.log(theme);
193
+ * });
194
+ * @param {object} data theme data object.
195
+ * @param {Function} [cb] Callback function.
196
+ * @returns {Promise|undefined}
197
+ */
198
+ createTheme(...args) {
199
+ return this.brandingThemes.create(...args);
200
+ }
201
+
202
+ /**
203
+ * Update a theme.
204
+ *
205
+ * @example
206
+ * var data = THEME_OBJ;
207
+ * var params = { id: THEME_ID };
208
+ *
209
+ * management.branding.updateTheme(params, data, function (err, theme) {
210
+ * if (err) {
211
+ * // Handle error.
212
+ * }
213
+ *
214
+ * // Theme updated.
215
+ * console.log(theme);
216
+ * });
217
+ * @param {object} params Theme parameters.
218
+ * @param {object} params.id Theme identifier.
219
+ * @param {object} data Updated theme data.
220
+ * @param {Function} [cb] Callback function.
221
+ * @returns {Promise|undefined}
222
+ */
223
+ updateTheme(...args) {
224
+ return this.brandingThemes.patch(...args);
225
+ }
226
+
227
+ /**
228
+ * Delete a theme.
229
+ *
230
+ * @example
231
+ * var params = { id: THEME_ID };
232
+ *
233
+ * management.branding.deleteTheme(params, function (err) {
234
+ * if (err) {
235
+ * // Handle error.
236
+ * }
237
+ *
238
+ * // Theme deleted.
239
+ * });
240
+ * @param {object} params Theme parameters.
241
+ * @param {object} params.id Theme identifier.
242
+ * @param {Function} [cb] Callback function.
243
+ * @returns {Promise|undefined}
244
+ */
245
+ deleteTheme(...args) {
246
+ return this.brandingThemes.delete(...args);
247
+ }
159
248
  }
160
249
 
161
250
  module.exports = BrandingManager;
@@ -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
  /**