auth0 2.39.0 → 2.40.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,13 @@
1
1
  # Change Log
2
2
 
3
+ ## [v2.40.0](https://github.com/auth0/node-auth0/tree/v2.40.0) (2022-02-11)
4
+
5
+ [Full Changelog](https://github.com/auth0/node-auth0/compare/v2.39.0...v2.40.0)
6
+
7
+ **Added**
8
+
9
+ - [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))
10
+
3
11
  ## [v2.39.0](https://github.com/auth0/node-auth0/tree/v2.39.0) (2022-01-31)
4
12
 
5
13
  [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.40.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.25.0",
38
38
  "form-data": "^3.0.1",
39
39
  "jsonwebtoken": "^8.5.1",
40
40
  "jwks-rsa": "^1.12.1",
@@ -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;
@@ -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
  /**