auth0 2.37.0 → 2.40.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 +37 -0
- package/README.md +33 -11
- package/package.json +22 -14
- package/src/Auth0RestClient.js +72 -71
- package/src/RetryRestClient.js +78 -81
- package/src/auth/DatabaseAuthenticator.js +242 -259
- package/src/auth/OAUthWithIDTokenValidation.js +99 -103
- package/src/auth/OAuthAuthenticator.js +325 -344
- package/src/auth/PasswordlessAuthenticator.js +238 -252
- package/src/auth/TokensManager.js +231 -246
- package/src/auth/UsersManager.js +149 -160
- package/src/auth/idToken.js +22 -19
- package/src/auth/index.js +510 -583
- package/src/errors.js +23 -23
- package/src/index.js +3 -2
- package/src/management/ActionsManager.js +510 -584
- package/src/management/AttackProtectionManager.js +187 -0
- package/src/management/BlacklistedTokensManager.js +77 -84
- package/src/management/BrandingManager.js +141 -163
- package/src/management/ClientGrantsManager.js +132 -145
- package/src/management/ClientsManager.js +145 -161
- package/src/management/ConnectionsManager.js +215 -239
- package/src/management/CustomDomainsManager.js +140 -157
- package/src/management/DeviceCredentialsManager.js +95 -111
- package/src/management/EmailProviderManager.js +110 -128
- package/src/management/EmailTemplatesManager.js +96 -112
- package/src/management/GrantsManager.js +94 -101
- package/src/management/GuardianManager.js +381 -455
- package/src/management/HooksManager.js +283 -325
- package/src/management/JobsManager.js +310 -343
- package/src/management/LogStreamsManager.js +142 -158
- package/src/management/LogsManager.js +92 -99
- package/src/management/ManagementTokenProvider.js +112 -120
- package/src/management/MigrationsManager.js +81 -90
- package/src/management/OrganizationsManager.js +686 -784
- package/src/management/PromptsManager.js +160 -182
- package/src/management/ResourceServersManager.js +143 -160
- package/src/management/RolesManager.js +323 -369
- package/src/management/RulesConfigsManager.js +94 -110
- package/src/management/RulesManager.js +154 -176
- package/src/management/StatsManager.js +87 -103
- package/src/management/TenantManager.js +81 -97
- package/src/management/TicketsManager.js +107 -115
- package/src/management/UserBlocksManager.js +135 -162
- package/src/management/UsersManager.js +729 -852
- package/src/management/index.js +3102 -3625
- package/src/utils.js +31 -60
|
@@ -1,147 +1,129 @@
|
|
|
1
|
-
|
|
2
|
-
|
|
3
|
-
|
|
4
|
-
var RetryRestClient = require('../RetryRestClient');
|
|
1
|
+
const { ArgumentError } = require('rest-facade');
|
|
2
|
+
const Auth0RestClient = require('../Auth0RestClient');
|
|
3
|
+
const RetryRestClient = require('../RetryRestClient');
|
|
5
4
|
|
|
6
5
|
/**
|
|
7
|
-
* Simple facade for consuming a REST API endpoint.
|
|
8
|
-
* @external RestClient
|
|
9
|
-
* @see https://github.com/ngonzalvez/rest-facade
|
|
10
|
-
*/
|
|
11
|
-
|
|
12
|
-
/**
|
|
13
|
-
* @class EmailProviderManager
|
|
14
6
|
* Auth0 Email Provider.
|
|
15
|
-
* @constructor
|
|
16
|
-
* @memberOf module:management
|
|
17
|
-
*
|
|
18
|
-
* @param {Object} options The client options.
|
|
19
|
-
* @param {String} options.baseUrl The URL of the API.
|
|
20
|
-
* @param {Object} [options.headers] Headers to be included in all requests.
|
|
21
|
-
* @param {Object} [options.retry] Retry Policy Config
|
|
22
7
|
*/
|
|
23
|
-
|
|
24
|
-
|
|
25
|
-
|
|
26
|
-
|
|
8
|
+
class EmailProviderManager {
|
|
9
|
+
/**
|
|
10
|
+
* @param {object} options The client options.
|
|
11
|
+
* @param {string} options.baseUrl The URL of the API.
|
|
12
|
+
* @param {object} [options.headers] Headers to be included in all requests.
|
|
13
|
+
* @param {object} [options.retry] Retry Policy Config
|
|
14
|
+
*/
|
|
15
|
+
constructor(options) {
|
|
16
|
+
if (options === null || typeof options !== 'object') {
|
|
17
|
+
throw new ArgumentError('Must provide client options');
|
|
18
|
+
}
|
|
27
19
|
|
|
28
|
-
|
|
29
|
-
|
|
30
|
-
|
|
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
|
+
};
|
|
31
38
|
|
|
32
|
-
|
|
33
|
-
|
|
39
|
+
/**
|
|
40
|
+
* Provides an abstraction layer for consuming the
|
|
41
|
+
* [Auth0 Clients endpoint]{@link https://auth0.com/docs/api/v2#!/Clients}.
|
|
42
|
+
*
|
|
43
|
+
* @type {external:RestClient}
|
|
44
|
+
*/
|
|
45
|
+
const auth0RestClient = new Auth0RestClient(
|
|
46
|
+
`${options.baseUrl}/emails/provider`,
|
|
47
|
+
clientOptions,
|
|
48
|
+
options.tokenProvider
|
|
49
|
+
);
|
|
50
|
+
this.resource = new RetryRestClient(auth0RestClient, options.retry);
|
|
34
51
|
}
|
|
35
52
|
|
|
36
53
|
/**
|
|
37
|
-
*
|
|
54
|
+
* Configure the email provider.
|
|
38
55
|
*
|
|
39
|
-
* @
|
|
56
|
+
* @example
|
|
57
|
+
* management.emailProvider.configure(data, function (err) {
|
|
58
|
+
* if (err) {
|
|
59
|
+
* // Handle error.
|
|
60
|
+
* }
|
|
61
|
+
*
|
|
62
|
+
* // Email provider configured.
|
|
63
|
+
* });
|
|
64
|
+
* @param {object} data The email provider data object.
|
|
65
|
+
* @param {Function} [cb] Callback function.
|
|
66
|
+
* @returns {Promise|undefined}
|
|
40
67
|
*/
|
|
41
|
-
|
|
42
|
-
|
|
43
|
-
|
|
44
|
-
query: { repeatParams: false }
|
|
45
|
-
};
|
|
68
|
+
configure(...args) {
|
|
69
|
+
return this.resource.create(...args);
|
|
70
|
+
}
|
|
46
71
|
|
|
47
72
|
/**
|
|
48
|
-
*
|
|
49
|
-
* [Auth0 Clients endpoint]{@link https://auth0.com/docs/api/v2#!/Clients}.
|
|
73
|
+
* Get the email provider.
|
|
50
74
|
*
|
|
51
|
-
* @
|
|
75
|
+
* @example
|
|
76
|
+
* management.emailProvider.get(function (err, provider) {
|
|
77
|
+
* console.log(provider);
|
|
78
|
+
* });
|
|
79
|
+
* @param {Function} [cb] Callback function.
|
|
80
|
+
* @param {object} [params] Clients parameters.
|
|
81
|
+
* @param {number} [params.fields] A comma separated list of fields to include or exclude (depending on include_fields) from the result, empty to retrieve: name, enabled, settings fields.
|
|
82
|
+
* @param {number} [params.include_fields] true if the fields specified are to be excluded from the result, false otherwise (defaults to true)
|
|
83
|
+
* @returns {Promise|undefined}
|
|
52
84
|
*/
|
|
53
|
-
|
|
54
|
-
|
|
55
|
-
|
|
56
|
-
options.tokenProvider
|
|
57
|
-
);
|
|
58
|
-
this.resource = new RetryRestClient(auth0RestClient, options.retry);
|
|
59
|
-
};
|
|
60
|
-
|
|
61
|
-
/**
|
|
62
|
-
* Configure the email provider.
|
|
63
|
-
*
|
|
64
|
-
* @method configure
|
|
65
|
-
* @memberOf module:management.EmailProviderManager.prototype
|
|
66
|
-
*
|
|
67
|
-
* @example
|
|
68
|
-
* management.emailProvider.configure(data, function (err) {
|
|
69
|
-
* if (err) {
|
|
70
|
-
* // Handle error.
|
|
71
|
-
* }
|
|
72
|
-
*
|
|
73
|
-
* // Email provider configured.
|
|
74
|
-
* });
|
|
75
|
-
* @param {Object} data The email provider data object.
|
|
76
|
-
* @param {Function} [cb] Callback function.
|
|
77
|
-
*
|
|
78
|
-
* @return {Promise|undefined}
|
|
79
|
-
*/
|
|
80
|
-
utils.wrapPropertyMethod(EmailProviderManager, 'configure', 'resource.create');
|
|
81
|
-
|
|
82
|
-
/**
|
|
83
|
-
* Get the email provider.
|
|
84
|
-
*
|
|
85
|
-
* @method get
|
|
86
|
-
* @memberOf module:management.EmailProviderManager.prototype
|
|
87
|
-
*
|
|
88
|
-
* @example
|
|
89
|
-
* management.emailProvider.get(function (err, provider) {
|
|
90
|
-
* console.log(provider);
|
|
91
|
-
* });
|
|
92
|
-
*
|
|
93
|
-
* @param {Function} [cb] Callback function.
|
|
94
|
-
* @param {Object} [params] Clients parameters.
|
|
95
|
-
* @param {Number} [params.fields] A comma separated list of fields to include or exclude (depending on include_fields) from the result, empty to retrieve: name, enabled, settings fields.
|
|
96
|
-
* @param {Number} [params.include_fields] true if the fields specified are to be excluded from the result, false otherwise (defaults to true)
|
|
97
|
-
|
|
98
|
-
* @return {Promise|undefined}
|
|
99
|
-
*/
|
|
100
|
-
utils.wrapPropertyMethod(EmailProviderManager, 'get', 'resource.getAll');
|
|
85
|
+
get(...args) {
|
|
86
|
+
return this.resource.getAll(...args);
|
|
87
|
+
}
|
|
101
88
|
|
|
102
|
-
/**
|
|
103
|
-
|
|
104
|
-
|
|
105
|
-
|
|
106
|
-
|
|
107
|
-
|
|
108
|
-
|
|
109
|
-
|
|
110
|
-
|
|
111
|
-
|
|
112
|
-
|
|
113
|
-
|
|
114
|
-
|
|
115
|
-
|
|
116
|
-
|
|
117
|
-
|
|
118
|
-
|
|
119
|
-
|
|
120
|
-
|
|
121
|
-
|
|
122
|
-
* @return {Promise|undefined}
|
|
123
|
-
*/
|
|
124
|
-
utils.wrapPropertyMethod(EmailProviderManager, 'update', 'resource.patch');
|
|
89
|
+
/**
|
|
90
|
+
* Update the email provider.
|
|
91
|
+
*
|
|
92
|
+
* @example
|
|
93
|
+
* management.emailProvider.update(params, data, function (err, provider) {
|
|
94
|
+
* if (err) {
|
|
95
|
+
* // Handle error.
|
|
96
|
+
* }
|
|
97
|
+
*
|
|
98
|
+
* // Updated email provider.
|
|
99
|
+
* console.log(provider);
|
|
100
|
+
* });
|
|
101
|
+
* @param {object} params Email provider parameters.
|
|
102
|
+
* @param {object} data Updated email provider data.
|
|
103
|
+
* @param {Function} [cb] Callback function.
|
|
104
|
+
* @returns {Promise|undefined}
|
|
105
|
+
*/
|
|
106
|
+
update(...args) {
|
|
107
|
+
return this.resource.patch(...args);
|
|
108
|
+
}
|
|
125
109
|
|
|
126
|
-
/**
|
|
127
|
-
|
|
128
|
-
|
|
129
|
-
|
|
130
|
-
|
|
131
|
-
|
|
132
|
-
|
|
133
|
-
|
|
134
|
-
|
|
135
|
-
|
|
136
|
-
|
|
137
|
-
|
|
138
|
-
|
|
139
|
-
|
|
140
|
-
|
|
141
|
-
|
|
142
|
-
|
|
143
|
-
|
|
144
|
-
*/
|
|
145
|
-
utils.wrapPropertyMethod(EmailProviderManager, 'delete', 'resource.delete');
|
|
110
|
+
/**
|
|
111
|
+
* Delete email provider.
|
|
112
|
+
*
|
|
113
|
+
* @example
|
|
114
|
+
* management.emailProvider.delete(function (err) {
|
|
115
|
+
* if (err) {
|
|
116
|
+
* // Handle error.
|
|
117
|
+
* }
|
|
118
|
+
*
|
|
119
|
+
* // Email provider configured.
|
|
120
|
+
* });
|
|
121
|
+
* @param {Function} [cb] Callback function.
|
|
122
|
+
* @returns {Promise|undefined}
|
|
123
|
+
*/
|
|
124
|
+
delete(...args) {
|
|
125
|
+
return this.resource.delete(...args);
|
|
126
|
+
}
|
|
127
|
+
}
|
|
146
128
|
|
|
147
129
|
module.exports = EmailProviderManager;
|
|
@@ -1,129 +1,113 @@
|
|
|
1
|
-
|
|
2
|
-
|
|
3
|
-
|
|
4
|
-
var RetryRestClient = require('../RetryRestClient');
|
|
1
|
+
const { ArgumentError } = require('rest-facade');
|
|
2
|
+
const Auth0RestClient = require('../Auth0RestClient');
|
|
3
|
+
const RetryRestClient = require('../RetryRestClient');
|
|
5
4
|
|
|
6
5
|
/**
|
|
7
|
-
* Simple facade for consuming a REST API endpoint.
|
|
8
|
-
* @external RestClient
|
|
9
|
-
* @see https://github.com/ngonzalvez/rest-facade
|
|
10
|
-
*/
|
|
11
|
-
|
|
12
|
-
/**
|
|
13
|
-
* @class EmailTemplatesManager
|
|
14
6
|
* This class provides a simple abstraction for performing CRUD operations
|
|
15
|
-
* on Auth0's Email Templates. {@
|
|
16
|
-
* @constructor
|
|
17
|
-
* @memberOf module:management
|
|
18
|
-
*
|
|
19
|
-
* @param {Object} options The client options.
|
|
20
|
-
* @param {String} options.baseUrl The URL of the API.
|
|
21
|
-
* @param {Object} [options.headers] Headers to be included in all requests.
|
|
22
|
-
* @param {Object} [options.retry] Retry Policy Config
|
|
7
|
+
* on Auth0's Email Templates. {@link https://auth0.com/docs/api/management/v2#!/Email_Templates/get_email_templates_by_templateName}
|
|
23
8
|
*/
|
|
24
|
-
|
|
25
|
-
|
|
26
|
-
|
|
27
|
-
|
|
9
|
+
class EmailTemplatesManager {
|
|
10
|
+
/**
|
|
11
|
+
* @param {object} options The client options.
|
|
12
|
+
* @param {string} options.baseUrl The URL of the API.
|
|
13
|
+
* @param {object} [options.headers] Headers to be included in all requests.
|
|
14
|
+
* @param {object} [options.retry] Retry Policy Config
|
|
15
|
+
*/
|
|
16
|
+
constructor(options) {
|
|
17
|
+
if (!options || 'object' !== typeof options) {
|
|
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
|
+
}
|
|
28
24
|
|
|
29
|
-
|
|
30
|
-
|
|
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
|
+
};
|
|
34
|
+
|
|
35
|
+
/**
|
|
36
|
+
* Provides an abstraction layer for performing CRUD operations on
|
|
37
|
+
* {@link https://auth0.com/docs/api/management/v2#!/Email_Templates/get_email_templates_by_templateName Auth0's Email Templates}.
|
|
38
|
+
*
|
|
39
|
+
* @type {external:RestClient}
|
|
40
|
+
*/
|
|
41
|
+
const auth0RestClient = new Auth0RestClient(
|
|
42
|
+
`${options.baseUrl}/email-templates/:name`,
|
|
43
|
+
clientOptions,
|
|
44
|
+
options.tokenProvider
|
|
45
|
+
);
|
|
46
|
+
this.resource = new RetryRestClient(auth0RestClient, options.retry);
|
|
31
47
|
}
|
|
32
48
|
|
|
33
49
|
/**
|
|
34
|
-
*
|
|
50
|
+
* Create a new Email Template.
|
|
51
|
+
*
|
|
52
|
+
* @example
|
|
53
|
+
* management.emailTemplates.create(data, function (err) {
|
|
54
|
+
* if (err) {
|
|
55
|
+
* // Handle error.
|
|
56
|
+
* }
|
|
35
57
|
*
|
|
36
|
-
*
|
|
58
|
+
* // Email Template created.
|
|
59
|
+
* });
|
|
60
|
+
* @param {object} data Email Template data object.
|
|
61
|
+
* @param {Function} [cb] Callback function.
|
|
62
|
+
* @returns {Promise|undefined}
|
|
37
63
|
*/
|
|
38
|
-
|
|
39
|
-
|
|
40
|
-
|
|
41
|
-
};
|
|
64
|
+
create(...args) {
|
|
65
|
+
return this.resource.create(...args);
|
|
66
|
+
}
|
|
42
67
|
|
|
43
68
|
/**
|
|
44
|
-
*
|
|
45
|
-
* {@link https://auth0.com/docs/api/management/v2#!/Email_Templates/get_email_templates_by_templateName Auth0's Email Templates}.
|
|
69
|
+
* Get an Auth0 Email Template.
|
|
46
70
|
*
|
|
47
|
-
* @
|
|
71
|
+
* @example
|
|
72
|
+
* management.emailTemplates.get({ name: EMAIL_TEMPLATE_NAME }, function (err, emailTemplate) {
|
|
73
|
+
* if (err) {
|
|
74
|
+
* // Handle error.
|
|
75
|
+
* }
|
|
76
|
+
*
|
|
77
|
+
* console.log(emailTemplate);
|
|
78
|
+
* });
|
|
79
|
+
* @param {object} params Email Template parameters.
|
|
80
|
+
* @param {string} params.name Template Name
|
|
81
|
+
* @param {Function} [cb] Callback function.
|
|
82
|
+
* @returns {Promise|undefined}
|
|
48
83
|
*/
|
|
49
|
-
|
|
50
|
-
|
|
51
|
-
|
|
52
|
-
options.tokenProvider
|
|
53
|
-
);
|
|
54
|
-
this.resource = new RetryRestClient(auth0RestClient, options.retry);
|
|
55
|
-
};
|
|
56
|
-
|
|
57
|
-
/**
|
|
58
|
-
* Create a new Email Template.
|
|
59
|
-
*
|
|
60
|
-
* @method create
|
|
61
|
-
* @memberOf module:management.EmailTemplatesManager.prototype
|
|
62
|
-
*
|
|
63
|
-
* @example
|
|
64
|
-
* management.emailTemplates.create(data, function (err) {
|
|
65
|
-
* if (err) {
|
|
66
|
-
* // Handle error.
|
|
67
|
-
* }
|
|
68
|
-
*
|
|
69
|
-
* // Email Template created.
|
|
70
|
-
* });
|
|
71
|
-
*
|
|
72
|
-
* @param {Object} data Email Template data object.
|
|
73
|
-
* @param {Function} [cb] Callback function.
|
|
74
|
-
*
|
|
75
|
-
* @return {Promise|undefined}
|
|
76
|
-
*/
|
|
77
|
-
utils.wrapPropertyMethod(EmailTemplatesManager, 'create', 'resource.create');
|
|
78
|
-
|
|
79
|
-
/**
|
|
80
|
-
* Get an Auth0 Email Template.
|
|
81
|
-
*
|
|
82
|
-
* @method get
|
|
83
|
-
* @memberOf module:management.EmailTemplatesManager.prototype
|
|
84
|
-
*
|
|
85
|
-
* @example
|
|
86
|
-
* management.emailTemplates.get({ name: EMAIL_TEMPLATE_NAME }, function (err, emailTemplate) {
|
|
87
|
-
* if (err) {
|
|
88
|
-
* // Handle error.
|
|
89
|
-
* }
|
|
90
|
-
*
|
|
91
|
-
* console.log(emailTemplate);
|
|
92
|
-
* });
|
|
93
|
-
*
|
|
94
|
-
* @param {Object} params Email Template parameters.
|
|
95
|
-
* @param {String} params.name Template Name
|
|
96
|
-
* @param {Function} [cb] Callback function.
|
|
97
|
-
*
|
|
98
|
-
* @return {Promise|undefined}
|
|
99
|
-
*/
|
|
100
|
-
utils.wrapPropertyMethod(EmailTemplatesManager, 'get', 'resource.get');
|
|
84
|
+
get(...args) {
|
|
85
|
+
return this.resource.get(...args);
|
|
86
|
+
}
|
|
101
87
|
|
|
102
|
-
/**
|
|
103
|
-
|
|
104
|
-
|
|
105
|
-
|
|
106
|
-
|
|
107
|
-
|
|
108
|
-
|
|
109
|
-
|
|
110
|
-
|
|
111
|
-
|
|
112
|
-
|
|
113
|
-
|
|
114
|
-
|
|
115
|
-
|
|
116
|
-
|
|
117
|
-
|
|
118
|
-
|
|
119
|
-
|
|
120
|
-
|
|
121
|
-
|
|
122
|
-
|
|
123
|
-
|
|
124
|
-
|
|
125
|
-
|
|
126
|
-
*/
|
|
127
|
-
utils.wrapPropertyMethod(EmailTemplatesManager, 'update', 'resource.patch');
|
|
88
|
+
/**
|
|
89
|
+
* Update an existing Email Template.
|
|
90
|
+
*
|
|
91
|
+
* @example
|
|
92
|
+
* var data = { from: 'new@email.com' };
|
|
93
|
+
* var params = { name: EMAIL_TEMPLATE_NAME };
|
|
94
|
+
*
|
|
95
|
+
* management.emailTemplates.update(params, data, function (err, emailTemplate) {
|
|
96
|
+
* if (err) {
|
|
97
|
+
* // Handle error.
|
|
98
|
+
* }
|
|
99
|
+
*
|
|
100
|
+
* console.log(emailTemplate.from); // 'new@email.com'
|
|
101
|
+
* });
|
|
102
|
+
* @param {object} params Email Template parameters.
|
|
103
|
+
* @param {string} params.name Template Name
|
|
104
|
+
* @param {object} data Updated Email Template data.
|
|
105
|
+
* @param {Function} [cb] Callback function.
|
|
106
|
+
* @returns {Promise|undefined}
|
|
107
|
+
*/
|
|
108
|
+
update(...args) {
|
|
109
|
+
return this.resource.patch(...args);
|
|
110
|
+
}
|
|
111
|
+
}
|
|
128
112
|
|
|
129
113
|
module.exports = EmailTemplatesManager;
|