auth0 3.3.0 → 4.0.0-beta.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/README.md +19 -15
- package/package.json +47 -33
- package/CHANGELOG.md +0 -673
- package/src/Auth0RestClient.js +0 -123
- package/src/RetryRestClient.js +0 -105
- package/src/auth/DatabaseAuthenticator.js +0 -282
- package/src/auth/OAUthWithIDTokenValidation.js +0 -124
- package/src/auth/OAuthAuthenticator.js +0 -405
- package/src/auth/PasswordlessAuthenticator.js +0 -303
- package/src/auth/TokensManager.js +0 -254
- package/src/auth/UsersManager.js +0 -161
- package/src/auth/clientAuthentication.js +0 -86
- package/src/auth/idToken.js +0 -167
- package/src/auth/index.js +0 -573
- package/src/errors.js +0 -60
- package/src/index.js +0 -11
- package/src/index.mjs +0 -11
- package/src/management/ActionsManager.js +0 -526
- package/src/management/AttackProtectionManager.js +0 -158
- package/src/management/BaseManager.js +0 -41
- package/src/management/BlacklistedTokensManager.js +0 -67
- package/src/management/BrandingManager.js +0 -250
- package/src/management/ClientCredentialsManager.js +0 -112
- package/src/management/ClientGrantsManager.js +0 -124
- package/src/management/ClientsManager.js +0 -184
- package/src/management/ConnectionsManager.js +0 -213
- package/src/management/CustomDomainsManager.js +0 -141
- package/src/management/DeviceCredentialsManager.js +0 -91
- package/src/management/EmailProviderManager.js +0 -101
- package/src/management/EmailTemplatesManager.js +0 -90
- package/src/management/GrantsManager.js +0 -84
- package/src/management/GuardianManager.js +0 -361
- package/src/management/HooksManager.js +0 -295
- package/src/management/JobsManager.js +0 -324
- package/src/management/LogStreamsManager.js +0 -136
- package/src/management/LogsManager.js +0 -82
- package/src/management/ManagementTokenProvider.js +0 -144
- package/src/management/MigrationsManager.js +0 -76
- package/src/management/OrganizationsManager.js +0 -721
- package/src/management/PromptsManager.js +0 -162
- package/src/management/ResourceServersManager.js +0 -143
- package/src/management/RolesManager.js +0 -329
- package/src/management/RulesConfigsManager.js +0 -86
- package/src/management/RulesManager.js +0 -148
- package/src/management/StatsManager.js +0 -84
- package/src/management/TenantManager.js +0 -76
- package/src/management/TicketsManager.js +0 -104
- package/src/management/UserBlocksManager.js +0 -121
- package/src/management/UsersManager.js +0 -882
- package/src/management/index.js +0 -3405
- package/src/utils.js +0 -60
|
@@ -1,526 +0,0 @@
|
|
|
1
|
-
const BaseManager = require('./BaseManager');
|
|
2
|
-
|
|
3
|
-
/**
|
|
4
|
-
* {@link https://auth0.com/docs/api/v2#!/Actions/get_actions Actions} provide a way to extend
|
|
5
|
-
* Auth0 flows with custom logic.
|
|
6
|
-
* See the {@link https://auth0.com/docs/actions Actions documentation} for more information.
|
|
7
|
-
*/
|
|
8
|
-
class ActionsManager extends BaseManager {
|
|
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
|
-
super(options);
|
|
17
|
-
|
|
18
|
-
/**
|
|
19
|
-
* Provides an abstraction layer for consuming the
|
|
20
|
-
* [Auth0 Actions endpoint]{@link https://auth0.com/docs/api/v2#!/actions}.
|
|
21
|
-
*
|
|
22
|
-
* @type {external:RestClient}
|
|
23
|
-
*/
|
|
24
|
-
this.resource = this._getRestClient('/actions/actions/:id');
|
|
25
|
-
|
|
26
|
-
this.actionsDeploy = this._getRestClient('/actions/actions/:id/deploy');
|
|
27
|
-
|
|
28
|
-
this.actionsTest = this._getRestClient('/actions/actions/:id/test');
|
|
29
|
-
|
|
30
|
-
this.triggers = this._getRestClient('/actions/triggers/:trigger_id');
|
|
31
|
-
|
|
32
|
-
this.triggerBindings = this._getRestClient('/actions/triggers/:trigger_id/bindings');
|
|
33
|
-
|
|
34
|
-
this.executions = this._getRestClient('/actions/executions/:execution_id');
|
|
35
|
-
|
|
36
|
-
this.actionVersions = this._getRestClient('/actions/actions/:id/versions/:version_id');
|
|
37
|
-
|
|
38
|
-
this.actionVersionDeploy = this._getRestClient(
|
|
39
|
-
'/actions/actions/:id/versions/:version_id/deploy'
|
|
40
|
-
);
|
|
41
|
-
}
|
|
42
|
-
|
|
43
|
-
/**
|
|
44
|
-
* Get all Triggers.
|
|
45
|
-
*
|
|
46
|
-
* @example <caption>
|
|
47
|
-
* This method takes an optional object as first argument that may be used to
|
|
48
|
-
* specify pagination settings. If pagination options are not present,
|
|
49
|
-
* the first page of a limited number of results will be returned.
|
|
50
|
-
* </caption>
|
|
51
|
-
* // Pagination settings.
|
|
52
|
-
* var params = {
|
|
53
|
-
* per_page: 10,
|
|
54
|
-
* page: 0
|
|
55
|
-
* };
|
|
56
|
-
*
|
|
57
|
-
* management.actions.getAllTriggers(params, function (err, actions) {
|
|
58
|
-
* console.log(actions.length);
|
|
59
|
-
* });
|
|
60
|
-
* @param {object} [params] Actions parameters.
|
|
61
|
-
* @param {number} [params.per_page] Number of results per page.
|
|
62
|
-
* @param {number} [params.page] Page number, zero indexed.
|
|
63
|
-
* @param {Function} [cb] Callback function.
|
|
64
|
-
* @returns {Promise|undefined}
|
|
65
|
-
*/
|
|
66
|
-
getAllTriggers(params, cb) {
|
|
67
|
-
params = params || {};
|
|
68
|
-
|
|
69
|
-
if (cb && cb instanceof Function) {
|
|
70
|
-
return this.triggers.getAll(params, cb);
|
|
71
|
-
}
|
|
72
|
-
|
|
73
|
-
return this.triggers.getAll(params);
|
|
74
|
-
}
|
|
75
|
-
|
|
76
|
-
/**
|
|
77
|
-
* Update the actions bound to a trigger .
|
|
78
|
-
*
|
|
79
|
-
* @example
|
|
80
|
-
* var data = { bindings: [{ id_type: "action_id", id_value: ACTION_ID1},{id_type: "action_name", id_value: ACTION_NAME2}];
|
|
81
|
-
* var params = { trigger_id: TRIGGER_ID };
|
|
82
|
-
*
|
|
83
|
-
* // Using auth0 instance.
|
|
84
|
-
* management.actions.updateTriggerBindings(params, data, function (err, bindings) {
|
|
85
|
-
* if (err) {
|
|
86
|
-
* // Handle error.
|
|
87
|
-
* }
|
|
88
|
-
*
|
|
89
|
-
* console.log(bindings.length); // 2
|
|
90
|
-
* });
|
|
91
|
-
* @param {object} params Actions Binding parameters.
|
|
92
|
-
* @param {string} params.trigger_id Actions Trigger ID.
|
|
93
|
-
* @param {object} data bindings array
|
|
94
|
-
* @param {Function} [cb] Callback function.
|
|
95
|
-
* @returns {Promise|undefined}
|
|
96
|
-
*/
|
|
97
|
-
updateTriggerBindings(params, data, cb) {
|
|
98
|
-
params = params || {};
|
|
99
|
-
|
|
100
|
-
if (cb && cb instanceof Function) {
|
|
101
|
-
return this.triggerBindings.patch(params, data, cb);
|
|
102
|
-
}
|
|
103
|
-
|
|
104
|
-
return this.triggerBindings.patch(params, data);
|
|
105
|
-
}
|
|
106
|
-
|
|
107
|
-
/**
|
|
108
|
-
* Get the actions bound to a trigger .
|
|
109
|
-
*
|
|
110
|
-
* @example
|
|
111
|
-
* var params = { trigger_id: TRIGGER_ID };
|
|
112
|
-
*
|
|
113
|
-
* // Using auth0 instance.
|
|
114
|
-
* management.actions.getTriggerBindings(params, function (err, bindings) {
|
|
115
|
-
* if (err) {
|
|
116
|
-
* // Handle error.
|
|
117
|
-
* }
|
|
118
|
-
*
|
|
119
|
-
* console.log(bindings.length); // 2
|
|
120
|
-
* });
|
|
121
|
-
* @param {object} params Actions Binding parameters.
|
|
122
|
-
* @param {string} params.trigger_id Actions Trigger ID.
|
|
123
|
-
* @param {Function} [cb] Callback function.
|
|
124
|
-
* @returns {Promise|undefined}
|
|
125
|
-
*/
|
|
126
|
-
getTriggerBindings(params, cb) {
|
|
127
|
-
params = params || {};
|
|
128
|
-
|
|
129
|
-
if (cb && cb instanceof Function) {
|
|
130
|
-
return this.triggerBindings.getAll(params, cb);
|
|
131
|
-
}
|
|
132
|
-
|
|
133
|
-
return this.triggerBindings.getAll(params);
|
|
134
|
-
}
|
|
135
|
-
|
|
136
|
-
/**
|
|
137
|
-
* Create a new Action.
|
|
138
|
-
*
|
|
139
|
-
* @example
|
|
140
|
-
* management.actions.create(data, function (err) {
|
|
141
|
-
* if (err) {
|
|
142
|
-
* // Handle error.
|
|
143
|
-
* }
|
|
144
|
-
*
|
|
145
|
-
* // Action created.
|
|
146
|
-
* });
|
|
147
|
-
* @param {object} data Action data object.
|
|
148
|
-
* @param {Function} [cb] Callback function.
|
|
149
|
-
* @returns {Promise|undefined}
|
|
150
|
-
*/
|
|
151
|
-
create(...args) {
|
|
152
|
-
return this.resource.create(...args);
|
|
153
|
-
}
|
|
154
|
-
|
|
155
|
-
/**
|
|
156
|
-
* Get all actions.
|
|
157
|
-
*
|
|
158
|
-
* @example <caption>
|
|
159
|
-
* This method takes an optional object as first argument that may be used to
|
|
160
|
-
* specify pagination settings. If pagination options are not present,
|
|
161
|
-
* the first page of a limited number of results will be returned.
|
|
162
|
-
* </caption>
|
|
163
|
-
* // Pagination settings.
|
|
164
|
-
* var params = {
|
|
165
|
-
* per_page: 10,
|
|
166
|
-
* page: 0,
|
|
167
|
-
* triggerId:'TRIGGER_ID',
|
|
168
|
-
* actionName: 'ACTION_NAME'
|
|
169
|
-
* };
|
|
170
|
-
*
|
|
171
|
-
* management.actions.getAll(params, function (err, actions) {
|
|
172
|
-
* console.log(actions.length);
|
|
173
|
-
* });
|
|
174
|
-
* @param {object} [params] Actions parameters.
|
|
175
|
-
* @param {number} [params.per_page] Number of results per page.
|
|
176
|
-
* @param {number} [params.page] Page number, zero indexed.
|
|
177
|
-
* @param {string} [params.triggerId] The trigger ID of the actions to retrieve.
|
|
178
|
-
* @param {string} [params.actionName] The name of the actions to retrieve.
|
|
179
|
-
* @param {Function} [cb] Callback function.
|
|
180
|
-
* @returns {Promise|undefined}
|
|
181
|
-
*/
|
|
182
|
-
getAll(...args) {
|
|
183
|
-
return this.resource.getAll(...args);
|
|
184
|
-
}
|
|
185
|
-
|
|
186
|
-
/**
|
|
187
|
-
* Get an Auth0 action.
|
|
188
|
-
*
|
|
189
|
-
* @example
|
|
190
|
-
* management.actions.get({ id: ACTION_ID }, function (err, action) {
|
|
191
|
-
* if (err) {
|
|
192
|
-
* // Handle error.
|
|
193
|
-
* }
|
|
194
|
-
*
|
|
195
|
-
* console.log(action);
|
|
196
|
-
* });
|
|
197
|
-
* @param {object} params Action parameters.
|
|
198
|
-
* @param {string} params.id Action ID.
|
|
199
|
-
* @param {Function} [cb] Callback function.
|
|
200
|
-
* @returns {Promise|undefined}
|
|
201
|
-
*/
|
|
202
|
-
get(params, cb) {
|
|
203
|
-
params = params || {};
|
|
204
|
-
|
|
205
|
-
if (params.action_id) {
|
|
206
|
-
params.id = params.action_id;
|
|
207
|
-
delete params.action_id;
|
|
208
|
-
}
|
|
209
|
-
|
|
210
|
-
if (cb && cb instanceof Function) {
|
|
211
|
-
return this.resource.get(params, cb);
|
|
212
|
-
}
|
|
213
|
-
|
|
214
|
-
return this.resource.get(params);
|
|
215
|
-
}
|
|
216
|
-
|
|
217
|
-
/**
|
|
218
|
-
* Update an existing action.
|
|
219
|
-
*
|
|
220
|
-
* @example
|
|
221
|
-
* var data = { name: 'new-name' };
|
|
222
|
-
* var params = { id: ACTION_ID };
|
|
223
|
-
*
|
|
224
|
-
* // Using auth0 instance.
|
|
225
|
-
* management.updateAction(params, data, function (err, action) {
|
|
226
|
-
* if (err) {
|
|
227
|
-
* // Handle error.
|
|
228
|
-
* }
|
|
229
|
-
*
|
|
230
|
-
* console.log(action.name); // 'new-name'
|
|
231
|
-
* });
|
|
232
|
-
*
|
|
233
|
-
* // Using the Actions manager directly.
|
|
234
|
-
* management.actions.update(params, data, function (err, action) {
|
|
235
|
-
* if (err) {
|
|
236
|
-
* // Handle error.
|
|
237
|
-
* }
|
|
238
|
-
*
|
|
239
|
-
* console.log(action.name); // 'new-name'
|
|
240
|
-
* });
|
|
241
|
-
* @param {object} params Action parameters.
|
|
242
|
-
* @param {string} params.id Action ID.
|
|
243
|
-
* @param {object} data Updated action data.
|
|
244
|
-
* @param {Function} [cb] Callback function.
|
|
245
|
-
* @returns {Promise|undefined}
|
|
246
|
-
*/
|
|
247
|
-
update(params, data, cb) {
|
|
248
|
-
params = params || {};
|
|
249
|
-
|
|
250
|
-
if (params.action_id) {
|
|
251
|
-
params.id = params.action_id;
|
|
252
|
-
delete params.action_id;
|
|
253
|
-
}
|
|
254
|
-
|
|
255
|
-
if (cb && cb instanceof Function) {
|
|
256
|
-
return this.resource.patch(params, data, cb);
|
|
257
|
-
}
|
|
258
|
-
|
|
259
|
-
return this.resource.patch(params, data);
|
|
260
|
-
}
|
|
261
|
-
|
|
262
|
-
/**
|
|
263
|
-
* Delete an existing action. Deleting an Action deletes all the action's versions
|
|
264
|
-
*
|
|
265
|
-
* @example
|
|
266
|
-
* management.actions.delete({ id: ACTION_ID }, function (err) {
|
|
267
|
-
* if (err) {
|
|
268
|
-
* // Handle error.
|
|
269
|
-
* }
|
|
270
|
-
*
|
|
271
|
-
* // Action deleted.
|
|
272
|
-
* });
|
|
273
|
-
* @param {object} params Action parameters.
|
|
274
|
-
* @param {string} params.id Action ID.
|
|
275
|
-
* @param {Function} [cb] Callback function.
|
|
276
|
-
* @returns {Promise|undefined}
|
|
277
|
-
*/
|
|
278
|
-
delete(params, cb) {
|
|
279
|
-
params = params || {};
|
|
280
|
-
|
|
281
|
-
if (params.action_id) {
|
|
282
|
-
params.id = params.action_id;
|
|
283
|
-
delete params.action_id;
|
|
284
|
-
}
|
|
285
|
-
|
|
286
|
-
if (cb && cb instanceof Function) {
|
|
287
|
-
return this.resource.delete(params, cb);
|
|
288
|
-
}
|
|
289
|
-
|
|
290
|
-
return this.resource.delete(params);
|
|
291
|
-
}
|
|
292
|
-
|
|
293
|
-
/**
|
|
294
|
-
* test an Action.
|
|
295
|
-
*
|
|
296
|
-
* @example
|
|
297
|
-
* var params = { id: ACTION_ID};
|
|
298
|
-
* management.actions.test(params, payload, function (err) {
|
|
299
|
-
* if (err) {
|
|
300
|
-
* // Handle error.
|
|
301
|
-
* }
|
|
302
|
-
* });
|
|
303
|
-
* @param {object} params Action parameters.
|
|
304
|
-
* @param {string} params.id Action ID.
|
|
305
|
-
* @param {object} payload Payload represents the entire structure necessary to test a particular trigger
|
|
306
|
-
* @param {Function} [cb] Callback function.
|
|
307
|
-
* @returns {Promise|undefined}
|
|
308
|
-
*/
|
|
309
|
-
test(params, payload, cb) {
|
|
310
|
-
params = params || {};
|
|
311
|
-
payload = payload || {};
|
|
312
|
-
|
|
313
|
-
if (params.action_id) {
|
|
314
|
-
params.id = params.action_id;
|
|
315
|
-
delete params.action_id;
|
|
316
|
-
}
|
|
317
|
-
|
|
318
|
-
if (cb && cb instanceof Function) {
|
|
319
|
-
return this.actionsTest.create(params, payload, cb);
|
|
320
|
-
}
|
|
321
|
-
|
|
322
|
-
return this.actionsTest.create(params, payload);
|
|
323
|
-
}
|
|
324
|
-
|
|
325
|
-
/**
|
|
326
|
-
* deploy an Action.
|
|
327
|
-
* The action must be in a state of 'built' before it can be deployed.
|
|
328
|
-
*
|
|
329
|
-
* @example
|
|
330
|
-
* var params = { id: ACTION_ID};
|
|
331
|
-
* mangement.actions.deploy(params, function (err, actionVersion) {
|
|
332
|
-
* if (err) {
|
|
333
|
-
* // Handle error.
|
|
334
|
-
* }
|
|
335
|
-
* });
|
|
336
|
-
* @param {object} params Action parameters.
|
|
337
|
-
* @param {string} params.id Action ID.
|
|
338
|
-
* @param {Function} [cb] Callback function.
|
|
339
|
-
* @returns {Promise|undefined}
|
|
340
|
-
*/
|
|
341
|
-
deploy(params, cb) {
|
|
342
|
-
params = params || {};
|
|
343
|
-
|
|
344
|
-
if (params.action_id) {
|
|
345
|
-
params.id = params.action_id;
|
|
346
|
-
delete params.action_id;
|
|
347
|
-
}
|
|
348
|
-
|
|
349
|
-
if (cb && cb instanceof Function) {
|
|
350
|
-
return this.actionsDeploy.create(params, {}, cb);
|
|
351
|
-
}
|
|
352
|
-
|
|
353
|
-
return this.actionsDeploy.create(params, {});
|
|
354
|
-
}
|
|
355
|
-
|
|
356
|
-
/**
|
|
357
|
-
* Get all action versions
|
|
358
|
-
*
|
|
359
|
-
* @example <caption>
|
|
360
|
-
* This method takes an optional object as first argument that may be used to
|
|
361
|
-
* specify pagination settings. If pagination options are not present,
|
|
362
|
-
* the first page of a limited number of results will be returned.
|
|
363
|
-
* </caption>
|
|
364
|
-
* // Pagination settings.
|
|
365
|
-
* var params = {
|
|
366
|
-
* per_page: 10,
|
|
367
|
-
* page: 0
|
|
368
|
-
* };
|
|
369
|
-
*
|
|
370
|
-
* management.actions.getVersions({ id: ACTION_ID }, function (err, actionVersions) {
|
|
371
|
-
* console.log(actionVersions.length);
|
|
372
|
-
* });
|
|
373
|
-
* @param {object} [params] ActionVersions parameters.
|
|
374
|
-
* @param {number} [params.per_page] Number of results per page.
|
|
375
|
-
* @param {number} [params.page] Page number, zero indexed.
|
|
376
|
-
* @param {string} [params.id] Action ID.
|
|
377
|
-
* @param {Function} [cb] Callback function.
|
|
378
|
-
* @returns {Promise|undefined}
|
|
379
|
-
*/
|
|
380
|
-
getVersions(params, cb) {
|
|
381
|
-
params = params || {};
|
|
382
|
-
|
|
383
|
-
if (params.action_id) {
|
|
384
|
-
params.id = params.action_id;
|
|
385
|
-
delete params.action_id;
|
|
386
|
-
}
|
|
387
|
-
|
|
388
|
-
if (cb && cb instanceof Function) {
|
|
389
|
-
return this.actionVersions.getAll(params, cb);
|
|
390
|
-
}
|
|
391
|
-
|
|
392
|
-
return this.actionVersions.getAll(params);
|
|
393
|
-
}
|
|
394
|
-
|
|
395
|
-
/**
|
|
396
|
-
* Get an Action Version.
|
|
397
|
-
*
|
|
398
|
-
* @example
|
|
399
|
-
* var params = { id: ACTION_ID, version_id: VERSION_ID };
|
|
400
|
-
* management.actions.getVersion(params, function (err, actionVersion) {
|
|
401
|
-
* if (err) {
|
|
402
|
-
* // Handle error.
|
|
403
|
-
* }
|
|
404
|
-
* });
|
|
405
|
-
* @param {object} params Action parameters.
|
|
406
|
-
* @param {string} params.id Action ID.
|
|
407
|
-
* @param {string} params.version_id ActionVersion ID.
|
|
408
|
-
* @param {Function} [cb] Callback function.
|
|
409
|
-
* @returns {Promise|undefined}
|
|
410
|
-
*/
|
|
411
|
-
getVersion(params, cb) {
|
|
412
|
-
params = params || {};
|
|
413
|
-
|
|
414
|
-
if (params.action_id) {
|
|
415
|
-
params.id = params.action_id;
|
|
416
|
-
delete params.action_id;
|
|
417
|
-
}
|
|
418
|
-
|
|
419
|
-
if (cb && cb instanceof Function) {
|
|
420
|
-
return this.actionVersions.get(params, cb);
|
|
421
|
-
}
|
|
422
|
-
|
|
423
|
-
return this.actionVersions.get(params);
|
|
424
|
-
}
|
|
425
|
-
|
|
426
|
-
/**
|
|
427
|
-
* Create an Action Version. In general, updating an action and then
|
|
428
|
-
* deploying it is the preferred way of creating an action version, but
|
|
429
|
-
* this operation is supported as a way of creating versions without
|
|
430
|
-
* updating the action's code (which can be useful in some CI/CD scenarios).
|
|
431
|
-
*
|
|
432
|
-
* @example
|
|
433
|
-
* var params = { id: ACTION_ID };
|
|
434
|
-
* management.actions.createActionVersion(params, data, function (err, actionVersion) {
|
|
435
|
-
* if (err) {
|
|
436
|
-
* // Handle error.
|
|
437
|
-
* }
|
|
438
|
-
* });
|
|
439
|
-
* @param {object} params Action parameters.
|
|
440
|
-
* @param {string} params.id Action ID.
|
|
441
|
-
* @param {object} data ActionVersion parameters.
|
|
442
|
-
* @param {Function} [cb] Callback function.
|
|
443
|
-
* @returns {Promise|undefined}
|
|
444
|
-
*/
|
|
445
|
-
createVersion(params, data, cb) {
|
|
446
|
-
params = params || {};
|
|
447
|
-
|
|
448
|
-
if (params.action_id) {
|
|
449
|
-
params.id = params.action_id;
|
|
450
|
-
delete params.action_id;
|
|
451
|
-
}
|
|
452
|
-
|
|
453
|
-
if (cb && cb instanceof Function) {
|
|
454
|
-
return this.actionVersions.create(params, data, cb);
|
|
455
|
-
}
|
|
456
|
-
|
|
457
|
-
return this.actionVersions.create(params, data);
|
|
458
|
-
}
|
|
459
|
-
|
|
460
|
-
/**
|
|
461
|
-
* deploy an Action Version to roll back to a previous version.
|
|
462
|
-
*
|
|
463
|
-
* @example
|
|
464
|
-
* var params = { id: ACTION_ID, version_id: VERSION_ID };
|
|
465
|
-
* management.actions.deployVersion(params, function (err, actionVersion) {
|
|
466
|
-
* if (err) {
|
|
467
|
-
* // Handle error.
|
|
468
|
-
* }
|
|
469
|
-
* });
|
|
470
|
-
* @param {object} params Action parameters.
|
|
471
|
-
* @param {string} params.id Action ID.
|
|
472
|
-
* @param {string} params.version_id Action ID.
|
|
473
|
-
* @param {boolean} params.update_draft Update draft
|
|
474
|
-
* @param {Function} [cb] Callback function.
|
|
475
|
-
* @returns {Promise|undefined}
|
|
476
|
-
*/
|
|
477
|
-
deployVersion(params, cb) {
|
|
478
|
-
params = params || {};
|
|
479
|
-
|
|
480
|
-
if (params.action_id) {
|
|
481
|
-
params.id = params.action_id;
|
|
482
|
-
delete params.action_id;
|
|
483
|
-
}
|
|
484
|
-
|
|
485
|
-
const body = {};
|
|
486
|
-
|
|
487
|
-
if (params.update_draft) {
|
|
488
|
-
body.update_draft = params.update_draft;
|
|
489
|
-
delete params.update_draft;
|
|
490
|
-
}
|
|
491
|
-
|
|
492
|
-
if (cb && cb instanceof Function) {
|
|
493
|
-
return this.actionVersionDeploy.create(params, body, cb);
|
|
494
|
-
}
|
|
495
|
-
|
|
496
|
-
return this.actionVersionDeploy.create(params, body);
|
|
497
|
-
}
|
|
498
|
-
|
|
499
|
-
/**
|
|
500
|
-
* Get an execution by ID.
|
|
501
|
-
*
|
|
502
|
-
* @example
|
|
503
|
-
* management.actions.getExecution({ execution_id: EXECUTION_ID }, function (err, action) {
|
|
504
|
-
* if (err) {
|
|
505
|
-
* // Handle error.
|
|
506
|
-
* }
|
|
507
|
-
*
|
|
508
|
-
* console.log(ActionExecution);
|
|
509
|
-
* });
|
|
510
|
-
* @param {object} params Action Execution parameters.
|
|
511
|
-
* @param {string} params.id Action Execution ID.
|
|
512
|
-
* @param {Function} [cb] Callback function.
|
|
513
|
-
* @returns {Promise|undefined}
|
|
514
|
-
*/
|
|
515
|
-
getExecution(params, cb) {
|
|
516
|
-
params = params || {};
|
|
517
|
-
|
|
518
|
-
if (cb && cb instanceof Function) {
|
|
519
|
-
return this.executions.get(params, cb);
|
|
520
|
-
}
|
|
521
|
-
|
|
522
|
-
return this.executions.get(params);
|
|
523
|
-
}
|
|
524
|
-
}
|
|
525
|
-
|
|
526
|
-
module.exports = ActionsManager;
|
|
@@ -1,158 +0,0 @@
|
|
|
1
|
-
const BaseManager = require('./BaseManager');
|
|
2
|
-
|
|
3
|
-
/**
|
|
4
|
-
* Simple facade for consuming a REST API endpoint.
|
|
5
|
-
*
|
|
6
|
-
* @external RestClient
|
|
7
|
-
* @see https://github.com/ngonzalvez/rest-facade
|
|
8
|
-
*/
|
|
9
|
-
|
|
10
|
-
class AttackProtectionManager extends BaseManager {
|
|
11
|
-
/**
|
|
12
|
-
* @class
|
|
13
|
-
* Abstracts interaction with the attack-protection endpoints.
|
|
14
|
-
* @class
|
|
15
|
-
* @param {object} options The client options.
|
|
16
|
-
* @param {string} options.baseUrl The URL of the API.
|
|
17
|
-
* @param {object} [options.headers] Headers to be included in all requests.
|
|
18
|
-
* @param {object} [options.retry] Retry Policy Config
|
|
19
|
-
* @param {object} [options.tokenProvider] Management API Token Provider
|
|
20
|
-
*/
|
|
21
|
-
constructor(options) {
|
|
22
|
-
super(options);
|
|
23
|
-
|
|
24
|
-
this.bruteForceProtection = this._getRestClient('/attack-protection/brute-force-protection');
|
|
25
|
-
|
|
26
|
-
this.suspiciousIpThrottling = this._getRestClient(
|
|
27
|
-
'/attack-protection/suspicious-ip-throttling'
|
|
28
|
-
);
|
|
29
|
-
|
|
30
|
-
this.breachedPasswordDetection = this._getRestClient(
|
|
31
|
-
'/attack-protection/breached-password-detection'
|
|
32
|
-
);
|
|
33
|
-
}
|
|
34
|
-
|
|
35
|
-
/**
|
|
36
|
-
* Get the Brute Force Protection configuration.
|
|
37
|
-
*
|
|
38
|
-
* @example
|
|
39
|
-
* management.attackProtection.getBruteForceConfig(params, function (err, bruteForceConfig) {
|
|
40
|
-
* if (err) {
|
|
41
|
-
* // Handle error.
|
|
42
|
-
* }
|
|
43
|
-
*
|
|
44
|
-
* // Brute force config
|
|
45
|
-
* console.log(bruteForceConfig);
|
|
46
|
-
* });
|
|
47
|
-
* @param {object} params Brute force parameters (leave empty).
|
|
48
|
-
* @param {Function} [cb] Callback function.
|
|
49
|
-
* @returns {Promise|undefined}
|
|
50
|
-
*/
|
|
51
|
-
getBruteForceConfig(...args) {
|
|
52
|
-
return this.bruteForceProtection.get(...args);
|
|
53
|
-
}
|
|
54
|
-
|
|
55
|
-
/**
|
|
56
|
-
* Update the Brute Force Protection configuration.
|
|
57
|
-
*
|
|
58
|
-
* @example
|
|
59
|
-
* management.attackProtection.updateBruteForceConfig(params, data, function (err, bruteForceConfig) {
|
|
60
|
-
* if (err) {
|
|
61
|
-
* // Handle error.
|
|
62
|
-
* }
|
|
63
|
-
*
|
|
64
|
-
* // Brute force config
|
|
65
|
-
* console.log(bruteForceConfig);
|
|
66
|
-
* });
|
|
67
|
-
* @param {object} params Brute force parameters (leave empty).
|
|
68
|
-
* @param {object} data Updated brute force configuration.
|
|
69
|
-
* @param {Function} [cb] Callback function.
|
|
70
|
-
* @returns {Promise|undefined}
|
|
71
|
-
*/
|
|
72
|
-
updateBruteForceConfig(...args) {
|
|
73
|
-
return this.bruteForceProtection.patch(...args);
|
|
74
|
-
}
|
|
75
|
-
|
|
76
|
-
/**
|
|
77
|
-
* Get the Suspicious IP Throttling configuration.
|
|
78
|
-
*
|
|
79
|
-
* @example
|
|
80
|
-
* management.attackProtection.getSuspiciousIpThrottlingConfig(params, function (err, suspiciousIpThrottlingConfig) {
|
|
81
|
-
* if (err) {
|
|
82
|
-
* // Handle error.
|
|
83
|
-
* }
|
|
84
|
-
*
|
|
85
|
-
* // Access suspicious IP throttling configuration
|
|
86
|
-
* console.log(suspiciousIpThrottlingConfig);
|
|
87
|
-
* });
|
|
88
|
-
* @param {object} params Suspicious IP throttling parameters (leave empty).
|
|
89
|
-
* @param {Function} [cb] Callback function.
|
|
90
|
-
* @returns {Promise|undefined}
|
|
91
|
-
*/
|
|
92
|
-
getSuspiciousIpThrottlingConfig(...args) {
|
|
93
|
-
return this.suspiciousIpThrottling.get(...args);
|
|
94
|
-
}
|
|
95
|
-
|
|
96
|
-
/**
|
|
97
|
-
* Update the Suspicious IP Throttling configuration.
|
|
98
|
-
*
|
|
99
|
-
* @example
|
|
100
|
-
* management.attackProtection.updateSuspiciousIpThrottlingConfig(params, data, function (err, suspiciousIpThrottlingConfig) {
|
|
101
|
-
* if (err) {
|
|
102
|
-
* // Handle error.
|
|
103
|
-
* }
|
|
104
|
-
*
|
|
105
|
-
* // Access suspicious IP throttling configuration
|
|
106
|
-
* console.log(suspiciousIpThrottlingConfig);
|
|
107
|
-
* });
|
|
108
|
-
* @param {object} params Suspicious IP throttling parameters (leave empty).
|
|
109
|
-
* @param {object} data Updated suspicious IP throttling configuration.
|
|
110
|
-
* @param {Function} [cb] Callback function.
|
|
111
|
-
* @returns {Promise|undefined}
|
|
112
|
-
*/
|
|
113
|
-
updateSuspiciousIpThrottlingConfig(...args) {
|
|
114
|
-
return this.suspiciousIpThrottling.patch(...args);
|
|
115
|
-
}
|
|
116
|
-
|
|
117
|
-
/**
|
|
118
|
-
* Get the Breached Password Detection configuration.
|
|
119
|
-
*
|
|
120
|
-
* @example
|
|
121
|
-
* management.attackProtection.getBreachedPasswordDetectionConfig(params, function (err, breachedPasswordDetectionConfig) {
|
|
122
|
-
* if (err) {
|
|
123
|
-
* // Handle error.
|
|
124
|
-
* }
|
|
125
|
-
*
|
|
126
|
-
* // Access breached password detection configuration
|
|
127
|
-
* console.log(breachedPasswordDetectionConfig);
|
|
128
|
-
* });
|
|
129
|
-
* @param {object} params Breached password detection parameters (leave empty).
|
|
130
|
-
* @param {Function} [cb] Callback function.
|
|
131
|
-
* @returns {Promise|undefined}
|
|
132
|
-
*/
|
|
133
|
-
getBreachedPasswordDetectionConfig(...args) {
|
|
134
|
-
return this.breachedPasswordDetection.get(...args);
|
|
135
|
-
}
|
|
136
|
-
|
|
137
|
-
/**
|
|
138
|
-
* Update the breached password detection configuration.
|
|
139
|
-
*
|
|
140
|
-
* @example
|
|
141
|
-
* management.attackProtection.updateBreachedPasswordDetectionConfig(params, data, function (err, breachedPasswordDetectionConfig) {
|
|
142
|
-
* if (err) {
|
|
143
|
-
* // Handle error.
|
|
144
|
-
* }
|
|
145
|
-
*
|
|
146
|
-
* // Access breached password detection configuration
|
|
147
|
-
* console.log(breachedPasswordDetectionConfig);
|
|
148
|
-
* });
|
|
149
|
-
* @param {object} params Breached password detection parameters (leave empty).
|
|
150
|
-
* @param {object} data Updated breached password detection configuration.
|
|
151
|
-
* @param {Function} [cb] Callback function.
|
|
152
|
-
* @returns {Promise|undefined}
|
|
153
|
-
*/
|
|
154
|
-
updateBreachedPasswordDetectionConfig(...args) {
|
|
155
|
-
return this.breachedPasswordDetection.patch(...args);
|
|
156
|
-
}
|
|
157
|
-
}
|
|
158
|
-
module.exports = AttackProtectionManager;
|