auth0 2.36.1 → 2.38.1

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 +557 -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 +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 +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 -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,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 CustomDomainsManager
8
6
  * Auth0 Custom Domains Manager.
9
7
  *
10
8
  * {@link https://auth0.com/docs/api/management/v2#!/Custom_Domains/get_custom_domains CustomDomains} represent
@@ -12,179 +10,164 @@ var RetryRestClient = require('../RetryRestClient');
12
10
  * You can learn more about this in the
13
11
  * {@link https://auth0.com/docs/custom-domains CustomDomains} 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 CustomDomainsManager = function(options) {
24
- if (options === null || typeof options !== 'object') {
25
- throw new ArgumentError('Must provide manager options');
26
- }
14
+ class CustomDomainsManager {
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 manager 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
+ }
29
+
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#!/Custom_Domains Auth0 Custom Domains endpoint}.
48
+ *
49
+ * @type {external:RestClient}
50
+ */
51
+ const auth0CustomDomainsRestClient = new Auth0RestClient(
52
+ `${options.baseUrl}/custom-domains/:id`,
53
+ clientOptions,
54
+ options.tokenProvider
55
+ );
56
+ this.resource = new RetryRestClient(auth0CustomDomainsRestClient, options.retry);
31
57
 
32
- if ('string' !== typeof options.baseUrl || options.baseUrl.length === 0) {
33
- throw new ArgumentError('The provided base URL is invalid');
58
+ /**
59
+ * Provides an abstraction layer for consuming the
60
+ * {@link https://auth0.com/docs/api/v2#!/Custom_Domains Auth0 Custom Domains Verify endpoint}.
61
+ *
62
+ * @type {external:RestClient}
63
+ */
64
+ const auth0VerifyRestClient = new Auth0RestClient(
65
+ `${options.baseUrl}/custom-domains/:id/verify`,
66
+ clientOptions,
67
+ options.tokenProvider
68
+ );
69
+ this.vefifyResource = new RetryRestClient(auth0VerifyRestClient, options.retry);
34
70
  }
35
71
 
36
72
  /**
37
- * Options object for the Rest Client instance.
73
+ * Create an Auth0 Custom Domain.
38
74
  *
39
- * @type {Object}
75
+ * @example
76
+ * management.customDomains.create(data, function (err) {
77
+ * if (err) {
78
+ * // Handle error.
79
+ * }
80
+ *
81
+ * // CustomDomain created.
82
+ * });
83
+ * @param {object} data The custom domain data object.
84
+ * @param {Function} [cb] Callback function.
85
+ * @returns {Promise|undefined}
40
86
  */
41
- var clientOptions = {
42
- errorFormatter: { message: 'message', name: 'error' },
43
- headers: options.headers,
44
- query: { repeatParams: false }
45
- };
87
+ create(...args) {
88
+ return this.resource.create(...args);
89
+ }
46
90
 
47
91
  /**
48
- * Provides an abstraction layer for consuming the
49
- * {@link https://auth0.com/docs/api/v2#!/Custom_Domains Auth0 Custom Domains endpoint}.
92
+ * Get all Auth0 CustomDomains.
50
93
  *
51
- * @type {external:RestClient}
94
+ * @example
95
+ * management.customDomains.getAll(function (err, customDomains) {
96
+ * console.log(customDomains.length);
97
+ * });
98
+ * @returns {Promise|undefined}
52
99
  */
53
- var auth0CustomDomainsRestClient = new Auth0RestClient(
54
- options.baseUrl + '/custom-domains/:id',
55
- clientOptions,
56
- options.tokenProvider
57
- );
58
- this.resource = new RetryRestClient(auth0CustomDomainsRestClient, options.retry);
100
+ getAll(...args) {
101
+ return this.resource.getAll(...args);
102
+ }
59
103
 
60
104
  /**
61
- * Provides an abstraction layer for consuming the
62
- * {@link https://auth0.com/docs/api/v2#!/Custom_Domains Auth0 Custom Domains Verify endpoint}.
105
+ * Get a Custom Domain.
106
+ *
107
+ * @example
108
+ * management.customDomains.get({ id: CUSTOM_DOMAIN_ID }, function (err, customDomain) {
109
+ * if (err) {
110
+ * // Handle error.
111
+ * }
63
112
  *
64
- * @type {external:RestClient}
113
+ * console.log(customDomain);
114
+ * });
115
+ * @param {object} params Custom Domain parameters.
116
+ * @param {string} params.id Custom Domain ID.
117
+ * @param {Function} [cb] Callback function.
118
+ * @returns {Promise|undefined}
65
119
  */
66
- var auth0VerifyRestClient = new Auth0RestClient(
67
- options.baseUrl + '/custom-domains/:id/verify',
68
- clientOptions,
69
- options.tokenProvider
70
- );
71
- this.vefifyResource = new RetryRestClient(auth0VerifyRestClient, options.retry);
72
- };
73
-
74
- /**
75
- * Create an Auth0 Custom Domain.
76
- *
77
- * @method create
78
- * @memberOf module:management.CustomDomainsManager.prototype
79
- *
80
- * @example
81
- * management.customDomains.create(data, function (err) {
82
- * if (err) {
83
- * // Handle error.
84
- * }
85
- *
86
- * // CustomDomain created.
87
- * });
88
- *
89
- * @param {Object} data The custom domain data object.
90
- * @param {Function} [cb] Callback function.
91
- *
92
- * @return {Promise|undefined}
93
- */
94
- utils.wrapPropertyMethod(CustomDomainsManager, 'create', 'resource.create');
120
+ get(...args) {
121
+ return this.resource.get(...args);
122
+ }
95
123
 
96
- /**
97
- * Get all Auth0 CustomDomains.
98
- *
99
- * @method getAll
100
- * @memberOf module:management.CustomDomainsManager.prototype
101
- *
102
- * @example
103
- * management.customDomains.getAll(function (err, customDomains) {
104
- * console.log(customDomains.length);
105
- * });
106
- *
107
- * @return {Promise|undefined}
108
- */
109
- utils.wrapPropertyMethod(CustomDomainsManager, 'getAll', 'resource.getAll');
124
+ /**
125
+ * Verify a Custom Domain.
126
+ *
127
+ * @example
128
+ * management.customDomains.verify({ id: CUSTOM_DOMAIN_ID }, function (err, customDomain) {
129
+ * if (err) {
130
+ * // Handle error.
131
+ * }
132
+ *
133
+ * console.log(customDomain);
134
+ * });
135
+ * @param {object} params Custom Domain parameters.
136
+ * @param {string} params.id Custom Domain ID.
137
+ * @param {Function} [cb] Callback function.
138
+ * @returns {Promise|undefined}
139
+ */
140
+ verify(params, cb) {
141
+ if (!params || !params.id) {
142
+ throw new ArgumentError('The custom domain id cannot be null or undefined');
143
+ }
110
144
 
111
- /**
112
- * Get a Custom Domain.
113
- *
114
- * @method get
115
- * @memberOf module:management.CustomDomainsManager.prototype
116
- *
117
- * @example
118
- * management.customDomains.get({ id: CUSTOM_DOMAIN_ID }, function (err, customDomain) {
119
- * if (err) {
120
- * // Handle error.
121
- * }
122
- *
123
- * console.log(customDomain);
124
- * });
125
- *
126
- * @param {Object} params Custom Domain parameters.
127
- * @param {String} params.id Custom Domain ID.
128
- * @param {Function} [cb] Callback function.
129
- *
130
- * @return {Promise|undefined}
131
- */
132
- utils.wrapPropertyMethod(CustomDomainsManager, 'get', 'resource.get');
145
+ if (cb && cb instanceof Function) {
146
+ return this.vefifyResource.create(params, {}, cb);
147
+ }
133
148
 
134
- /**
135
- * Verify a Custom Domain.
136
- *
137
- * @method verify
138
- * @memberOf module:management.CustomDomainsManager.prototype
139
- *
140
- * @example
141
- * management.customDomains.verify({ id: CUSTOM_DOMAIN_ID }, function (err, customDomain) {
142
- * if (err) {
143
- * // Handle error.
144
- * }
145
- *
146
- * console.log(customDomain);
147
- * });
148
- *
149
- * @param {Object} params Custom Domain parameters.
150
- * @param {String} params.id Custom Domain ID.
151
- * @param {Function} [cb] Callback function.
152
- *
153
- * @return {Promise|undefined}
154
- */
155
- CustomDomainsManager.prototype.verify = function(params, cb) {
156
- if (!params || !params.id) {
157
- throw new ArgumentError('The custom domain id cannot be null or undefined');
149
+ return this.vefifyResource.create(params, {});
158
150
  }
159
151
 
160
- if (cb && cb instanceof Function) {
161
- return this.vefifyResource.create(params, {}, cb);
152
+ /**
153
+ * Delete a Custom Domain.
154
+ *
155
+ * @example
156
+ * management.customDomains.delete({ id: CUSTOM_DOMAIN_ID }, function (err) {
157
+ * if (err) {
158
+ * // Handle error.
159
+ * }
160
+ *
161
+ * // CustomDomain deleted.
162
+ * });
163
+ * @param {object} params Custom Domain parameters.
164
+ * @param {string} params.id Custom Domain ID.
165
+ * @param {Function} [cb] Callback function.
166
+ * @returns {Promise|undefined}
167
+ */
168
+ delete(...args) {
169
+ return this.resource.delete(...args);
162
170
  }
163
-
164
- return this.vefifyResource.create(params, {});
165
- };
166
-
167
- /**
168
- * Delete a Custom Domain.
169
- *
170
- * @method delete
171
- * @memberOf module:management.CustomDomainsManager.prototype
172
- *
173
- * @example
174
- * management.customDomains.delete({ id: CUSTOM_DOMAIN_ID }, function (err) {
175
- * if (err) {
176
- * // Handle error.
177
- * }
178
- *
179
- * // CustomDomain deleted.
180
- * });
181
- *
182
- * @param {Object} params Custom Domain parameters.
183
- * @param {String} params.id Custom Domain ID.
184
- * @param {Function} [cb] Callback function.
185
- *
186
- * @return {Promise|undefined}
187
- */
188
- utils.wrapPropertyMethod(CustomDomainsManager, 'delete', 'resource.delete');
171
+ }
189
172
 
190
173
  module.exports = CustomDomainsManager;
@@ -1,129 +1,113 @@
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
- * Simple facade for consuming a REST API endpoint.
8
- * @external RestClient
9
- * @see https://github.com/ngonzalvez/rest-facade
10
- */
11
-
12
- /**
13
- * @class DeviceCredentialsManager
14
6
  * Manages Auth0 Device Credentials.
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
7
  */
23
- var DeviceCredentialsManager = function(options) {
24
- if (options === null || typeof options !== 'object') {
25
- throw new ArgumentError('Must provide manager options');
26
- }
8
+ class DeviceCredentialsManager {
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
+ }
27
19
 
28
- if (options.baseUrl === null || options.baseUrl === undefined) {
29
- throw new ArgumentError('Must provide a base URL for the API');
30
- }
20
+ if (options.baseUrl === null || options.baseUrl === undefined) {
21
+ throw new ArgumentError('Must provide a base URL for the API');
22
+ }
31
23
 
32
- if ('string' !== typeof options.baseUrl || options.baseUrl.length === 0) {
33
- throw new ArgumentError('The provided base URL is invalid');
24
+ if ('string' !== typeof options.baseUrl || options.baseUrl.length === 0) {
25
+ throw new ArgumentError('The provided base URL is invalid');
26
+ }
27
+
28
+ /**
29
+ * Options object for the RestClient instance.
30
+ *
31
+ * @type {object}
32
+ */
33
+ const clientOptions = {
34
+ errorFormatter: { message: 'message', name: 'error' },
35
+ headers: options.headers,
36
+ query: { repeatParams: false },
37
+ };
38
+
39
+ /**
40
+ * Provides an abstraction layer for consuming the
41
+ * {@link https://auth0.com/docs/api/v2#!/Device_Credentials
42
+ * Auth0 DeviceCredentialsManagers endpoint}.
43
+ *
44
+ * @type {external:RestClient}
45
+ */
46
+ const auth0RestClient = new Auth0RestClient(
47
+ `${options.baseUrl}/device-credentials/:id`,
48
+ clientOptions,
49
+ options.tokenProvider
50
+ );
51
+ this.resource = new RetryRestClient(auth0RestClient, options.retry);
34
52
  }
35
53
 
36
54
  /**
37
- * Options object for the RestClient instance.
55
+ * Create an Auth0 credential.
38
56
  *
39
- * @type {Object}
57
+ * @example
58
+ * management.deviceCredentials.create(data, function (err) {
59
+ * if (err) {
60
+ * // Handle error.
61
+ * }
62
+ *
63
+ * // Credential created.
64
+ * });
65
+ * @param {object} data The device credential data object.
66
+ * @param {Function} [cb] Callback function.
67
+ * @returns {Promise|undefined}
40
68
  */
41
- var clientOptions = {
42
- errorFormatter: { message: 'message', name: 'error' },
43
- headers: options.headers,
44
- query: { repeatParams: false }
45
- };
69
+ createPublicKey(...args) {
70
+ return this.resource.create(...args);
71
+ }
46
72
 
47
73
  /**
48
- * Provides an abstraction layer for consuming the
49
- * {@link https://auth0.com/docs/api/v2#!/Device_Credentials
50
- * Auth0 DeviceCredentialsManagers endpoint}.
74
+ * Get all Auth0 credentials.
51
75
  *
52
- * @type {external:RestClient}
76
+ * @example
77
+ * var params = {user_id: "USER_ID"};
78
+ *
79
+ * management.deviceCredentials.getAll(params, function (err, credentials) {
80
+ * console.log(credentials.length);
81
+ * });
82
+ * @param {object} params Credential parameters.
83
+ * @param {Function} [cb] Callback function.
84
+ * @returns {Promise|undefined}
53
85
  */
54
- var auth0RestClient = new Auth0RestClient(
55
- options.baseUrl + '/device-credentials/:id',
56
- clientOptions,
57
- options.tokenProvider
58
- );
59
- this.resource = new RetryRestClient(auth0RestClient, options.retry);
60
- };
61
-
62
- /**
63
- * Create an Auth0 credential.
64
- *
65
- * @method create
66
- * @memberOf module:management.DeviceCredentialsManager.prototype
67
- *
68
- * @example
69
- * management.deviceCredentials.create(data, function (err) {
70
- * if (err) {
71
- * // Handle error.
72
- * }
73
- *
74
- * // Credential created.
75
- * });
76
- *
77
- * @param {Object} data The device credential data object.
78
- * @param {Function} [cb] Callback function.
79
- *
80
- * @return {Promise|undefined}
81
- */
82
- utils.wrapPropertyMethod(DeviceCredentialsManager, 'createPublicKey', 'resource.create');
83
-
84
- /**
85
- * Get all Auth0 credentials.
86
- *
87
- * @method getAll
88
- * @memberOf module:management.DeviceCredentialsManager.prototype
89
- *
90
- * @example
91
- * var params = {user_id: "USER_ID"};
92
- *
93
- * management.deviceCredentials.getAll(params, function (err, credentials) {
94
- * console.log(credentials.length);
95
- * });
96
- *
97
- * @param {Object} params Credential parameters.
98
- * @param {Function} [cb] Callback function.
99
- *
100
- * @return {Promise|undefined}
101
- */
102
- utils.wrapPropertyMethod(DeviceCredentialsManager, 'getAll', 'resource.getAll');
86
+ getAll(...args) {
87
+ return this.resource.getAll(...args);
88
+ }
103
89
 
104
- /**
105
- * Delete an Auth0 device credential.
106
- *
107
- * @method delete
108
- * @memberOf module:management.DeviceCredentialsManager.prototype
109
- *
110
- * @example
111
- * var params = { id: CREDENTIAL_ID };
112
- *
113
- * management.deviceCredentials.delete(params, function (err) {
114
- * if (err) {
115
- * // Handle error.
116
- * }
117
- *
118
- * // Credential deleted.
119
- * });
120
- *
121
- * @param {Object} params Credential parameters.
122
- * @param {String} params.id Device credential ID.
123
- * @param {Function} [cb] Callback function.
124
- *
125
- * @return {Promise|undefined}
126
- */
127
- utils.wrapPropertyMethod(DeviceCredentialsManager, 'delete', 'resource.delete');
90
+ /**
91
+ * Delete an Auth0 device credential.
92
+ *
93
+ * @example
94
+ * var params = { id: CREDENTIAL_ID };
95
+ *
96
+ * management.deviceCredentials.delete(params, function (err) {
97
+ * if (err) {
98
+ * // Handle error.
99
+ * }
100
+ *
101
+ * // Credential deleted.
102
+ * });
103
+ * @param {object} params Credential parameters.
104
+ * @param {string} params.id Device credential ID.
105
+ * @param {Function} [cb] Callback function.
106
+ * @returns {Promise|undefined}
107
+ */
108
+ delete(...args) {
109
+ return this.resource.delete(...args);
110
+ }
111
+ }
128
112
 
129
113
  module.exports = DeviceCredentialsManager;