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
@@ -3,13 +3,12 @@ const FormData = require('form-data');
3
3
  const fs = require('fs');
4
4
 
5
5
  const { ArgumentError } = require('rest-facade');
6
- const Auth0RestClient = require('../Auth0RestClient');
7
- const RetryRestClient = require('../RetryRestClient');
6
+ const BaseManager = require('./BaseManager');
8
7
 
9
8
  /**
10
9
  * Abstract the creation as well as the retrieval of async jobs.
11
10
  */
12
- class JobsManager {
11
+ class JobsManager extends BaseManager {
13
12
  /**
14
13
  * @param {object} options The client options.
15
14
  * @param {string} options.baseUrl The URL of the API.
@@ -17,23 +16,7 @@ class JobsManager {
17
16
  * @param {object} [options.retry] Retry Policy Config
18
17
  */
19
18
  constructor(options) {
20
- if (options === null || typeof options !== 'object') {
21
- throw new ArgumentError('Must provide client options');
22
- }
23
-
24
- if (options.baseUrl === null || options.baseUrl === undefined) {
25
- throw new ArgumentError('Must provide a base URL for the API');
26
- }
27
-
28
- if ('string' !== typeof options.baseUrl || options.baseUrl.length === 0) {
29
- throw new ArgumentError('The provided base URL is invalid');
30
- }
31
-
32
- const clientOptions = {
33
- errorFormatter: { message: 'message', name: 'error' },
34
- headers: options.headers,
35
- query: { repeatParams: false },
36
- };
19
+ super(options);
37
20
 
38
21
  this.options = options;
39
22
 
@@ -43,12 +26,7 @@ class JobsManager {
43
26
  *
44
27
  * @type {external:RestClient}
45
28
  */
46
- const auth0RestClient = new Auth0RestClient(
47
- `${options.baseUrl}/jobs/:id`,
48
- clientOptions,
49
- options.tokenProvider
50
- );
51
- this.jobs = new RetryRestClient(auth0RestClient, options.retry);
29
+ this.jobs = this._getRestClient('/jobs/:id');
52
30
 
53
31
  /**
54
32
  * Provides an abstraction layer for consuming the
@@ -56,12 +34,7 @@ class JobsManager {
56
34
  *
57
35
  * @type {external:RestClient}
58
36
  */
59
- const jobErrorsRestClient = new Auth0RestClient(
60
- `${options.baseUrl}/jobs/:id/errors`,
61
- clientOptions,
62
- options.tokenProvider
63
- );
64
- this.jobErrors = new RetryRestClient(jobErrorsRestClient, options.retry);
37
+ this.jobErrors = this._getRestClient('/jobs/:id/errors');
65
38
 
66
39
  /**
67
40
  * Provides an abstraction layer for consuming the
@@ -69,12 +42,7 @@ class JobsManager {
69
42
  *
70
43
  * @type {external:RestClient}
71
44
  */
72
- const usersExportsRestClient = new Auth0RestClient(
73
- `${options.baseUrl}/jobs/users-exports`,
74
- clientOptions,
75
- options.tokenProvider
76
- );
77
- this.usersExports = new RetryRestClient(usersExportsRestClient, options.retry);
45
+ this.usersExports = this._getRestClient('/jobs/users-exports');
78
46
  }
79
47
 
80
48
  /**
@@ -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 logStreams class provides a simple abstraction for performing CRUD operations
7
5
  * on Auth0 Log Streams.
8
6
  */
9
- class LogStreamsManager {
7
+ class LogStreamsManager extends BaseManager {
10
8
  /**
11
9
  * @param {object} options The client options.
12
10
  * @param {string} options.baseUrl The URL of the API.
@@ -14,27 +12,7 @@ class LogStreamsManager {
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
- headers: options.headers,
36
- query: { repeatParams: false },
37
- };
15
+ super(options);
38
16
 
39
17
  /**
40
18
  * Provides an abstraction layer for performing CRUD operations on
@@ -43,12 +21,7 @@ class LogStreamsManager {
43
21
  *
44
22
  * @type {external:RestClient}
45
23
  */
46
- const auth0RestClient = new Auth0RestClient(
47
- `${options.baseUrl}/log-streams/:id `,
48
- clientOptions,
49
- options.tokenProvider
50
- );
51
- this.resource = new RetryRestClient(auth0RestClient, options.retry);
24
+ this.resource = this._getRestClient('/log-streams/:id ');
52
25
  }
53
26
 
54
27
  /**
@@ -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
  * Represents the relationship between Auth0 and an Identity provider.
7
5
  */
8
- class LogsManager {
6
+ class LogsManager extends BaseManager {
9
7
  /**
10
8
  * @param {object} options The client options.
11
9
  * @param {string} options.baseUrl The URL of the API.
@@ -13,27 +11,7 @@ class LogsManager {
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 client 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
- /**
29
- * Options object for the Rest Client instance.
30
- *
31
- * @type {object}
32
- */
33
- const clientOptions = {
34
- headers: options.headers,
35
- query: { repeatParams: false },
36
- };
14
+ super(options);
37
15
 
38
16
  /**
39
17
  * Provides an abstraction layer for performing CRUD operations on
@@ -42,12 +20,7 @@ class LogsManager {
42
20
  *
43
21
  * @type {external:RestClient}
44
22
  */
45
- const auth0RestClient = new Auth0RestClient(
46
- `${options.baseUrl}/logs/:id`,
47
- clientOptions,
48
- options.tokenProvider
49
- );
50
- this.resource = new RetryRestClient(auth0RestClient, options.retry);
23
+ this.resource = this._getRestClient('/logs/:id');
51
24
  }
52
25
 
53
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
  * Abstracts interaction with the migrations endpoint.
7
5
  */
8
- class MigrationsManager {
6
+ class MigrationsManager extends BaseManager {
9
7
  /**
10
8
  * @param {object} options The client options.
11
9
  * @param {string} options.baseUrl The URL of the API.
@@ -13,35 +11,14 @@ class MigrationsManager {
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 migrations endpoint
36
18
  *
37
19
  * @type {external:RestClient}
38
20
  */
39
- const auth0RestClient = new Auth0RestClient(
40
- `${options.baseUrl}/migrations`,
41
- clientOptions,
42
- options.tokenProvider
43
- );
44
- this.resource = new RetryRestClient(auth0RestClient, options.retry);
21
+ this.resource = this._getRestClient('/migrations');
45
22
  }
46
23
 
47
24
  /**
@@ -1,12 +1,11 @@
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
  * The organizations class provides a simple abstraction for performing CRUD operations
7
6
  * on Auth0 OrganizationsManager.
8
7
  */
9
- class OrganizationsManager {
8
+ class OrganizationsManager extends BaseManager {
10
9
  /**
11
10
  * @param {object} options The client options.
12
11
  * @param {string} options.baseUrl The URL of the API.
@@ -14,27 +13,7 @@ class OrganizationsManager {
14
13
  * @param {object} [options.retry] Retry Policy Config
15
14
  */
16
15
  constructor(options) {
17
- if (options === null || typeof options !== 'object') {
18
- throw new ArgumentError('Must provide manager 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
- headers: options.headers,
36
- query: { repeatParams: false },
37
- };
16
+ super(options);
38
17
 
39
18
  /**
40
19
  * Provides an abstraction layer for performing CRUD operations on
@@ -42,47 +21,17 @@ class OrganizationsManager {
42
21
  *
43
22
  * @type {external:RestClient}
44
23
  */
45
- const auth0RestClient = new Auth0RestClient(
46
- `${options.baseUrl}/organizations/:id`,
47
- clientOptions,
48
- options.tokenProvider
49
- );
50
- this.organizations = new RetryRestClient(auth0RestClient, options.retry);
51
-
52
- const connectionsInRoleClient = new Auth0RestClient(
53
- `${options.baseUrl}/organizations/:id/enabled_connections/:connection_id`,
54
- clientOptions,
55
- options.tokenProvider
56
- );
57
- this.connections = new RetryRestClient(connectionsInRoleClient, options.retry);
58
-
59
- const membersClient = new Auth0RestClient(
60
- `${options.baseUrl}/organizations/:id/members/:user_id`,
61
- clientOptions,
62
- options.tokenProvider
63
- );
64
- this.members = new RetryRestClient(membersClient, options.retry);
65
-
66
- const invitationClient = new Auth0RestClient(
67
- `${options.baseUrl}/organizations/:id/invitations/:invitation_id`,
68
- clientOptions,
69
- options.tokenProvider
70
- );
71
- this.invitations = new RetryRestClient(invitationClient, options.retry);
72
-
73
- const rolesClient = new Auth0RestClient(
74
- `${options.baseUrl}/organizations/:id/members/:user_id/roles`,
75
- clientOptions,
76
- options.tokenProvider
77
- );
78
- this.roles = new RetryRestClient(rolesClient, options.retry);
79
-
80
- const organizationByNameClient = new Auth0RestClient(
81
- `${options.baseUrl}/organizations/name/:name`,
82
- clientOptions,
83
- options.tokenProvider
84
- );
85
- this.organizationsByName = new RetryRestClient(organizationByNameClient, options.retry);
24
+ this.organizations = this._getRestClient('/organizations/:id');
25
+
26
+ this.connections = this._getRestClient('/organizations/:id/enabled_connections/:connection_id');
27
+
28
+ this.members = this._getRestClient('/organizations/:id/members/:user_id');
29
+
30
+ this.invitations = this._getRestClient('/organizations/:id/invitations/:invitation_id');
31
+
32
+ this.roles = this._getRestClient('/organizations/:id/members/:user_id/roles');
33
+
34
+ this.organizationsByName = this._getRestClient('/organizations/name/:name');
86
35
  }
87
36
 
88
37
  /**
@@ -1,11 +1,10 @@
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
  * Manages settings related to prompts.
7
6
  */
8
- class PromptsManager {
7
+ class PromptsManager extends BaseManager {
9
8
  /**
10
9
  * @param {object} options The client options.
11
10
  * @param {string} options.baseUrl The URL of the API.
@@ -13,23 +12,7 @@ class PromptsManager {
13
12
  * @param {object} [options.retry] Retry Policy Config
14
13
  */
15
14
  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
- };
15
+ super(options);
33
16
 
34
17
  /**
35
18
  * Provides an abstraction layer for consuming the
@@ -37,12 +20,7 @@ class PromptsManager {
37
20
  *
38
21
  * @type {external:RestClient}
39
22
  */
40
- const auth0RestClient = new Auth0RestClient(
41
- `${options.baseUrl}/prompts`,
42
- clientOptions,
43
- options.tokenProvider
44
- );
45
- this.resource = new RetryRestClient(auth0RestClient, options.retry);
23
+ this.resource = this._getRestClient('/prompts');
46
24
 
47
25
  /**
48
26
  * Retrieve custom text for a specific prompt and language.
@@ -51,15 +29,7 @@ class PromptsManager {
51
29
  *
52
30
  * @type {external:RestClient}
53
31
  */
54
- const customTextByLanguageAuth0RestClient = new Auth0RestClient(
55
- `${options.baseUrl}/prompts/:prompt/custom-text/:language`,
56
- clientOptions,
57
- options.tokenProvider
58
- );
59
- this.customTextByLanguage = new RetryRestClient(
60
- customTextByLanguageAuth0RestClient,
61
- options.retry
62
- );
32
+ this.customTextByLanguage = this._getRestClient('/prompts/:prompt/custom-text/:language');
63
33
  }
64
34
 
65
35
  /**
@@ -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
  * Auth0 Resource Servers Manager.
@@ -11,7 +9,7 @@ const RetryRestClient = require('../RetryRestClient');
11
9
  * {@link https://auth0.com/docs/api-auth API Authorization} section of the
12
10
  * documentation.
13
11
  */
14
- class ResourceServersManager {
12
+ class ResourceServersManager extends BaseManager {
15
13
  /**
16
14
  * @param {object} options The client options.
17
15
  * @param {string} options.baseUrl The URL of the API.
@@ -19,27 +17,7 @@ class ResourceServersManager {
19
17
  * @param {object} [options.retry] Retry Policy Config
20
18
  */
21
19
  constructor(options) {
22
- if (options === null || typeof options !== 'object') {
23
- throw new ArgumentError('Must provide resource server 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
- headers: options.headers,
41
- query: { repeatParams: false },
42
- };
20
+ super(options);
43
21
 
44
22
  /**
45
23
  * Provides an abstraction layer for consuming the
@@ -47,12 +25,7 @@ class ResourceServersManager {
47
25
  *
48
26
  * @type {external:RestClient}
49
27
  */
50
- const auth0RestClient = new Auth0RestClient(
51
- `${options.baseUrl}/resource-servers/:id`,
52
- clientOptions,
53
- options.tokenProvider
54
- );
55
- this.resource = new RetryRestClient(auth0RestClient, options.retry);
28
+ this.resource = this._getRestClient('/resource-servers/:id');
56
29
  }
57
30
 
58
31
  /**
@@ -1,12 +1,11 @@
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
  * The role class provides a simple abstraction for performing CRUD operations
7
6
  * on Auth0 RolesManager.
8
7
  */
9
- class RolesManager {
8
+ class RolesManager extends BaseManager {
10
9
  /**
11
10
  * @param {object} options The client options.
12
11
  * @param {string} options.baseUrl The URL of the API.
@@ -14,27 +13,7 @@ class RolesManager {
14
13
  * @param {object} [options.retry] Retry Policy Config
15
14
  */
16
15
  constructor(options) {
17
- if (options === null || typeof options !== 'object') {
18
- throw new ArgumentError('Must provide manager 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
- headers: options.headers,
36
- query: { repeatParams: false },
37
- };
16
+ super(options);
38
17
 
39
18
  /**
40
19
  * Provides an abstraction layer for performing CRUD operations on
@@ -42,26 +21,11 @@ class RolesManager {
42
21
  *
43
22
  * @type {external:RestClient}
44
23
  */
45
- const auth0RestClient = new Auth0RestClient(
46
- `${options.baseUrl}/roles/:id`,
47
- clientOptions,
48
- options.tokenProvider
49
- );
50
- this.resource = new RetryRestClient(auth0RestClient, options.retry);
24
+ this.resource = this._getRestClient('/roles/:id');
51
25
 
52
- const permissionsInRoleClient = new Auth0RestClient(
53
- `${options.baseUrl}/roles/:id/permissions`,
54
- clientOptions,
55
- options.tokenProvider
56
- );
57
- this.permissions = new RetryRestClient(permissionsInRoleClient, options.retry);
26
+ this.permissions = this._getRestClient('/roles/:id/permissions');
58
27
 
59
- const usersInRoleClient = new Auth0RestClient(
60
- `${options.baseUrl}/roles/:id/users`,
61
- clientOptions,
62
- options.tokenProvider
63
- );
64
- this.users = new RetryRestClient(usersInRoleClient, options.retry);
28
+ this.users = this._getRestClient('/roles/:id/users');
65
29
  }
66
30
 
67
31
  /**
@@ -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 rules configs manager class provides a simple abstraction for performing CRUD operations
7
5
  * on Auth0 RulesConfigsManager.
8
6
  */
9
- class RulesConfigsManager {
7
+ class RulesConfigsManager extends BaseManager {
10
8
  /**
11
9
  * @param {object} options The client options.
12
10
  * @param {string} options.baseUrl The URL of the API.
@@ -14,27 +12,7 @@ class RulesConfigsManager {
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 manager 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
- headers: options.headers,
36
- query: { repeatParams: false },
37
- };
15
+ super(options);
38
16
 
39
17
  /**
40
18
  * Provides an abstraction layer for performing CRUD operations on
@@ -42,12 +20,7 @@ class RulesConfigsManager {
42
20
  *
43
21
  * @type {external:RestClient}
44
22
  */
45
- const auth0RestClient = new Auth0RestClient(
46
- `${options.baseUrl}/rules-configs/:key`,
47
- clientOptions,
48
- options.tokenProvider
49
- );
50
- this.resource = new RetryRestClient(auth0RestClient, options.retry);
23
+ this.resource = this._getRestClient('/rules-configs/:key');
51
24
  }
52
25
 
53
26
  /**
@@ -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 rule class provides a simple abstraction for performing CRUD operations
7
5
  * on Auth0 RulesManagers.
8
6
  */
9
- class RulesManager {
7
+ class RulesManager extends BaseManager {
10
8
  /**
11
9
  * @param {object} options The client options.
12
10
  * @param {string} options.baseUrl The URL of the API.
@@ -14,27 +12,7 @@ class RulesManager {
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 manager 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
- headers: options.headers,
36
- query: { repeatParams: false },
37
- };
15
+ super(options);
38
16
 
39
17
  /**
40
18
  * Provides an abstraction layer for performing CRUD operations on
@@ -42,12 +20,7 @@ class RulesManager {
42
20
  *
43
21
  * @type {external:RestClient}
44
22
  */
45
- const auth0RestClient = new Auth0RestClient(
46
- `${options.baseUrl}/rules/:id`,
47
- clientOptions,
48
- options.tokenProvider
49
- );
50
- this.resource = new RetryRestClient(auth0RestClient, options.retry);
23
+ this.resource = this._getRestClient('/rules/:id');
51
24
  }
52
25
 
53
26
  /**