auth0 2.37.0 → 2.38.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 (46) hide show
  1. package/CHANGELOG.md +18 -0
  2. package/README.md +33 -11
  3. package/package.json +22 -14
  4. package/src/Auth0RestClient.js +72 -71
  5. package/src/RetryRestClient.js +78 -81
  6. package/src/auth/DatabaseAuthenticator.js +242 -259
  7. package/src/auth/OAUthWithIDTokenValidation.js +99 -103
  8. package/src/auth/OAuthAuthenticator.js +325 -344
  9. package/src/auth/PasswordlessAuthenticator.js +237 -252
  10. package/src/auth/TokensManager.js +231 -246
  11. package/src/auth/UsersManager.js +149 -160
  12. package/src/auth/idToken.js +22 -19
  13. package/src/auth/index.js +510 -583
  14. package/src/errors.js +23 -23
  15. package/src/index.js +3 -2
  16. package/src/management/ActionsManager.js +503 -585
  17. package/src/management/BlacklistedTokensManager.js +77 -84
  18. package/src/management/BrandingManager.js +141 -163
  19. package/src/management/ClientGrantsManager.js +132 -145
  20. package/src/management/ClientsManager.js +145 -161
  21. package/src/management/ConnectionsManager.js +215 -239
  22. package/src/management/CustomDomainsManager.js +140 -157
  23. package/src/management/DeviceCredentialsManager.js +95 -111
  24. package/src/management/EmailProviderManager.js +110 -128
  25. package/src/management/EmailTemplatesManager.js +96 -112
  26. package/src/management/GrantsManager.js +94 -101
  27. package/src/management/GuardianManager.js +381 -455
  28. package/src/management/HooksManager.js +283 -325
  29. package/src/management/JobsManager.js +310 -343
  30. package/src/management/LogStreamsManager.js +142 -158
  31. package/src/management/LogsManager.js +92 -99
  32. package/src/management/ManagementTokenProvider.js +112 -120
  33. package/src/management/MigrationsManager.js +81 -90
  34. package/src/management/OrganizationsManager.js +686 -784
  35. package/src/management/PromptsManager.js +160 -182
  36. package/src/management/ResourceServersManager.js +143 -160
  37. package/src/management/RolesManager.js +323 -369
  38. package/src/management/RulesConfigsManager.js +94 -110
  39. package/src/management/RulesManager.js +154 -176
  40. package/src/management/StatsManager.js +87 -103
  41. package/src/management/TenantManager.js +81 -97
  42. package/src/management/TicketsManager.js +107 -115
  43. package/src/management/UserBlocksManager.js +135 -162
  44. package/src/management/UsersManager.js +729 -852
  45. package/src/management/index.js +3094 -3625
  46. package/src/utils.js +31 -60
@@ -1,147 +1,129 @@
1
- var ArgumentError = require('rest-facade').ArgumentError;
2
- var utils = require('../utils');
3
- var Auth0RestClient = require('../Auth0RestClient');
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
- var EmailProviderManager = function(options) {
24
- if (options === null || typeof options !== 'object') {
25
- throw new ArgumentError('Must provide client options');
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
- if (options.baseUrl === null || options.baseUrl === undefined) {
29
- throw new ArgumentError('Must provide a base URL for the API');
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
- if ('string' !== typeof options.baseUrl || options.baseUrl.length === 0) {
33
- throw new ArgumentError('The provided base URL is invalid');
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
- * Options object for the Rest Client instance.
54
+ * Configure the email provider.
38
55
  *
39
- * @type {Object}
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
- var clientOptions = {
42
- errorFormatter: { message: 'message', name: 'error' },
43
- headers: options.headers,
44
- query: { repeatParams: false }
45
- };
68
+ configure(...args) {
69
+ return this.resource.create(...args);
70
+ }
46
71
 
47
72
  /**
48
- * Provides an abstraction layer for consuming the
49
- * [Auth0 Clients endpoint]{@link https://auth0.com/docs/api/v2#!/Clients}.
73
+ * Get the email provider.
50
74
  *
51
- * @type {external:RestClient}
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
- var auth0RestClient = new Auth0RestClient(
54
- options.baseUrl + '/emails/provider',
55
- clientOptions,
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
- * Update the email provider.
104
- *
105
- * @method update
106
- * @memberOf module:management.EmailProviderManager.prototype
107
- *
108
- * @example
109
- * management.emailProvider.update(params, data, function (err, provider) {
110
- * if (err) {
111
- * // Handle error.
112
- * }
113
- *
114
- * // Updated email provider.
115
- * console.log(provider);
116
- * });
117
- *
118
- * @param {Object} params Email provider parameters.
119
- * @param {Object} data Updated email provider data.
120
- * @param {Function} [cb] Callback function.
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
- * Delete email provider.
128
- *
129
- * @method delete
130
- * @memberOf module:management.EmailProviderManager.prototype
131
- *
132
- * @example
133
- * management.emailProvider.delete(function (err) {
134
- * if (err) {
135
- * // Handle error.
136
- * }
137
- *
138
- * // Email provider configured.
139
- * });
140
- *
141
- * @param {Function} [cb] Callback function.
142
- *
143
- * @return {Promise|undefined}
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
- var ArgumentError = require('rest-facade').ArgumentError;
2
- var utils = require('../utils');
3
- var Auth0RestClient = require('../Auth0RestClient');
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. {@see https://auth0.com/docs/api/management/v2#!/Email_Templates/get_email_templates_by_templateName}
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
- var EmailTemplatesManager = function(options) {
25
- if (!options || 'object' !== typeof options) {
26
- throw new ArgumentError('Must provide manager options');
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
- if (!options.baseUrl || 'string' !== typeof options.baseUrl) {
30
- throw new ArgumentError('Must provide a valid string as base URL for the API');
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
- * Options object for the Rest Client instance.
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
- * @type {Object}
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
- var clientOptions = {
39
- headers: options.headers,
40
- query: { repeatParams: false }
41
- };
64
+ create(...args) {
65
+ return this.resource.create(...args);
66
+ }
42
67
 
43
68
  /**
44
- * Provides an abstraction layer for performing CRUD operations on
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
- * @type {external:RestClient}
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
- var auth0RestClient = new Auth0RestClient(
50
- options.baseUrl + '/email-templates/:name',
51
- clientOptions,
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
- * Update an existing Email Template.
104
- *
105
- * @method update
106
- * @memberOf module:management.EmailTemplatesManager.prototype
107
- *
108
- * @example
109
- * var data = { from: 'new@email.com' };
110
- * var params = { name: EMAIL_TEMPLATE_NAME };
111
- *
112
- * management.emailTemplates.update(params, data, function (err, emailTemplate) {
113
- * if (err) {
114
- * // Handle error.
115
- * }
116
- *
117
- * console.log(emailTemplate.from); // 'new@email.com'
118
- * });
119
- *
120
- * @param {Object} params Email Template parameters.
121
- * @param {String} params.name Template Name
122
- * @param {Object} data Updated Email Template data.
123
- * @param {Function} [cb] Callback function.
124
- *
125
- * @return {Promise|undefined}
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;