auth0 2.37.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 +37 -0
- package/README.md +33 -11
- package/package.json +22 -14
- package/src/Auth0RestClient.js +72 -71
- package/src/RetryRestClient.js +78 -81
- package/src/auth/DatabaseAuthenticator.js +242 -259
- package/src/auth/OAUthWithIDTokenValidation.js +99 -103
- package/src/auth/OAuthAuthenticator.js +325 -344
- package/src/auth/PasswordlessAuthenticator.js +238 -252
- package/src/auth/TokensManager.js +231 -246
- package/src/auth/UsersManager.js +149 -160
- package/src/auth/idToken.js +22 -19
- package/src/auth/index.js +510 -583
- package/src/errors.js +23 -23
- package/src/index.js +3 -2
- package/src/management/ActionsManager.js +510 -584
- package/src/management/AttackProtectionManager.js +187 -0
- package/src/management/BlacklistedTokensManager.js +77 -84
- package/src/management/BrandingManager.js +141 -163
- package/src/management/ClientGrantsManager.js +132 -145
- package/src/management/ClientsManager.js +145 -161
- package/src/management/ConnectionsManager.js +215 -239
- package/src/management/CustomDomainsManager.js +140 -157
- package/src/management/DeviceCredentialsManager.js +95 -111
- package/src/management/EmailProviderManager.js +110 -128
- package/src/management/EmailTemplatesManager.js +96 -112
- package/src/management/GrantsManager.js +94 -101
- package/src/management/GuardianManager.js +381 -455
- package/src/management/HooksManager.js +283 -325
- package/src/management/JobsManager.js +310 -343
- package/src/management/LogStreamsManager.js +142 -158
- package/src/management/LogsManager.js +92 -99
- package/src/management/ManagementTokenProvider.js +112 -120
- package/src/management/MigrationsManager.js +81 -90
- package/src/management/OrganizationsManager.js +686 -784
- package/src/management/PromptsManager.js +160 -182
- package/src/management/ResourceServersManager.js +143 -160
- package/src/management/RolesManager.js +323 -369
- package/src/management/RulesConfigsManager.js +94 -110
- package/src/management/RulesManager.js +154 -176
- package/src/management/StatsManager.js +87 -103
- package/src/management/TenantManager.js +81 -97
- package/src/management/TicketsManager.js +107 -115
- package/src/management/UserBlocksManager.js +135 -162
- package/src/management/UsersManager.js +729 -852
- package/src/management/index.js +3102 -3625
- package/src/utils.js +31 -60
|
@@ -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;
|
|
@@ -1,102 +1,95 @@
|
|
|
1
|
-
|
|
2
|
-
|
|
3
|
-
|
|
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 BlacklistedTokensManager
|
|
8
6
|
* The BlacklistedTokensManager class provides methods to retrieve the list of
|
|
9
7
|
* blacklisted tokens and blacklist new ones..
|
|
10
|
-
* @constructor
|
|
11
|
-
* @memberOf module:management
|
|
12
|
-
*
|
|
13
|
-
* @param {Object} options The client options.
|
|
14
|
-
* @param {String} options.baseUrl The URL of the API.
|
|
15
|
-
* @param {Object} [options.headers] Headers to be included in all requests.
|
|
16
|
-
* @param {Object} [options.retry] Retry Policy Config
|
|
17
8
|
*/
|
|
18
|
-
|
|
19
|
-
|
|
20
|
-
|
|
21
|
-
|
|
9
|
+
class BlacklistedTokensManager {
|
|
10
|
+
/**
|
|
11
|
+
* @param {object} options The client options.
|
|
12
|
+
* @param {string} options.baseUrl The URL of the API.
|
|
13
|
+
* @param {object} [options.headers] Headers to be included in all requests.
|
|
14
|
+
* @param {object} [options.retry] Retry Policy Config
|
|
15
|
+
*/
|
|
16
|
+
constructor(options) {
|
|
17
|
+
if (options === null || typeof options !== 'object') {
|
|
18
|
+
throw new ArgumentError('Must provide client options');
|
|
19
|
+
}
|
|
22
20
|
|
|
23
|
-
|
|
24
|
-
|
|
25
|
-
|
|
21
|
+
if (options.baseUrl === null || options.baseUrl === undefined) {
|
|
22
|
+
throw new ArgumentError('Must provide a base URL for the API');
|
|
23
|
+
}
|
|
26
24
|
|
|
27
|
-
|
|
28
|
-
|
|
25
|
+
if ('string' !== typeof options.baseUrl || options.baseUrl.length === 0) {
|
|
26
|
+
throw new ArgumentError('The provided base URL is invalid');
|
|
27
|
+
}
|
|
28
|
+
|
|
29
|
+
/**
|
|
30
|
+
* Options object for the Rest Client instance.
|
|
31
|
+
*
|
|
32
|
+
* @type {object}
|
|
33
|
+
*/
|
|
34
|
+
const clientOptions = {
|
|
35
|
+
errorFormatter: { message: 'message', name: 'error' },
|
|
36
|
+
headers: options.headers,
|
|
37
|
+
query: { repeatParams: false },
|
|
38
|
+
};
|
|
39
|
+
|
|
40
|
+
/**
|
|
41
|
+
* Provides an abstraction layer for consuming the
|
|
42
|
+
* [Auth0 Blacklisted Tokens endpoint]{@link https://auth0.com/docs/api/v2#!/Clients}.
|
|
43
|
+
*
|
|
44
|
+
* @type {external:RestClient}
|
|
45
|
+
*/
|
|
46
|
+
const auth0RestClient = new Auth0RestClient(
|
|
47
|
+
`${options.baseUrl}/blacklists/tokens`,
|
|
48
|
+
clientOptions,
|
|
49
|
+
options.tokenProvider
|
|
50
|
+
);
|
|
51
|
+
this.resource = new RetryRestClient(auth0RestClient, options.retry);
|
|
29
52
|
}
|
|
30
53
|
|
|
31
54
|
/**
|
|
32
|
-
*
|
|
55
|
+
* Blacklist a new token.
|
|
56
|
+
*
|
|
57
|
+
* @example
|
|
58
|
+
* var token = {
|
|
59
|
+
* aud: 'aud',
|
|
60
|
+
* jti: 'jti'
|
|
61
|
+
* };
|
|
62
|
+
*
|
|
63
|
+
* management.blacklistedTokens.add(token, function (err) {
|
|
64
|
+
* if (err) {
|
|
65
|
+
* // Handle error.
|
|
66
|
+
* }
|
|
33
67
|
*
|
|
34
|
-
*
|
|
68
|
+
* // Token blacklisted.
|
|
69
|
+
* });
|
|
70
|
+
* @param {object} token Token data.
|
|
71
|
+
* @param {string} token.aud Audience (your app client ID).
|
|
72
|
+
* @param {string} token.jti The JWT ID claim.
|
|
73
|
+
* @param {Function} [cb] Callback function.
|
|
74
|
+
* @returns {Promise|undefined}
|
|
35
75
|
*/
|
|
36
|
-
|
|
37
|
-
|
|
38
|
-
|
|
39
|
-
query: { repeatParams: false }
|
|
40
|
-
};
|
|
76
|
+
add(...args) {
|
|
77
|
+
return this.resource.create(...args);
|
|
78
|
+
}
|
|
41
79
|
|
|
42
80
|
/**
|
|
43
|
-
*
|
|
44
|
-
* [Auth0 Blacklisted Tokens endpoint]{@link https://auth0.com/docs/api/v2#!/Clients}.
|
|
81
|
+
* Get all blacklisted tokens.
|
|
45
82
|
*
|
|
46
|
-
* @
|
|
83
|
+
* @example
|
|
84
|
+
* management.blacklistedTokens.getAll(function (err, tokens) {
|
|
85
|
+
* console.log(tokens.length);
|
|
86
|
+
* });
|
|
87
|
+
* @param {Function} [cb] Callback function.
|
|
88
|
+
* @returns {Promise|undefined}
|
|
47
89
|
*/
|
|
48
|
-
|
|
49
|
-
|
|
50
|
-
|
|
51
|
-
|
|
52
|
-
);
|
|
53
|
-
this.resource = new RetryRestClient(auth0RestClient, options.retry);
|
|
54
|
-
};
|
|
55
|
-
|
|
56
|
-
/**
|
|
57
|
-
* Blacklist a new token.
|
|
58
|
-
*
|
|
59
|
-
* @method add
|
|
60
|
-
* @memberOf module:management.BlacklistedTokensManager.prototype
|
|
61
|
-
*
|
|
62
|
-
* @example
|
|
63
|
-
* var token = {
|
|
64
|
-
* aud: 'aud',
|
|
65
|
-
* jti: 'jti'
|
|
66
|
-
* };
|
|
67
|
-
*
|
|
68
|
-
* management.blacklistedTokens.add(token, function (err) {
|
|
69
|
-
* if (err) {
|
|
70
|
-
* // Handle error.
|
|
71
|
-
* }
|
|
72
|
-
*
|
|
73
|
-
* // Token blacklisted.
|
|
74
|
-
* });
|
|
75
|
-
*
|
|
76
|
-
* @param {Object} token Token data.
|
|
77
|
-
* @param {String} token.aud Audience (your app client ID).
|
|
78
|
-
* @param {String} token.jti The JWT ID claim.
|
|
79
|
-
* @param {Function} [cb] Callback function.
|
|
80
|
-
*
|
|
81
|
-
* @return {Promise|undefined}
|
|
82
|
-
*/
|
|
83
|
-
utils.wrapPropertyMethod(BlacklistedTokensManager, 'add', 'resource.create');
|
|
84
|
-
|
|
85
|
-
/**
|
|
86
|
-
* Get all blacklisted tokens.
|
|
87
|
-
*
|
|
88
|
-
* @method getAll
|
|
89
|
-
* @memberOf module:management.BlacklistedTokensManager.prototype
|
|
90
|
-
*
|
|
91
|
-
* @example
|
|
92
|
-
* management.blacklistedTokens.getAll(function (err, tokens) {
|
|
93
|
-
* console.log(tokens.length);
|
|
94
|
-
* });
|
|
95
|
-
*
|
|
96
|
-
* @param {Function} [cb] Callback function.
|
|
97
|
-
*
|
|
98
|
-
* @return {Promise|undefined}
|
|
99
|
-
*/
|
|
100
|
-
utils.wrapPropertyMethod(BlacklistedTokensManager, 'getAll', 'resource.getAll');
|
|
90
|
+
getAll(...args) {
|
|
91
|
+
return this.resource.getAll(...args);
|
|
92
|
+
}
|
|
93
|
+
}
|
|
101
94
|
|
|
102
95
|
module.exports = BlacklistedTokensManager;
|