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,178 +1,151 @@
1
- var ArgumentError = require('rest-facade').ArgumentError;
2
- var Auth0RestClient = require('../Auth0RestClient');
3
- var RetryRestClient = require('../RetryRestClient');
1
+ const { ArgumentError } = require('rest-facade');
2
+ const Auth0RestClient = require('../Auth0RestClient');
3
+ const RetryRestClient = require('../RetryRestClient');
4
4
 
5
5
  /**
6
- * Simple facade for consuming a REST API endpoint.
7
- * @external RestClient
8
- * @see https://github.com/ngonzalvez/rest-facade
9
- */
10
-
11
- /**
12
- * @class
13
6
  * Abstracts interaction with the user-blocks endpoint.
14
- * @constructor
15
- * @memberOf module:management
16
- *
17
- * @param {Object} options The client options.
18
- * @param {String} options.baseUrl The URL of the API.
19
- * @param {Object} [options.headers] Headers to be included in all requests.
20
- * @param {Object} [options.retry] Retry Policy Config
21
7
  */
22
- var UserBlocksManager = function(options) {
23
- if (options === null || typeof options !== 'object') {
24
- throw new ArgumentError('Must provide manager options');
25
- }
8
+ class UserBlocksManager {
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 manager options');
18
+ }
19
+
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
+ const clientOptions = {
29
+ errorFormatter: { message: 'message', name: 'error' },
30
+ headers: options.headers,
31
+ query: { repeatParams: false },
32
+ };
33
+
34
+ const userBlocksByIdResource = new Auth0RestClient(
35
+ `${options.baseUrl}/user-blocks/:id`,
36
+ clientOptions,
37
+ options.tokenProvider
38
+ );
39
+ this.userBlocksById = new RetryRestClient(userBlocksByIdResource, options.retry);
26
40
 
27
- if (options.baseUrl === null || options.baseUrl === undefined) {
28
- throw new ArgumentError('Must provide a base URL for the API');
41
+ const userBlocksByIdentifierResource = new Auth0RestClient(
42
+ `${options.baseUrl}/user-blocks`,
43
+ clientOptions,
44
+ options.tokenProvider
45
+ );
46
+ this.userBlocksByIdentifier = new RetryRestClient(
47
+ userBlocksByIdentifierResource,
48
+ options.retry
49
+ );
29
50
  }
30
51
 
31
- if ('string' !== typeof options.baseUrl || options.baseUrl.length === 0) {
32
- throw new ArgumentError('The provided base URL is invalid');
52
+ /**
53
+ * Get user blocks by id.
54
+ *
55
+ * @example
56
+ * management.userBlocks.get({ id: USER_ID }, function (err, blocks) {
57
+ * if (err) {
58
+ * // Handle error.
59
+ * }
60
+ *
61
+ * console.log(blocks);
62
+ * });
63
+ * @param {object} params The user data object..
64
+ * @param {string} params.id The user id.
65
+ * @param {Function} [cb] Callback function
66
+ * @returns {Promise|undefined}
67
+ */
68
+ get(params, ...restOfArgs) {
69
+ if (typeof params !== 'object' || typeof params.id !== 'string') {
70
+ throw new ArgumentError('You must provide an user id for the get method');
71
+ }
72
+
73
+ return this.userBlocksById.get(params, ...restOfArgs);
33
74
  }
34
75
 
35
- var clientOptions = {
36
- errorFormatter: { message: 'message', name: 'error' },
37
- headers: options.headers,
38
- query: { repeatParams: false }
39
- };
40
-
41
- var userBlocksByIdResource = new Auth0RestClient(
42
- options.baseUrl + '/user-blocks/:id',
43
- clientOptions,
44
- options.tokenProvider
45
- );
46
- this.userBlocksById = new RetryRestClient(userBlocksByIdResource, options.retry);
47
-
48
- var userBlocksByIdentifierResource = new Auth0RestClient(
49
- options.baseUrl + '/user-blocks',
50
- clientOptions,
51
- options.tokenProvider
52
- );
53
- this.userBlocksByIdentifier = new RetryRestClient(userBlocksByIdentifierResource, options.retry);
54
- };
55
-
56
- /**
57
- * Get user blocks by id.
58
- *
59
- * @method get
60
- * @memberOf module:management.UserBlocksManager.prototype
61
- *
62
- * @example
63
- * management.userBlocks.get({ id: USER_ID }, function (err, blocks) {
64
- * if (err) {
65
- * // Handle error.
66
- * }
67
- *
68
- * console.log(blocks);
69
- * });
70
- *
71
- *
72
- * @param {Object} params The user data object..
73
- * @param {String} params.id The user id.
74
- * @param {Function} [cb] Callback function
75
- *
76
- * @return {Promise|undefined}
77
- */
78
- UserBlocksManager.prototype.get = function(params) {
79
- if (typeof params !== 'object' || typeof params.id !== 'string') {
80
- throw new ArgumentError('You must provide an user id for the get method');
76
+ /**
77
+ * Unblock an user by its id.
78
+ *
79
+ * @example
80
+ * management.userBlocks.delete({ id: USER_ID }, function (err) {
81
+ * if (err) {
82
+ * // Handle error.
83
+ * }
84
+ *
85
+ * // User unblocked.
86
+ * });
87
+ * @param {object} params The user data object..
88
+ * @param {string} params.id The user id.
89
+ * @param {Function} [cb] Callback function
90
+ * @returns {Promise|undefined}
91
+ */
92
+ delete(params, ...restOfArgs) {
93
+ if (typeof params !== 'object' || typeof params.id !== 'string') {
94
+ throw new ArgumentError('You must provide an user id for the delete method');
95
+ }
96
+
97
+ return this.userBlocksById.delete(params, ...restOfArgs);
81
98
  }
82
99
 
83
- return this.userBlocksById.get.apply(this.userBlocksById, arguments);
84
- };
85
-
86
- /**
87
- * Unblock an user by its id.
88
- *
89
- * @method delete
90
- * @memberOf module:management.UserBlocksManager.prototype
91
- *
92
- * @example
93
- * management.userBlocks.delete({ id: USER_ID }, function (err) {
94
- * if (err) {
95
- * // Handle error.
96
- * }
97
- *
98
- * // User unblocked.
99
- * });
100
- *
101
- *
102
- * @param {Object} params The user data object..
103
- * @param {String} params.id The user id.
104
- * @param {Function} [cb] Callback function
105
- *
106
- * @return {Promise|undefined}
107
- */
108
- UserBlocksManager.prototype.delete = function(params) {
109
- if (typeof params !== 'object' || typeof params.id !== 'string') {
110
- throw new ArgumentError('You must provide an user id for the delete method');
111
- }
112
-
113
- return this.userBlocksById.delete.apply(this.userBlocksById, arguments);
114
- };
115
-
116
- /**
117
- * Get user blocks by identifier.
118
- *
119
- * @method getByIdentifier
120
- * @memberOf module:management.UserBlocksManager.prototype
121
- *
122
- * @example
123
- * management.userBlocks.getByIdentifier({ identifier: USER_ID }, function (err, blocks) {
124
- * if (err) {
125
- * // Handle error.
126
- * }
127
- *
128
- * console.log(blocks);
129
- * });
130
- *
131
- *
132
- * @param {Object} params The user data object..
133
- * @param {String} params.identifier The user identifier, any of: username, phone_number, email.
134
- * @param {Function} [cb] Callback function
135
- *
136
- * @return {Promise|undefined}
137
- */
138
- UserBlocksManager.prototype.getByIdentifier = function(params) {
139
- if (typeof params !== 'object' || typeof params.identifier !== 'string') {
140
- throw new ArgumentError('You must provide an user identifier for the getByIdentifier method');
100
+ /**
101
+ * Get user blocks by identifier.
102
+ *
103
+ * @example
104
+ * management.userBlocks.getByIdentifier({ identifier: USER_ID }, function (err, blocks) {
105
+ * if (err) {
106
+ * // Handle error.
107
+ * }
108
+ *
109
+ * console.log(blocks);
110
+ * });
111
+ * @param {object} params The user data object..
112
+ * @param {string} params.identifier The user identifier, any of: username, phone_number, email.
113
+ * @param {Function} [cb] Callback function
114
+ * @returns {Promise|undefined}
115
+ */
116
+ getByIdentifier(params, ...restOfArgs) {
117
+ if (typeof params !== 'object' || typeof params.identifier !== 'string') {
118
+ throw new ArgumentError('You must provide an user identifier for the getByIdentifier method');
119
+ }
120
+
121
+ return this.userBlocksByIdentifier.get(params, ...restOfArgs);
141
122
  }
142
123
 
143
- return this.userBlocksByIdentifier.get.apply(this.userBlocksByIdentifier, arguments);
144
- };
145
-
146
- /**
147
- * Unblock an user by identifier.
148
- *
149
- * @method deleteByIdentifier
150
- * @memberOf module:management.UserBlocksManager.prototype
151
- *
152
- * @example
153
- * management.userBlocks.deleteByIdentifier({ identifier: USER_ID }, function (err) {
154
- * if (err) {
155
- * // Handle error.
156
- * }
157
- *
158
- * // User unblocked.
159
- * });
160
- *
161
- *
162
- * @param {Object} params The user data object..
163
- * @param {String} params.identifier The user identifier, any of: username, phone_number, email.
164
- * @param {Function} [cb] Callback function
165
- *
166
- * @return {Promise|undefined}
167
- */
168
- UserBlocksManager.prototype.deleteByIdentifier = function(params) {
169
- if (typeof params !== 'object' || typeof params.identifier !== 'string') {
170
- throw new ArgumentError(
171
- 'You must provide an user identifier for the deleteByIdentifier method'
172
- );
124
+ /**
125
+ * Unblock an user by identifier.
126
+ *
127
+ * @example
128
+ * management.userBlocks.deleteByIdentifier({ identifier: USER_ID }, function (err) {
129
+ * if (err) {
130
+ * // Handle error.
131
+ * }
132
+ *
133
+ * // User unblocked.
134
+ * });
135
+ * @param {object} params The user data object..
136
+ * @param {string} params.identifier The user identifier, any of: username, phone_number, email.
137
+ * @param {Function} [cb] Callback function
138
+ * @returns {Promise|undefined}
139
+ */
140
+ deleteByIdentifier(params, ...restOfArgs) {
141
+ if (typeof params !== 'object' || typeof params.identifier !== 'string') {
142
+ throw new ArgumentError(
143
+ 'You must provide an user identifier for the deleteByIdentifier method'
144
+ );
145
+ }
146
+
147
+ return this.userBlocksByIdentifier.delete(params, ...restOfArgs);
173
148
  }
174
-
175
- return this.userBlocksByIdentifier.delete.apply(this.userBlocksByIdentifier, arguments);
176
- };
149
+ }
177
150
 
178
151
  module.exports = UserBlocksManager;