auth0 2.36.2 → 2.39.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 +41 -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 -581
  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/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 -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 -3619
  46. package/src/utils.js +31 -60
@@ -1,179 +1,163 @@
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 LogStreamsManager
8
6
  * The logStreams class provides a simple abstraction for performing CRUD operations
9
7
  * on Auth0 Log Streams.
10
- * @constructor
11
- * @memberOf module:management
12
- *
13
- * @param {Object} options The client options.
14
- * @param {String} options.baseUrl The URL of the API.
15
- * @param {Object} [options.headers] Headers to be included in all requests.
16
- * @param {Object} [options.retry] Retry Policy Config
17
8
  */
18
- var LogStreamsManager = function(options) {
19
- if (options === null || typeof options !== 'object') {
20
- throw new ArgumentError('Must provide client options');
21
- }
9
+ class LogStreamsManager {
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 === null || typeof options !== 'object') {
18
+ throw new ArgumentError('Must provide client options');
19
+ }
22
20
 
23
- if (options.baseUrl === null || options.baseUrl === undefined) {
24
- throw new ArgumentError('Must provide a base URL for the API');
25
- }
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
+ }
26
28
 
27
- if ('string' !== typeof options.baseUrl || options.baseUrl.length === 0) {
28
- throw new ArgumentError('The provided base URL is invalid');
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
+ };
38
+
39
+ /**
40
+ * Provides an abstraction layer for performing CRUD operations on
41
+ * {@link https://auth0.com/docs/api/management/v2#!/Log_Streams Auth0
42
+ * Log Streams}.
43
+ *
44
+ * @type {external:RestClient}
45
+ */
46
+ const auth0RestClient = new Auth0RestClient(
47
+ `${options.baseUrl}/log-streams/:id `,
48
+ clientOptions,
49
+ options.tokenProvider
50
+ );
51
+ this.resource = new RetryRestClient(auth0RestClient, options.retry);
29
52
  }
30
53
 
31
54
  /**
32
- * Options object for the Rest Client instance.
55
+ * Get all Log Streams.
56
+ *
57
+ * @example
33
58
  *
34
- * @type {Object}
59
+ * management.logStreams.getAll(function (err, logStreams) {
60
+ * console.log(logStreams.length);
61
+ * });
62
+ * @param {Function} [cb] Callback function.
63
+ * @returns {Promise|undefined}
35
64
  */
36
- var clientOptions = {
37
- headers: options.headers,
38
- query: { repeatParams: false }
39
- };
65
+ getAll(...args) {
66
+ return this.resource.getAll(...args);
67
+ }
40
68
 
41
69
  /**
42
- * Provides an abstraction layer for performing CRUD operations on
43
- * {@link https://auth0.com/docs/api/management/v2#!/Log_Streams Auth0
44
- * Log Streams}.
70
+ * Get an Auth0 Log Streams.
45
71
  *
46
- * @type {external:RestClient}
72
+ * @example
73
+ * management.logStreams.get({ id: LOG_STREAM_ID }, function (err, logStream) {
74
+ * if (err) {
75
+ * // Handle error.
76
+ * }
77
+ *
78
+ * console.log(logStream);
79
+ * });
80
+ * @param {object} params Log Stream parameters.
81
+ * @param {string} params.id Log Stream ID.
82
+ * @param {Function} [cb] Callback function.
83
+ * @returns {Promise|undefined}
47
84
  */
48
- var auth0RestClient = new Auth0RestClient(
49
- options.baseUrl + '/log-streams/:id ',
50
- clientOptions,
51
- options.tokenProvider
52
- );
53
- this.resource = new RetryRestClient(auth0RestClient, options.retry);
54
- };
55
-
56
- /**
57
- * Get all Log Streams.
58
- *
59
- * @method getAll
60
- * @memberOf module:management.LogStreamsManager.prototype
61
- *
62
- * @example
63
- *
64
- * management.logStreams.getAll(function (err, logStreams) {
65
- * console.log(logStreams.length);
66
- * });
67
- *
68
- * @param {Function} [cb] Callback function.
69
- *
70
- * @return {Promise|undefined}
71
- */
72
- utils.wrapPropertyMethod(LogStreamsManager, 'getAll', 'resource.getAll');
73
-
74
- /**
75
- * Get an Auth0 Log Streams.
76
- *
77
- * @method get
78
- * @memberOf module:management.LogStreamsManager.prototype
79
- *
80
- * @example
81
- * management.logStreams.get({ id: LOG_STREAM_ID }, function (err, logStream) {
82
- * if (err) {
83
- * // Handle error.
84
- * }
85
- *
86
- * console.log(logStream);
87
- * });
88
- *
89
- * @param {Object} params Log Stream parameters.
90
- * @param {String} params.id Log Stream ID.
91
- * @param {Function} [cb] Callback function.
92
- *
93
- * @return {Promise|undefined}
94
- */
95
- utils.wrapPropertyMethod(LogStreamsManager, 'get', 'resource.get');
85
+ get(...args) {
86
+ return this.resource.get(...args);
87
+ }
96
88
 
97
- /**
98
- * Create an Auth0 Log Stream.
99
- *
100
- * @method create
101
- * @memberOf module:management.LogStreamsManager.prototype
102
- *
103
- * @example
104
- * management.logStreams.create(data, function (err, log) {
105
- * if (err) {
106
- * // Handle error.
107
- * }
108
- *
109
- * console.log(log);
110
- * });
111
- *
112
- * @param {Object} data Log Stream data.
113
- * @param {Function} [cb] Callback function.
114
- *
115
- * @return {Promise|undefined}
116
- */
117
- utils.wrapPropertyMethod(LogStreamsManager, 'create', 'resource.create');
89
+ /**
90
+ * Create an Auth0 Log Stream.
91
+ *
92
+ * @example
93
+ * management.logStreams.create(data, function (err, log) {
94
+ * if (err) {
95
+ * // Handle error.
96
+ * }
97
+ *
98
+ * console.log(log);
99
+ * });
100
+ * @param {object} data Log Stream data.
101
+ * @param {Function} [cb] Callback function.
102
+ * @returns {Promise|undefined}
103
+ */
104
+ create(...args) {
105
+ return this.resource.create(...args);
106
+ }
118
107
 
119
- /**
120
- * Update an Auth0 Log Streams.
121
- *
122
- * @method update
123
- * @memberOf module:management.LogStreamsManager.prototype
124
- *
125
- * @example
126
- * var data = { name: 'New name' };
127
- * var params = { id: LOG_STREAM_ID };
128
- *
129
- * // Using auth0 instance.
130
- * management.updateLogStream(params, data, function (err, logStream) {
131
- * if (err) {
132
- * // Handle error.
133
- * }
134
- *
135
- * console.log(logStream.name); // 'New name'
136
- * });
137
- *
138
- * // Using the logStreams manager directly.
139
- * management.logStreams.update(params, data, function (err, logStream) {
140
- * if (err) {
141
- * // Handle error.
142
- * }
143
- *
144
- * console.log(logStream.name);
145
- * });
146
- *
147
- * @param {Object} params Log Stream parameters.
148
- * @param {String} params.id Log Stream ID.
149
- * @param {Object} data Updated Log Stream data.
150
- * @param {Function} [cb] Callback function.
151
- *
152
- * @return {Promise|undefined}
153
- */
154
- utils.wrapPropertyMethod(LogStreamsManager, 'update', 'resource.patch');
108
+ /**
109
+ * Update an Auth0 Log Streams.
110
+ *
111
+ * @example
112
+ * var data = { name: 'New name' };
113
+ * var params = { id: LOG_STREAM_ID };
114
+ *
115
+ * // Using auth0 instance.
116
+ * management.updateLogStream(params, data, function (err, logStream) {
117
+ * if (err) {
118
+ * // Handle error.
119
+ * }
120
+ *
121
+ * console.log(logStream.name); // 'New name'
122
+ * });
123
+ *
124
+ * // Using the logStreams manager directly.
125
+ * management.logStreams.update(params, data, function (err, logStream) {
126
+ * if (err) {
127
+ * // Handle error.
128
+ * }
129
+ *
130
+ * console.log(logStream.name);
131
+ * });
132
+ * @param {object} params Log Stream parameters.
133
+ * @param {string} params.id Log Stream ID.
134
+ * @param {object} data Updated Log Stream data.
135
+ * @param {Function} [cb] Callback function.
136
+ * @returns {Promise|undefined}
137
+ */
138
+ update(...args) {
139
+ return this.resource.patch(...args);
140
+ }
155
141
 
156
- /**
157
- * Delete an Auth0 Log Streams.
158
- *
159
- * @method delete
160
- * @memberOf module:management.LogStreamsManager.prototype
161
- *
162
- * @example
163
- * management.logStreams.delete({ id: LOG_STREAM_ID }, function (err, log) {
164
- * if (err) {
165
- * // Handle error.
166
- * }
167
- *
168
- * console.log(log);
169
- * });
170
- *
171
- * @param {Object} params Log Stream parameters.
172
- * @param {String} params.id Log Stream ID.
173
- * @param {Function} [cb] Callback function.
174
- *
175
- * @return {Promise|undefined}
176
- */
177
- utils.wrapPropertyMethod(LogStreamsManager, 'delete', 'resource.delete');
142
+ /**
143
+ * Delete an Auth0 Log Streams.
144
+ *
145
+ * @example
146
+ * management.logStreams.delete({ id: LOG_STREAM_ID }, function (err, log) {
147
+ * if (err) {
148
+ * // Handle error.
149
+ * }
150
+ *
151
+ * console.log(log);
152
+ * });
153
+ * @param {object} params Log Stream parameters.
154
+ * @param {string} params.id Log Stream ID.
155
+ * @param {Function} [cb] Callback function.
156
+ * @returns {Promise|undefined}
157
+ */
158
+ delete(...args) {
159
+ return this.resource.delete(...args);
160
+ }
161
+ }
178
162
 
179
163
  module.exports = LogStreamsManager;
@@ -1,116 +1,109 @@
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 LogsManager
8
6
  * Represents the relationship between Auth0 and an Identity provider.
9
- * @constructor
10
- * @memberOf module:management
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
7
  */
17
- var LogsManager = function(options) {
18
- if (options === null || typeof options !== 'object') {
19
- throw new ArgumentError('Must provide client options');
20
- }
8
+ class LogsManager {
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
+ }
21
19
 
22
- if (options.baseUrl === null || options.baseUrl === undefined) {
23
- throw new ArgumentError('Must provide a base URL for the API');
24
- }
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
+ }
25
27
 
26
- if ('string' !== typeof options.baseUrl || options.baseUrl.length === 0) {
27
- throw new ArgumentError('The provided base URL is invalid');
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
+ };
37
+
38
+ /**
39
+ * Provides an abstraction layer for performing CRUD operations on
40
+ * {@link https://auth0.com/docs/api/v2#!/LogsManagers Auth0
41
+ * Logs}.
42
+ *
43
+ * @type {external:RestClient}
44
+ */
45
+ const auth0RestClient = new Auth0RestClient(
46
+ `${options.baseUrl}/logs/:id`,
47
+ clientOptions,
48
+ options.tokenProvider
49
+ );
50
+ this.resource = new RetryRestClient(auth0RestClient, options.retry);
28
51
  }
29
52
 
30
53
  /**
31
- * Options object for the Rest Client instance.
54
+ * Get all logs.
55
+ *
56
+ * @example <caption>
57
+ * This method takes an optional object as first argument that may be used to
58
+ * specify pagination settings and the search query. If pagination options are
59
+ * not present, the first page of a limited number of results will be returned.
60
+ * </caption>
32
61
  *
33
- * @type {Object}
62
+ * // Pagination settings.
63
+ * var params = {
64
+ * per_page: 10,
65
+ * page: 2
66
+ * };
67
+ *
68
+ * management.logs.getAll(params, function (err, logs) {
69
+ * console.log(logs.length);
70
+ * });
71
+ * @param {object} [params] Logs params.
72
+ * @param {string} [params.q] Search Criteria using Query String Syntax
73
+ * @param {number} [params.page] Page number. Zero based
74
+ * @param {number} [params.per_page] The amount of entries per page
75
+ * @param {string} [params.sort] The field to use for sorting.
76
+ * @param {string} [params.fields] A comma separated list of fields to include or exclude
77
+ * @param {boolean} [params.include_fields] true if the fields specified are to be included in the result, false otherwise.
78
+ * @param {boolean} [params.include_totals] true if a query summary must be included in the result, false otherwise. Default false
79
+ * @param {string} [params.from] For checkpoint pagination, log event Id from which to start selection from.
80
+ * @param {number} [params.take] When using the `from` parameter, the number of entries to retrieve. Default 50, max 100.
81
+ * @param {Function} [cb] Callback function.
82
+ * @returns {Promise|undefined}
34
83
  */
35
- var clientOptions = {
36
- headers: options.headers,
37
- query: { repeatParams: false }
38
- };
84
+ getAll(...args) {
85
+ return this.resource.getAll(...args);
86
+ }
39
87
 
40
88
  /**
41
- * Provides an abstraction layer for performing CRUD operations on
42
- * {@link https://auth0.com/docs/api/v2#!/LogsManagers Auth0
43
- * Logs}.
89
+ * Get an Auth0 log.
44
90
  *
45
- * @type {external:RestClient}
91
+ * @example
92
+ * management.logs.get({ id: EVENT_ID }, function (err, log) {
93
+ * if (err) {
94
+ * // Handle error.
95
+ * }
96
+ *
97
+ * console.log(log);
98
+ * });
99
+ * @param {object} params Log parameters.
100
+ * @param {string} params.id Log ID.
101
+ * @param {Function} [cb] Callback function.
102
+ * @returns {Promise|undefined}
46
103
  */
47
- var auth0RestClient = new Auth0RestClient(
48
- options.baseUrl + '/logs/:id ',
49
- clientOptions,
50
- options.tokenProvider
51
- );
52
- this.resource = new RetryRestClient(auth0RestClient, options.retry);
53
- };
54
-
55
- /**
56
- * Get all logs.
57
- *
58
- * @method getAll
59
- * @memberOf module:management.LogsManager.prototype
60
- *
61
- * @example <caption>
62
- * This method takes an optional object as first argument that may be used to
63
- * specify pagination settings and the search query. If pagination options are
64
- * not present, the first page of a limited number of results will be returned.
65
- * </caption>
66
- *
67
- * // Pagination settings.
68
- * var params = {
69
- * per_page: 10,
70
- * page: 2
71
- * };
72
- *
73
- * management.logs.getAll(params, function (err, logs) {
74
- * console.log(logs.length);
75
- * });
76
- *
77
- * @param {Object} [params] Logs params.
78
- * @param {String} [params.q] Search Criteria using Query String Syntax
79
- * @param {Number} [params.page] Page number. Zero based
80
- * @param {Number} [params.per_page] The amount of entries per page
81
- * @param {String} [params.sort] The field to use for sorting.
82
- * @param {String} [params.fields] A comma separated list of fields to include or exclude
83
- * @param {Boolean} [params.include_fields] true if the fields specified are to be included in the result, false otherwise.
84
- * @param {Boolean} [params.include_totals] true if a query summary must be included in the result, false otherwise. Default false
85
- * @param {String} [params.from] For checkpoint pagination, log event Id from which to start selection from.
86
- * @param {Number} [params.take] When using the `from` parameter, the number of entries to retrieve. Default 50, max 100.
87
- * @param {Function} [cb] Callback function.
88
- *
89
- * @return {Promise|undefined}
90
- */
91
- utils.wrapPropertyMethod(LogsManager, 'getAll', 'resource.getAll');
92
-
93
- /**
94
- * Get an Auth0 log.
95
- *
96
- * @method get
97
- * @memberOf module:management.LogsManager.prototype
98
- *
99
- * @example
100
- * management.logs.get({ id: EVENT_ID }, function (err, log) {
101
- * if (err) {
102
- * // Handle error.
103
- * }
104
- *
105
- * console.log(log);
106
- * });
107
- *
108
- * @param {Object} params Log parameters.
109
- * @param {String} params.id Log ID.
110
- * @param {Function} [cb] Callback function.
111
- *
112
- * @return {Promise|undefined}
113
- */
114
- utils.wrapPropertyMethod(LogsManager, 'get', 'resource.get');
104
+ get(...args) {
105
+ return this.resource.get(...args);
106
+ }
107
+ }
115
108
 
116
109
  module.exports = LogsManager;