auth0 2.36.2 → 2.39.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 +41 -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 -581
- package/src/errors.js +23 -23
- package/src/index.js +3 -2
- package/src/management/ActionsManager.js +510 -584
- 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 -204
- 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 -761
- 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 +3094 -3619
- package/src/utils.js +31 -60
|
@@ -1,178 +1,151 @@
|
|
|
1
|
-
|
|
2
|
-
|
|
3
|
-
|
|
1
|
+
const { ArgumentError } = require('rest-facade');
|
|
2
|
+
const Auth0RestClient = require('../Auth0RestClient');
|
|
3
|
+
const RetryRestClient = require('../RetryRestClient');
|
|
4
4
|
|
|
5
5
|
/**
|
|
6
|
-
* Simple facade for consuming a REST API endpoint.
|
|
7
|
-
* @external RestClient
|
|
8
|
-
* @see https://github.com/ngonzalvez/rest-facade
|
|
9
|
-
*/
|
|
10
|
-
|
|
11
|
-
/**
|
|
12
|
-
* @class
|
|
13
6
|
* Abstracts interaction with the user-blocks endpoint.
|
|
14
|
-
* @constructor
|
|
15
|
-
* @memberOf module:management
|
|
16
|
-
*
|
|
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
7
|
*/
|
|
22
|
-
|
|
23
|
-
|
|
24
|
-
|
|
25
|
-
|
|
8
|
+
class UserBlocksManager {
|
|
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
|
+
}
|
|
19
|
+
|
|
20
|
+
if (options.baseUrl === null || options.baseUrl === undefined) {
|
|
21
|
+
throw new ArgumentError('Must provide a base URL for the API');
|
|
22
|
+
}
|
|
23
|
+
|
|
24
|
+
if ('string' !== typeof options.baseUrl || options.baseUrl.length === 0) {
|
|
25
|
+
throw new ArgumentError('The provided base URL is invalid');
|
|
26
|
+
}
|
|
27
|
+
|
|
28
|
+
const clientOptions = {
|
|
29
|
+
errorFormatter: { message: 'message', name: 'error' },
|
|
30
|
+
headers: options.headers,
|
|
31
|
+
query: { repeatParams: false },
|
|
32
|
+
};
|
|
33
|
+
|
|
34
|
+
const userBlocksByIdResource = new Auth0RestClient(
|
|
35
|
+
`${options.baseUrl}/user-blocks/:id`,
|
|
36
|
+
clientOptions,
|
|
37
|
+
options.tokenProvider
|
|
38
|
+
);
|
|
39
|
+
this.userBlocksById = new RetryRestClient(userBlocksByIdResource, options.retry);
|
|
26
40
|
|
|
27
|
-
|
|
28
|
-
|
|
41
|
+
const userBlocksByIdentifierResource = new Auth0RestClient(
|
|
42
|
+
`${options.baseUrl}/user-blocks`,
|
|
43
|
+
clientOptions,
|
|
44
|
+
options.tokenProvider
|
|
45
|
+
);
|
|
46
|
+
this.userBlocksByIdentifier = new RetryRestClient(
|
|
47
|
+
userBlocksByIdentifierResource,
|
|
48
|
+
options.retry
|
|
49
|
+
);
|
|
29
50
|
}
|
|
30
51
|
|
|
31
|
-
|
|
32
|
-
|
|
52
|
+
/**
|
|
53
|
+
* Get user blocks by id.
|
|
54
|
+
*
|
|
55
|
+
* @example
|
|
56
|
+
* management.userBlocks.get({ id: USER_ID }, function (err, blocks) {
|
|
57
|
+
* if (err) {
|
|
58
|
+
* // Handle error.
|
|
59
|
+
* }
|
|
60
|
+
*
|
|
61
|
+
* console.log(blocks);
|
|
62
|
+
* });
|
|
63
|
+
* @param {object} params The user data object..
|
|
64
|
+
* @param {string} params.id The user id.
|
|
65
|
+
* @param {Function} [cb] Callback function
|
|
66
|
+
* @returns {Promise|undefined}
|
|
67
|
+
*/
|
|
68
|
+
get(params, ...restOfArgs) {
|
|
69
|
+
if (typeof params !== 'object' || typeof params.id !== 'string') {
|
|
70
|
+
throw new ArgumentError('You must provide an user id for the get method');
|
|
71
|
+
}
|
|
72
|
+
|
|
73
|
+
return this.userBlocksById.get(params, ...restOfArgs);
|
|
33
74
|
}
|
|
34
75
|
|
|
35
|
-
|
|
36
|
-
|
|
37
|
-
|
|
38
|
-
|
|
39
|
-
|
|
40
|
-
|
|
41
|
-
|
|
42
|
-
|
|
43
|
-
|
|
44
|
-
|
|
45
|
-
|
|
46
|
-
|
|
47
|
-
|
|
48
|
-
|
|
49
|
-
|
|
50
|
-
|
|
51
|
-
|
|
52
|
-
|
|
53
|
-
|
|
54
|
-
}
|
|
55
|
-
|
|
56
|
-
|
|
57
|
-
* Get user blocks by id.
|
|
58
|
-
*
|
|
59
|
-
* @method get
|
|
60
|
-
* @memberOf module:management.UserBlocksManager.prototype
|
|
61
|
-
*
|
|
62
|
-
* @example
|
|
63
|
-
* management.userBlocks.get({ id: USER_ID }, function (err, blocks) {
|
|
64
|
-
* if (err) {
|
|
65
|
-
* // Handle error.
|
|
66
|
-
* }
|
|
67
|
-
*
|
|
68
|
-
* console.log(blocks);
|
|
69
|
-
* });
|
|
70
|
-
*
|
|
71
|
-
*
|
|
72
|
-
* @param {Object} params The user data object..
|
|
73
|
-
* @param {String} params.id The user id.
|
|
74
|
-
* @param {Function} [cb] Callback function
|
|
75
|
-
*
|
|
76
|
-
* @return {Promise|undefined}
|
|
77
|
-
*/
|
|
78
|
-
UserBlocksManager.prototype.get = function(params) {
|
|
79
|
-
if (typeof params !== 'object' || typeof params.id !== 'string') {
|
|
80
|
-
throw new ArgumentError('You must provide an user id for the get method');
|
|
76
|
+
/**
|
|
77
|
+
* Unblock an user by its id.
|
|
78
|
+
*
|
|
79
|
+
* @example
|
|
80
|
+
* management.userBlocks.delete({ id: USER_ID }, function (err) {
|
|
81
|
+
* if (err) {
|
|
82
|
+
* // Handle error.
|
|
83
|
+
* }
|
|
84
|
+
*
|
|
85
|
+
* // User unblocked.
|
|
86
|
+
* });
|
|
87
|
+
* @param {object} params The user data object..
|
|
88
|
+
* @param {string} params.id The user id.
|
|
89
|
+
* @param {Function} [cb] Callback function
|
|
90
|
+
* @returns {Promise|undefined}
|
|
91
|
+
*/
|
|
92
|
+
delete(params, ...restOfArgs) {
|
|
93
|
+
if (typeof params !== 'object' || typeof params.id !== 'string') {
|
|
94
|
+
throw new ArgumentError('You must provide an user id for the delete method');
|
|
95
|
+
}
|
|
96
|
+
|
|
97
|
+
return this.userBlocksById.delete(params, ...restOfArgs);
|
|
81
98
|
}
|
|
82
99
|
|
|
83
|
-
|
|
84
|
-
|
|
85
|
-
|
|
86
|
-
|
|
87
|
-
|
|
88
|
-
|
|
89
|
-
|
|
90
|
-
|
|
91
|
-
|
|
92
|
-
|
|
93
|
-
|
|
94
|
-
|
|
95
|
-
|
|
96
|
-
|
|
97
|
-
|
|
98
|
-
|
|
99
|
-
|
|
100
|
-
|
|
101
|
-
|
|
102
|
-
|
|
103
|
-
|
|
104
|
-
|
|
105
|
-
*
|
|
106
|
-
* @return {Promise|undefined}
|
|
107
|
-
*/
|
|
108
|
-
UserBlocksManager.prototype.delete = function(params) {
|
|
109
|
-
if (typeof params !== 'object' || typeof params.id !== 'string') {
|
|
110
|
-
throw new ArgumentError('You must provide an user id for the delete method');
|
|
111
|
-
}
|
|
112
|
-
|
|
113
|
-
return this.userBlocksById.delete.apply(this.userBlocksById, arguments);
|
|
114
|
-
};
|
|
115
|
-
|
|
116
|
-
/**
|
|
117
|
-
* Get user blocks by identifier.
|
|
118
|
-
*
|
|
119
|
-
* @method getByIdentifier
|
|
120
|
-
* @memberOf module:management.UserBlocksManager.prototype
|
|
121
|
-
*
|
|
122
|
-
* @example
|
|
123
|
-
* management.userBlocks.getByIdentifier({ identifier: USER_ID }, function (err, blocks) {
|
|
124
|
-
* if (err) {
|
|
125
|
-
* // Handle error.
|
|
126
|
-
* }
|
|
127
|
-
*
|
|
128
|
-
* console.log(blocks);
|
|
129
|
-
* });
|
|
130
|
-
*
|
|
131
|
-
*
|
|
132
|
-
* @param {Object} params The user data object..
|
|
133
|
-
* @param {String} params.identifier The user identifier, any of: username, phone_number, email.
|
|
134
|
-
* @param {Function} [cb] Callback function
|
|
135
|
-
*
|
|
136
|
-
* @return {Promise|undefined}
|
|
137
|
-
*/
|
|
138
|
-
UserBlocksManager.prototype.getByIdentifier = function(params) {
|
|
139
|
-
if (typeof params !== 'object' || typeof params.identifier !== 'string') {
|
|
140
|
-
throw new ArgumentError('You must provide an user identifier for the getByIdentifier method');
|
|
100
|
+
/**
|
|
101
|
+
* Get user blocks by identifier.
|
|
102
|
+
*
|
|
103
|
+
* @example
|
|
104
|
+
* management.userBlocks.getByIdentifier({ identifier: USER_ID }, function (err, blocks) {
|
|
105
|
+
* if (err) {
|
|
106
|
+
* // Handle error.
|
|
107
|
+
* }
|
|
108
|
+
*
|
|
109
|
+
* console.log(blocks);
|
|
110
|
+
* });
|
|
111
|
+
* @param {object} params The user data object..
|
|
112
|
+
* @param {string} params.identifier The user identifier, any of: username, phone_number, email.
|
|
113
|
+
* @param {Function} [cb] Callback function
|
|
114
|
+
* @returns {Promise|undefined}
|
|
115
|
+
*/
|
|
116
|
+
getByIdentifier(params, ...restOfArgs) {
|
|
117
|
+
if (typeof params !== 'object' || typeof params.identifier !== 'string') {
|
|
118
|
+
throw new ArgumentError('You must provide an user identifier for the getByIdentifier method');
|
|
119
|
+
}
|
|
120
|
+
|
|
121
|
+
return this.userBlocksByIdentifier.get(params, ...restOfArgs);
|
|
141
122
|
}
|
|
142
123
|
|
|
143
|
-
|
|
144
|
-
|
|
145
|
-
|
|
146
|
-
|
|
147
|
-
|
|
148
|
-
|
|
149
|
-
|
|
150
|
-
|
|
151
|
-
|
|
152
|
-
|
|
153
|
-
|
|
154
|
-
|
|
155
|
-
|
|
156
|
-
|
|
157
|
-
|
|
158
|
-
|
|
159
|
-
|
|
160
|
-
|
|
161
|
-
|
|
162
|
-
|
|
163
|
-
|
|
164
|
-
|
|
165
|
-
|
|
166
|
-
|
|
167
|
-
*/
|
|
168
|
-
UserBlocksManager.prototype.deleteByIdentifier = function(params) {
|
|
169
|
-
if (typeof params !== 'object' || typeof params.identifier !== 'string') {
|
|
170
|
-
throw new ArgumentError(
|
|
171
|
-
'You must provide an user identifier for the deleteByIdentifier method'
|
|
172
|
-
);
|
|
124
|
+
/**
|
|
125
|
+
* Unblock an user by identifier.
|
|
126
|
+
*
|
|
127
|
+
* @example
|
|
128
|
+
* management.userBlocks.deleteByIdentifier({ identifier: USER_ID }, function (err) {
|
|
129
|
+
* if (err) {
|
|
130
|
+
* // Handle error.
|
|
131
|
+
* }
|
|
132
|
+
*
|
|
133
|
+
* // User unblocked.
|
|
134
|
+
* });
|
|
135
|
+
* @param {object} params The user data object..
|
|
136
|
+
* @param {string} params.identifier The user identifier, any of: username, phone_number, email.
|
|
137
|
+
* @param {Function} [cb] Callback function
|
|
138
|
+
* @returns {Promise|undefined}
|
|
139
|
+
*/
|
|
140
|
+
deleteByIdentifier(params, ...restOfArgs) {
|
|
141
|
+
if (typeof params !== 'object' || typeof params.identifier !== 'string') {
|
|
142
|
+
throw new ArgumentError(
|
|
143
|
+
'You must provide an user identifier for the deleteByIdentifier method'
|
|
144
|
+
);
|
|
145
|
+
}
|
|
146
|
+
|
|
147
|
+
return this.userBlocksByIdentifier.delete(params, ...restOfArgs);
|
|
173
148
|
}
|
|
174
|
-
|
|
175
|
-
return this.userBlocksByIdentifier.delete.apply(this.userBlocksByIdentifier, arguments);
|
|
176
|
-
};
|
|
149
|
+
}
|
|
177
150
|
|
|
178
151
|
module.exports = UserBlocksManager;
|