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.
- package/CHANGELOG.md +16 -0
- package/package.json +7 -9
- 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 +122 -33
- 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
|
@@ -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
|
/**
|
|
@@ -1,11 +1,10 @@
|
|
|
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
|
* Represents the relationship between Auth0 and an Identity provider.
|
|
7
6
|
*/
|
|
8
|
-
class ConnectionsManager {
|
|
7
|
+
class ConnectionsManager extends BaseManager {
|
|
9
8
|
/**
|
|
10
9
|
* @param {object} options The client options.
|
|
11
10
|
* @param {string} options.baseUrl The URL of the API.
|
|
@@ -13,27 +12,7 @@ class ConnectionsManager {
|
|
|
13
12
|
* @param {object} [options.retry] Retry Policy Config
|
|
14
13
|
*/
|
|
15
14
|
constructor(options) {
|
|
16
|
-
|
|
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
|
-
};
|
|
15
|
+
super(options);
|
|
37
16
|
|
|
38
17
|
/**
|
|
39
18
|
* Provides an abstraction layer for performing CRUD operations on
|
|
@@ -42,19 +21,9 @@ class ConnectionsManager {
|
|
|
42
21
|
*
|
|
43
22
|
* @type {external:RestClient}
|
|
44
23
|
*/
|
|
45
|
-
|
|
46
|
-
`${options.baseUrl}/connections/:id`,
|
|
47
|
-
clientOptions,
|
|
48
|
-
options.tokenProvider
|
|
49
|
-
);
|
|
50
|
-
this.resource = new RetryRestClient(auth0RestClient, options.retry);
|
|
24
|
+
this.resource = this._getRestClient('/connections/:id');
|
|
51
25
|
|
|
52
|
-
|
|
53
|
-
`${options.baseUrl}/connections/:id/status`,
|
|
54
|
-
clientOptions,
|
|
55
|
-
options.tokenProvider
|
|
56
|
-
);
|
|
57
|
-
this.status = new RetryRestClient(statusClient, options.retry);
|
|
26
|
+
this.status = this._getRestClient('/connections/:id/status');
|
|
58
27
|
|
|
59
28
|
/**
|
|
60
29
|
* Provides an abstraction layer for consuming the
|
|
@@ -63,12 +32,7 @@ class ConnectionsManager {
|
|
|
63
32
|
*
|
|
64
33
|
* @type {external:RestClient}
|
|
65
34
|
*/
|
|
66
|
-
|
|
67
|
-
`${options.baseUrl}/connections/:id/users`,
|
|
68
|
-
clientOptions,
|
|
69
|
-
options.tokenProvider
|
|
70
|
-
);
|
|
71
|
-
this.user = new RetryRestClient(userAuth0RestClient, options.retry);
|
|
35
|
+
this.user = this._getRestClient('/connections/:id/users');
|
|
72
36
|
}
|
|
73
37
|
|
|
74
38
|
/**
|
|
@@ -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 Custom Domains Manager.
|
|
@@ -11,7 +10,7 @@ const RetryRestClient = require('../RetryRestClient');
|
|
|
11
10
|
* {@link https://auth0.com/docs/custom-domains CustomDomains} section of the
|
|
12
11
|
* documentation.
|
|
13
12
|
*/
|
|
14
|
-
class CustomDomainsManager {
|
|
13
|
+
class CustomDomainsManager 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 CustomDomainsManager {
|
|
|
19
18
|
* @param {object} [options.retry] Retry Policy Config
|
|
20
19
|
*/
|
|
21
20
|
constructor(options) {
|
|
22
|
-
|
|
23
|
-
throw new ArgumentError('Must provide manager 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 CustomDomainsManager {
|
|
|
48
26
|
*
|
|
49
27
|
* @type {external:RestClient}
|
|
50
28
|
*/
|
|
51
|
-
|
|
52
|
-
`${options.baseUrl}/custom-domains/:id`,
|
|
53
|
-
clientOptions,
|
|
54
|
-
options.tokenProvider
|
|
55
|
-
);
|
|
56
|
-
this.resource = new RetryRestClient(auth0CustomDomainsRestClient, options.retry);
|
|
29
|
+
this.resource = this._getRestClient('/custom-domains/:id');
|
|
57
30
|
|
|
58
31
|
/**
|
|
59
32
|
* Provides an abstraction layer for consuming the
|
|
@@ -61,12 +34,7 @@ class CustomDomainsManager {
|
|
|
61
34
|
*
|
|
62
35
|
* @type {external:RestClient}
|
|
63
36
|
*/
|
|
64
|
-
|
|
65
|
-
`${options.baseUrl}/custom-domains/:id/verify`,
|
|
66
|
-
clientOptions,
|
|
67
|
-
options.tokenProvider
|
|
68
|
-
);
|
|
69
|
-
this.vefifyResource = new RetryRestClient(auth0VerifyRestClient, options.retry);
|
|
37
|
+
this.vefifyResource = this._getRestClient('/custom-domains/:id/verify');
|
|
70
38
|
}
|
|
71
39
|
|
|
72
40
|
/**
|
|
@@ -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 Auth0 Device Credentials.
|
|
7
5
|
*/
|
|
8
|
-
class DeviceCredentialsManager {
|
|
6
|
+
class DeviceCredentialsManager extends BaseManager {
|
|
9
7
|
/**
|
|
10
8
|
* @param {object} options The client options.
|
|
11
9
|
* @param {string} options.baseUrl The URL of the API.
|
|
@@ -13,28 +11,13 @@ class DeviceCredentialsManager {
|
|
|
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
|
-
}
|
|
14
|
+
super(options);
|
|
27
15
|
|
|
28
16
|
/**
|
|
29
17
|
* Options object for the RestClient instance.
|
|
30
18
|
*
|
|
31
19
|
* @type {object}
|
|
32
20
|
*/
|
|
33
|
-
const clientOptions = {
|
|
34
|
-
errorFormatter: { message: 'message', name: 'error' },
|
|
35
|
-
headers: options.headers,
|
|
36
|
-
query: { repeatParams: false },
|
|
37
|
-
};
|
|
38
21
|
|
|
39
22
|
/**
|
|
40
23
|
* Provides an abstraction layer for consuming the
|
|
@@ -43,12 +26,7 @@ class DeviceCredentialsManager {
|
|
|
43
26
|
*
|
|
44
27
|
* @type {external:RestClient}
|
|
45
28
|
*/
|
|
46
|
-
|
|
47
|
-
`${options.baseUrl}/device-credentials/:id`,
|
|
48
|
-
clientOptions,
|
|
49
|
-
options.tokenProvider
|
|
50
|
-
);
|
|
51
|
-
this.resource = new RetryRestClient(auth0RestClient, options.retry);
|
|
29
|
+
this.resource = this._getRestClient('/device-credentials/:id');
|
|
52
30
|
}
|
|
53
31
|
|
|
54
32
|
/**
|
|
@@ -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
|
* Auth0 Email Provider.
|
|
7
5
|
*/
|
|
8
|
-
class EmailProviderManager {
|
|
6
|
+
class EmailProviderManager extends BaseManager {
|
|
9
7
|
/**
|
|
10
8
|
* @param {object} options The client options.
|
|
11
9
|
* @param {string} options.baseUrl The URL of the API.
|
|
@@ -13,28 +11,7 @@ class EmailProviderManager {
|
|
|
13
11
|
* @param {object} [options.retry] Retry Policy Config
|
|
14
12
|
*/
|
|
15
13
|
constructor(options) {
|
|
16
|
-
|
|
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
|
-
errorFormatter: { message: 'message', name: 'error' },
|
|
35
|
-
headers: options.headers,
|
|
36
|
-
query: { repeatParams: false },
|
|
37
|
-
};
|
|
14
|
+
super(options);
|
|
38
15
|
|
|
39
16
|
/**
|
|
40
17
|
* Provides an abstraction layer for consuming the
|
|
@@ -42,12 +19,7 @@ class EmailProviderManager {
|
|
|
42
19
|
*
|
|
43
20
|
* @type {external:RestClient}
|
|
44
21
|
*/
|
|
45
|
-
|
|
46
|
-
`${options.baseUrl}/emails/provider`,
|
|
47
|
-
clientOptions,
|
|
48
|
-
options.tokenProvider
|
|
49
|
-
);
|
|
50
|
-
this.resource = new RetryRestClient(auth0RestClient, options.retry);
|
|
22
|
+
this.resource = this._getRestClient('/emails/provider');
|
|
51
23
|
}
|
|
52
24
|
|
|
53
25
|
/**
|
|
@@ -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
|
* This class provides a simple abstraction for performing CRUD operations
|
|
7
5
|
* on Auth0's Email Templates. {@link https://auth0.com/docs/api/management/v2#!/Email_Templates/get_email_templates_by_templateName}
|
|
8
6
|
*/
|
|
9
|
-
class EmailTemplatesManager {
|
|
7
|
+
class EmailTemplatesManager extends BaseManager {
|
|
10
8
|
/**
|
|
11
9
|
* @param {object} options The client options.
|
|
12
10
|
* @param {string} options.baseUrl The URL of the API.
|
|
@@ -14,23 +12,7 @@ class EmailTemplatesManager {
|
|
|
14
12
|
* @param {object} [options.retry] Retry Policy Config
|
|
15
13
|
*/
|
|
16
14
|
constructor(options) {
|
|
17
|
-
|
|
18
|
-
throw new ArgumentError('Must provide manager options');
|
|
19
|
-
}
|
|
20
|
-
|
|
21
|
-
if (!options.baseUrl || 'string' !== typeof options.baseUrl) {
|
|
22
|
-
throw new ArgumentError('Must provide a valid string as base URL for the API');
|
|
23
|
-
}
|
|
24
|
-
|
|
25
|
-
/**
|
|
26
|
-
* Options object for the Rest Client instance.
|
|
27
|
-
*
|
|
28
|
-
* @type {object}
|
|
29
|
-
*/
|
|
30
|
-
const clientOptions = {
|
|
31
|
-
headers: options.headers,
|
|
32
|
-
query: { repeatParams: false },
|
|
33
|
-
};
|
|
15
|
+
super(options);
|
|
34
16
|
|
|
35
17
|
/**
|
|
36
18
|
* Provides an abstraction layer for performing CRUD operations on
|
|
@@ -38,12 +20,7 @@ class EmailTemplatesManager {
|
|
|
38
20
|
*
|
|
39
21
|
* @type {external:RestClient}
|
|
40
22
|
*/
|
|
41
|
-
|
|
42
|
-
`${options.baseUrl}/email-templates/:name`,
|
|
43
|
-
clientOptions,
|
|
44
|
-
options.tokenProvider
|
|
45
|
-
);
|
|
46
|
-
this.resource = new RetryRestClient(auth0RestClient, options.retry);
|
|
23
|
+
this.resource = this._getRestClient('/email-templates/:name');
|
|
47
24
|
}
|
|
48
25
|
|
|
49
26
|
/**
|
|
@@ -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 Grants Manager.
|
|
7
5
|
*
|
|
8
6
|
* See {@link https://auth0.com/docs/api/v2#!/Grants Grants}
|
|
9
7
|
*/
|
|
10
|
-
class GrantsManager {
|
|
8
|
+
class GrantsManager 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 GrantsManager {
|
|
|
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 GrantsManager {
|
|
|
44
21
|
*
|
|
45
22
|
* @type {external:RestClient}
|
|
46
23
|
*/
|
|
47
|
-
|
|
48
|
-
`${options.baseUrl}/grants/:id`,
|
|
49
|
-
clientOptions,
|
|
50
|
-
options.tokenProvider
|
|
51
|
-
);
|
|
52
|
-
this.resource = new RetryRestClient(auth0RestClient, options.retry);
|
|
24
|
+
this.resource = this._getRestClient('/grants/:id');
|
|
53
25
|
}
|
|
54
26
|
|
|
55
27
|
/**
|
|
@@ -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
|
* Abstracts interaction with the Guardian endpoint.
|
|
7
5
|
*/
|
|
8
|
-
class GuardianManager {
|
|
6
|
+
class GuardianManager extends BaseManager {
|
|
9
7
|
/**
|
|
10
8
|
* @param {object} options The client options.
|
|
11
9
|
* @param {string} options.baseUrl The URL of the API.
|
|
@@ -13,127 +11,64 @@ class GuardianManager {
|
|
|
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 retrieving Guardian enrollments.
|
|
36
18
|
*
|
|
37
19
|
* @type {external:RestClient}
|
|
38
20
|
*/
|
|
39
|
-
|
|
40
|
-
`${options.baseUrl}/guardian/enrollments/:id`,
|
|
41
|
-
clientOptions,
|
|
42
|
-
options.tokenProvider
|
|
43
|
-
);
|
|
44
|
-
this.enrollments = new RetryRestClient(guardianEnrollmentsAuth0RestClient, options.retry);
|
|
21
|
+
this.enrollments = this._getRestClient('/guardian/enrollments/:id');
|
|
45
22
|
|
|
46
23
|
/**
|
|
47
24
|
* Provides an abstraction layer for retrieving Guardian tickets.
|
|
48
25
|
*
|
|
49
26
|
* @type {external:RestClient}
|
|
50
27
|
*/
|
|
51
|
-
|
|
52
|
-
`${options.baseUrl}/guardian/enrollments/ticket`,
|
|
53
|
-
clientOptions,
|
|
54
|
-
options.tokenProvider
|
|
55
|
-
);
|
|
56
|
-
this.tickets = new RetryRestClient(guardianTicketsAuth0RestClient, options.retry);
|
|
28
|
+
this.tickets = this._getRestClient('/guardian/enrollments/ticket');
|
|
57
29
|
|
|
58
30
|
/**
|
|
59
31
|
* Provides an abstraction layer for retrieving Guardian factors.
|
|
60
32
|
*
|
|
61
33
|
* @type {external:RestClient}
|
|
62
34
|
*/
|
|
63
|
-
|
|
64
|
-
`${options.baseUrl}/guardian/factors/:name`,
|
|
65
|
-
clientOptions,
|
|
66
|
-
options.tokenProvider
|
|
67
|
-
);
|
|
68
|
-
this.factors = new RetryRestClient(guardianFactorsAuth0RestClient, options.retry);
|
|
35
|
+
this.factors = this._getRestClient('/guardian/factors/:name');
|
|
69
36
|
|
|
70
37
|
/**
|
|
71
38
|
* Provides an abstraction layer for configuring Factor settings
|
|
72
39
|
*
|
|
73
40
|
* @type {external:RestClient}
|
|
74
41
|
*/
|
|
75
|
-
|
|
76
|
-
`${options.baseUrl}/guardian/factors/:name/settings`,
|
|
77
|
-
clientOptions,
|
|
78
|
-
options.tokenProvider
|
|
79
|
-
);
|
|
80
|
-
this.factorSettings = new RetryRestClient(guardianFactorSettingsAuth0RestClient, options.retry);
|
|
42
|
+
this.factorSettings = this._getRestClient('/guardian/factors/:name/settings');
|
|
81
43
|
|
|
82
44
|
/**
|
|
83
45
|
* Provides an abstraction layer for retrieving Guardian factor templates.
|
|
84
46
|
*
|
|
85
47
|
* @type {external:RestClient}
|
|
86
48
|
*/
|
|
87
|
-
|
|
88
|
-
`${options.baseUrl}/guardian/factors/:name/templates`,
|
|
89
|
-
clientOptions,
|
|
90
|
-
options.tokenProvider
|
|
91
|
-
);
|
|
92
|
-
this.factorsTemplates = new RetryRestClient(
|
|
93
|
-
guardianFactorsTemplatesAuth0RestClient,
|
|
94
|
-
options.retry
|
|
95
|
-
);
|
|
49
|
+
this.factorsTemplates = this._getRestClient('/guardian/factors/:name/templates');
|
|
96
50
|
|
|
97
51
|
/**
|
|
98
52
|
* Provides an abstraction layer for retrieving Guardian factor providers.
|
|
99
53
|
*
|
|
100
54
|
* @type {external:RestClient}
|
|
101
55
|
*/
|
|
102
|
-
|
|
103
|
-
`${options.baseUrl}/guardian/factors/:name/providers/:provider`,
|
|
104
|
-
clientOptions,
|
|
105
|
-
options.tokenProvider
|
|
106
|
-
);
|
|
107
|
-
this.factorsProviders = new RetryRestClient(
|
|
108
|
-
guardianFactorsProvidersAuth0RestClient,
|
|
109
|
-
options.retry
|
|
110
|
-
);
|
|
56
|
+
this.factorsProviders = this._getRestClient('/guardian/factors/:name/providers/:provider');
|
|
111
57
|
|
|
112
58
|
/**
|
|
113
59
|
* Provides an abstraction layer for retrieving Guardian policies.
|
|
114
60
|
*
|
|
115
61
|
* @type {external:RestClient}
|
|
116
62
|
*/
|
|
117
|
-
|
|
118
|
-
`${options.baseUrl}/guardian/policies`,
|
|
119
|
-
clientOptions,
|
|
120
|
-
options.tokenProvider
|
|
121
|
-
);
|
|
122
|
-
this.policies = new RetryRestClient(guardianPoliciesAuth0RestClient, options.retry);
|
|
63
|
+
this.policies = this._getRestClient('/guardian/policies');
|
|
123
64
|
|
|
124
65
|
/**
|
|
125
66
|
* Provides an abstraction layer for retrieving Guardian phone factor selected provider.
|
|
126
67
|
*
|
|
127
68
|
* @type {external:RestClient}
|
|
128
69
|
*/
|
|
129
|
-
|
|
130
|
-
|
|
131
|
-
clientOptions,
|
|
132
|
-
options.tokenProvider
|
|
133
|
-
);
|
|
134
|
-
this.factorsPhoneSelectedProvider = new RetryRestClient(
|
|
135
|
-
guardianFactorsPhoneSelectedProviderAuth0RestClient,
|
|
136
|
-
options.retry
|
|
70
|
+
this.factorsPhoneSelectedProvider = this._getRestClient(
|
|
71
|
+
'/guardian/factors/sms/selected-provider'
|
|
137
72
|
);
|
|
138
73
|
|
|
139
74
|
/**
|
|
@@ -141,15 +76,7 @@ class GuardianManager {
|
|
|
141
76
|
*
|
|
142
77
|
* @type {external:RestClient}
|
|
143
78
|
*/
|
|
144
|
-
|
|
145
|
-
`${options.baseUrl}/guardian/factors/phone/message-types`,
|
|
146
|
-
clientOptions,
|
|
147
|
-
options.tokenProvider
|
|
148
|
-
);
|
|
149
|
-
this.factorsPhoneMessageTypes = new RetryRestClient(
|
|
150
|
-
guardianFactorsPhoneMessageTypesAuth0RestClient,
|
|
151
|
-
options.retry
|
|
152
|
-
);
|
|
79
|
+
this.factorsPhoneMessageTypes = this._getRestClient('/guardian/factors/phone/message-types');
|
|
153
80
|
}
|
|
154
81
|
|
|
155
82
|
/**
|
|
@@ -1,12 +1,11 @@
|
|
|
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
|
* The hooks manager class provides a simple abstraction for performing CRUD operations
|
|
7
6
|
* on Auth0 HooksManagers.
|
|
8
7
|
*/
|
|
9
|
-
class HooksManager {
|
|
8
|
+
class HooksManager 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 HooksManager {
|
|
|
14
13
|
* @param {object} [options.retry] Retry Policy Config
|
|
15
14
|
*/
|
|
16
15
|
constructor(options) {
|
|
17
|
-
|
|
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,19 +21,9 @@ class HooksManager {
|
|
|
42
21
|
*
|
|
43
22
|
* @type {external:RestClient}
|
|
44
23
|
*/
|
|
45
|
-
|
|
46
|
-
`${options.baseUrl}/hooks/:id`,
|
|
47
|
-
clientOptions,
|
|
48
|
-
options.tokenProvider
|
|
49
|
-
);
|
|
50
|
-
this.resource = new RetryRestClient(auth0RestClient, options.retry);
|
|
24
|
+
this.resource = this._getRestClient('/hooks/:id');
|
|
51
25
|
|
|
52
|
-
|
|
53
|
-
`${options.baseUrl}/hooks/:id/secrets`,
|
|
54
|
-
clientOptions,
|
|
55
|
-
options.tokenProvider
|
|
56
|
-
);
|
|
57
|
-
this.secrets = new RetryRestClient(hookSecretsClient, options.retry);
|
|
26
|
+
this.secrets = this._getRestClient('/hooks/:id/secrets');
|
|
58
27
|
}
|
|
59
28
|
|
|
60
29
|
/**
|