auth0 2.36.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 +554 -0
  2. package/README.md +33 -11
  3. package/package.json +22 -15
  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 -581
  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 -204
  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 -761
  35. package/src/management/PromptsManager.js +160 -178
  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 -3619
  46. package/src/utils.js +31 -60
@@ -1,165 +1,152 @@
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');
4
+
5
5
  /**
6
- * @class ClientGrantsManager
7
6
  * Auth0 Client Grants Manager.
8
7
  *
9
8
  * See {@link https://auth0.com/docs/api/v2#!/Client_Grants Client Grants}
10
- *
11
- * @constructor
12
- * @memberOf module:management
13
- *
14
- * @param {Object} options The client options.
15
- * @param {String} options.baseUrl The URL of the API.
16
- * @param {Object} [options.headers] Headers to be included in all requests.
17
- * @param {Object} [options.retry] Retry Policy Config
18
9
  */
19
- var ClientGrantsManager = function(options) {
20
- if (options === null || typeof options !== 'object') {
21
- throw new ArgumentError('Must provide client options');
22
- }
10
+ class ClientGrantsManager {
11
+ /**
12
+ * @param {object} options The client options.
13
+ * @param {string} options.baseUrl The URL of the API.
14
+ * @param {object} [options.headers] Headers to be included in all requests.
15
+ * @param {object} [options.retry] Retry Policy Config
16
+ */
17
+ constructor(options) {
18
+ if (options === null || typeof options !== 'object') {
19
+ throw new ArgumentError('Must provide client options');
20
+ }
23
21
 
24
- if (options.baseUrl === null || options.baseUrl === undefined) {
25
- throw new ArgumentError('Must provide a base URL for the API');
26
- }
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
+ }
27
29
 
28
- if ('string' !== typeof options.baseUrl || options.baseUrl.length === 0) {
29
- throw new ArgumentError('The provided base URL is invalid');
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
+ };
40
+
41
+ /**
42
+ * Provides an abstraction layer for consuming the
43
+ * {@link https://auth0.com/docs/api/v2#!/Client_Grants Auth0 Client Grants endpoint}.
44
+ *
45
+ * @type {external:RestClient}
46
+ */
47
+ const auth0RestClient = new Auth0RestClient(
48
+ `${options.baseUrl}/client-grants/:id`,
49
+ clientOptions,
50
+ options.tokenProvider
51
+ );
52
+ this.resource = new RetryRestClient(auth0RestClient, options.retry);
30
53
  }
31
54
 
32
55
  /**
33
- * Options object for the Rest Client instance.
56
+ * Create an Auth0 client grant.
57
+ *
58
+ * @example
59
+ * management.clientGrants.create(data, function (err) {
60
+ * if (err) {
61
+ * // Handle error.
62
+ * }
34
63
  *
35
- * @type {Object}
64
+ * // Client grant created.
65
+ * });
66
+ * @param {object} data The client data object.
67
+ * @param {Function} [cb] Callback function.
68
+ * @returns {Promise|undefined}
36
69
  */
37
- var clientOptions = {
38
- errorFormatter: { message: 'message', name: 'error' },
39
- headers: options.headers,
40
- query: { repeatParams: false }
41
- };
70
+ create(...args) {
71
+ return this.resource.create(...args);
72
+ }
42
73
 
43
74
  /**
44
- * Provides an abstraction layer for consuming the
45
- * {@link https://auth0.com/docs/api/v2#!/Client_Grants Auth0 Client Grants endpoint}.
75
+ * Get all Auth0 Client Grants.
76
+ *
77
+ * @example <caption>
78
+ * This method takes an optional object as first argument that may be used to
79
+ * specify pagination settings. If pagination options are not present,
80
+ * the first page of a limited number of results will be returned.
81
+ * </caption>
46
82
  *
47
- * @type {external:RestClient}
83
+ * // Pagination settings.
84
+ * var params = {
85
+ * per_page: 10,
86
+ * page: 0
87
+ * };
88
+ *
89
+ *
90
+ * management.clientGrants.getAll(params, function (err, grants) {
91
+ * console.log(grants.length);
92
+ * });
93
+ * @param {object} [params] Client Grants parameters.
94
+ * @param {number} [params.per_page] Number of results per page.
95
+ * @param {number} [params.page] Page number, zero indexed.
96
+ * @param {Function} [cb] Callback function.
97
+ * @returns {Promise|undefined}
48
98
  */
49
- var auth0RestClient = new Auth0RestClient(
50
- options.baseUrl + '/client-grants/:id',
51
- clientOptions,
52
- options.tokenProvider
53
- );
54
- this.resource = new RetryRestClient(auth0RestClient, options.retry);
55
- };
56
-
57
- /**
58
- * Create an Auth0 client grant.
59
- *
60
- * @method create
61
- * @memberOf module:management.ClientGrantsManager.prototype
62
- *
63
- * @example
64
- * management.clientGrants.create(data, function (err) {
65
- * if (err) {
66
- * // Handle error.
67
- * }
68
- *
69
- * // Client grant created.
70
- * });
71
- *
72
- * @param {Object} data The client data object.
73
- * @param {Function} [cb] Callback function.
74
- *
75
- * @return {Promise|undefined}
76
- */
77
- utils.wrapPropertyMethod(ClientGrantsManager, 'create', 'resource.create');
78
-
79
- /**
80
- * Get all Auth0 Client Grants.
81
- *
82
- * @method getAll
83
- * @memberOf module:management.ClientGrantsManager.prototype
84
- *
85
- * @example <caption>
86
- * This method takes an optional object as first argument that may be used to
87
- * specify pagination settings. If pagination options are not present,
88
- * the first page of a limited number of results will be returned.
89
- * </caption>
90
- *
91
- * // Pagination settings.
92
- * var params = {
93
- * per_page: 10,
94
- * page: 0
95
- * };
96
- *
97
- *
98
- * management.clientGrants.getAll(params, function (err, grants) {
99
- * console.log(grants.length);
100
- * });
101
- *
102
- * @param {Object} [params] Client Grants parameters.
103
- * @param {Number} [params.per_page] Number of results per page.
104
- * @param {Number} [params.page] Page number, zero indexed.
105
- * @param {Function} [cb] Callback function.
106
- *
107
- * @return {Promise|undefined}
108
- */
109
- utils.wrapPropertyMethod(ClientGrantsManager, 'getAll', 'resource.getAll');
99
+ getAll(...args) {
100
+ return this.resource.getAll(...args);
101
+ }
110
102
 
111
- /**
112
- * Update an Auth0 client grant.
113
- *
114
- * @method update
115
- * @memberOf module:management.ClientGrantsManager.prototype
116
- *
117
- * @example
118
- * var data = {
119
- * client_id: CLIENT_ID,
120
- * audience: AUDIENCE,
121
- * scope: []
122
- * };
123
- * var params = { id: CLIENT_GRANT_ID };
124
- *
125
- * management.clientGrants.update(params, data, function (err, grant) {
126
- * if (err) {
127
- * // Handle error.
128
- * }
129
- *
130
- * console.log(grant.id);
131
- * });
132
- *
133
- * @param {Object} params Client parameters.
134
- * @param {String} params.id Client grant ID.
135
- * @param {Object} data Updated client data.
136
- * @param {Function} [cb] Callback function.
137
- *
138
- * @return {Promise|undefined}
139
- */
140
- utils.wrapPropertyMethod(ClientGrantsManager, 'update', 'resource.patch');
103
+ /**
104
+ * Update an Auth0 client grant.
105
+ *
106
+ * @example
107
+ * var data = {
108
+ * client_id: CLIENT_ID,
109
+ * audience: AUDIENCE,
110
+ * scope: []
111
+ * };
112
+ * var params = { id: CLIENT_GRANT_ID };
113
+ *
114
+ * management.clientGrants.update(params, data, function (err, grant) {
115
+ * if (err) {
116
+ * // Handle error.
117
+ * }
118
+ *
119
+ * console.log(grant.id);
120
+ * });
121
+ * @param {object} params Client parameters.
122
+ * @param {string} params.id Client grant ID.
123
+ * @param {object} data Updated client data.
124
+ * @param {Function} [cb] Callback function.
125
+ * @returns {Promise|undefined}
126
+ */
127
+ update(...args) {
128
+ return this.resource.patch(...args);
129
+ }
141
130
 
142
- /**
143
- * Delete an Auth0 client grant.
144
- *
145
- * @method delete
146
- * @memberOf module:management.ClientGrantsManager.prototype
147
- *
148
- * @example
149
- * management.clientGrants.delete({ id: GRANT_ID }, function (err) {
150
- * if (err) {
151
- * // Handle error.
152
- * }
153
- *
154
- * // Grant deleted.
155
- * });
156
- *
157
- * @param {Object} params Client parameters.
158
- * @param {String} params.id Client grant ID.
159
- * @param {Function} [cb] Callback function.
160
- *
161
- * @return {Promise|undefined}
162
- */
163
- utils.wrapPropertyMethod(ClientGrantsManager, 'delete', 'resource.delete');
131
+ /**
132
+ * Delete an Auth0 client grant.
133
+ *
134
+ * @example
135
+ * management.clientGrants.delete({ id: GRANT_ID }, function (err) {
136
+ * if (err) {
137
+ * // Handle error.
138
+ * }
139
+ *
140
+ * // Grant deleted.
141
+ * });
142
+ * @param {object} params Client parameters.
143
+ * @param {string} params.id Client grant ID.
144
+ * @param {Function} [cb] Callback function.
145
+ * @returns {Promise|undefined}
146
+ */
147
+ delete(...args) {
148
+ return this.resource.delete(...args);
149
+ }
150
+ }
164
151
 
165
152
  module.exports = ClientGrantsManager;
@@ -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;