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,119 +1,112 @@
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 GrantsManager
7
6
  * Auth0 Grants Manager.
8
7
  *
9
8
  * See {@link https://auth0.com/docs/api/v2#!/Grants 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 GrantsManager = function(options) {
20
- if (options === null || typeof options !== 'object') {
21
- throw new ArgumentError('Must provide client options');
22
- }
10
+ class GrantsManager {
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#!/Grants Auth0 Grants endpoint}.
44
+ *
45
+ * @type {external:RestClient}
46
+ */
47
+ const auth0RestClient = new Auth0RestClient(
48
+ `${options.baseUrl}/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
+ * Get all Auth0 Grants.
57
+ *
58
+ * @example
59
+ * var params = {
60
+ * per_page: 10,
61
+ * page: 0,
62
+ * include_totals: true,
63
+ * user_id: 'USER_ID',
64
+ * client_id: 'CLIENT_ID',
65
+ * audience: 'AUDIENCE'
66
+ * };
34
67
  *
35
- * @type {Object}
68
+ * management.getGrants(params, function (err, grants) {
69
+ * console.log(grants.length);
70
+ * });
71
+ * @param {object} params Grants parameters.
72
+ * @param {number} params.per_page Number of results per page.
73
+ * @param {number} params.page Page number, zero indexed.
74
+ * @param {boolean} params.include_totals true if a query summary must be included in the result, false otherwise. Default false;
75
+ * @param {string} params.user_id The user_id of the grants to retrieve.
76
+ * @param {string} params.client_id The client_id of the grants to retrieve.
77
+ * @param {string} params.audience The audience of the grants to retrieve.
78
+ * @param {Function} [cb] Callback function.
79
+ * @returns {Promise|undefined}
36
80
  */
37
- var clientOptions = {
38
- errorFormatter: { message: 'message', name: 'error' },
39
- headers: options.headers,
40
- query: { repeatParams: false }
41
- };
81
+ getAll(...args) {
82
+ return this.resource.getAll(...args);
83
+ }
42
84
 
43
85
  /**
44
- * Provides an abstraction layer for consuming the
45
- * {@link https://auth0.com/docs/api/v2#!/Grants Auth0 Grants endpoint}.
86
+ * Delete an Auth0 grant.
87
+ *
88
+ * @example
89
+ * var params = {
90
+ * id: 'GRANT_ID',
91
+ * user_id: 'USER_ID'
92
+ * };
46
93
  *
47
- * @type {external:RestClient}
94
+ * management.deleteGrant(params, function (err) {
95
+ * if (err) {
96
+ * // Handle error.
97
+ * }
98
+ *
99
+ * // Grant deleted.
100
+ * });
101
+ * @param {object} params Grant parameters.
102
+ * @param {string} params.id Grant ID.
103
+ * @param {string} params.user_id The user_id of the grants to delete.
104
+ * @param {Function} [cb] Callback function.
105
+ * @returns {Promise|undefined}
48
106
  */
49
- var auth0RestClient = new Auth0RestClient(
50
- options.baseUrl + '/grants/:id',
51
- clientOptions,
52
- options.tokenProvider
53
- );
54
- this.resource = new RetryRestClient(auth0RestClient, options.retry);
55
- };
56
-
57
- /**
58
- * Get all Auth0 Grants.
59
- *
60
- * @method getAll
61
- * @memberOf module:management.GrantsManager.prototype
62
- *
63
- * @example
64
- * var params = {
65
- * per_page: 10,
66
- * page: 0,
67
- * include_totals: true,
68
- * user_id: 'USER_ID',
69
- * client_id: 'CLIENT_ID',
70
- * audience: 'AUDIENCE'
71
- * };
72
- *
73
- * management.getGrants(params, function (err, grants) {
74
- * console.log(grants.length);
75
- * });
76
- *
77
- * @param {Object} params Grants parameters.
78
- * @param {Number} params.per_page Number of results per page.
79
- * @param {Number} params.page Page number, zero indexed.
80
- * @param {Boolean} params.include_totals true if a query summary must be included in the result, false otherwise. Default false;
81
- * @param {String} params.user_id The user_id of the grants to retrieve.
82
- * @param {String} params.client_id The client_id of the grants to retrieve.
83
- * @param {String} params.audience The audience of the grants to retrieve.
84
- * @param {Function} [cb] Callback function.
85
- *
86
- * @return {Promise|undefined}
87
- */
88
- utils.wrapPropertyMethod(GrantsManager, 'getAll', 'resource.getAll');
89
-
90
- /**
91
- * Delete an Auth0 grant.
92
- *
93
- * @method delete
94
- * @memberOf module:management.GrantsManager.prototype
95
- *
96
- * @example
97
- * var params = {
98
- * id: 'GRANT_ID',
99
- * user_id: 'USER_ID'
100
- * };
101
- *
102
- * management.deleteGrant(params, function (err) {
103
- * if (err) {
104
- * // Handle error.
105
- * }
106
- *
107
- * // Grant deleted.
108
- * });
109
- *
110
- * @param {Object} params Grant parameters.
111
- * @param {String} params.id Grant ID.
112
- * @param {String} params.user_id The user_id of the grants to delete.
113
- * @param {Function} [cb] Callback function.
114
- *
115
- * @return {Promise|undefined}
116
- */
117
- utils.wrapPropertyMethod(GrantsManager, 'delete', 'resource.delete');
107
+ delete(...args) {
108
+ return this.resource.delete(...args);
109
+ }
110
+ }
118
111
 
119
112
  module.exports = GrantsManager;