auth0 2.39.0 → 2.42.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.
package/CHANGELOG.md CHANGED
@@ -1,5 +1,29 @@
1
1
  # Change Log
2
2
 
3
+ ## [v2.42.0](https://github.com/auth0/node-auth0/tree/v2.42.0) (2022-05-23)
4
+
5
+ [Full Changelog](https://github.com/auth0/node-auth0/compare/v2.41.0...v2.42.0)
6
+
7
+ **Added**
8
+
9
+ - chore: add branding theme routes [\#725](https://github.com/auth0/node-auth0/pull/725) ([alejofernandez](https://github.com/alejofernandez))
10
+
11
+ ## [v2.41.0](https://github.com/auth0/node-auth0/tree/v2.41.0) (2022-05-20)
12
+
13
+ [Full Changelog](https://github.com/auth0/node-auth0/compare/v2.40.0...v2.41.0)
14
+
15
+ **Added**
16
+
17
+ - Added ClientsManager.rotateClientSecret method [\#721](https://github.com/auth0/node-auth0/pull/721) ([sbmelvin](https://github.com/sbmelvin))
18
+
19
+ ## [v2.40.0](https://github.com/auth0/node-auth0/tree/v2.40.0) (2022-02-11)
20
+
21
+ [Full Changelog](https://github.com/auth0/node-auth0/compare/v2.39.0...v2.40.0)
22
+
23
+ **Added**
24
+
25
+ - [CAUTH-1270]: feat(attack protection): add three features (bf, sipt, bpd) [\#705](https://github.com/auth0/node-auth0/pull/705) ([sdwvit](https://github.com/sdwvit))
26
+
3
27
  ## [v2.39.0](https://github.com/auth0/node-auth0/tree/v2.39.0) (2022-01-31)
4
28
 
5
29
  [Full Changelog](https://github.com/auth0/node-auth0/compare/v2.38.1...v2.39.0)
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "auth0",
3
- "version": "2.39.0",
3
+ "version": "2.42.0",
4
4
  "description": "SDK for Auth0 API v2",
5
5
  "main": "src/index.js",
6
6
  "sideEffects": false,
@@ -34,7 +34,7 @@
34
34
  },
35
35
  "homepage": "https://github.com/auth0/node-auth0",
36
36
  "dependencies": {
37
- "axios": "^0.24.0",
37
+ "axios": "^0.26.1",
38
38
  "form-data": "^3.0.1",
39
39
  "jsonwebtoken": "^8.5.1",
40
40
  "jwks-rsa": "^1.12.1",
@@ -46,12 +46,12 @@
46
46
  "chai": "^4.2.0",
47
47
  "codecov": "^3.7.2",
48
48
  "cross-env": "^5.2.0",
49
- "eslint": "^8.1.0",
50
- "eslint-config-prettier": "^8.3.0",
49
+ "eslint": "^8.16.0",
50
+ "eslint-config-prettier": "^8.5.0",
51
51
  "eslint-plugin-jsdoc": "^37.0.3",
52
52
  "eslint-plugin-node": "^11.1.0",
53
53
  "eslint-plugin-prettier": "^4.0.0",
54
- "eslint-plugin-promise": "^5.1.1",
54
+ "eslint-plugin-promise": "^6.0.0",
55
55
  "husky": "^3.0.1",
56
56
  "jsdoc": "^3.6.7",
57
57
  "json-loader": "^0.5.7",
@@ -0,0 +1,187 @@
1
+ const { ArgumentError } = require('rest-facade');
2
+ const Auth0RestClient = require('../Auth0RestClient');
3
+ const RetryRestClient = require('../RetryRestClient');
4
+
5
+ /**
6
+ * Simple facade for consuming a REST API endpoint.
7
+ *
8
+ * @external RestClient
9
+ * @see https://github.com/ngonzalvez/rest-facade
10
+ */
11
+
12
+ class AttackProtectionManager {
13
+ /**
14
+ * @class
15
+ * Abstracts interaction with the attack-protection endpoints.
16
+ * @class
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
+ * @param {object} [options.tokenProvider] Management API Token Provider
22
+ */
23
+ constructor(options) {
24
+ if (options === null || typeof options !== 'object') {
25
+ throw new ArgumentError('Must provide manager options');
26
+ }
27
+
28
+ if (options.baseUrl === null || options.baseUrl === undefined) {
29
+ throw new ArgumentError('Must provide a base URL for the API');
30
+ }
31
+
32
+ if ('string' !== typeof options.baseUrl || options.baseUrl.length === 0) {
33
+ throw new ArgumentError('The provided base URL is invalid');
34
+ }
35
+
36
+ const clientOptions = {
37
+ errorFormatter: { message: 'message', name: 'error' },
38
+ headers: options.headers,
39
+ query: { repeatParams: false },
40
+ };
41
+
42
+ const bruteForceProtection = new Auth0RestClient(
43
+ `${options.baseUrl}/attack-protection/brute-force-protection`,
44
+ clientOptions,
45
+ options.tokenProvider
46
+ );
47
+ this.bruteForceProtection = new RetryRestClient(bruteForceProtection, options.retry);
48
+
49
+ const suspiciousIpThrottling = new Auth0RestClient(
50
+ `${options.baseUrl}/attack-protection/suspicious-ip-throttling`,
51
+ clientOptions,
52
+ options.tokenProvider
53
+ );
54
+ this.suspiciousIpThrottling = new RetryRestClient(suspiciousIpThrottling, options.retry);
55
+
56
+ const breachedPasswordDetection = new Auth0RestClient(
57
+ `${options.baseUrl}/attack-protection/breached-password-detection`,
58
+ clientOptions,
59
+ options.tokenProvider
60
+ );
61
+ this.breachedPasswordDetection = new RetryRestClient(breachedPasswordDetection, options.retry);
62
+ }
63
+
64
+ /**
65
+ * Get the Brute Force Protection configuration.
66
+ *
67
+ * @example
68
+ * management.attackProtection.getBruteForceConfig(params, function (err, bruteForceConfig) {
69
+ * if (err) {
70
+ * // Handle error.
71
+ * }
72
+ *
73
+ * // Brute force config
74
+ * console.log(bruteForceConfig);
75
+ * });
76
+ * @param {object} params Brute force parameters (leave empty).
77
+ * @param {Function} [cb] Callback function.
78
+ * @returns {Promise|undefined}
79
+ */
80
+ getBruteForceConfig(...args) {
81
+ return this.bruteForceProtection.get(...args);
82
+ }
83
+
84
+ /**
85
+ * Update the Brute Force Protection configuration.
86
+ *
87
+ * @example
88
+ * management.attackProtection.updateBruteForceConfig(params, data, function (err, bruteForceConfig) {
89
+ * if (err) {
90
+ * // Handle error.
91
+ * }
92
+ *
93
+ * // Brute force config
94
+ * console.log(bruteForceConfig);
95
+ * });
96
+ * @param {object} params Brute force parameters (leave empty).
97
+ * @param {object} data Updated brute force configuration.
98
+ * @param {Function} [cb] Callback function.
99
+ * @returns {Promise|undefined}
100
+ */
101
+ updateBruteForceConfig(...args) {
102
+ return this.bruteForceProtection.patch(...args);
103
+ }
104
+
105
+ /**
106
+ * Get the Suspicious IP Throttling configuration.
107
+ *
108
+ * @example
109
+ * management.attackProtection.getSuspiciousIpThrottlingConfig(params, function (err, suspiciousIpThrottlingConfig) {
110
+ * if (err) {
111
+ * // Handle error.
112
+ * }
113
+ *
114
+ * // Access suspicious IP throttling configuration
115
+ * console.log(suspiciousIpThrottlingConfig);
116
+ * });
117
+ * @param {object} params Suspicious IP throttling parameters (leave empty).
118
+ * @param {Function} [cb] Callback function.
119
+ * @returns {Promise|undefined}
120
+ */
121
+ getSuspiciousIpThrottlingConfig(...args) {
122
+ return this.suspiciousIpThrottling.get(...args);
123
+ }
124
+
125
+ /**
126
+ * Update the Suspicious IP Throttling configuration.
127
+ *
128
+ * @example
129
+ * management.attackProtection.updateSuspiciousIpThrottlingConfig(params, data, function (err, suspiciousIpThrottlingConfig) {
130
+ * if (err) {
131
+ * // Handle error.
132
+ * }
133
+ *
134
+ * // Access suspicious IP throttling configuration
135
+ * console.log(suspiciousIpThrottlingConfig);
136
+ * });
137
+ * @param {object} params Suspicious IP throttling parameters (leave empty).
138
+ * @param {object} data Updated suspicious IP throttling configuration.
139
+ * @param {Function} [cb] Callback function.
140
+ * @returns {Promise|undefined}
141
+ */
142
+ updateSuspiciousIpThrottlingConfig(...args) {
143
+ return this.suspiciousIpThrottling.patch(...args);
144
+ }
145
+
146
+ /**
147
+ * Get the Breached Password Detection configuration.
148
+ *
149
+ * @example
150
+ * management.attackProtection.getBreachedPasswordDetectionConfig(params, function (err, breachedPasswordDetectionConfig) {
151
+ * if (err) {
152
+ * // Handle error.
153
+ * }
154
+ *
155
+ * // Access breached password detection configuration
156
+ * console.log(breachedPasswordDetectionConfig);
157
+ * });
158
+ * @param {object} params Breached password detection parameters (leave empty).
159
+ * @param {Function} [cb] Callback function.
160
+ * @returns {Promise|undefined}
161
+ */
162
+ getBreachedPasswordDetectionConfig(...args) {
163
+ return this.breachedPasswordDetection.get(...args);
164
+ }
165
+
166
+ /**
167
+ * Update the breached password detection configuration.
168
+ *
169
+ * @example
170
+ * management.attackProtection.updateBreachedPasswordDetectionConfig(params, data, function (err, breachedPasswordDetectionConfig) {
171
+ * if (err) {
172
+ * // Handle error.
173
+ * }
174
+ *
175
+ * // Access breached password detection configuration
176
+ * console.log(breachedPasswordDetectionConfig);
177
+ * });
178
+ * @param {object} params Breached password detection parameters (leave empty).
179
+ * @param {object} data Updated breached password detection configuration.
180
+ * @param {Function} [cb] Callback function.
181
+ * @returns {Promise|undefined}
182
+ */
183
+ updateBreachedPasswordDetectionConfig(...args) {
184
+ return this.breachedPasswordDetection.patch(...args);
185
+ }
186
+ }
187
+ module.exports = AttackProtectionManager;
@@ -56,6 +56,19 @@ class BrandingManager {
56
56
  options.tokenProvider
57
57
  );
58
58
  this.brandingTemplates = new RetryRestClient(brandingTemplateAuth0RestClient, options.retry);
59
+
60
+ /**
61
+ * Provides an abstraction layer for consuming the
62
+ * {@link https://auth0.com/docs/api/management/v2#!/Branding/get_branding_theme Branding theme endpoint}.
63
+ *
64
+ * @type {external:RestClient}
65
+ */
66
+ const brandingThemesAuth0RestClient = new Auth0RestClient(
67
+ `${options.baseUrl}/branding/themes/:id`,
68
+ clientOptions,
69
+ options.tokenProvider
70
+ );
71
+ this.brandingThemes = new RetryRestClient(brandingThemesAuth0RestClient, options.retry);
59
72
  }
60
73
 
61
74
  /**
@@ -156,6 +169,115 @@ class BrandingManager {
156
169
  deleteUniversalLoginTemplate(...args) {
157
170
  return this.brandingTemplates.delete(...args);
158
171
  }
172
+
173
+ /**
174
+ * Get the new universal login theme by id.
175
+ *
176
+ * @example
177
+ * var params = { id: THEME_ID };
178
+ *
179
+ * management.branding.getTheme(params, function (err, theme) {
180
+ * if (err) {
181
+ * // Handle error.
182
+ * }
183
+ *
184
+ * // Theme
185
+ * console.log(theme);
186
+ * });
187
+ * @param {object} params Theme params
188
+ * @param {object} params.id Theme identifier.
189
+ * @param {Function} [cb] Callback function.
190
+ * @returns {Promise|undefined}
191
+ */
192
+ getTheme(...args) {
193
+ return this.brandingThemes.get(...args);
194
+ }
195
+
196
+ /**
197
+ * Get the default new universal login theme.
198
+ *
199
+ * @example
200
+ * management.branding.getDefaultTheme(function (err, theme) {
201
+ * if (err) {
202
+ * // Handle error.
203
+ * }
204
+ *
205
+ * // Theme
206
+ * console.log(theme);
207
+ * });
208
+ * @param {Function} [cb] Callback function.
209
+ * @returns {Promise|undefined}
210
+ */
211
+ getDefaultTheme(...args) {
212
+ return this.brandingThemes.get(...[{ id: 'default' }].concat(args));
213
+ }
214
+
215
+ /**
216
+ * Create a new theme.
217
+ *
218
+ * @example
219
+ * management.branding.createTheme(data, function (err, theme) {
220
+ * if (err) {
221
+ * // Handle error.
222
+ * }
223
+ *
224
+ * // Theme created.
225
+ * console.log(theme);
226
+ * });
227
+ * @param {object} data theme data object.
228
+ * @param {Function} [cb] Callback function.
229
+ * @returns {Promise|undefined}
230
+ */
231
+ createTheme(...args) {
232
+ return this.brandingThemes.create(...args);
233
+ }
234
+
235
+ /**
236
+ * Update a theme.
237
+ *
238
+ * @example
239
+ * var data = THEME_OBJ;
240
+ * var params = { id: THEME_ID };
241
+ *
242
+ * management.branding.updateTheme(params, data, function (err, theme) {
243
+ * if (err) {
244
+ * // Handle error.
245
+ * }
246
+ *
247
+ * // Theme updated.
248
+ * console.log(theme);
249
+ * });
250
+ * @param {object} params Theme parameters.
251
+ * @param {object} params.id Theme identifier.
252
+ * @param {object} data Updated theme data.
253
+ * @param {Function} [cb] Callback function.
254
+ * @returns {Promise|undefined}
255
+ */
256
+ updateTheme(...args) {
257
+ return this.brandingThemes.patch(...args);
258
+ }
259
+
260
+ /**
261
+ * Delete a theme.
262
+ *
263
+ * @example
264
+ * var params = { id: THEME_ID };
265
+ *
266
+ * management.branding.deleteTheme(params, function (err) {
267
+ * if (err) {
268
+ * // Handle error.
269
+ * }
270
+ *
271
+ * // Theme deleted.
272
+ * });
273
+ * @param {object} params Theme parameters.
274
+ * @param {object} params.id Theme identifier.
275
+ * @param {Function} [cb] Callback function.
276
+ * @returns {Promise|undefined}
277
+ */
278
+ deleteTheme(...args) {
279
+ return this.brandingThemes.delete(...args);
280
+ }
159
281
  }
160
282
 
161
283
  module.exports = BrandingManager;
@@ -54,6 +54,19 @@ class ClientsManager {
54
54
  options.tokenProvider
55
55
  );
56
56
  this.resource = new RetryRestClient(auth0RestClient, options.retry);
57
+
58
+ /**
59
+ * Provides an abstraction layer for consuming the
60
+ * {@link https://auth0.com/docs/api/management/v2#!/Clients/post_rotate_secret Auth0 Clients Rotate a client secret}.
61
+ *
62
+ * @type {external:RestClient}
63
+ */
64
+ const auth0RotateSecretClient = new Auth0RestClient(
65
+ `${options.baseUrl}/clients/:client_id/rotate-secret`,
66
+ clientOptions,
67
+ options.tokenProvider
68
+ );
69
+ this.rotateSecretResource = new RetryRestClient(auth0RotateSecretClient, options.retry);
57
70
  }
58
71
 
59
72
  /**
@@ -166,6 +179,36 @@ class ClientsManager {
166
179
  delete(...args) {
167
180
  return this.resource.delete(...args);
168
181
  }
182
+
183
+ /**
184
+ * Rotate a client secret
185
+ *
186
+ * @example
187
+ * management.clients.rotateClientSecret({ client_id: CLIENT_ID }, function (err, user) {
188
+ * if (err) {
189
+ * // Handle error.
190
+ * }
191
+ *
192
+ * // Client secret rotated.
193
+ * });
194
+ * @param {object} params params object
195
+ * @param {string} params.client_id Application client ID.
196
+ * @returns {Promise|undefined}
197
+ */
198
+ rotateClientSecret(params, cb) {
199
+ const query = params || {};
200
+
201
+ // Require a client ID.
202
+ if (!params.client_id) {
203
+ throw new ArgumentError('The client_id cannot be null or undefined');
204
+ }
205
+
206
+ if (cb && cb instanceof Function) {
207
+ return this.rotateSecretResource.create(query, {}, cb);
208
+ }
209
+
210
+ return this.rotateSecretResource.create(query, {});
211
+ }
169
212
  }
170
213
 
171
214
  module.exports = ClientsManager;
@@ -10,6 +10,7 @@ const GrantsManager = require('./GrantsManager');
10
10
  const UsersManager = require('./UsersManager');
11
11
  const UserBlocksManager = require('./UserBlocksManager');
12
12
  const ConnectionsManager = require('./ConnectionsManager');
13
+ const AttackProtectionManager = require('./AttackProtectionManager');
13
14
  const BlacklistedTokensManager = require('./BlacklistedTokensManager');
14
15
  const RulesManager = require('./RulesManager');
15
16
  const DeviceCredentialsManager = require('./DeviceCredentialsManager');
@@ -360,6 +361,13 @@ class ManagementClient {
360
361
  * @type {OrganizationsManager}
361
362
  */
362
363
  this.organizations = new OrganizationsManager(managerOptions);
364
+
365
+ /**
366
+ * Attack Protection Manager
367
+ *
368
+ * @type {AttackProtectionManager}
369
+ */
370
+ this.attackProtection = new AttackProtectionManager(managerOptions);
363
371
  }
364
372
 
365
373
  /**
@@ -3218,10 +3226,10 @@ class ManagementClient {
3218
3226
  }
3219
3227
 
3220
3228
  /**
3221
- * Get the new universal login template.
3229
+ * Set the new universal login template.
3222
3230
  *
3223
3231
  * @example
3224
- * management.setBrandingUniversalLoginTemplate({ template: "a template" }, function (err, template) {
3232
+ * management.setBrandingUniversalLoginTemplate({}, { template: "a template" }, function (err, template) {
3225
3233
  * if (err) {
3226
3234
  * // Handle error.
3227
3235
  * }