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.
Files changed (47) hide show
  1. package/CHANGELOG.md +37 -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 +238 -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 +510 -584
  17. package/src/management/AttackProtectionManager.js +187 -0
  18. package/src/management/BlacklistedTokensManager.js +77 -84
  19. package/src/management/BrandingManager.js +141 -163
  20. package/src/management/ClientGrantsManager.js +132 -145
  21. package/src/management/ClientsManager.js +145 -161
  22. package/src/management/ConnectionsManager.js +215 -239
  23. package/src/management/CustomDomainsManager.js +140 -157
  24. package/src/management/DeviceCredentialsManager.js +95 -111
  25. package/src/management/EmailProviderManager.js +110 -128
  26. package/src/management/EmailTemplatesManager.js +96 -112
  27. package/src/management/GrantsManager.js +94 -101
  28. package/src/management/GuardianManager.js +381 -455
  29. package/src/management/HooksManager.js +283 -325
  30. package/src/management/JobsManager.js +310 -343
  31. package/src/management/LogStreamsManager.js +142 -158
  32. package/src/management/LogsManager.js +92 -99
  33. package/src/management/ManagementTokenProvider.js +112 -120
  34. package/src/management/MigrationsManager.js +81 -90
  35. package/src/management/OrganizationsManager.js +686 -784
  36. package/src/management/PromptsManager.js +160 -182
  37. package/src/management/ResourceServersManager.js +143 -160
  38. package/src/management/RolesManager.js +323 -369
  39. package/src/management/RulesConfigsManager.js +94 -110
  40. package/src/management/RulesManager.js +154 -176
  41. package/src/management/StatsManager.js +87 -103
  42. package/src/management/TenantManager.js +81 -97
  43. package/src/management/TicketsManager.js +107 -115
  44. package/src/management/UserBlocksManager.js +135 -162
  45. package/src/management/UsersManager.js +729 -852
  46. package/src/management/index.js +3102 -3625
  47. package/src/utils.js +31 -60
@@ -1,10 +1,8 @@
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
- * @class ClientsManager
8
6
  * Auth0 Clients Manager.
9
7
  *
10
8
  * {@link https://auth0.com/docs/api/v2#!/Clients Clients} represent
@@ -12,176 +10,162 @@ var RetryRestClient = require('../RetryRestClient');
12
10
  * You can learn more about this in the
13
11
  * {@link https://auth0.com/docs/applications Applications} section of the
14
12
  * documentation.
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
13
  */
23
- var ClientsManager = function(options) {
24
- if (options === null || typeof options !== 'object') {
25
- throw new ArgumentError('Must provide client options');
26
- }
14
+ class ClientsManager {
15
+ /**
16
+ * @param {object} options The client options.
17
+ * @param {string} options.baseUrl The URL of the API.
18
+ * @param {object} [options.headers] Headers to be included in all requests.
19
+ * @param {object} [options.retry] Retry Policy Config
20
+ */
21
+ constructor(options) {
22
+ if (options === null || typeof options !== 'object') {
23
+ throw new ArgumentError('Must provide client options');
24
+ }
27
25
 
28
- if (options.baseUrl === null || options.baseUrl === undefined) {
29
- throw new ArgumentError('Must provide a base URL for the API');
30
- }
26
+ if (options.baseUrl === null || options.baseUrl === undefined) {
27
+ throw new ArgumentError('Must provide a base URL for the API');
28
+ }
31
29
 
32
- if ('string' !== typeof options.baseUrl || options.baseUrl.length === 0) {
33
- throw new ArgumentError('The provided base URL is invalid');
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
+ };
44
+
45
+ /**
46
+ * Provides an abstraction layer for consuming the
47
+ * {@link https://auth0.com/docs/api/v2#!/Clients Auth0 Clients endpoint}.
48
+ *
49
+ * @type {external:RestClient}
50
+ */
51
+ const auth0RestClient = new Auth0RestClient(
52
+ `${options.baseUrl}/clients/:client_id`,
53
+ clientOptions,
54
+ options.tokenProvider
55
+ );
56
+ this.resource = new RetryRestClient(auth0RestClient, options.retry);
34
57
  }
35
58
 
36
59
  /**
37
- * Options object for the Rest Client instance.
60
+ * Create an Auth0 client.
38
61
  *
39
- * @type {Object}
62
+ * @example
63
+ * management.clients.create(data, function (err) {
64
+ * if (err) {
65
+ * // Handle error.
66
+ * }
67
+ *
68
+ * // Client created.
69
+ * });
70
+ * @param {object} data The client data object.
71
+ * @param {Function} [cb] Callback function.
72
+ * @returns {Promise|undefined}
40
73
  */
41
- var clientOptions = {
42
- errorFormatter: { message: 'message', name: 'error' },
43
- headers: options.headers,
44
- query: { repeatParams: false }
45
- };
74
+ create(...args) {
75
+ return this.resource.create(...args);
76
+ }
46
77
 
47
78
  /**
48
- * Provides an abstraction layer for consuming the
49
- * {@link https://auth0.com/docs/api/v2#!/Clients Auth0 Clients endpoint}.
79
+ * Get all Auth0 clients.
50
80
  *
51
- * @type {external:RestClient}
81
+ * @example <caption>
82
+ * This method takes an optional object as first argument that may be used to
83
+ * specify pagination settings. If pagination options are not present,
84
+ * the first page of a limited number of results will be returned.
85
+ * </caption>
86
+ *
87
+ * // Pagination settings.
88
+ * var params = {
89
+ * per_page: 10,
90
+ * page: 0
91
+ * };
92
+ *
93
+ * management.clients.getAll(params, function (err, clients) {
94
+ * console.log(clients.length);
95
+ * });
96
+ * @param {object} [params] Clients parameters.
97
+ * @param {number} [params.per_page] Number of results per page.
98
+ * @param {number} [params.page] Page number, zero indexed.
99
+ * @param {Function} [cb] Callback function.
100
+ * @returns {Promise|undefined}
52
101
  */
53
- var auth0RestClient = new Auth0RestClient(
54
- options.baseUrl + '/clients/:client_id',
55
- clientOptions,
56
- options.tokenProvider
57
- );
58
- this.resource = new RetryRestClient(auth0RestClient, options.retry);
59
- };
60
-
61
- /**
62
- * Create an Auth0 client.
63
- *
64
- * @method create
65
- * @memberOf module:management.ClientsManager.prototype
66
- *
67
- * @example
68
- * management.clients.create(data, function (err) {
69
- * if (err) {
70
- * // Handle error.
71
- * }
72
- *
73
- * // Client created.
74
- * });
75
- *
76
- * @param {Object} data The client data object.
77
- * @param {Function} [cb] Callback function.
78
- *
79
- * @return {Promise|undefined}
80
- */
81
- utils.wrapPropertyMethod(ClientsManager, 'create', 'resource.create');
82
-
83
- /**
84
- * Get all Auth0 clients.
85
- *
86
- * @method getAll
87
- * @memberOf module:management.ClientsManager.prototype
88
- *
89
- * @example <caption>
90
- * This method takes an optional object as first argument that may be used to
91
- * specify pagination settings. If pagination options are not present,
92
- * the first page of a limited number of results will be returned.
93
- * </caption>
94
- *
95
- * // Pagination settings.
96
- * var params = {
97
- * per_page: 10,
98
- * page: 0
99
- * };
100
- *
101
- * management.clients.getAll(params, function (err, clients) {
102
- * console.log(clients.length);
103
- * });
104
- *
105
- * @param {Object} [params] Clients parameters.
106
- * @param {Number} [params.per_page] Number of results per page.
107
- * @param {Number} [params.page] Page number, zero indexed.
108
- * @param {Function} [cb] Callback function.
109
- *
110
- * @return {Promise|undefined}
111
- */
112
- utils.wrapPropertyMethod(ClientsManager, 'getAll', 'resource.getAll');
102
+ getAll(...args) {
103
+ return this.resource.getAll(...args);
104
+ }
113
105
 
114
- /**
115
- * Get an Auth0 client.
116
- *
117
- * @method get
118
- * @memberOf module:management.ClientsManager.prototype
119
- *
120
- * @example
121
- * management.clients.get({ client_id: CLIENT_ID }, function (err, client) {
122
- * if (err) {
123
- * // Handle error.
124
- * }
125
- *
126
- * console.log(client);
127
- * });
128
- *
129
- * @param {Object} params Client parameters.
130
- * @param {String} params.client_id Application client ID.
131
- * @param {Function} [cb] Callback function.
132
- *
133
- * @return {Promise|undefined}
134
- */
135
- utils.wrapPropertyMethod(ClientsManager, 'get', 'resource.get');
106
+ /**
107
+ * Get an Auth0 client.
108
+ *
109
+ * @example
110
+ * management.clients.get({ client_id: CLIENT_ID }, function (err, client) {
111
+ * if (err) {
112
+ * // Handle error.
113
+ * }
114
+ *
115
+ * console.log(client);
116
+ * });
117
+ * @param {object} params Client parameters.
118
+ * @param {string} params.client_id Application client ID.
119
+ * @param {Function} [cb] Callback function.
120
+ * @returns {Promise|undefined}
121
+ */
122
+ get(...args) {
123
+ return this.resource.get(...args);
124
+ }
136
125
 
137
- /**
138
- * Update an Auth0 client.
139
- *
140
- * @method update
141
- * @memberOf module:management.ClientsManager.prototype
142
- *
143
- * @example
144
- * var data = { name: 'newClientName' };
145
- * var params = { client_id: CLIENT_ID };
146
- *
147
- * management.clients.update(params, data, function (err, client) {
148
- * if (err) {
149
- * // Handle error.
150
- * }
151
- *
152
- * console.log(client.name); // 'newClientName'
153
- * });
154
- *
155
- * @param {Object} params Client parameters.
156
- * @param {String} params.client_id Application client ID.
157
- * @param {Object} data Updated client data.
158
- * @param {Function} [cb] Callback function.
159
- *
160
- * @return {Promise|undefined}
161
- */
162
- utils.wrapPropertyMethod(ClientsManager, 'update', 'resource.patch');
126
+ /**
127
+ * Update an Auth0 client.
128
+ *
129
+ * @example
130
+ * var data = { name: 'newClientName' };
131
+ * var params = { client_id: CLIENT_ID };
132
+ *
133
+ * management.clients.update(params, data, function (err, client) {
134
+ * if (err) {
135
+ * // Handle error.
136
+ * }
137
+ *
138
+ * console.log(client.name); // 'newClientName'
139
+ * });
140
+ * @param {object} params Client parameters.
141
+ * @param {string} params.client_id Application client ID.
142
+ * @param {object} data Updated client data.
143
+ * @param {Function} [cb] Callback function.
144
+ * @returns {Promise|undefined}
145
+ */
146
+ update(...args) {
147
+ return this.resource.patch(...args);
148
+ }
163
149
 
164
- /**
165
- * Delete an Auth0 client.
166
- *
167
- * @method delete
168
- * @memberOf module:management.ClientsManager.prototype
169
- *
170
- * @example
171
- * management.clients.delete({ client_id: CLIENT_ID }, function (err) {
172
- * if (err) {
173
- * // Handle error.
174
- * }
175
- *
176
- * // Client deleted.
177
- * });
178
- *
179
- * @param {Object} params Client parameters.
180
- * @param {String} params.client_id Application client ID.
181
- * @param {Function} [cb] Callback function.
182
- *
183
- * @return {Promise|undefined}
184
- */
185
- utils.wrapPropertyMethod(ClientsManager, 'delete', 'resource.delete');
150
+ /**
151
+ * Delete an Auth0 client.
152
+ *
153
+ * @example
154
+ * management.clients.delete({ client_id: CLIENT_ID }, function (err) {
155
+ * if (err) {
156
+ * // Handle error.
157
+ * }
158
+ *
159
+ * // Client deleted.
160
+ * });
161
+ * @param {object} params Client parameters.
162
+ * @param {string} params.client_id Application client ID.
163
+ * @param {Function} [cb] Callback function.
164
+ * @returns {Promise|undefined}
165
+ */
166
+ delete(...args) {
167
+ return this.resource.delete(...args);
168
+ }
169
+ }
186
170
 
187
171
  module.exports = ClientsManager;