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.
- package/CHANGELOG.md +557 -0
- package/README.md +33 -11
- package/package.json +22 -15
- 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 +503 -585
- 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,214 +1,192 @@
|
|
|
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
|
-
* Simple facade for consuming a REST API endpoint.
|
|
8
|
-
* @external RestClient
|
|
9
|
-
* @see https://github.com/ngonzalvez/rest-facade
|
|
10
|
-
*/
|
|
11
|
-
|
|
12
|
-
/**
|
|
13
|
-
* @class PromptsManager
|
|
14
6
|
* Manages settings related to prompts.
|
|
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
|
-
|
|
24
|
-
|
|
25
|
-
|
|
26
|
-
|
|
27
|
-
|
|
28
|
-
|
|
29
|
-
|
|
8
|
+
class PromptsManager {
|
|
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
|
+
/**
|
|
35
|
+
* Provides an abstraction layer for consuming the
|
|
36
|
+
* {@link https://auth0.com/docs/api/management/v2#!/Prompts Prompts endpoint}.
|
|
37
|
+
*
|
|
38
|
+
* @type {external:RestClient}
|
|
39
|
+
*/
|
|
40
|
+
const auth0RestClient = new Auth0RestClient(
|
|
41
|
+
`${options.baseUrl}/prompts`,
|
|
42
|
+
clientOptions,
|
|
43
|
+
options.tokenProvider
|
|
44
|
+
);
|
|
45
|
+
this.resource = new RetryRestClient(auth0RestClient, options.retry);
|
|
46
|
+
|
|
47
|
+
/**
|
|
48
|
+
* Retrieve custom text for a specific prompt and language.
|
|
49
|
+
* {@link https://auth0.com/docs/api/management/v2#!/Prompts/get_custom_text_by_language Custom Text endpoint}
|
|
50
|
+
*
|
|
51
|
+
*
|
|
52
|
+
* @type {external:RestClient}
|
|
53
|
+
*/
|
|
54
|
+
const customTextByLanguageAuth0RestClient = new Auth0RestClient(
|
|
55
|
+
`${options.baseUrl}/prompts/:prompt/custom-text/:language`,
|
|
56
|
+
clientOptions,
|
|
57
|
+
options.tokenProvider
|
|
58
|
+
);
|
|
59
|
+
this.customTextByLanguage = new RetryRestClient(
|
|
60
|
+
customTextByLanguageAuth0RestClient,
|
|
61
|
+
options.retry
|
|
62
|
+
);
|
|
30
63
|
}
|
|
31
64
|
|
|
32
|
-
|
|
33
|
-
|
|
65
|
+
/**
|
|
66
|
+
* Update the prompts settings.
|
|
67
|
+
*
|
|
68
|
+
* @example
|
|
69
|
+
* management.prompts.updateSettings(params, data, function (err, prompts) {
|
|
70
|
+
* if (err) {
|
|
71
|
+
* // Handle error.
|
|
72
|
+
* }
|
|
73
|
+
*
|
|
74
|
+
* // Updated prompts
|
|
75
|
+
* console.log(prompts);
|
|
76
|
+
* });
|
|
77
|
+
* @param {object} params Prompts parameters.
|
|
78
|
+
* @param {object} data Updated prompts data.
|
|
79
|
+
* @param {Function} [cb] Callback function.
|
|
80
|
+
* @returns {Promise|undefined}
|
|
81
|
+
*/
|
|
82
|
+
updateSettings(...args) {
|
|
83
|
+
return this.resource.patch(...args);
|
|
34
84
|
}
|
|
35
85
|
|
|
36
|
-
var clientOptions = {
|
|
37
|
-
errorFormatter: { message: 'message', name: 'error' },
|
|
38
|
-
headers: options.headers,
|
|
39
|
-
query: { repeatParams: false }
|
|
40
|
-
};
|
|
41
|
-
|
|
42
86
|
/**
|
|
43
|
-
*
|
|
44
|
-
* {@link https://auth0.com/docs/api/management/v2#!/Prompts Prompts endpoint}.
|
|
87
|
+
* Get the prompts settings..
|
|
45
88
|
*
|
|
46
|
-
* @
|
|
89
|
+
* @example
|
|
90
|
+
* management.prompts.getSettings(data, function (err, prompts) {
|
|
91
|
+
* if (err) {
|
|
92
|
+
* // Handle error.
|
|
93
|
+
* }
|
|
94
|
+
*
|
|
95
|
+
* // Prompts
|
|
96
|
+
* console.log(prompts);
|
|
97
|
+
* });
|
|
98
|
+
* @param {object} params Prompts parameters.
|
|
99
|
+
* @param {object} data Prompts data.
|
|
100
|
+
* @param {Function} [cb] Callback function.
|
|
101
|
+
* @returns {Promise|undefined}
|
|
47
102
|
*/
|
|
48
|
-
|
|
49
|
-
|
|
50
|
-
|
|
51
|
-
options.tokenProvider
|
|
52
|
-
);
|
|
53
|
-
this.resource = new RetryRestClient(auth0RestClient, options.retry);
|
|
103
|
+
getSettings(...args) {
|
|
104
|
+
return this.resource.get(...args);
|
|
105
|
+
}
|
|
54
106
|
|
|
55
107
|
/**
|
|
56
108
|
* Retrieve custom text for a specific prompt and language.
|
|
57
|
-
* {@link https://auth0.com/docs/api/management/v2#!/Prompts/get_custom_text_by_language Custom Text endpoint}
|
|
58
109
|
*
|
|
110
|
+
* @example
|
|
111
|
+
* var params = { prompt: PROMPT_NAME, language: LANGUAGE };
|
|
59
112
|
*
|
|
60
|
-
*
|
|
113
|
+
* management.prompts.getCustomTextByLanguage(params, function (err, customText) {
|
|
114
|
+
* if (err) {
|
|
115
|
+
* // Handle error.
|
|
116
|
+
* }
|
|
117
|
+
*
|
|
118
|
+
* console.log('CustomText', customText);
|
|
119
|
+
* });
|
|
120
|
+
* @param {object} params Data object.
|
|
121
|
+
* @param {string} params.prompt Name of the prompt.
|
|
122
|
+
* @param {string} params.language Language to retrieve.
|
|
123
|
+
* @param {Function} [cb] Callback function
|
|
124
|
+
* @returns {Promise|undefined}
|
|
61
125
|
*/
|
|
62
|
-
|
|
63
|
-
|
|
64
|
-
clientOptions,
|
|
65
|
-
options.tokenProvider
|
|
66
|
-
);
|
|
67
|
-
this.customTextByLanguage = new RetryRestClient(
|
|
68
|
-
customTextByLanguageAuth0RestClient,
|
|
69
|
-
options.retry
|
|
70
|
-
);
|
|
71
|
-
};
|
|
72
|
-
|
|
73
|
-
/**
|
|
74
|
-
* Update the prompts settings.
|
|
75
|
-
*
|
|
76
|
-
* @method updateSettings
|
|
77
|
-
* @memberOf module:management.PromptsManager.prototype
|
|
78
|
-
*
|
|
79
|
-
* @example
|
|
80
|
-
* management.prompts.updateSettings(params, data, function (err, prompts) {
|
|
81
|
-
* if (err) {
|
|
82
|
-
* // Handle error.
|
|
83
|
-
* }
|
|
84
|
-
*
|
|
85
|
-
* // Updated prompts
|
|
86
|
-
* console.log(prompts);
|
|
87
|
-
* });
|
|
88
|
-
*
|
|
89
|
-
* @param {Object} params Prompts parameters.
|
|
90
|
-
* @param {Object} data Updated prompts data.
|
|
91
|
-
* @param {Function} [cb] Callback function.
|
|
92
|
-
*
|
|
93
|
-
* @return {Promise|undefined}
|
|
94
|
-
*/
|
|
95
|
-
utils.wrapPropertyMethod(PromptsManager, 'updateSettings', 'resource.patch');
|
|
126
|
+
getCustomTextByLanguage(params, cb) {
|
|
127
|
+
params = params || {};
|
|
96
128
|
|
|
97
|
-
|
|
98
|
-
|
|
99
|
-
|
|
100
|
-
* @method getSettings
|
|
101
|
-
* @memberOf module:management.PromptsManager.prototype
|
|
102
|
-
*
|
|
103
|
-
* @example
|
|
104
|
-
* management.prompts.getSettings(data, function (err, prompts) {
|
|
105
|
-
* if (err) {
|
|
106
|
-
* // Handle error.
|
|
107
|
-
* }
|
|
108
|
-
*
|
|
109
|
-
* // Prompts
|
|
110
|
-
* console.log(prompts);
|
|
111
|
-
* });
|
|
112
|
-
*
|
|
113
|
-
* @param {Object} params Prompts parameters.
|
|
114
|
-
* @param {Object} data Prompts data.
|
|
115
|
-
* @param {Function} [cb] Callback function.
|
|
116
|
-
*
|
|
117
|
-
* @return {Promise|undefined}
|
|
118
|
-
*/
|
|
119
|
-
utils.wrapPropertyMethod(PromptsManager, 'getSettings', 'resource.get');
|
|
129
|
+
if (!params.prompt || typeof params.prompt !== 'string') {
|
|
130
|
+
throw new ArgumentError('The prompt parameter must be a string');
|
|
131
|
+
}
|
|
120
132
|
|
|
121
|
-
|
|
122
|
-
|
|
123
|
-
|
|
124
|
-
* @method getCustomTextByLanguage
|
|
125
|
-
* @memberOf module:management.PromptsManager.prototype
|
|
126
|
-
*
|
|
127
|
-
* @example
|
|
128
|
-
* var params = { prompt: PROMPT_NAME, language: LANGUAGE };
|
|
129
|
-
*
|
|
130
|
-
* management.prompts.getCustomTextByLanguage(params, function (err, customText) {
|
|
131
|
-
* if (err) {
|
|
132
|
-
* // Handle error.
|
|
133
|
-
* }
|
|
134
|
-
*
|
|
135
|
-
* console.log('CustomText', customText);
|
|
136
|
-
* });
|
|
137
|
-
*
|
|
138
|
-
* @param {Object} params Data object.
|
|
139
|
-
* @param {String} params.prompt Name of the prompt.
|
|
140
|
-
* @param {String} params.language Language to retrieve.
|
|
141
|
-
* @param {Function} [cb] Callback function
|
|
142
|
-
*
|
|
143
|
-
* @return {Promise|undefined}
|
|
144
|
-
*/
|
|
145
|
-
PromptsManager.prototype.getCustomTextByLanguage = function(params, cb) {
|
|
146
|
-
params = params || {};
|
|
133
|
+
if (!params.language || typeof params.language !== 'string') {
|
|
134
|
+
throw new ArgumentError('The language parameter must be a string');
|
|
135
|
+
}
|
|
147
136
|
|
|
148
|
-
|
|
149
|
-
|
|
150
|
-
|
|
137
|
+
if (cb && cb instanceof Function) {
|
|
138
|
+
return this.customTextByLanguage.get(params, cb);
|
|
139
|
+
}
|
|
151
140
|
|
|
152
|
-
|
|
153
|
-
throw new ArgumentError('The language parameter must be a string');
|
|
141
|
+
return this.customTextByLanguage.get(params);
|
|
154
142
|
}
|
|
155
143
|
|
|
156
|
-
|
|
157
|
-
|
|
158
|
-
|
|
159
|
-
|
|
160
|
-
|
|
161
|
-
|
|
144
|
+
/**
|
|
145
|
+
* Set custom text for a specific prompt.
|
|
146
|
+
*
|
|
147
|
+
* @example
|
|
148
|
+
* var params = { prompt: PROMPT_NAME, language: LANGUAGE, body: BODY_OBJECT };
|
|
149
|
+
*
|
|
150
|
+
* management.prompts.updateCustomTextByLanguage(params, function (err, customText) {
|
|
151
|
+
* if (err) {
|
|
152
|
+
* // Handle error.
|
|
153
|
+
* }
|
|
154
|
+
*
|
|
155
|
+
* console.log('CustomText', customText);
|
|
156
|
+
* });
|
|
157
|
+
* @param {object} params Data object.
|
|
158
|
+
* @param {string} params.prompt Name of the prompt.
|
|
159
|
+
* @param {string} params.language Language to retrieve.
|
|
160
|
+
* @param {object} params.body An object containing custom dictionaries for a group of screens.
|
|
161
|
+
* @param {Function} [cb] Callback function
|
|
162
|
+
* @returns {Promise|undefined}
|
|
163
|
+
*/
|
|
164
|
+
updateCustomTextByLanguage(params, cb) {
|
|
165
|
+
params = params || {};
|
|
162
166
|
|
|
163
|
-
|
|
164
|
-
|
|
165
|
-
|
|
166
|
-
* @method updateCustomTextByLanguage
|
|
167
|
-
* @memberOf module:management.PromptsManager.prototype
|
|
168
|
-
*
|
|
169
|
-
* @example
|
|
170
|
-
* var params = { prompt: PROMPT_NAME, language: LANGUAGE, body: BODY_OBJECT };
|
|
171
|
-
*
|
|
172
|
-
* management.prompts.updateCustomTextByLanguage(params, function (err, customText) {
|
|
173
|
-
* if (err) {
|
|
174
|
-
* // Handle error.
|
|
175
|
-
* }
|
|
176
|
-
*
|
|
177
|
-
* console.log('CustomText', customText);
|
|
178
|
-
* });
|
|
179
|
-
*
|
|
180
|
-
* @param {Object} params Data object.
|
|
181
|
-
* @param {String} params.prompt Name of the prompt.
|
|
182
|
-
* @param {String} params.language Language to retrieve.
|
|
183
|
-
* @param {Object} params.body An object containing custom dictionaries for a group of screens.
|
|
184
|
-
* @param {Function} [cb] Callback function
|
|
185
|
-
*
|
|
186
|
-
* @return {Promise|undefined}
|
|
187
|
-
*/
|
|
188
|
-
PromptsManager.prototype.updateCustomTextByLanguage = function(params, cb) {
|
|
189
|
-
params = params || {};
|
|
190
|
-
options = {};
|
|
167
|
+
if (!params.prompt || typeof params.prompt !== 'string') {
|
|
168
|
+
throw new ArgumentError('The prompt parameter must be a string');
|
|
169
|
+
}
|
|
191
170
|
|
|
192
|
-
|
|
193
|
-
|
|
194
|
-
|
|
171
|
+
if (!params.language || typeof params.language !== 'string') {
|
|
172
|
+
throw new ArgumentError('The language parameter must be a string');
|
|
173
|
+
}
|
|
195
174
|
|
|
196
|
-
|
|
197
|
-
|
|
198
|
-
|
|
175
|
+
if (!params.body || typeof params.body !== 'object') {
|
|
176
|
+
throw new ArgumentError('The body parameter must be an object');
|
|
177
|
+
}
|
|
199
178
|
|
|
200
|
-
|
|
201
|
-
|
|
202
|
-
|
|
179
|
+
const options = {
|
|
180
|
+
prompt: params.prompt,
|
|
181
|
+
language: params.language,
|
|
182
|
+
};
|
|
203
183
|
|
|
204
|
-
|
|
205
|
-
|
|
184
|
+
if (cb && cb instanceof Function) {
|
|
185
|
+
return this.customTextByLanguage.update(options, params.body, cb);
|
|
186
|
+
}
|
|
206
187
|
|
|
207
|
-
|
|
208
|
-
return this.customTextByLanguage.update(options, params.body, cb);
|
|
188
|
+
return this.customTextByLanguage.update(options, params.body);
|
|
209
189
|
}
|
|
210
|
-
|
|
211
|
-
return this.customTextByLanguage.update(options, params.body);
|
|
212
|
-
};
|
|
190
|
+
}
|
|
213
191
|
|
|
214
192
|
module.exports = PromptsManager;
|