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.
Files changed (51) hide show
  1. package/README.md +19 -15
  2. package/package.json +47 -33
  3. package/CHANGELOG.md +0 -673
  4. package/src/Auth0RestClient.js +0 -123
  5. package/src/RetryRestClient.js +0 -105
  6. package/src/auth/DatabaseAuthenticator.js +0 -282
  7. package/src/auth/OAUthWithIDTokenValidation.js +0 -124
  8. package/src/auth/OAuthAuthenticator.js +0 -405
  9. package/src/auth/PasswordlessAuthenticator.js +0 -303
  10. package/src/auth/TokensManager.js +0 -254
  11. package/src/auth/UsersManager.js +0 -161
  12. package/src/auth/clientAuthentication.js +0 -86
  13. package/src/auth/idToken.js +0 -167
  14. package/src/auth/index.js +0 -573
  15. package/src/errors.js +0 -60
  16. package/src/index.js +0 -11
  17. package/src/index.mjs +0 -11
  18. package/src/management/ActionsManager.js +0 -526
  19. package/src/management/AttackProtectionManager.js +0 -158
  20. package/src/management/BaseManager.js +0 -41
  21. package/src/management/BlacklistedTokensManager.js +0 -67
  22. package/src/management/BrandingManager.js +0 -250
  23. package/src/management/ClientCredentialsManager.js +0 -112
  24. package/src/management/ClientGrantsManager.js +0 -124
  25. package/src/management/ClientsManager.js +0 -184
  26. package/src/management/ConnectionsManager.js +0 -213
  27. package/src/management/CustomDomainsManager.js +0 -141
  28. package/src/management/DeviceCredentialsManager.js +0 -91
  29. package/src/management/EmailProviderManager.js +0 -101
  30. package/src/management/EmailTemplatesManager.js +0 -90
  31. package/src/management/GrantsManager.js +0 -84
  32. package/src/management/GuardianManager.js +0 -361
  33. package/src/management/HooksManager.js +0 -295
  34. package/src/management/JobsManager.js +0 -324
  35. package/src/management/LogStreamsManager.js +0 -136
  36. package/src/management/LogsManager.js +0 -82
  37. package/src/management/ManagementTokenProvider.js +0 -144
  38. package/src/management/MigrationsManager.js +0 -76
  39. package/src/management/OrganizationsManager.js +0 -721
  40. package/src/management/PromptsManager.js +0 -162
  41. package/src/management/ResourceServersManager.js +0 -143
  42. package/src/management/RolesManager.js +0 -329
  43. package/src/management/RulesConfigsManager.js +0 -86
  44. package/src/management/RulesManager.js +0 -148
  45. package/src/management/StatsManager.js +0 -84
  46. package/src/management/TenantManager.js +0 -76
  47. package/src/management/TicketsManager.js +0 -104
  48. package/src/management/UserBlocksManager.js +0 -121
  49. package/src/management/UsersManager.js +0 -882
  50. package/src/management/index.js +0 -3405
  51. package/src/utils.js +0 -60
@@ -1,3405 +0,0 @@
1
- const util = require('util');
2
- const utils = require('../utils');
3
- const { jsonToBase64, generateClientInfo } = utils;
4
- const { ArgumentError } = require('rest-facade');
5
-
6
- // Managers.
7
- const ClientCredentialsManager = require('./ClientCredentialsManager');
8
- const ClientsManager = require('./ClientsManager');
9
- const ClientGrantsManager = require('./ClientGrantsManager');
10
- const GrantsManager = require('./GrantsManager');
11
- const UsersManager = require('./UsersManager');
12
- const UserBlocksManager = require('./UserBlocksManager');
13
- const ConnectionsManager = require('./ConnectionsManager');
14
- const AttackProtectionManager = require('./AttackProtectionManager');
15
- const BlacklistedTokensManager = require('./BlacklistedTokensManager');
16
- const RulesManager = require('./RulesManager');
17
- const DeviceCredentialsManager = require('./DeviceCredentialsManager');
18
- const EmailProviderManager = require('./EmailProviderManager');
19
- const StatsManager = require('./StatsManager');
20
- const TenantManager = require('./TenantManager');
21
- const JobsManager = require('./JobsManager');
22
- const TicketsManager = require('./TicketsManager');
23
- const LogsManager = require('./LogsManager');
24
- const LogStreamsManager = require('./LogStreamsManager');
25
- const ResourceServersManager = require('./ResourceServersManager');
26
- const ManagementTokenProvider = require('./ManagementTokenProvider');
27
- const RulesConfigsManager = require('./RulesConfigsManager');
28
- const EmailTemplatesManager = require('./EmailTemplatesManager');
29
- const GuardianManager = require('./GuardianManager');
30
- const CustomDomainsManager = require('./CustomDomainsManager');
31
- const RolesManager = require('./RolesManager');
32
- const HooksManager = require('./HooksManager');
33
- const BrandingManager = require('./BrandingManager');
34
- const MigrationsManager = require('./MigrationsManager');
35
- const PromptsManager = require('./PromptsManager');
36
- const ActionsManager = require('./ActionsManager');
37
- const OrganizationsManager = require('./OrganizationsManager');
38
-
39
- const BASE_URL_FORMAT = 'https://%s/api/v2';
40
- const MANAGEMENT_API_AUD_FORMAT = 'https://%s/api/v2/';
41
-
42
- /**
43
- * Management API SDK.
44
- *
45
- * The Auth0 Management API is meant to be used by back-end servers or trusted
46
- * parties performing administrative tasks. Generally speaking, anything that
47
- * can be done through the Auth0 dashboard (and more) can also be done through
48
- * this API.
49
- *
50
- * @example <caption>
51
- * Initialize your client class with an API v2 token (you can generate one
52
- * <a href="https://auth0.com/docs/apiv2">here</a>) and a domain.
53
- * </caption>
54
- *
55
- * var ManagementClient = require('auth0').ManagementClient;
56
- * var auth0 = new ManagementClient({
57
- * domain: '{YOUR_ACCOUNT}.auth0.com',
58
- * token: '{YOUR_API_V2_TOKEN}'
59
- * });
60
- * @example <caption>
61
- * Initialize your client class, by using a Non Interactive Client to fetch an access_token
62
- * via the Client Credentials Grant.
63
- * </caption>
64
- *
65
- * var ManagementClient = require('auth0').ManagementClient;
66
- * var auth0 = new ManagementClient({
67
- * domain: '{YOUR_ACCOUNT}.auth0.com',
68
- * clientId: '{YOUR_NON_INTERACTIVE_CLIENT_ID}',
69
- * clientSecret: '{YOUR_NON_INTERACTIVE_CLIENT_SECRET}',
70
- * scope: "read:users write:users",
71
- * audience: 'https://{YOUR_TENANT_NAME}.auth0.com/api/v2/',
72
- * tokenProvider: {
73
- * enableCache: true,
74
- * cacheTTLInSeconds: 10
75
- * }
76
- * });
77
- * @example <caption>
78
- * Initialize your client class, by using a Non Interactive Client to fetch an access_token
79
- * via the Client Credentials Grant, providing a Private Key using the private_key_jwt token
80
- * endpoint auth method.
81
- * </caption>
82
- *
83
- * var ManagementClient = require('auth0').ManagementClient;
84
- * var auth0 = new ManagementClient({
85
- * domain: '{YOUR_ACCOUNT}.auth0.com',
86
- * clientId: '{YOUR_NON_INTERACTIVE_CLIENT_ID}',
87
- * clientAssertionSigningKey: fs.readFileSync('private-key.pem'),
88
- * scope: "read:users write:users"
89
- * });
90
- */
91
- class ManagementClient {
92
- /**
93
- * @param {object} options Options for the ManagementClient SDK.
94
- * If a token is provided only the domain is required, other parameters are ignored.
95
- * If no token is provided domain, clientId and clientSecret (or clientAssertionSigningKey)
96
- * are required.
97
- * @param {string} options.domain ManagementClient server domain.
98
- * @param {string} [options.token] API access token.
99
- * @param {string} [options.clientId] Management API Non Interactive Client Id.
100
- * @param {string} [options.clientSecret] Management API Non Interactive Client Secret.
101
- * @param {string} [options.clientAssertionSigningKey] Private key used to sign the client assertion JWT.
102
- * @param {string} [options.clientAssertionSigningAlg] Default 'RS256'.
103
- * @param {string} [options.audience] Management API Audience. By default is your domain's, e.g. the domain is `tenant.auth0.com` and the audience is `http://tenant.auth0.com/api/v2/`
104
- * @param {string} [options.scope] Management API Scopes.
105
- * @param {boolean} [options.tokenProvider.enableCache=true] Enabled or Disable Cache.
106
- * @param {number} [options.tokenProvider.cacheTTLInSeconds] By default the `expires_in` value will be used to determine the cached time of the token, this can be overridden.
107
- * @param {boolean} [options.retry.enabled=true] Enabled or Disable Retry Policy functionality.
108
- * @param {number} [options.retry.maxRetries=10] Retry failed requests X times.
109
- * @param {object} [options.headers] Additional headers that will be added to the outgoing requests.
110
- * @param {string} [options.proxy] Add the `superagent-proxy` dependency and specify a proxy url eg 'https://myproxy.com:1234'
111
- * @param {boolean} [options.includeResponseHeaders] Include the response headers in the payload in the format `{ data, headers }`.
112
- */
113
- constructor(options) {
114
- if (!options || typeof options !== 'object') {
115
- throw new ArgumentError('Management API SDK options must be an object');
116
- }
117
-
118
- if (!options.domain || options.domain.length === 0) {
119
- throw new ArgumentError('Must provide a domain');
120
- }
121
-
122
- const baseUrl = util.format(BASE_URL_FORMAT, options.domain);
123
-
124
- const defaultHeaders = {
125
- 'User-Agent': `node.js/${process.version.replace('v', '')}`,
126
- 'Content-Type': 'application/json',
127
- };
128
-
129
- const managerOptions = {
130
- headers: Object.assign(defaultHeaders, options.headers || {}),
131
- baseUrl,
132
- };
133
-
134
- if (options.token === undefined) {
135
- const config = Object.assign(
136
- { audience: util.format(MANAGEMENT_API_AUD_FORMAT, options.domain) },
137
- options
138
- );
139
-
140
- if (options.tokenProvider) {
141
- config.enableCache = options.tokenProvider.enableCache;
142
- config.cacheTTLInSeconds = options.tokenProvider.cacheTTLInSeconds;
143
- delete config.tokenProvider;
144
- }
145
-
146
- this.tokenProvider = new ManagementTokenProvider(config);
147
- } else if (typeof options.token !== 'string' || options.token.length === 0) {
148
- throw new ArgumentError('Must provide a token');
149
- } else {
150
- this.tokenProvider = {
151
- getAccessToken() {
152
- return Promise.resolve(options.token);
153
- },
154
- };
155
- managerOptions.headers['Authorization'] = `Bearer ${options.token}`;
156
- }
157
-
158
- managerOptions.tokenProvider = this.tokenProvider;
159
-
160
- if (options.telemetry !== false) {
161
- const clientInfo = options.clientInfo || generateClientInfo();
162
- if ('string' === typeof clientInfo.name && clientInfo.name.length > 0) {
163
- const telemetry = jsonToBase64(clientInfo);
164
- managerOptions.headers['Auth0-Client'] = telemetry;
165
- }
166
- }
167
-
168
- managerOptions.retry = options.retry;
169
- managerOptions.includeResponseHeaders = options.includeResponseHeaders;
170
- managerOptions.proxy = options.proxy;
171
-
172
- /**
173
- * Simple abstraction for performing CRUD operations on the
174
- * clients endpoint.
175
- *
176
- * @type {ClientsManager}
177
- */
178
- this.clients = new ClientsManager(managerOptions);
179
-
180
- /**
181
- * Simple abstraction for performing CRUD operations on the
182
- * client credentials endpoint.
183
- *
184
- * @type {module:management.ClientCredentialsManager}
185
- */
186
- this.clientCredentials = new ClientCredentialsManager(managerOptions);
187
-
188
- /**
189
- * Simple abstraction for performing CRUD operations on the client grants
190
- * endpoint.
191
- *
192
- * @type {ClientGrantsManager}
193
- */
194
- this.clientGrants = new ClientGrantsManager(managerOptions);
195
-
196
- /**
197
- * Simple abstraction for performing CRUD operations on the grants
198
- * endpoint.
199
- *
200
- * @type {GrantsManager}
201
- */
202
- this.grants = new GrantsManager(managerOptions);
203
-
204
- /**
205
- * Simple abstraction for performing CRUD operations on the
206
- * users endpoint.
207
- *
208
- * @type {UsersManager}
209
- */
210
- this.users = new UsersManager(managerOptions);
211
-
212
- /**
213
- * Simple abstraction for performing CRUD operations on the
214
- * user-blocks endpoint.
215
- *
216
- * @type {UserBlocksManager}
217
- */
218
- this.userBlocks = new UserBlocksManager(managerOptions);
219
-
220
- /**
221
- * Simple abstraction for performing CRUD operations on the
222
- * guardian endpoint.
223
- *
224
- * @type {GuardianManager}
225
- */
226
- this.guardian = new GuardianManager(managerOptions);
227
-
228
- /**
229
- * Simple abstraction for performing CRUD operations on the
230
- * custom domains endpoint.
231
- *
232
- * @type {CustomDomainsManager}
233
- */
234
- this.customDomains = new CustomDomainsManager(managerOptions);
235
-
236
- /**
237
- * Simple abstraction for performing CRUD operations on the
238
- * connections endpoint.
239
- *
240
- * @type {ConnectionsManager}
241
- */
242
- this.connections = new ConnectionsManager(managerOptions);
243
-
244
- /**
245
- * Simple abstraction for performing CRUD operations on the
246
- * device credentials endpoint.
247
- *
248
- * @type {DeviceCredentialsManager}
249
- */
250
- this.deviceCredentials = new DeviceCredentialsManager(managerOptions);
251
-
252
- /**
253
- * Simple abstraction for performing CRUD operations on the
254
- * rules endpoint.
255
- *
256
- * @type {RulesManager}
257
- */
258
- this.rules = new RulesManager(managerOptions);
259
-
260
- /**
261
- * Simple abstraction for performing CRUD operations on the
262
- * blacklisted tokens endpoint.
263
- *
264
- * @type {BlacklistedTokensManager}
265
- */
266
- this.blacklistedTokens = new BlacklistedTokensManager(managerOptions);
267
-
268
- /**
269
- * Simple abstraction for performing CRUD operations on the
270
- * email provider endpoint.
271
- *
272
- * @type {EmailProviderManager}
273
- */
274
- this.emailProvider = new EmailProviderManager(managerOptions);
275
-
276
- /**
277
- * ManagementClient account statistics manager.
278
- *
279
- * @type {StatsManager}
280
- */
281
- this.stats = new StatsManager(managerOptions);
282
-
283
- /**
284
- * ManagementClient tenant settings manager.
285
- *
286
- * @type {TenantManager}
287
- */
288
- this.tenant = new TenantManager(managerOptions);
289
-
290
- /**
291
- * Jobs manager.
292
- *
293
- * @type {JobsManager}
294
- */
295
- this.jobs = new JobsManager(managerOptions);
296
-
297
- /**
298
- * Tickets manager.
299
- *
300
- * @type {TicketsManager}
301
- */
302
- this.tickets = new TicketsManager(managerOptions);
303
-
304
- /**
305
- * Logs manager.
306
- *
307
- * @type {LogsManager}
308
- */
309
- this.logs = new LogsManager(managerOptions);
310
-
311
- /**
312
- * Log Streams manager.
313
- *
314
- * @type {LogStreamsManager}
315
- */
316
- this.logStreams = new LogStreamsManager(managerOptions);
317
-
318
- /**
319
- * Simple abstraction for performing CRUD operations on the
320
- * resource servers endpoint.
321
- *
322
- * @type {ResourceServersManager}
323
- */
324
- this.resourceServers = new ResourceServersManager(managerOptions);
325
-
326
- /**
327
- * Simple abstraction for performing CRUD operations on
328
- * Auth0's Email Templates
329
- *
330
- * @type {EmailTemplatesManager}
331
- */
332
- this.emailTemplates = new EmailTemplatesManager(managerOptions);
333
-
334
- /**
335
- * RulesConfigs manager.
336
- *
337
- * @type {RulesConfigsManager}
338
- */
339
- this.rulesConfigs = new RulesConfigsManager(managerOptions);
340
-
341
- /**
342
- * Simple abstraction for performing CRUD operations on the
343
- * roles endpoint.
344
- *
345
- * @type {RolesManager}
346
- */
347
- this.roles = new RolesManager(managerOptions);
348
-
349
- /**
350
- * Simple abstraction for performing CRUD operations on the
351
- * hooks endpoint.
352
- *
353
- * @type {HooksManager}
354
- */
355
- this.hooks = new HooksManager(managerOptions);
356
-
357
- /**
358
- * Simple abstraction for performing CRUD operations on the
359
- * branding endpoint.
360
- *
361
- * @type {BrandingManager}
362
- */
363
- this.branding = new BrandingManager(managerOptions);
364
-
365
- /**
366
- * ManagementClient migrations manager.
367
- *
368
- * @type {MigrationsManager}
369
- */
370
- this.migrations = new MigrationsManager(managerOptions);
371
-
372
- /**
373
- * Prompts Manager
374
- *
375
- * @type {PromptsManager}
376
- */
377
- this.prompts = new PromptsManager(managerOptions);
378
-
379
- /**
380
- * Simple abstraction for performing CRUD operations on the
381
- * actions endpoint.
382
- *
383
- * @type {ActionsManager}
384
- */
385
- this.actions = new ActionsManager(managerOptions);
386
-
387
- /**
388
- * Organizations Manager
389
- *
390
- * @type {OrganizationsManager}
391
- */
392
- this.organizations = new OrganizationsManager(managerOptions);
393
-
394
- /**
395
- * Attack Protection Manager
396
- *
397
- * @type {AttackProtectionManager}
398
- */
399
- this.attackProtection = new AttackProtectionManager(managerOptions);
400
- }
401
-
402
- /**
403
- * Get all connections.
404
- *
405
- * @example <caption>
406
- * This method takes an optional object as first argument that may be used to
407
- * specify pagination settings. If pagination options are not present,
408
- * the first page of a limited number of results will be returned.
409
- * </caption>
410
- *
411
- * // Pagination settings.
412
- * var params = {
413
- * per_page: 10,
414
- * page: 0
415
- * };
416
- *
417
- * management.getConnections(params, function (err, connections) {
418
- * console.log(connections.length);
419
- * });
420
- * @param {object} [params] Connections params.
421
- * @param {number} [params.per_page] Number of results per page.
422
- * @param {number} [params.page] Page number, zero indexed.
423
- * @param {Function} [cb] Callback function.
424
- * @returns {Promise|undefined}
425
- */
426
- getConnections(...args) {
427
- return this.connections.getAll(...args);
428
- }
429
-
430
- /**
431
- * Create a new connection.
432
- *
433
- * @example
434
- * management.createConnection(data, function (err) {
435
- * if (err) {
436
- * // Handle error.
437
- * }
438
- *
439
- * // Connection created.
440
- * });
441
- * @param {object} data Connection data object.
442
- * @param {Function} [cb] Callback function.
443
- * @returns {Promise|undefined}
444
- */
445
-
446
- createConnection(...args) {
447
- return this.connections.create(...args);
448
- }
449
-
450
- /**
451
- * Get an Auth0 connection.
452
- *
453
- * @example
454
- * management.getConnection({ id: CONNECTION_ID }, function (err, connection) {
455
- * if (err) {
456
- * // Handle error.
457
- * }
458
- *
459
- * console.log(connection);
460
- * });
461
- * @param {object} params Connection parameters.
462
- * @param {string} params.id Connection ID.
463
- * @param {Function} [cb] Callback function.
464
- * @returns {Promise|undefined}
465
- */
466
- getConnection(...args) {
467
- return this.connections.get(...args);
468
- }
469
-
470
- /**
471
- * Delete an existing connection.
472
- *
473
- * @example
474
- * management.deleteConnection({ id: CONNECTION_ID }, function (err) {
475
- * if (err) {
476
- * // Handle error.
477
- * }
478
- *
479
- * // Connection deleted.
480
- * });
481
- * @param {object} params Connection parameters.
482
- * @param {string} params.id Connection ID.
483
- * @param {Function} [cb] Callback function.
484
- * @returns {Promise|undefined}
485
- */
486
- deleteConnection(...args) {
487
- return this.connections.delete(...args);
488
- }
489
-
490
- /**
491
- * Update an existing connection.
492
- *
493
- * @example
494
- * var data = { name: 'newConnectionName' };
495
- * var params = { id: CONNECTION_ID };
496
- *
497
- * management.updateConnection(params, data, function (err, connection) {
498
- * if (err) {
499
- * // Handle error.
500
- * }
501
- *
502
- * console.log(connection.name); // 'newConnectionName'
503
- * });
504
- * @param {object} params Connection parameters.
505
- * @param {string} params.id Connection ID.
506
- * @param {object} data Updated connection data.
507
- * @param {Function} [cb] Callback function.
508
- * @returns {Promise|undefined}
509
- */
510
- updateConnection(...args) {
511
- return this.connections.update(...args);
512
- }
513
-
514
- /**
515
- * Get all Auth0 clients.
516
- *
517
- * @example <caption>
518
- * This method takes an optional object as first argument that may be used to
519
- * specify pagination settings. If pagination options are not present,
520
- * the first page of a limited number of results will be returned.
521
- * </caption>
522
- *
523
- * // Pagination settings.
524
- * var params = {
525
- * per_page: 10,
526
- * page: 0
527
- * };
528
- *
529
- * management.getClients(params, function (err, clients) {
530
- * console.log(clients.length);
531
- * });
532
- * @param {object} [params] Clients parameters.
533
- * @param {number} [params.per_page] Number of results per page.
534
- * @param {number} [params.page] Page number, zero indexed.
535
- * @param {Function} [cb] Callback function.
536
- * @returns {Promise|undefined}
537
- */
538
- getClients(...args) {
539
- return this.clients.getAll(...args);
540
- }
541
-
542
- /**
543
- * Get an Auth0 client.
544
- *
545
- * @example
546
- * management.getClient({ client_id: CLIENT_ID }, function (err, client) {
547
- * if (err) {
548
- * // Handle error.
549
- * }
550
- *
551
- * console.log(client);
552
- * });
553
- * @param {object} params Client parameters.
554
- * @param {string} params.client_id Application client ID.
555
- * @param {string} params.fields Comma-separated list of fields to include or exclude (based on value provided for include_fields).
556
- * @param {string} params.include_fields Whether specified fields are to be included (true) or excluded (false).
557
- * @param {Function} [cb] Callback function.
558
- * @returns {Promise|undefined}
559
- */
560
- getClient(...args) {
561
- return this.clients.get(...args);
562
- }
563
-
564
- /**
565
- * Create an Auth0 client.
566
- *
567
- * @example
568
- * management.createClient(data, function (err) {
569
- * if (err) {
570
- * // Handle error.
571
- * }
572
- *
573
- * // Client created.
574
- * });
575
- * @param {object} data The client data object.
576
- * @param {Function} [cb] Callback function.
577
- * @returns {Promise|undefined}
578
- */
579
- createClient(...args) {
580
- return this.clients.create(...args);
581
- }
582
-
583
- /**
584
- * Update an Auth0 client.
585
- *
586
- * @example
587
- * var data = { name: 'newClientName' };
588
- * var params = { client_id: CLIENT_ID };
589
- *
590
- * management.updateClient(params, data, function (err, client) {
591
- * if (err) {
592
- * // Handle error.
593
- * }
594
- *
595
- * console.log(client.name); // 'newClientName'
596
- * });
597
- * @param {object} params Client parameters.
598
- * @param {string} params.client_id Application client ID.
599
- * @param {object} data Updated client data.
600
- * @param {Function} [cb] Callback function.
601
- * @returns {Promise|undefined}
602
- */
603
- updateClient(...args) {
604
- return this.clients.update(...args);
605
- }
606
-
607
- /**
608
- * Delete an Auth0 client.
609
- *
610
- * @example
611
- * management.deleteClient({ client_id: CLIENT_ID }, function (err) {
612
- * if (err) {
613
- * // Handle error.
614
- * }
615
- *
616
- * // Client deleted.
617
- * });
618
- * @param {object} params Client parameters.
619
- * @param {string} params.client_id Application client ID.
620
- * @param {Function} [cb] Callback function.
621
- * @returns {Promise|undefined}
622
- */
623
- deleteClient(...args) {
624
- return this.clients.delete(...args);
625
- }
626
-
627
- /**
628
- * Get all Auth0 Client Grants.
629
- *
630
- * @example <caption>
631
- * This method takes an optional object as first argument that may be used to
632
- * specify pagination settings. If pagination options are not present,
633
- * the first page of a limited number of results will be returned.
634
- * </caption>
635
- *
636
- * // Pagination settings.
637
- * var params = {
638
- * per_page: 10,
639
- * page: 0
640
- * };
641
- *
642
- * management.getClientGrants(params, function (err, grants) {
643
- * console.log(grants.length);
644
- * });
645
- * @param {object} [params] Client Grants parameters.
646
- * @param {number} [params.per_page] Number of results per page.
647
- * @param {number} [params.page] Page number, zero indexed.
648
- * @param {Function} [cb] Callback function.
649
- * @returns {Promise|undefined}
650
- */
651
- getClientGrants(...args) {
652
- return this.clientGrants.getAll(...args);
653
- }
654
-
655
- /**
656
- * Create an Auth0 client grant.
657
- *
658
- * @example
659
- * management.clientGrants.create(data, function (err) {
660
- * if (err) {
661
- * // Handle error.
662
- * }
663
- *
664
- * // Client grant created.
665
- * });
666
- * @param {object} data The client data object.
667
- * @param {Function} [cb] Callback function.
668
- * @returns {Promise|undefined}
669
- */
670
- createClientGrant(...args) {
671
- return this.clientGrants.create(...args);
672
- }
673
-
674
- /**
675
- * Update an Auth0 client grant.
676
- *
677
- * @example
678
- * var data = {
679
- * client_id: CLIENT_ID,
680
- * audience: AUDIENCE,
681
- * scope: []
682
- * };
683
- * var params = { id: CLIENT_GRANT_ID };
684
- *
685
- * management.clientGrants.update(params, data, function (err, grant) {
686
- * if (err) {
687
- * // Handle error.
688
- * }
689
- *
690
- * console.log(grant.id);
691
- * });
692
- * @param {object} params Client parameters.
693
- * @param {string} params.id Client grant ID.
694
- * @param {object} data Updated client data.
695
- * @param {Function} [cb] Callback function.
696
- * @returns {Promise|undefined}
697
- */
698
- updateClientGrant(...args) {
699
- return this.clientGrants.update(...args);
700
- }
701
-
702
- /**
703
- * Delete an Auth0 client grant.
704
- *
705
- * @example
706
- * management.clientGrants.delete({ id: GRANT_ID }, function (err) {
707
- * if (err) {
708
- * // Handle error.
709
- * }
710
- *
711
- * // Grant deleted.
712
- * });
713
- * @param {object} params Client parameters.
714
- * @param {string} params.id Client grant ID.
715
- * @param {Function} [cb] Callback function.
716
- * @returns {Promise|undefined}
717
- */
718
- deleteClientGrant(...args) {
719
- return this.clientGrants.delete(...args);
720
- }
721
-
722
- /**
723
- * Get all Auth0 Grants.
724
- *
725
- * @example
726
- * var params = {
727
- * per_page: 10,
728
- * page: 0,
729
- * include_totals: true,
730
- * user_id: USER_ID,
731
- * client_id: CLIENT_ID,
732
- * audience: AUDIENCE
733
- * };
734
- *
735
- * management.getGrants(params, function (err, grants) {
736
- * console.log(grants.length);
737
- * });
738
- * @param {object} params Grants parameters.
739
- * @param {number} params.per_page Number of results per page.
740
- * @param {number} params.page Page number, zero indexed.
741
- * @param {boolean} params.include_totals true if a query summary must be included in the result, false otherwise. Default false;
742
- * @param {string} params.user_id The user_id of the grants to retrieve.
743
- * @param {string} params.client_id The client_id of the grants to retrieve.
744
- * @param {string} params.audience The audience of the grants to retrieve.
745
- * @param {Function} [cb] Callback function.
746
- * @returns {Promise|undefined}
747
- */
748
- getGrants(...args) {
749
- return this.grants.getAll(...args);
750
- }
751
-
752
- /**
753
- * Delete an Auth0 grant.
754
- *
755
- * @example
756
- * var params = {
757
- * id: GRANT_ID,
758
- * user_id: USER_ID
759
- * };
760
- *
761
- * management.deleteGrant(params, function (err) {
762
- * if (err) {
763
- * // Handle error.
764
- * }
765
- *
766
- * // Grant deleted.
767
- * });
768
- * @param {object} params Grant parameters.
769
- * @param {string} params.id Grant ID.
770
- * @param {string} params.user_id The user_id of the grants to delete.
771
- * @param {Function} [cb] Callback function.
772
- * @returns {Promise|undefined}
773
- */
774
- deleteGrant(...args) {
775
- return this.grants.delete(...args);
776
- }
777
-
778
- /**
779
- * Create an Auth0 credential.
780
- *
781
- * @example
782
- * management.createConnection(data, function (err) {
783
- * if (err) {
784
- * // Handle error.
785
- * }
786
- *
787
- * // Credential created.
788
- * });
789
- * @param {object} data The device credential data object.
790
- * @param {Function} [cb] Callback function.
791
- * @returns {Promise|undefined}
792
- */
793
- createDevicePublicKey(...args) {
794
- return this.deviceCredentials.createPublicKey(...args);
795
- }
796
-
797
- /**
798
- * Get all Auth0 credentials.
799
- *
800
- * @example
801
- * var params = {user_id: "USER_ID"};
802
- *
803
- * management.getDeviceCredentials(params, function (err, credentials) {
804
- * console.log(credentials.length);
805
- * });
806
- * @param {object} params Credential parameters.
807
- * @param {Function} [cb] Callback function.
808
- * @returns {Promise|undefined}
809
- */
810
- getDeviceCredentials(...args) {
811
- return this.deviceCredentials.getAll(...args);
812
- }
813
-
814
- /**
815
- * Delete an Auth0 device credential.
816
- *
817
- * @example
818
- * var params = { id: CREDENTIAL_ID };
819
- *
820
- * management.deleteDeviceCredential(params, function (err) {
821
- * if (err) {
822
- * // Handle error.
823
- * }
824
- *
825
- * // Credential deleted.
826
- * });
827
- * @param {object} params Credential parameters.
828
- * @param {string} params.id Device credential ID.
829
- * @param {Function} [cb] Callback function.
830
- * @returns {Promise|undefined}
831
- */
832
- deleteDeviceCredential(...args) {
833
- return this.deviceCredentials.delete(...args);
834
- }
835
-
836
- /**
837
- * Get all rules.
838
- *
839
- * @example <caption>
840
- * This method takes an optional object as first argument that may be used to
841
- * specify pagination settings. If pagination options are not present,
842
- * the first page of a limited number of results will be returned.
843
- * </caption>
844
- *
845
- * // Pagination settings.
846
- * var params = {
847
- * per_page: 10,
848
- * page: 0
849
- * };
850
- *
851
- * management.getRules(params, function (err, rules) {
852
- * console.log(rules.length);
853
- * });
854
- * @param {object} [params] Rules parameters.
855
- * @param {number} [params.per_page] Number of results per page.
856
- * @param {number} [params.page] Page number, zero indexed.
857
- * @param {Function} [cb] Callback function.
858
- * @returns {Promise|undefined}
859
- */
860
- getRules(...args) {
861
- return this.rules.getAll(...args);
862
- }
863
-
864
- /**
865
- * Create a new rule.
866
- *
867
- * @example
868
- * management.createRule(data, function (err) {
869
- * if (err) {
870
- * // Handle error.
871
- * }
872
- *
873
- * // Rule created.
874
- * });
875
- * @param {object} data Rule data object.
876
- * @param {Function} [cb] Callback function.
877
- * @returns {Promise|undefined}
878
- */
879
- createRule(...args) {
880
- return this.rules.create(...args);
881
- }
882
-
883
- /**
884
- * Get an Auth0 rule.
885
- *
886
- * @example
887
- * management.getRule({ id: RULE_ID }, function (err, rule) {
888
- * if (err) {
889
- * // Handle error.
890
- * }
891
- *
892
- * console.log(rule);
893
- * });
894
- * @param {object} params Rule parameters.
895
- * @param {string} params.id Rule ID.
896
- * @param {Function} [cb] Callback function.
897
- * @returns {Promise|undefined}
898
- */
899
- getRule(...args) {
900
- return this.rules.get(...args);
901
- }
902
-
903
- /**
904
- * Delete an existing rule.
905
- *
906
- * @example
907
- * auth0.deleteRule({ id: RULE_ID }, function (err) {
908
- * if (err) {
909
- * // Handle error.
910
- * }
911
- *
912
- * // Rule deleted.
913
- * });
914
- * @param {object} params Rule parameters.
915
- * @param {string} params.id Rule ID.
916
- * @param {Function} [cb] Callback function.
917
- * @returns {Promise|undefined}
918
- */
919
- deleteRule(...args) {
920
- return this.rules.delete(...args);
921
- }
922
-
923
- /**
924
- * Update an existing rule.
925
- *
926
- * @example
927
- * var params = { id: RULE_ID };
928
- * var data = { name: 'my-rule'};
929
- * management.updateRule(params, data, function (err, rule) {
930
- * if (err) {
931
- * // Handle error.
932
- * }
933
- *
934
- * console.log(rule.name); // 'my-rule'.
935
- * });
936
- * @param {object} params Rule parameters.
937
- * @param {string} params.id Rule ID.
938
- * @param {object} data Updated rule data.
939
- * @param {Function} [cb] Callback function.
940
- * @returns {Promise|undefined}
941
- */
942
- updateRule(...args) {
943
- return this.rules.update(...args);
944
- }
945
-
946
- /**
947
- * Get all users.
948
- *
949
- * @example <caption>
950
- * This method takes an optional object as first argument that may be used to
951
- * specify pagination settings. If pagination options are not present,
952
- * the first page of a limited number of results will be returned.
953
- * </caption>
954
- *
955
- * // Pagination settings.
956
- * var params = {
957
- * search_engine: 'v3',
958
- * q: 'name:*jane*',
959
- * per_page: 10,
960
- * page: 0
961
- * };
962
- *
963
- * auth0.getUsers(params, function (err, users) {
964
- * console.log(users.length);
965
- * });
966
- * @param {object} [params] Users params.
967
- * @param {number} [params.search_engine] The version of the search engine to use.
968
- * @param {string} [params.q] User Search string to filter which users are returned. Follows Lucene query string syntax as documented at https://auth0.com/docs/api/management/v2#!/Users/get_users.
969
- * @param {number} [params.per_page] Number of results per page.
970
- * @param {number} [params.page] Page number, zero indexed.
971
- * @param {Function} [cb] Callback function.
972
- * @returns {Promise|undefined}
973
- */
974
- getUsers(...args) {
975
- return this.users.getAll(...args);
976
- }
977
-
978
- /**
979
- * Get users for a given email address
980
- *
981
- * @example <caption>
982
- * This method takes an email address as the first argument,
983
- * and returns all users with that email address
984
- * </caption>
985
- *
986
- * auth0.getUsersByEmail(email, function (err, users) {
987
- * console.log(users);
988
- * });
989
- * @param {string} [email] Email address of user(s) to find
990
- * @param {object} [options] Additional options to pass to the endpoint
991
- * @param {string} [options.fields] Comma-separated list of fields to include or exclude in the result
992
- * @param {boolean} [options.include_fields] Whether specified fields are to be included (true) or excluded (false). Defaults to true.
993
- * @param {Function} [cb] Callback function.
994
- * @returns {Promise|undefined}
995
- */
996
- getUsersByEmail(...args) {
997
- return this.users.getByEmail(...args);
998
- }
999
-
1000
- /**
1001
- * Get a user by its id.
1002
- *
1003
- * @example
1004
- * management.getUser({ id: USER_ID }, function (err, user) {
1005
- * console.log(user);
1006
- * });
1007
- * @param {object} data The user data object.
1008
- * @param {string} data.id The user id.
1009
- * @param {Function} [cb] Callback function.
1010
- * @returns {Promise|undefined}
1011
- */
1012
- getUser(...args) {
1013
- return this.users.get(...args);
1014
- }
1015
-
1016
- /**
1017
- * Delete all users.
1018
- *
1019
- * @example
1020
- * management.deleteAllUsers(function (err) {
1021
- * if (err) {
1022
- * // Handle error.
1023
- * }
1024
- *
1025
- * // Users deleted
1026
- * });
1027
- * @param {Function} [cb] Callback function
1028
- * @returns {Promise|undefined}
1029
- * @deprecated This method will be removed in the next major release.
1030
- */
1031
- deleteAllUsers(...args) {
1032
- return this.users.deleteAll(...args);
1033
- }
1034
-
1035
- /**
1036
- * Delete a user by its id.
1037
- *
1038
- * @example
1039
- * management.deleteUser({ id: USER_ID }, function (err) {
1040
- * if (err) {
1041
- * // Handle error.
1042
- * }
1043
- *
1044
- * // User deleted.
1045
- * });
1046
- * @param {object} params The user data object..
1047
- * @param {string} params.id The user id.
1048
- * @param {Function} [cb] Callback function
1049
- * @returns {Promise|undefined}
1050
- */
1051
- deleteUser(...args) {
1052
- return this.users.delete(...args);
1053
- }
1054
-
1055
- /**
1056
- * Create a new user.
1057
- *
1058
- * @example
1059
- * management.createUser(data, function (err) {
1060
- * if (err) {
1061
- * // Handle error.
1062
- * }
1063
- *
1064
- * // User created.
1065
- * });
1066
- * @param {object} data User data.
1067
- * @param {Function} [cb] Callback function.
1068
- * @returns {Promise|undefined}
1069
- */
1070
- createUser(...args) {
1071
- return this.users.create(...args);
1072
- }
1073
-
1074
- /**
1075
- * Update a user by its id.
1076
- *
1077
- * @example
1078
- * var params = { id: USER_ID };
1079
- *
1080
- * management.updateUser(params, data, function (err, user) {
1081
- * if (err) {
1082
- * // Handle error.
1083
- * }
1084
- *
1085
- * // Updated user.
1086
- * console.log(user);
1087
- * });
1088
- * @param {object} params The user parameters.
1089
- * @param {string} params.id The user id.
1090
- * @param {object} data New user data.
1091
- * @param {Function} [cb] Callback function
1092
- * @returns {Promise|undefined}
1093
- */
1094
- updateUser(...args) {
1095
- return this.users.update(...args);
1096
- }
1097
-
1098
- /**
1099
- * Update the user metadata for a user.
1100
- *
1101
- * @example
1102
- * var params = { id: USER_ID };
1103
- * var metadata = {
1104
- * address: '123th Node.js Street'
1105
- * };
1106
- *
1107
- * management.updateUserMetadata(params, metadata, function (err, user) {
1108
- * if (err) {
1109
- * // Handle error.
1110
- * }
1111
- *
1112
- * // Updated user.
1113
- * console.log(user);
1114
- * });
1115
- * @param {object} params The user data object..
1116
- * @param {string} params.id The user id.
1117
- * @param {object} metadata New user metadata.
1118
- * @param {Function} [cb] Callback function
1119
- * @returns {Promise|undefined}
1120
- */
1121
- updateUserMetadata(...args) {
1122
- return this.users.updateUserMetadata(...args);
1123
- }
1124
-
1125
- /**
1126
- * Update the app metadata for a user.
1127
- *
1128
- * @example
1129
- * var params = { id: USER_ID };
1130
- * var metadata = {
1131
- * foo: 'bar'
1132
- * };
1133
- *
1134
- * management.updateAppMetadata(params, metadata, function (err, user) {
1135
- * if (err) {
1136
- * // Handle error.
1137
- * }
1138
- *
1139
- * // Updated user.
1140
- * console.log(user);
1141
- * });
1142
- * @param {object} params The user data object..
1143
- * @param {string} params.id The user id.
1144
- * @param {object} metadata New app metadata.
1145
- * @param {Function} [cb] Callback function
1146
- * @returns {Promise|undefined}
1147
- */
1148
- updateAppMetadata(...args) {
1149
- return this.users.updateAppMetadata(...args);
1150
- }
1151
-
1152
- /**
1153
- * Delete a multifactor provider for a user.
1154
- *
1155
- * @example
1156
- * var params = { id: USER_ID, provider: MULTIFACTOR_PROVIDER };
1157
- *
1158
- * management.deleteUserMultifactor(params, function (err, user) {
1159
- * if (err) {
1160
- * // Handle error.
1161
- * }
1162
- *
1163
- * // Users accounts unlinked.
1164
- * });
1165
- * @param {object} params Data object.
1166
- * @param {string} params.id The user id.
1167
- * @param {string} params.provider Multifactor provider.
1168
- * @param {Function} [cb] Callback function
1169
- * @returns {Promise|undefined}
1170
- */
1171
- deleteUserMultifactor(...args) {
1172
- return this.users.deleteMultifactorProvider(...args);
1173
- }
1174
-
1175
- /**
1176
- * Delete a multifactor provider for a user.
1177
- *
1178
- * @example
1179
- * var params = { id: USER_ID, provider: MULTIFACTOR_PROVIDER };
1180
- *
1181
- * management.deleteUserMultifcator(params, function (err, user) {
1182
- * if (err) {
1183
- * // Handle error.
1184
- * }
1185
- *
1186
- * // Users accounts unlinked.
1187
- * });
1188
- * @param {object} params Data object.
1189
- * @param {string} params.id The user id.
1190
- * @param {string} params.provider Multifactor provider.
1191
- * @param {Function} [cb] Callback function
1192
- * @returns {Promise|undefined}
1193
- * @deprecated The function name has a typo.
1194
- * We're shipping this so it doesn't break compatibility.
1195
- * Use {@link deleteUserMultifactor} instead.
1196
- */
1197
- deleteUserMultifcator(...args) {
1198
- return this.users.deleteMultifactorProvider(...args);
1199
- }
1200
-
1201
- /**
1202
- * Unlink the given accounts.
1203
- *
1204
- * @example
1205
- * var params = { id: USER_ID, provider: 'auht0', user_id: OTHER_USER_ID };
1206
- *
1207
- * management.unlinkUsers(params, function (err, user) {
1208
- * if (err) {
1209
- * // Handle error.
1210
- * }
1211
- *
1212
- * // Users accounts unlinked.
1213
- * });
1214
- * @param {object} params Linked users data.
1215
- * @param {string} params.id Primary user ID.
1216
- * @param {string} params.provider Identity provider in use.
1217
- * @param {string} params.user_id Secondary user ID.
1218
- * @param {Function} [cb] Callback function.
1219
- * @returns {Promise|undefined}
1220
- */
1221
- unlinkUsers(...args) {
1222
- return this.users.unlink(...args);
1223
- }
1224
-
1225
- /**
1226
- * Link the user with another account.
1227
- *
1228
- * @example
1229
- * var userId = 'USER_ID';
1230
- * var params = {
1231
- * user_id: 'OTHER_USER_ID',
1232
- * connection_id: 'CONNECTION_ID'
1233
- * };
1234
- *
1235
- * management.linkUsers(userId, params, function (err, user) {
1236
- * if (err) {
1237
- * // Handle error.
1238
- * }
1239
- *
1240
- * // Users linked.
1241
- * });
1242
- * @param {string} userId ID of the primary user.
1243
- * @param {object} params Secondary user data.
1244
- * @param {string} params.user_id ID of the user to be linked.
1245
- * @param {string} params.connection_id ID of the connection to be used.
1246
- * @param {string} params.provider Identity provider of the secondary user account being linked.
1247
- * @param {string} params.link_with JWT for the secondary account being linked. If sending this parameter, provider, user_id, and connection_id must not be sent.
1248
- * @param {Function} [cb] Callback function.
1249
- * @returns {Promise|undefined}
1250
- */
1251
- linkUsers(...args) {
1252
- return this.users.link(...args);
1253
- }
1254
-
1255
- /**
1256
- * Get user's log events.
1257
- *
1258
- * @example
1259
- * var params = { id: USER_ID, page: 0, per_page: 50, sort: 'date:-1', include_totals: true };
1260
- *
1261
- * management.getUserLogs(params, function (err, logs) {
1262
- * if (err) {
1263
- * // Handle error.
1264
- * }
1265
- *
1266
- * console.log(logs);
1267
- * });
1268
- * @param {object} params Get logs data.
1269
- * @param {string} params.id User id.
1270
- * @param {number} params.per_page Number of results per page.
1271
- * @param {number} params.page Page number, zero indexed.
1272
- * @param {string} params.sort The field to use for sorting. Use field:order where order is 1 for ascending and -1 for descending. For example date:-1.
1273
- * @param {boolean} params.include_totals true if a query summary must be included in the result, false otherwise. Default false;
1274
- * @param {Function} [cb] Callback function.
1275
- * @returns {Promise|undefined}
1276
- */
1277
- getUserLogs(...args) {
1278
- return this.users.logs(...args);
1279
- }
1280
-
1281
- /**
1282
- * Get user's roles
1283
- *
1284
- * @example
1285
- * var params = { id: USER_ID, page: 0, per_page: 50, sort: 'date:-1', include_totals: true };
1286
- *
1287
- * management.getUserRoles(params, function (err, logs) {
1288
- * if (err) {
1289
- * // Handle error.
1290
- * }
1291
- *
1292
- * console.log(logs);
1293
- * });
1294
- * @param {object} params Get roles data.
1295
- * @param {string} params.id User id.
1296
- * @param {number} params.per_page Number of results per page.
1297
- * @param {number} params.page Page number, zero indexed.
1298
- * @param {string} params.sort The field to use for sorting. Use field:order where order is 1 for ascending and -1 for descending. For example date:-1.
1299
- * @param {boolean} params.include_totals true if a query summary must be included in the result, false otherwise. Default false;
1300
- * @param {Function} [cb] Callback function.
1301
- * @returns {Promise|undefined}
1302
- */
1303
- getUserRoles(...args) {
1304
- return this.users.getRoles(...args);
1305
- }
1306
-
1307
- /**
1308
- * Assign roles to a user
1309
- *
1310
- * @example
1311
- * var parms = { id : 'USER_ID'};
1312
- * var data = { "roles" :["role1"]};
1313
- *
1314
- * management.assignRolestoUser(params, data, function (err) {
1315
- * if (err) {
1316
- * // Handle error.
1317
- * }
1318
- *
1319
- * // User assigned roles.
1320
- * });
1321
- * @param {object} params params object
1322
- * @param {string} params.id user_id
1323
- * @param {object} data data object containing list of role IDs
1324
- * @param {string} data.roles Array of role IDs
1325
- * @param {Function} [cb] Callback function.
1326
- * @returns {Promise|undefined}
1327
- */
1328
- assignRolestoUser(...args) {
1329
- return this.users.assignRoles(...args);
1330
- }
1331
-
1332
- /**
1333
- * Assign users to a role
1334
- *
1335
- * @example
1336
- * var params = { id :'ROLE_ID'};
1337
- * var data = { "users" : ["userId1","userId2"]};
1338
- *
1339
- * management.roles.assignUsers(params, data, function (err, user) {
1340
- * if (err) {
1341
- * // Handle error.
1342
- * }
1343
- *
1344
- * // permissions added.
1345
- * });
1346
- * @param {string} params.id ID of the Role.
1347
- * @param {object} data permissions data
1348
- * @param {string} data.permissions Array of permissions
1349
- * @param {string} data.permissions.permission_name Name of a permission
1350
- * @param {string} data.permissions.resource_server_identifier Identifier for a resource
1351
- * @param {Function} [cb] Callback function.
1352
- * @returns {Promise|undefined}
1353
- */
1354
- assignUsersToRole(...args) {
1355
- return this.roles.assignUsers(...args);
1356
- }
1357
-
1358
- /**
1359
- * Remove roles from a user
1360
- *
1361
- * @example
1362
- * var parms = { id : 'USER_ID'};
1363
- * var data = { "roles" :["role1"]};
1364
- *
1365
- * management.removeRolesFromUser(params, data, function (err) {
1366
- * if (err) {
1367
- * // Handle error.
1368
- * }
1369
- *
1370
- * // User assigned roles.
1371
- * });
1372
- * @param {object} params params object
1373
- * @param {string} params.id user_id
1374
- * @param {string} data data object containing list of role IDs
1375
- * @param {string} data.roles Array of role IDs
1376
- * @param {Function} [cb] Callback function.
1377
- * @returns {Promise|undefined}
1378
- */
1379
- removeRolesFromUser(...args) {
1380
- return this.users.removeRoles(...args);
1381
- }
1382
-
1383
- /**
1384
- * Get user's permissions
1385
- *
1386
- * @example
1387
- * var params = { id: USER_ID, page: 0, per_page: 50, sort: 'date:-1', include_totals: true };
1388
- *
1389
- * management.getUserPermissions(params, function (err, logs) {
1390
- * if (err) {
1391
- * // Handle error.
1392
- * }
1393
- *
1394
- * console.log(logs);
1395
- * });
1396
- * @param {object} params Get permissions data.
1397
- * @param {string} params.id User id.
1398
- * @param {number} params.per_page Number of results per page.
1399
- * @param {number} params.page Page number, zero indexed.
1400
- * @param {string} params.sort The field to use for sorting. Use field:order where order is 1 for ascending and -1 for descending. For example date:-1.
1401
- * @param {boolean} params.include_totals true if a query summary must be included in the result, false otherwise. Default false;
1402
- * @param {Function} [cb] Callback function.
1403
- * @returns {Promise|undefined}
1404
- */
1405
- getUserPermissions(...args) {
1406
- return this.users.getPermissions(...args);
1407
- }
1408
-
1409
- /**
1410
- * Assign permissions to a user
1411
- *
1412
- * @example
1413
- * var parms = { id : 'USER_ID'};
1414
- * var data = { "permissions" : [{"permission_name" :"do:something" ,"resource_server_identifier" :"test123" }]};
1415
- *
1416
- * management.assignPermissionsToUser(params, data, function (err) {
1417
- * if (err) {
1418
- * // Handle error.
1419
- * }
1420
- *
1421
- * // User assigned permissions.
1422
- * });
1423
- * @param {object} params params object
1424
- * @param {string} params.id user_id
1425
- * @param {string} data data object containing list of permissions
1426
- * @param {string} data.permissions Array of permission IDs
1427
- * @param {Function} [cb] Callback function.
1428
- * @returns {Promise|undefined}
1429
- */
1430
- assignPermissionsToUser(...args) {
1431
- return this.users.assignPermissions(...args);
1432
- }
1433
-
1434
- /**
1435
- * Remove permissions from a user
1436
- *
1437
- * @example
1438
- * var parms = { id : 'USER_ID'};
1439
- * var data = { "permissions" : [{"permission_name" :"do:something" ,"resource_server_identifier" :"test123" }]};
1440
- *
1441
- * management.removePermissionsFromUser(params, data, function (err) {
1442
- * if (err) {
1443
- * // Handle error.
1444
- * }
1445
- *
1446
- * // User assigned permissions.
1447
- * });
1448
- * @param {object} params params object
1449
- * @param {string} params.id user_id
1450
- * @param {string} data data object containing list of permission IDs
1451
- * @param {string} data.permissions Array of permission IDs
1452
- * @param {Function} [cb] Callback function.
1453
- * @returns {Promise|undefined}
1454
- */
1455
- removePermissionsFromUser(...args) {
1456
- return this.users.removePermissions(...args);
1457
- }
1458
-
1459
- /**
1460
- * Get a list of a user's Guardian enrollments.
1461
- *
1462
- * @example
1463
- * management.getGuardianEnrollments({ id: USER_ID }, function (err, enrollments) {
1464
- * console.log(enrollments);
1465
- * });
1466
- * @param {object} data The user data object.
1467
- * @param {string} data.id The user id.
1468
- * @param {Function} [cb] Callback function.
1469
- * @returns {Promise|undefined}
1470
- */
1471
- getGuardianEnrollments(...args) {
1472
- return this.users.getGuardianEnrollments(...args);
1473
- }
1474
-
1475
- /**
1476
- * Generate new Guardian recovery code.
1477
- *
1478
- * @example
1479
- * management.regenerateRecoveryCode({ id: USER_ID }, function (err, newRecoveryCode) {
1480
- * console.log(newRecoveryCode);
1481
- * });
1482
- * @param {object} data The user data object.
1483
- * @param {string} data.id The user id.
1484
- * @param {Function} [cb] Callback function.
1485
- * @returns {Promise|undefined}
1486
- */
1487
- regenerateRecoveryCode(...args) {
1488
- return this.users.regenerateRecoveryCode(...args);
1489
- }
1490
-
1491
- /**
1492
- * Invalidate all remembered browsers for MFA.
1493
- *
1494
- * @example
1495
- * management.invalidateRememberBrowser({ id: USER_ID }, function (err) {
1496
- * if (err) {
1497
- * // Handle error.
1498
- * }
1499
- *
1500
- * // Invalidated all remembered browsers.
1501
- * });
1502
- * @param {object} data The user data object.
1503
- * @param {string} data.id The user id.
1504
- * @param {Function} [cb] Callback function.
1505
- * @returns {Promise|undefined}
1506
- */
1507
- invalidateRememberBrowser(...args) {
1508
- return this.users.invalidateRememberBrowser(...args);
1509
- }
1510
-
1511
- /**
1512
- * Get user blocks by its id.
1513
- *
1514
- * @example
1515
- * management.getUserBlocks({ id: USER_ID }, function (err, blocks) {
1516
- * if (err) {
1517
- * // Handle error.
1518
- * }
1519
- *
1520
- * console.log(blocks);
1521
- * });
1522
- * @param {object} params The user data object..
1523
- * @param {string} params.id The user id.
1524
- * @param {Function} [cb] Callback function
1525
- * @returns {Promise|undefined}
1526
- */
1527
- getUserBlocks(...args) {
1528
- return this.userBlocks.get(...args);
1529
- }
1530
-
1531
- /**
1532
- * Unblock an user by its id.
1533
- *
1534
- * @example
1535
- * management.unblockUser({ id: USER_ID }, function (err) {
1536
- * if (err) {
1537
- * // Handle error.
1538
- * }
1539
- *
1540
- * // User unblocked.
1541
- * });
1542
- * @param {object} params The user data object..
1543
- * @param {string} params.id The user id.
1544
- * @param {Function} [cb] Callback function
1545
- * @returns {Promise|undefined}
1546
- */
1547
- unblockUser(...args) {
1548
- return this.userBlocks.delete(...args);
1549
- }
1550
-
1551
- /**
1552
- * Get user blocks by its identifier.
1553
- *
1554
- * @example
1555
- * management.getUserBlocksByIdentifier({ identifier: USER_ID }, function (err, blocks) {
1556
- * if (err) {
1557
- * // Handle error.
1558
- * }
1559
- *
1560
- * console.log(blocks);
1561
- * });
1562
- * @param {object} params The user data object..
1563
- * @param {string} params.identifier The user identifier, any of: username, phone_number, email.
1564
- * @param {Function} [cb] Callback function
1565
- * @returns {Promise|undefined}
1566
- */
1567
- getUserBlocksByIdentifier(...args) {
1568
- return this.userBlocks.getByIdentifier(...args);
1569
- }
1570
-
1571
- /**
1572
- * Unblock an user by its id.
1573
- *
1574
- * @example
1575
- * management.unblockUserByIdentifier({ identifier: USER_ID }, function (err) {
1576
- * if (err) {
1577
- * // Handle error.
1578
- * }
1579
- *
1580
- * // User unblocked.
1581
- * });
1582
- * @param {object} params The user data object..
1583
- * @param {string} params.identifier The user identifier, any of: username, phone_number, email.
1584
- * @param {Function} [cb] Callback function
1585
- * @returns {Promise|undefined}
1586
- */
1587
- unblockUserByIdentifier(...args) {
1588
- return this.userBlocks.deleteByIdentifier(...args);
1589
- }
1590
-
1591
- /**
1592
- * Get a single Guardian enrollment.
1593
- *
1594
- * @example
1595
- * management.getGuardianEnrollment({ id: ENROLLMENT_ID }, function (err, enrollment) {
1596
- * console.log(enrollment);
1597
- * });
1598
- * @param {object} data The Guardian enrollment data object.
1599
- * @param {string} data.id The Guardian enrollment id.
1600
- * @param {Function} [cb] Callback function.
1601
- * @returns {Promise|undefined}
1602
- */
1603
- getGuardianEnrollment(...args) {
1604
- return this.guardian.getGuardianEnrollment(...args);
1605
- }
1606
-
1607
- /**
1608
- * Delete a user's Guardian enrollment.
1609
- *
1610
- * @example
1611
- * management.deleteGuardianEnrollment({ id: ENROLLMENT_ID }, function (err) {
1612
- * if (err) {
1613
- * // Handle error.
1614
- * }
1615
- *
1616
- * // Email provider deleted.
1617
- * });
1618
- * @param {object} data The Guardian enrollment data object.
1619
- * @param {string} data.id The Guardian enrollment id.
1620
- * @param {Function} [cb] Callback function.
1621
- * @returns {Promise|undefined}
1622
- */
1623
- deleteGuardianEnrollment(...args) {
1624
- return this.guardian.deleteGuardianEnrollment(...args);
1625
- }
1626
-
1627
- /**
1628
- * Get all blacklisted tokens.
1629
- *
1630
- * @example
1631
- * management.getBlacklistedTokens(function (err, tokens) {
1632
- * console.log(tokens.length);
1633
- * });
1634
- * @param {Function} [cb] Callback function.
1635
- * @returns {Promise|undefined}
1636
- */
1637
- getBlacklistedTokens(...args) {
1638
- return this.blacklistedTokens.getAll(...args);
1639
- }
1640
-
1641
- /**
1642
- * Blacklist a new token.
1643
- *
1644
- * @example
1645
- * var token = {
1646
- * aud: 'aud',
1647
- * jti: 'jti'
1648
- * };
1649
- *
1650
- * management.blacklistToken(token, function (err) {
1651
- * if (err) {
1652
- * // Handle error.
1653
- * }
1654
- *
1655
- * // Token blacklisted.
1656
- * });
1657
- * @param {object} token Token data.
1658
- * @param {string} token.aud Audience (your app client ID).
1659
- * @param {string} token.jti The JWT ID claim.
1660
- * @param {Function} [cb] Callback function.
1661
- * @returns {Promise|undefined}
1662
- */
1663
- blacklistToken(...args) {
1664
- return this.blacklistedTokens.add(...args);
1665
- }
1666
-
1667
- /**
1668
- * Create a new Email Template.
1669
- *
1670
- * @example
1671
- * management.createEmailTemplate(data, function (err) {
1672
- * if (err) {
1673
- * // Handle error.
1674
- * // Email Template created.
1675
- * });
1676
- * @param {object} data Email Template data object.
1677
- * @param {Function} [cb] Callback function.
1678
- * @returns {Promise|undefined}
1679
- */
1680
- createEmailTemplate(...args) {
1681
- return this.emailTemplates.create(...args);
1682
- }
1683
-
1684
- /**
1685
- * Get an Auth0 Email Template.
1686
- *
1687
- * @example
1688
- * management.getEmailTemplate({ name: EMAIL_TEMPLATE_NAME }, function (err, emailTemplate) {
1689
- * if (err) {
1690
- * // Handle error.
1691
- * }
1692
- *
1693
- * console.log(emailTemplate);
1694
- * });
1695
- * @param {object} params Email Template parameters.
1696
- * @param {string} params.name Template Name
1697
- * @param {Function} [cb] Callback function.
1698
- * @returns {Promise|undefined}
1699
- */
1700
- getEmailTemplate(...args) {
1701
- return this.emailTemplates.get(...args);
1702
- }
1703
-
1704
- /**
1705
- * Update an existing Email Template.
1706
- *
1707
- * @example
1708
- * var data = { from: 'new@email.com' };
1709
- * var params = { name: EMAIL_TEMPLATE_NAME };
1710
- *
1711
- * management.updateEmailTemplates(params, data, function (err, emailTemplate) {
1712
- * if (err) {
1713
- * // Handle error.
1714
- * }
1715
- *
1716
- * console.log(emailTemplate.from); // 'new@email.com'
1717
- * });
1718
- * @param {object} params Email Template parameters.
1719
- * @param {string} params.name Template Name
1720
- * @param {object} data Updated Email Template data.
1721
- * @param {Function} [cb] Callback function.
1722
- * @returns {Promise|undefined}
1723
- */
1724
- updateEmailTemplate(...args) {
1725
- return this.emailTemplates.update(...args);
1726
- }
1727
-
1728
- /**
1729
- * Get the email provider.
1730
- *
1731
- * @example
1732
- * management.getEmailProvider(function (err, provider) {
1733
- * console.log(provider.length);
1734
- * });
1735
- * @param {Function} [cb] Callback function.
1736
- * @param {object} [params] Clients parameters.
1737
- * @param {number} [params.fields] A comma separated list of fields to include or exclude (depending on include_fields) from the result, empty to retrieve: name, enabled, settings fields.
1738
- * @param {number} [params.include_fields] true if the fields specified are to be excluded from the result, false otherwise (defaults to true)
1739
- * @returns {Promise|undefined}
1740
- */
1741
- getEmailProvider(...args) {
1742
- return this.emailProvider.get(...args);
1743
- }
1744
-
1745
- /**
1746
- * Configure the email provider.
1747
- *
1748
- * @example
1749
- * management.configureEmailProvider(data, function (err) {
1750
- * if (err) {
1751
- * // Handle error.
1752
- * }
1753
- *
1754
- * // Email provider configured.
1755
- * });
1756
- * @param {object} data The email provider data object.
1757
- * @param {Function} [cb] Callback function.
1758
- * @returns {Promise|undefined}
1759
- */
1760
- configureEmailProvider(...args) {
1761
- return this.emailProvider.configure(...args);
1762
- }
1763
-
1764
- /**
1765
- * Delete email provider.
1766
- *
1767
- * @example
1768
- * management.deleteEmailProvider(function (err) {
1769
- * if (err) {
1770
- * // Handle error.
1771
- * }
1772
- *
1773
- * // Email provider deleted.
1774
- * });
1775
- * @param {Function} [cb] Callback function.
1776
- * @returns {Promise|undefined}
1777
- */
1778
- deleteEmailProvider(...args) {
1779
- return this.emailProvider.delete(...args);
1780
- }
1781
-
1782
- /**
1783
- * Update the email provider.
1784
- *
1785
- * @example
1786
- * management.updateEmailProvider(params, data, function (err, provider) {
1787
- * if (err) {
1788
- * // Handle error.
1789
- * }
1790
- *
1791
- * // Updated email provider.
1792
- * console.log(provider);
1793
- * });
1794
- * @param {object} params Email provider parameters.
1795
- * @param {object} data Updated email provider data.
1796
- * @param {Function} [cb] Callback function.
1797
- * @returns {Promise|undefined}
1798
- */
1799
- updateEmailProvider(...args) {
1800
- return this.emailProvider.update(...args);
1801
- }
1802
-
1803
- /**
1804
- * Get a the active users count.
1805
- *
1806
- * @example
1807
- * management.getActiveUsersCount(function (err, usersCount) {
1808
- * if (err) {
1809
- * // Handle error.
1810
- * }
1811
- *
1812
- * console.log(usersCount);
1813
- * });
1814
- * @param {Function} [cb] Callback function.
1815
- * @returns {Promise|undefined}
1816
- */
1817
- getActiveUsersCount(...args) {
1818
- return this.stats.getActiveUsersCount(...args);
1819
- }
1820
-
1821
- /**
1822
- * Get the daily stats.
1823
- *
1824
- * @example
1825
- * var params = {
1826
- * from: '{YYYYMMDD}', // First day included in the stats.
1827
- * to: '{YYYYMMDD}' // Last day included in the stats.
1828
- * };
1829
- *
1830
- * management.getDaily(params, function (err, stats) {
1831
- * if (err) {
1832
- * // Handle error.
1833
- * }
1834
- *
1835
- * console.log(stats);
1836
- * });
1837
- * @param {object} params Stats parameters.
1838
- * @param {string} params.from The first day in YYYYMMDD format.
1839
- * @param {string} params.to The last day in YYYYMMDD format.
1840
- * @param {Function} [cb] Callback function.
1841
- * @returns {Promise|undefined}
1842
- */
1843
- getDailyStats(...args) {
1844
- return this.stats.getDaily(...args);
1845
- }
1846
-
1847
- /**
1848
- * Get the tenant settings..
1849
- *
1850
- * @example
1851
- * management.getSettings(function (err, settings) {
1852
- * if (err) {
1853
- * // Handle error.
1854
- * }
1855
- *
1856
- * console.log(settings);
1857
- * });
1858
- * @param {Function} [cb] Callback function.
1859
- * @returns {Promise|undefined}
1860
- */
1861
- getTenantSettings(...args) {
1862
- return this.tenant.getSettings(...args);
1863
- }
1864
-
1865
- /**
1866
- * Update the tenant settings.
1867
- *
1868
- * @example
1869
- * management.updateTenantSettings(data, function (err) {
1870
- * if (err) {
1871
- * // Handle error.
1872
- * }
1873
- * });
1874
- * @param {object} data The new tenant settings.
1875
- * @param {Function} [cb] Callback function.
1876
- * @returns {Promise|undefined}
1877
- */
1878
- updateTenantSettings(...args) {
1879
- return this.tenant.updateSettings(...args);
1880
- }
1881
-
1882
- /**
1883
- * Get a job by its ID.
1884
- *
1885
- * @example
1886
- * var params = {
1887
- * id: '{JOB_ID}'
1888
- * };
1889
- *
1890
- * management.getJob(params, function (err, job) {
1891
- * if (err) {
1892
- * // Handle error.
1893
- * }
1894
- *
1895
- * // Retrieved job.
1896
- * console.log(job);
1897
- * });
1898
- * @param {object} params Job parameters.
1899
- * @param {string} params.id Job ID.
1900
- * @param {Function} [cb] Callback function.
1901
- * @returns {Promise|undefined}
1902
- */
1903
- getJob(...args) {
1904
- return this.jobs.get(...args);
1905
- }
1906
-
1907
- /**
1908
- * Given a path to a file and a connection id, create a new job that imports the
1909
- * users contained in the file or JSON string and associate them with the given
1910
- * connection.
1911
- *
1912
- * @example
1913
- * var params = {
1914
- * connection_id: '{CONNECTION_ID}',
1915
- * users: '{PATH_TO_USERS_FILE}' // or users_json: '{USERS_JSON_STRING}'
1916
- * };
1917
- *
1918
- * management.importUsers(params, function (err) {
1919
- * if (err) {
1920
- * // Handle error.
1921
- * }
1922
- * });
1923
- * @param {object} data Users import data.
1924
- * @param {string} data.connection_id connection_id of the connection to which users will be imported.
1925
- * @param {string} [data.users] Path to the users data file. Either users or users_json is mandatory.
1926
- * @param {string} [data.users_json] JSON data for the users.
1927
- * @param {boolean} [data.upsert] Whether to update users if they already exist (true) or to ignore them (false).
1928
- * @param {boolean} [data.send_completion_email] Whether to send a completion email to all tenant owners when the job is finished (true) or not (false).
1929
- * @param {Function} [cb] Callback function.
1930
- * @returns {Promise|undefined}
1931
- */
1932
- importUsers(...args) {
1933
- return this.jobs.importUsers(...args);
1934
- }
1935
-
1936
- /**
1937
- * Given a path to a file and a connection id, create a new job that imports the
1938
- * users contained in the file or JSON string and associate them with the given
1939
- * connection.
1940
- *
1941
- * @example
1942
- * var params = {
1943
- * connection_id: '{CONNECTION_ID}',
1944
- * users: '{PATH_TO_USERS_FILE}' // or users_json: '{USERS_JSON_STRING}'
1945
- * };
1946
- *
1947
- * management.importUsersJob(params, function (err) {
1948
- * if (err) {
1949
- * // Handle error.
1950
- * }
1951
- * });
1952
- * @param {object} data Users import data.
1953
- * @param {string} data.connection_id connection_id of the connection to which users will be imported.
1954
- * @param {string} [data.users] Path to the users data file. Either users or users_json is mandatory.
1955
- * @param {string} [data.users_json] JSON data for the users.
1956
- * @param {boolean} [data.upsert] Whether to update users if they already exist (true) or to ignore them (false).
1957
- * @param {boolean} [data.send_completion_email] Whether to send a completion email to all tenant owners when the job is finished (true) or not (false).
1958
- * @param {Function} [cb] Callback function.
1959
- * @returns {Promise|undefined}
1960
- */
1961
- importUsersJob(...args) {
1962
- return this.jobs.importUsersJob(...args);
1963
- }
1964
-
1965
- /**
1966
- * Export all users to a file using a long running job.
1967
- *
1968
- * @example
1969
- * var data = {
1970
- * connection_id: 'con_0000000000000001',
1971
- * format: 'csv',
1972
- * limit: 5,
1973
- * fields: [
1974
- * {
1975
- * "name": "user_id"
1976
- * },
1977
- * {
1978
- * "name": "name"
1979
- * },
1980
- * {
1981
- * "name": "email"
1982
- * },
1983
- * {
1984
- * "name": "identities[0].connection",
1985
- * "export_as": "provider"
1986
- * },
1987
- * {
1988
- * "name": "user_metadata.some_field"
1989
- * }
1990
- * ]
1991
- * }
1992
- *
1993
- * management.exportUsers(data, function (err, results) {
1994
- * if (err) {
1995
- * // Handle error.
1996
- * }
1997
- *
1998
- * // Retrieved job.
1999
- * console.log(results);
2000
- * });
2001
- * @param {object} data Users export data.
2002
- * @param {string} [data.connection_id] The connection id of the connection from which users will be exported
2003
- * @param {string} [data.format] The format of the file. Valid values are: "json" and "csv".
2004
- * @param {number} [data.limit] Limit the number of records.
2005
- * @param {object[]} [data.fields] A list of fields to be included in the CSV. If omitted, a set of predefined fields will be exported.
2006
- * @param {Function} [cb] Callback function.
2007
- * @returns {Promise|undefined}
2008
- */
2009
- exportUsers(...args) {
2010
- return this.jobs.exportUsers(...args);
2011
- }
2012
-
2013
- /**
2014
- * Given a job ID, retrieve the failed/errored items
2015
- *
2016
- * @example
2017
- * var params = {
2018
- * id: '{JOB_ID}'
2019
- * };
2020
- *
2021
- * management.jobs.errors(params, function (err, job) {
2022
- * if (err) {
2023
- * // Handle error.
2024
- * }
2025
- *
2026
- * // Retrieved job.
2027
- * console.log(job);
2028
- * });
2029
- * @param {object} params Job parameters.
2030
- * @param {string} params.id Job ID.
2031
- * @param {Function} [cb] Callback function.
2032
- * @returns {Promise|undefined}
2033
- */
2034
- getJobErrors(...args) {
2035
- return this.jobs.errors(...args);
2036
- }
2037
-
2038
- /**
2039
- * Send a verification email to a user.
2040
- *
2041
- * @example
2042
- * var params = {
2043
- * user_id: '{USER_ID}'
2044
- * };
2045
- *
2046
- * management.sendEmailVerification(params, function (err) {
2047
- * if (err) {
2048
- * // Handle error.
2049
- * }
2050
- * });
2051
- * @param {object} data User data object.
2052
- * @param {string} data.user_id ID of the user to be verified.
2053
- * @param {string} [data.organization_id] Organization ID
2054
- * @param {string} [data.client_id] client_id of the client (application). If no value provided, the global Client ID will be used.
2055
- * @param {object} [data.identity] Used to verify secondary, federated, and passwordless-email identities.
2056
- * @param {string} data.identity.user_id user_id of the identity.
2057
- * @param {string} data.identity.provider provider of the identity.
2058
- * @param {Function} [cb] Callback function.
2059
- * @returns {Promise|undefined}
2060
- */
2061
- sendEmailVerification(...args) {
2062
- return this.jobs.verifyEmail(...args);
2063
- }
2064
-
2065
- /**
2066
- * Create a new password change ticket.
2067
- *
2068
- * @example
2069
- *
2070
- * var params = {
2071
- * result_url: '{REDIRECT_URL}', // Redirect after using the ticket.
2072
- * user_id: '{USER_ID}'
2073
- * };
2074
- *
2075
- * // or
2076
- *
2077
- * var params = {
2078
- * result_url: '{REDIRECT_URL}', // Redirect after using the ticket.
2079
- * email: '{USER_EMAIL}',
2080
- * connection_id: '{CONNECTION}' // eg. con_00000000001
2081
- * };
2082
- *
2083
- * auth0.createPasswordChangeTicket(params, function (err) {
2084
- * if (err) {
2085
- * // Handle error.
2086
- * }
2087
- * });
2088
- * @param {Function} [cb] Callback function.
2089
- * @returns {Promise}
2090
- */
2091
- createPasswordChangeTicket(...args) {
2092
- return this.tickets.changePassword(...args);
2093
- }
2094
-
2095
- /**
2096
- * Create an email verification ticket.
2097
- *
2098
- * @example
2099
- * var data = {
2100
- * user_id: '{USER_ID}',
2101
- * result_url: '{REDIRECT_URL}' // Optional redirect after the ticket is used.
2102
- * };
2103
- *
2104
- * auth0.createEmailVerificationTicket(data, function (err) {
2105
- * if (err) {
2106
- * // Handle error.
2107
- * }
2108
- * });
2109
- * @param {Function} [cb] Callback function.
2110
- * @returns {Promise}
2111
- */
2112
- createEmailVerificationTicket(...args) {
2113
- return this.tickets.verifyEmail(...args);
2114
- }
2115
-
2116
- /**
2117
- * Get an Auth0 log.
2118
- *
2119
- * @example
2120
- * management.getLog({ id: EVENT_ID }, function (err, log) {
2121
- * if (err) {
2122
- * // Handle error.
2123
- * }
2124
- *
2125
- * console.log(log);
2126
- * });
2127
- * @param {object} params Log parameters.
2128
- * @param {string} params.id Event ID.
2129
- * @param {Function} [cb] Callback function.
2130
- * @returns {Promise|undefined}
2131
- */
2132
- getLog(...args) {
2133
- return this.logs.get(...args);
2134
- }
2135
-
2136
- /**
2137
- * Get all logs.
2138
- *
2139
- * @example <caption>
2140
- * This method takes an optional object as first argument that may be used to
2141
- * specify pagination settings and the search query. If pagination options are
2142
- * not present, the first page of a limited number of results will be returned.
2143
- * </caption>
2144
- *
2145
- * // Pagination settings.
2146
- * var params = {
2147
- * per_page: 10,
2148
- * page: 2
2149
- * };
2150
- *
2151
- * management.getLogs(params, function (err, logs) {
2152
- * console.log(logs.length);
2153
- * });
2154
- * @param {object} [params] Logs params.
2155
- * @param {string} [params.q] Search Criteria using Query String Syntax
2156
- * @param {number} [params.page] Page number. Zero based
2157
- * @param {number} [params.per_page] The amount of entries per page
2158
- * @param {string} [params.sort] The field to use for sorting.
2159
- * @param {string} [params.fields] A comma separated list of fields to include or exclude
2160
- * @param {boolean} [params.include_fields] true if the fields specified are to be included in the result, false otherwise.
2161
- * @param {boolean} [params.include_totals] true if a query summary must be included in the result, false otherwise. Default false
2162
- * @param {Function} [cb] Callback function.
2163
- * @returns {Promise|undefined}
2164
- */
2165
- getLogs(...args) {
2166
- return this.logs.getAll(...args);
2167
- }
2168
-
2169
- /**
2170
- * Get all Log Streams.
2171
- *
2172
- *
2173
- *
2174
- * management.getLogStreams( function (err, logStreams) {
2175
- * console.log(logStreams.length);
2176
- * });
2177
- *
2178
- * @param {Function} [cb] Callback function.
2179
- * @returns {Promise|undefined}
2180
- */
2181
- getLogStreams(...args) {
2182
- return this.logStreams.getAll(...args);
2183
- }
2184
-
2185
- /**
2186
- * Create a new Log Stream.
2187
- *
2188
- * @example
2189
- * management.createLogStream(data, function (err) {
2190
- * if (err) {
2191
- * // Handle error.
2192
- * }
2193
- *
2194
- * // Log Stream created.
2195
- * });
2196
- * @param {object} data Log Stream data.
2197
- * @param {Function} [cb] Callback function.
2198
- * @returns {Promise|undefined}
2199
- */
2200
- createLogStream(...args) {
2201
- return this.logStreams.create(...args);
2202
- }
2203
-
2204
- /**
2205
- * Get an Auth0 Log Stream.
2206
- *
2207
- * @example
2208
- * management.getLogStream({ id: LOG_STREAM_ID }, function (err, logStream) {
2209
- * if (err) {
2210
- * // Handle error.
2211
- * }
2212
- *
2213
- * console.log(logStream);
2214
- * });
2215
- * @param {object} params Log Stream parameters.
2216
- * @param {string} params.id Log Stream ID.
2217
- * @param {Function} [cb] Callback function.
2218
- * @returns {Promise|undefined}
2219
- */
2220
- getLogStream(...args) {
2221
- return this.logStreams.get(...args);
2222
- }
2223
-
2224
- /**
2225
- * Delete an existing Log Stream.
2226
- *
2227
- * @example
2228
- * management.deleteLogStream({ id: LOG_STREAM_ID }, function (err) {
2229
- * if (err) {
2230
- * // Handle error.
2231
- * }
2232
- *
2233
- * // Log Stream deleted.
2234
- * });
2235
- * @param {object} params Log Stream parameters.
2236
- * @param {string} params.id Log Stream ID.
2237
- * @param {Function} [cb] Callback function.
2238
- * @returns {Promise|undefined}
2239
- */
2240
- deleteLogStream(...args) {
2241
- return this.logStreams.delete(...args);
2242
- }
2243
-
2244
- /**
2245
- * Update an existing Log Stream.
2246
- *
2247
- * @example
2248
- * var params = { id: LOG_STREAM_ID };
2249
- * var data = { name: 'my-log-stream'};
2250
- * management.updateLogStream(params, data, function (err, logStream) {
2251
- * if (err) {
2252
- * // Handle error.
2253
- * }
2254
- *
2255
- * console.log(logStream.name); // 'my-log-stream'.
2256
- * });
2257
- * @param {object} params Rule parameters.
2258
- * @param {string} params.id Rule ID.
2259
- * @param {object} data Updated rule data.
2260
- * @param {Function} [cb] Callback function.
2261
- * @returns {Promise|undefined}
2262
- */
2263
- updateLogStream(...args) {
2264
- return this.logStreams.update(...args);
2265
- }
2266
-
2267
- /**
2268
- * Create a new resource server.
2269
- *
2270
- * @example
2271
- * management.createResourceServer(data, function (err) {
2272
- * if (err) {
2273
- * // Handle error.
2274
- * }
2275
- *
2276
- * // Resource Server created.
2277
- * });
2278
- * @param {object} data Resource Server data object.
2279
- * @param {Function} [cb] Callback function.
2280
- * @returns {Promise|undefined}
2281
- */
2282
- createResourceServer(...args) {
2283
- return this.resourceServers.create(...args);
2284
- }
2285
-
2286
- /**
2287
- * Get all resource servers.
2288
- *
2289
- * @example <caption>
2290
- * This method takes an optional object as first argument that may be used to
2291
- * specify pagination settings. If pagination options are not present,
2292
- * the first page of a limited number of results will be returned.
2293
- * </caption>
2294
- *
2295
- * // Pagination settings.
2296
- * var params = {
2297
- * per_page: 10,
2298
- * page: 0
2299
- * };
2300
- *
2301
- * management.getResourceServers(params, function (err, resourceServers) {
2302
- * console.log(resourceServers.length);
2303
- * });
2304
- * @param {object} [params] Resource Servers parameters.
2305
- * @param {number} [params.per_page] Number of results per page.
2306
- * @param {number} [params.page] Page number, zero indexed.
2307
- * @param {Function} [cb] Callback function.
2308
- * @returns {Promise|undefined}
2309
- */
2310
- getResourceServers(...args) {
2311
- return this.resourceServers.getAll(...args);
2312
- }
2313
-
2314
- /**
2315
- * Get a Resource Server.
2316
- *
2317
- * @example
2318
- * management.getResourceServer({ id: RESOURCE_SERVER_ID }, function (err, resourceServer) {
2319
- * if (err) {
2320
- * // Handle error.
2321
- * }
2322
- *
2323
- * console.log(resourceServer);
2324
- * });
2325
- * @param {object} params Resource Server parameters.
2326
- * @param {string} params.id Resource Server ID.
2327
- * @param {Function} [cb] Callback function.
2328
- * @returns {Promise|undefined}
2329
- */
2330
- getResourceServer(...args) {
2331
- return this.resourceServers.get(...args);
2332
- }
2333
-
2334
- /**
2335
- * Delete an existing resource server.
2336
- *
2337
- * @example
2338
- * management.deleteResourceServer({ id: RESOURCE_SERVER_ID }, function (err) {
2339
- * if (err) {
2340
- * // Handle error.
2341
- * }
2342
- *
2343
- * // Resource Server deleted.
2344
- * });
2345
- * @param {object} params Resource Server parameters.
2346
- * @param {string} params.id Resource Server ID.
2347
- * @param {Function} [cb] Callback function.
2348
- * @returns {Promise|undefined}
2349
- */
2350
- deleteResourceServer(...args) {
2351
- return this.resourceServers.delete(...args);
2352
- }
2353
-
2354
- /**
2355
- * Update an existing resource server.
2356
- *
2357
- * @example
2358
- * var data = { name: 'newResourceServerName' };
2359
- * var params = { id: RESOURCE_SERVER_ID };
2360
- *
2361
- * management.updateResourceServer(params, data, function (err, resourceServer) {
2362
- * if (err) {
2363
- * // Handle error.
2364
- * }
2365
- *
2366
- * console.log(resourceServer.name); // 'newResourceServerName'
2367
- * });
2368
- * @param {object} params Resource Server parameters.
2369
- * @param {string} params.id Resource Server ID.
2370
- * @param {object} data Updated Resource Server data.
2371
- * @param {Function} [cb] Callback function.
2372
- * @returns {Promise|undefined}
2373
- */
2374
- updateResourceServer(...args) {
2375
- return this.resourceServers.update(...args);
2376
- }
2377
-
2378
- /**
2379
- * Set a new rules config.
2380
- *
2381
- * @example
2382
- * var params = { key: RULE_CONFIG_KEY };
2383
- * var data = { value: RULES_CONFIG_VALUE };
2384
- *
2385
- * management.setRulesConfig(params, data, function (err, rulesConfig) {
2386
- * if (err) {
2387
- * // Handle error.
2388
- * }
2389
- *
2390
- * // Rules Config set.
2391
- * });
2392
- * @param {object} params Rule Config parameters.
2393
- * @param {string} params.key Rule Config key.
2394
- * @param {object} data Rule Config Data parameters.
2395
- * @param {string} data.value Rule Config Data value.
2396
- * @param {Function} [cb] Callback function.
2397
- * @returns {Promise|undefined}
2398
- */
2399
- setRulesConfig(...args) {
2400
- return this.rulesConfigs.set(...args);
2401
- }
2402
-
2403
- /**
2404
- * Get rules config.
2405
- *
2406
- * @param {Function} [cb] Callback function.
2407
- * @example
2408
- *
2409
- * management.getRulesConfigs(function (err, rulesConfigs) {
2410
- * if (err) {
2411
- * // Handle error.
2412
- * }
2413
- *
2414
- * // Get Rules Configs.
2415
- * });
2416
- * @returns {Promise|undefined}
2417
- */
2418
- getRulesConfigs(...args) {
2419
- return this.rulesConfigs.getAll(...args);
2420
- }
2421
-
2422
- /**
2423
- * Delete rules config.
2424
- *
2425
- * @example
2426
- *
2427
- * management.deleteRulesConfig({ key: RULE_CONFIG_KEY }, function (err) {
2428
- * if (err) {
2429
- * // Handle error.
2430
- * }
2431
- *
2432
- * // Rules Config deleted.
2433
- * });
2434
- * @param {object} params Rule Configs parameters.
2435
- * @param {string} params.key Rule Configs key.
2436
- * @param {Function} [cb] Callback function.
2437
- * @returns {Promise|undefined}
2438
- */
2439
- deleteRulesConfig(...args) {
2440
- return this.rulesConfigs.delete(...args);
2441
- }
2442
-
2443
- /**
2444
- * Create an Auth0 Custom Domain.
2445
- *
2446
- * @example
2447
- * management.createCustomDomain(data, function (err) {
2448
- * if (err) {
2449
- * // Handle error.
2450
- * }
2451
- *
2452
- * // CustomDomain created.
2453
- * });
2454
- * @param {object} data The custom domain data object.
2455
- * @param {Function} [cb] Callback function.
2456
- * @returns {Promise|undefined}
2457
- */
2458
- createCustomDomain(...args) {
2459
- return this.customDomains.create(...args);
2460
- }
2461
-
2462
- /**
2463
- * Get all Auth0 CustomDomains.
2464
- *
2465
- * @example
2466
- * management.getCustomDomains(function (err, customDomains) {
2467
- * console.log(customDomains.length);
2468
- * });
2469
- * @returns {Promise|undefined}
2470
- */
2471
- getCustomDomains(...args) {
2472
- return this.customDomains.getAll(...args);
2473
- }
2474
-
2475
- /**
2476
- * Get a Custom Domain.
2477
- *
2478
- * @example
2479
- * management.getCustomDomain({ id: CUSTOM_DOMAIN_ID }, function (err, customDomain) {
2480
- * if (err) {
2481
- * // Handle error.
2482
- * }
2483
- *
2484
- * console.log(customDomain);
2485
- * });
2486
- * @param {object} params Custom Domain parameters.
2487
- * @param {string} params.id Custom Domain ID.
2488
- * @param {Function} [cb] Callback function.
2489
- * @returns {Promise|undefined}
2490
- */
2491
- getCustomDomain(...args) {
2492
- return this.customDomains.get(...args);
2493
- }
2494
-
2495
- /**
2496
- * Verify a Custom Domain.
2497
- *
2498
- * @example
2499
- * management.verifyCustomDomain({ id: CUSTOM_DOMAIN_ID }, function (err, customDomain) {
2500
- * if (err) {
2501
- * // Handle error.
2502
- * }
2503
- *
2504
- * console.log(customDomain);
2505
- * });
2506
- * @param {object} params Custom Domain parameters.
2507
- * @param {string} params.id Custom Domain ID.
2508
- * @param {Function} [cb] Callback function.
2509
- * @returns {Promise|undefined}
2510
- */
2511
- verifyCustomDomain(...args) {
2512
- return this.customDomains.verify(...args);
2513
- }
2514
-
2515
- /**
2516
- * Delete a Custom Domain.
2517
- *
2518
- * @example
2519
- * management.deleteCustomDomain({ id: CUSTOM_DOMAIN_ID }, function (err) {
2520
- * if (err) {
2521
- * // Handle error.
2522
- * }
2523
- *
2524
- * // CustomDomain deleted.
2525
- * });
2526
- * @param {object} params Custom Domain parameters.
2527
- * @param {string} params.id Custom Domain ID.
2528
- * @param {Function} [cb] Callback function.
2529
- * @returns {Promise|undefined}
2530
- */
2531
- deleteCustomDomain(...args) {
2532
- return this.customDomains.delete(...args);
2533
- }
2534
-
2535
- /**
2536
- * Create a Guardian enrollment ticket.
2537
- *
2538
- * @example
2539
- * management.createGuardianEnrollmentTicket(function (err, ticket) {
2540
- * console.log(ticket);
2541
- * });
2542
- * @param {Function} [cb] Callback function.
2543
- * @returns {Promise|undefined}
2544
- */
2545
- createGuardianEnrollmentTicket(...args) {
2546
- return this.guardian.createEnrollmentTicket(...args);
2547
- }
2548
-
2549
- /**
2550
- * Get a list of Guardian factors and statuses.
2551
- *
2552
- * @example
2553
- * management.getGuardianFactors(function (err, factors) {
2554
- * console.log(factors.length);
2555
- * });
2556
- * @param {Function} [cb] Callback function.
2557
- * @returns {Promise|undefined}
2558
- */
2559
- getGuardianFactors(...args) {
2560
- return this.guardian.getFactors(...args);
2561
- }
2562
-
2563
- /**
2564
- * Get the settings of a Guardian factor.
2565
- *
2566
- * @example
2567
- * management.getGuardianFactorSettings({ name: 'duo' }, function (err, settings) {
2568
- * console.log(settings);
2569
- * });
2570
- * @param {object} params Factor parameters.
2571
- * @param {Function} [cb] Callback function.
2572
- * @returns {Promise|undefined}
2573
- */
2574
- getGuardianFactorSettings(...args) {
2575
- return this.guardian.getFactorSettings(...args);
2576
- }
2577
-
2578
- /**
2579
- * Get Guardian factor provider configuration
2580
- *
2581
- * @example
2582
- * management.getFactorProvider({ name: 'sms', provider: 'twilio'}, function (err, provider) {
2583
- * console.log(provider);
2584
- * });
2585
- * @param {object} params Factor provider parameters.
2586
- * @param {Function} [cb] Callback function.
2587
- * @returns {Promise|undefined}
2588
- */
2589
- getGuardianFactorProvider(...args) {
2590
- return this.guardian.getFactorProvider(...args);
2591
- }
2592
-
2593
- /**
2594
- * Update Guardian's factor provider
2595
- *
2596
- * @example
2597
- * management.updateGuardianFactorProvider({ name: 'sms', provider: 'twilio' }, {
2598
- * messaging_service_sid: 'XXXXXXXXXXXXXX',
2599
- * auth_token: 'XXXXXXXXXXXXXX',
2600
- * sid: 'XXXXXXXXXXXXXX'
2601
- * }, function (err, provider) {
2602
- * console.log(provider);
2603
- * });
2604
- * @param {object} params Factor provider parameters.
2605
- * @param {object} data Updated Factor provider data.
2606
- * @param {Function} [cb] Callback function.
2607
- * @returns {Promise|undefined}
2608
- */
2609
- updateGuardianFactorProvider(...args) {
2610
- return this.guardian.updateFactorProvider(...args);
2611
- }
2612
-
2613
- /**
2614
- * Update a Guardian's factor settings
2615
- *
2616
- * @example
2617
- * management.updateGuardianFactorSettings(
2618
- * { name: 'webauthn-roaming' },
2619
- * { userVerification: 'discouraged', overrideRelyingParty: false },
2620
- * function (err, settings) {
2621
- * console.log(settings);
2622
- * })
2623
- * @param {object} params Factor parameters.
2624
- * @param {object} data Updated Factor settings data.
2625
- * @param {Function} [cb] Callback function.
2626
- * @returns {Promise|undefined}
2627
- */
2628
- updateGuardianFactorSettings(...args) {
2629
- return this.guardian.updateFactorSettings(...args);
2630
- }
2631
-
2632
- /**
2633
- * Get Guardian enrollment and verification factor templates
2634
- *
2635
- * @example
2636
- * management.getGuardianFactorTemplates({ name: 'sms' }, function (err, templates) {
2637
- * console.log(templates);
2638
- * });
2639
- * @param {object} params Factor parameters.
2640
- * @param {Function} [cb] Callback function.
2641
- * @returns {Promise|undefined}
2642
- */
2643
- getGuardianFactorTemplates(...args) {
2644
- return this.guardian.getFactorTemplates(...args);
2645
- }
2646
-
2647
- /**
2648
- * Update Guardian enrollment and verification factor templates
2649
- *
2650
- * @example
2651
- * management.updateGuardianFactorTemplates({ name: 'sms' }, {
2652
- * enrollment_message: "{{code}} is your verification code for {{tenant.friendly_name}}. Please enter this code to verify your enrollment.",
2653
- * verification_message: "{{code}} is your verification code for {{tenant.friendly_name}}"
2654
- * }, function (err, templates) {
2655
- * console.log(templates);
2656
- * });
2657
- * @param {object} params Factor parameters.
2658
- * @param {object} data Updated factor templates data.
2659
- * @param {Function} [cb] Callback function.
2660
- * @returns {Promise|undefined}
2661
- */
2662
- updateGuardianFactorTemplates(...args) {
2663
- return this.guardian.updateFactorTemplates(...args);
2664
- }
2665
-
2666
- /**
2667
- * Update Guardian Factor
2668
- *
2669
- * @example
2670
- * management.updateGuardianFactor({ name: 'sms' }, {
2671
- * enabled: true
2672
- * }, function (err, factor) {
2673
- * console.log(factor);
2674
- * });
2675
- * @param {object} params Factor parameters.
2676
- * @param {object} data Updated factor data.
2677
- * @param {Function} [cb] Callback function.
2678
- * @returns {Promise|undefined}
2679
- */
2680
- updateGuardianFactor(...args) {
2681
- return this.guardian.updateFactor(...args);
2682
- }
2683
-
2684
- /**
2685
- * Get enabled Guardian policies
2686
- *
2687
- * @example
2688
- * management.getGuardianPolicies(function (err, policies) {
2689
- * console.log(policies);
2690
- * });
2691
- * @param {Function} [cb] Callback function.
2692
- * @returns {Promise|undefined}
2693
- */
2694
- getGuardianPolicies(...args) {
2695
- return this.guardian.getPolicies(...args);
2696
- }
2697
-
2698
- /**
2699
- * Update enabled Guardian policies
2700
- *
2701
- * @example
2702
- * management.updateGuardianPolicies({}, [
2703
- * 'all-applications'
2704
- * ], function (err, policies) {
2705
- * console.log(policies);
2706
- * });
2707
- * @param {object} params Parameters.
2708
- * @param {string[]} data Policies to enable. Empty array disables all policies.
2709
- * @param {Function} [cb] Callback function.
2710
- * @returns {Promise|undefined}
2711
- */
2712
- updateGuardianPolicies(...args) {
2713
- return this.guardian.updatePolicies(...args);
2714
- }
2715
-
2716
- /**
2717
- * Get the Guardian phone factor's selected provider
2718
- *
2719
- * @example
2720
- * management.getGuardianPhoneFactorSelectedProvider(function (err, selectedProvider) {
2721
- * console.log(selectedProvider);
2722
- * });
2723
- * @param {Function} [cb] Callback function.
2724
- * @returns {Promise|undefined}
2725
- */
2726
- getGuardianPhoneFactorSelectedProvider(...args) {
2727
- return this.guardian.getPhoneFactorSelectedProvider(...args);
2728
- }
2729
-
2730
- /**
2731
- * Update the Guardian phone factor's selected provider
2732
- *
2733
- * @example
2734
- * management.updateGuardianPhoneFactorSelectedProvider({}, {
2735
- * provider: 'twilio'
2736
- * }, function (err, factor) {
2737
- * console.log(factor);
2738
- * });
2739
- * @param {object} params Parameters.
2740
- * @param {object} data Updated selected provider data.
2741
- * @param {string} data.provider Name of the selected provider
2742
- * @param {Function} [cb] Callback function.
2743
- * @returns {Promise|undefined}
2744
- */
2745
- updateGuardianPhoneFactorSelectedProvider(...args) {
2746
- return this.guardian.updatePhoneFactorSelectedProvider(...args);
2747
- }
2748
-
2749
- /**
2750
- * Get the Guardian phone factor's message types
2751
- *
2752
- * @example
2753
- * management.getGuardianPhoneFactorMessageTypes(function (err, messageTypes) {
2754
- * console.log(messageTypes);
2755
- * });
2756
- * @param {Function} [cb] Callback function.
2757
- * @returns {Promise|undefined}
2758
- */
2759
- getGuardianPhoneFactorMessageTypes(...args) {
2760
- return this.guardian.getPhoneFactorMessageTypes(...args);
2761
- }
2762
-
2763
- /**
2764
- * Update the Guardian phone factor's message types
2765
- *
2766
- * @example
2767
- * management.updateGuardianPhoneFactorMessageTypes({}, {
2768
- * message_types: ['sms', 'voice']
2769
- * }, function (err, factor) {
2770
- * console.log(factor);
2771
- * });
2772
- * @param {object} params Parameters.
2773
- * @param {object} data Updated selected provider data.
2774
- * @param {string[]} data.message_types Message types (only `"sms"` and `"voice"` are supported).
2775
- * @param {Function} [cb] Callback function.
2776
- * @returns {Promise|undefined}
2777
- */
2778
- updateGuardianPhoneFactorMessageTypes(...args) {
2779
- return this.guardian.updatePhoneFactorMessageTypes(...args);
2780
- }
2781
-
2782
- /**
2783
- * Get all roles.
2784
- *
2785
- * @example <caption>
2786
- * This method takes an optional object as first argument that may be used to
2787
- * specify pagination settings. If pagination options are not present,
2788
- * the first page of a limited number of results will be returned.
2789
- * </caption>
2790
- *
2791
- * // Pagination settings.
2792
- * var params = {
2793
- * per_page: 10,
2794
- * page: 0
2795
- * };
2796
- *
2797
- * management.getRoles(params, function (err, roles) {
2798
- * console.log(roles.length);
2799
- * });
2800
- * @param {object} [params] Roles parameters.
2801
- * @param {number} [params.per_page] Number of results per page.
2802
- * @param {number} [params.page] Page number, zero indexed.
2803
- * @param {Function} [cb] Callback function.
2804
- * @returns {Promise|undefined}
2805
- */
2806
- getRoles(...args) {
2807
- return this.roles.getAll(...args);
2808
- }
2809
-
2810
- /**
2811
- * Create a new role.
2812
- *
2813
- * @example
2814
- * data = {"name": "test1","description": "123"}
2815
- * management.createRole(data, function (err) {
2816
- * if (err) {
2817
- * // Handle error.
2818
- * }
2819
- *
2820
- * // Role created.
2821
- * });
2822
- * @param {object} data Role data object.
2823
- * @param {Function} [cb] Callback function.
2824
- * @returns {Promise|undefined}
2825
- */
2826
- createRole(...args) {
2827
- return this.roles.create(...args);
2828
- }
2829
-
2830
- /**
2831
- * Get an Auth0 role.
2832
- *
2833
- * @example
2834
- * management.getRole({ id: ROLE_ID }, function (err, role) {
2835
- * if (err) {
2836
- * // Handle error.
2837
- * }
2838
- *
2839
- * console.log(role);
2840
- * });
2841
- * @param {object} params Role parameters.
2842
- * @param {string} params.id Role ID.
2843
- * @param {Function} [cb] Callback function.
2844
- * @returns {Promise|undefined}
2845
- */
2846
- getRole(...args) {
2847
- return this.roles.get(...args);
2848
- }
2849
-
2850
- /**
2851
- * Delete an existing role.
2852
- *
2853
- * @example
2854
- * management.deleteRole({ id: ROLE_ID }, function (err) {
2855
- * if (err) {
2856
- * // Handle error.
2857
- * }
2858
- *
2859
- * // Role deleted.
2860
- * });
2861
- * @param {object} params Role parameters.
2862
- * @param {string} params.id Role ID.
2863
- * @param {Function} [cb] Callback function.
2864
- * @returns {Promise|undefined}
2865
- */
2866
- deleteRole(...args) {
2867
- return this.roles.delete(...args);
2868
- }
2869
-
2870
- /**
2871
- * Update an existing role.
2872
- *
2873
- * @example
2874
- * var params = { id: ROLE_ID };
2875
- * var data = { name: 'my-role'};
2876
- * management.updateRole(params, data, function (err, role) {
2877
- * if (err) {
2878
- * // Handle error.
2879
- * }
2880
- *
2881
- * console.log(role.name); // 'my-role'.
2882
- * });
2883
- * @param {object} params Role parameters.
2884
- * @param {string} params.id Role ID.
2885
- * @param {object} data Updated role data.
2886
- * @param {Function} [cb] Callback function.
2887
- * @returns {Promise|undefined}
2888
- */
2889
- updateRole(...args) {
2890
- return this.roles.update(...args);
2891
- }
2892
-
2893
- /**
2894
- * Get permissions for a given role
2895
- *
2896
- * @example
2897
- * var params = { id :'ROLE_ID'};
2898
- * @example <caption>
2899
- * This method takes a roleId and
2900
- * returns all permissions within that role
2901
- *
2902
- * </caption>
2903
- *
2904
- * management.getPermissionsInRole(params, function (err, permissions) {
2905
- * console.log(permissions);
2906
- * });
2907
- * @param {string} [roleId] Id of the role
2908
- * @param {Function} [cb] Callback function.
2909
- * @returns {Promise|undefined}
2910
- */
2911
- getPermissionsInRole(...args) {
2912
- return this.roles.getPermissions(...args);
2913
- }
2914
-
2915
- /**
2916
- * Add permissions in a role
2917
- *
2918
- * @example
2919
- * var params = { id :'ROLE_ID'};
2920
- * var data = { "permissions" : [{"permission_name" :"do:something" ,"resource_server_identifier" :"test123" }]};
2921
- *
2922
- * management.addPermissionsInRole(params, data, function (err, permissions) {
2923
- * console.log(permissions);
2924
- * });
2925
- * @param {string} params.id ID of the Role.
2926
- * @param {object} data permissions data
2927
- * @param {string} data.permissions Array of permissions
2928
- * @param {string} data.permissions.permission_name Name of a permission
2929
- * @param {string} data.permissions.resource_server_identifier Identifier for a resource
2930
- * @param {Function} [cb] Callback function.
2931
- * @returns {Promise|undefined}
2932
- */
2933
- addPermissionsInRole(...args) {
2934
- return this.roles.addPermissions(...args);
2935
- }
2936
-
2937
- /**
2938
- * Remove permissions from a role
2939
- *
2940
- * @example
2941
- * var params = { id :'ROLE_ID'};
2942
- * var data = { "permissions" : [{"permission_name" :"do:something" ,"resource_server_identifier" :"test123" }]};
2943
- *
2944
- * management.removePermissionsFromRole(params, data, function (err, permissions) {
2945
- * console.log(permissions);
2946
- * });
2947
- * @param {string} params.id ID of the Role.
2948
- * @param {object} data permissions data
2949
- * @param {string} data.permissions Array of permissions
2950
- * @param {string} data.permissions.permission_name Name of a permission
2951
- * @param {string} data.permissions.resource_server_identifier Identifier for a resource
2952
- * @param {Function} [cb] Callback function.
2953
- * @returns {Promise|undefined}
2954
- */
2955
- removePermissionsFromRole(...args) {
2956
- return this.roles.removePermissions(...args);
2957
- }
2958
-
2959
- /**
2960
- * Get users in a given role
2961
- *
2962
- * @example
2963
- * var params = {
2964
- * id: 'ROLE_ID',
2965
- * per_page: 50,
2966
- * page: 0
2967
- * };
2968
- * @example <caption>
2969
- * This method takes a roleId and returns all users within that role. Supports offset (page, per_page) and checkpoint pagination (from, take). You must use checkpoint pagination to retrieve beyond the first 1000 records.
2970
- * </caption>
2971
- *
2972
- * management.getUsersInRole(params, function (err, users) {
2973
- * console.log(users);
2974
- * });
2975
- * @param {string} [id] Id of the role
2976
- * @param {number} [params.per_page] Number of results per page.
2977
- * @param {number} [params.page] Page number, zero indexed.
2978
- * @param {string} [params.from] Optional id from which to start selection.
2979
- * @param {number} [params.take] The total amount of entries to retrieve when using the from parameter. Defaults to 50.
2980
- * @param {Function} [cb] Callback function.
2981
- * @returns {Promise|undefined}
2982
- */
2983
- getUsersInRole(...args) {
2984
- return this.roles.getUsers(...args);
2985
- }
2986
-
2987
- /**
2988
- * Get all hooks.
2989
- *
2990
- * @example <caption>
2991
- * This method takes an optional object as first argument that may be used to
2992
- * specify pagination settings. If pagination options are not present,
2993
- * the first page of a limited number of results will be returned.
2994
- * </caption>
2995
- *
2996
- * // Pagination settings.
2997
- * var params = {
2998
- * per_page: 10,
2999
- * page: 0
3000
- * };
3001
- *
3002
- * management.getHooks(params, function (err, hooks) {
3003
- * console.log(hooks.length);
3004
- * });
3005
- * @param {object} [params] Hooks parameters.
3006
- * @param {number} [params.per_page] Number of results per page.
3007
- * @param {number} [params.page] Page number, zero indexed.
3008
- * @param {Function} [cb] Callback function.
3009
- * @returns {Promise|undefined}
3010
- */
3011
- getHooks(...args) {
3012
- return this.hooks.getAll(...args);
3013
- }
3014
-
3015
- /**
3016
- * Get an Auth0 hook.
3017
- *
3018
- * @example
3019
- * management.getHook({ id: HOOK_ID }, function (err, hook) {
3020
- * if (err) {
3021
- * // Handle error.
3022
- * }
3023
- *
3024
- * console.log(hook);
3025
- * });
3026
- * @param {object} params Hook parameters.
3027
- * @param {string} params.id Hook ID.
3028
- * @param {Function} [cb] Callback function.
3029
- * @returns {Promise|undefined}
3030
- */
3031
- getHook(...args) {
3032
- return this.hooks.get(...args);
3033
- }
3034
-
3035
- /**
3036
- * Create a new hook.
3037
- *
3038
- * @example
3039
- * management.createHook(data, function (err) {
3040
- * if (err) {
3041
- * // Handle error.
3042
- * }
3043
- *
3044
- * // Hook created.
3045
- * });
3046
- * @param {object} data Hook data object.
3047
- * @param {Function} [cb] Callback function.
3048
- * @returns {Promise|undefined}
3049
- */
3050
- createHook(...args) {
3051
- return this.hooks.create(...args);
3052
- }
3053
-
3054
- /**
3055
- * Update an existing hook.
3056
- *
3057
- * @example
3058
- * var params = { id: HOOK_ID };
3059
- * var data = { name: 'my-hook'};
3060
- * management.updateHook(params, data, function (err, hook) {
3061
- * if (err) {
3062
- * // Handle error.
3063
- * }
3064
- *
3065
- * console.log(hook.name); // 'my-hook'.
3066
- * });
3067
- * @param {object} params Hook parameters.
3068
- * @param {string} params.id Hook ID.
3069
- * @param {object} data Updated hook data.
3070
- * @param {Function} [cb] Callback function.
3071
- * @returns {Promise|undefined}
3072
- */
3073
- updateHook(...args) {
3074
- return this.hooks.update(...args);
3075
- }
3076
-
3077
- /**
3078
- * Delete an existing hook.
3079
- *
3080
- * @example
3081
- * auth0.deleteHook({ id: HOOK_ID }, function (err) {
3082
- * if (err) {
3083
- * // Handle error.
3084
- * }
3085
- *
3086
- * // Hook deleted.
3087
- * });
3088
- * @param {object} params Hook parameters.
3089
- * @param {string} params.id Hook ID.
3090
- * @param {Function} [cb] Callback function.
3091
- * @returns {Promise|undefined}
3092
- */
3093
- deleteHook(...args) {
3094
- return this.hooks.delete(...args);
3095
- }
3096
-
3097
- /**
3098
- * Get an Auth0 hook's secrets.
3099
- *
3100
- * @example
3101
- * var params = { id: HOOK_ID }
3102
- * management.getHookSecrets(params, function (err, secrets) {
3103
- * if (err) {
3104
- * // Handle error.
3105
- * }
3106
- *
3107
- * console.log(secrets);
3108
- * });
3109
- * @param {object} params Hook parameters.
3110
- * @param {string} params.id Hook ID.
3111
- * @param {Function} [cb] Callback function.
3112
- * @returns {Promise|undefined}
3113
- */
3114
- getHookSecrets(...args) {
3115
- return this.hooks.getSecrets(...args);
3116
- }
3117
-
3118
- /**
3119
- * Add hook screts.
3120
- *
3121
- * @example
3122
- * var params = { id: 'HOOK_ID' }
3123
- * var data = { DB_PASSWORD: 'password1', API_TOKEN: 'secret' }
3124
- * management.addHookScrets(params, data, function (err, secrets) {
3125
- * if (err) {
3126
- * // Handle error.
3127
- * }
3128
- *
3129
- * // Hook secrets created.
3130
- * });
3131
- * @param {object} params Hook parameters.
3132
- * @param {string} params.id Hook ID.
3133
- * @param {object} data Secrets key/value pairs
3134
- * @param {Function} [cb] Callback function.
3135
- * @returns {Promise|undefined}
3136
- */
3137
- addHookSecrets(...args) {
3138
- return this.hooks.addSecrets(...args);
3139
- }
3140
-
3141
- /**
3142
- * Update an existing hook.
3143
- *
3144
- * @example
3145
- * var params = { id: HOOK_ID };
3146
- * var data = { API_TOKEN: 'updated-secret'};
3147
- * management.updateHookSecrets(params, data, function (err, secrets) {
3148
- * if (err) {
3149
- * // Handle error.
3150
- * }
3151
- *
3152
- * console.log(secrets)
3153
- * });
3154
- * @param {object} params Hook parameters.
3155
- * @param {string} params.id Hook ID.
3156
- * @param {object} data Secrets key/value pairs
3157
- * @param {Function} [cb] Callback function.
3158
- * @returns {Promise|undefined}
3159
- */
3160
- updateHookSecrets(...args) {
3161
- return this.hooks.updateSecrets(...args);
3162
- }
3163
-
3164
- /**
3165
- * Delete an existing hook.
3166
- *
3167
- * @example
3168
- * var params = { id: HOOK_ID }
3169
- * var data = ['API_TOKEN', 'DB_PASSWORD']
3170
- * auth0.removeHookSecrets(params, data, function (err) {
3171
- * if (err) {
3172
- * // Handle error.
3173
- * }
3174
- *
3175
- * // Hook deleted.
3176
- * });
3177
- * @param {object} params Hook parameters.
3178
- * @param {string} params.id Hook ID.
3179
- * @param {object} data Secrets key/value pairs
3180
- * @param {Function} [cb] Callback function.
3181
- * @returns {Promise|undefined}
3182
- */
3183
- removeHookSecrets(...args) {
3184
- return this.hooks.removeSecrets(...args);
3185
- }
3186
-
3187
- /**
3188
- * Returns the access_token.
3189
- *
3190
- * @returns {Promise} Promise returning an access_token.
3191
- */
3192
- getAccessToken(...args) {
3193
- return this.tokenProvider.getAccessToken(...args);
3194
- }
3195
-
3196
- /**
3197
- * Update the branding settings.
3198
- *
3199
- * @example
3200
- * management.updateBrandingSettings(data, function (err, branding) {
3201
- * if (err) {
3202
- * // Handle error.
3203
- * }
3204
- *
3205
- * // Updated branding
3206
- * console.log(branding);
3207
- * });
3208
- * @param {object} params Branding parameters.
3209
- * @param {object} data Updated branding data.
3210
- * @param {Function} [cb] Callback function.
3211
- * @returns {Promise|undefined}
3212
- */
3213
- updateBrandingSettings(...args) {
3214
- return this.branding.updateSettings(...args);
3215
- }
3216
-
3217
- /**
3218
- * Get the branding settings..
3219
- *
3220
- * @example
3221
- * management.getBrandingSettings(data, function (err, branding) {
3222
- * if (err) {
3223
- * // Handle error.
3224
- * }
3225
- *
3226
- * // Branding
3227
- * console.log(branding);
3228
- * });
3229
- * @param {object} params Branding parameters.
3230
- * @param {object} data Branding data.
3231
- * @param {Function} [cb] Callback function.
3232
- * @returns {Promise|undefined}
3233
- */
3234
- getBrandingSettings(...args) {
3235
- return this.branding.getSettings(...args);
3236
- }
3237
-
3238
- /**
3239
- * Get the new universal login template.
3240
- *
3241
- * @example
3242
- * management.getBrandingUniversalLoginTemplate(data, function (err, template) {
3243
- * if (err) {
3244
- * // Handle error.
3245
- * }
3246
- *
3247
- * // Branding
3248
- * console.log(template);
3249
- * });
3250
- * @param {object} params Branding parameters (leave empty).
3251
- * @param {object} data Branding data (leave empty).
3252
- * @param {Function} [cb] Callback function.
3253
- * @returns {Promise|undefined}
3254
- */
3255
- getBrandingUniversalLoginTemplate(...args) {
3256
- return this.branding.getUniversalLoginTemplate(...args);
3257
- }
3258
-
3259
- /**
3260
- * Set the new universal login template.
3261
- *
3262
- * @example
3263
- * management.setBrandingUniversalLoginTemplate({}, { template: "a template" }, function (err, template) {
3264
- * if (err) {
3265
- * // Handle error.
3266
- * }
3267
- * });
3268
- * @param {object} params Branding parameters (leave empty).
3269
- * @param {object} template Branding data (object with template field).
3270
- * @param {Function} [cb] Callback function.
3271
- * @returns {Promise|undefined}
3272
- */
3273
- setBrandingUniversalLoginTemplate(...args) {
3274
- return this.branding.setUniversalLoginTemplate(...args);
3275
- }
3276
-
3277
- /**
3278
- * Delete the new universal login template.
3279
- *
3280
- * @example
3281
- * management.deleteBrandingUniversalLoginTemplate(template, function (err) {
3282
- * if (err) {
3283
- * // Handle error.
3284
- * }
3285
- * });
3286
- * @param {object} params Branding parameters (leave empty).
3287
- * @param {object} data Branding data (leave empty).
3288
- * @param {Function} [cb] Callback function.
3289
- * @returns {Promise|undefined}
3290
- */
3291
- deleteBrandingUniversalLoginTemplate(...args) {
3292
- return this.branding.deleteUniversalLoginTemplate(...args);
3293
- }
3294
-
3295
- /**
3296
- * Update the tenant migrations.
3297
- *
3298
- * @example
3299
- * data = { flags: { migration: true } };
3300
- * management.updateMigrations(data, function (err, migrations) {
3301
- * if (err) {
3302
- * // Handle error.
3303
- * }
3304
- *
3305
- * // Updated migrations flags
3306
- * console.log(migrations.flags);
3307
- * });
3308
- * @param {object} data Updated migrations data.
3309
- * @param {Function} [cb] Callback function.
3310
- * @returns {Promise|undefined}
3311
- */
3312
- updateMigrations(...args) {
3313
- return this.migrations.updateMigrations(...args);
3314
- }
3315
-
3316
- /**
3317
- * Get migrations flags
3318
- *
3319
- * @example
3320
- * management.getMigrations(function (err, migrations) {
3321
- * if (err) {
3322
- * // Handle error.
3323
- * }
3324
- *
3325
- * // Migration flags
3326
- * console.log(migrations.flags);
3327
- * });
3328
- * @param {Function} [cb] Callback function.
3329
- * @returns {Promise|undefined}
3330
- */
3331
- getMigrations(...args) {
3332
- return this.migrations.getMigrations(...args);
3333
- }
3334
-
3335
- /**
3336
- * Get prompts settings..
3337
- *
3338
- * @example
3339
- * management.getPromptsSettings(function (err, settings) {
3340
- * console.log(settings);
3341
- * });
3342
- * @param {Function} [cb] Callback function.
3343
- * @returns {Promise|undefined}
3344
- */
3345
- getPromptsSettings(...args) {
3346
- return this.prompts.getSettings(...args);
3347
- }
3348
-
3349
- /**
3350
- * Update prompts settings.
3351
- *
3352
- * @example
3353
- * management.updatePromptsSettings(data, function (err) {
3354
- * if (err) {
3355
- * // Handle error.
3356
- * }
3357
- * });
3358
- * @param {object} data The new prompts settings.
3359
- * @param {Function} [cb] Callback function.
3360
- * @returns {Promise|undefined}
3361
- */
3362
- updatePromptsSettings(...args) {
3363
- return this.prompts.updateSettings(...args);
3364
- }
3365
- /**
3366
- * Retrieve custom text for a specific prompt and language.
3367
- *
3368
- * @example
3369
- * var params = { prompt: PROMPT_NAME, language: LANGUAGE };
3370
- *
3371
- * management.prompts.getCustomTextByLanguage(params, function (err, customText) {
3372
- * console.log('CustomText', customText);
3373
- * });
3374
- * @param {object} params Data object.
3375
- * @param {string} params.prompt Name of the prompt.
3376
- * @param {string} params.language Language to retrieve.
3377
- * @param {Function} [cb] Callback function
3378
- * @returns {Promise|undefined}
3379
- */
3380
- getCustomTextByLanguage(...args) {
3381
- return this.prompts.getCustomTextByLanguage(...args);
3382
- }
3383
-
3384
- /**
3385
- * Set custom text for a specific prompt.
3386
- *
3387
- * @example
3388
- * var params = { prompt: PROMPT_NAME, language: LANGUAGE, body: BODY_OBJECT };
3389
- *
3390
- * management.prompts.updateCustomTextByLanguage(params, function (err, customText) {
3391
- * console.log('CustomText', customText);
3392
- * });
3393
- * @param {object} params Data object.
3394
- * @param {string} params.prompt Name of the prompt.
3395
- * @param {string} params.language Language to retrieve.
3396
- * @param {object} params.body An object containing custom dictionaries for a group of screens.
3397
- * @param {Function} [cb] Callback function
3398
- * @returns {Promise|undefined}
3399
- */
3400
- updateCustomTextByLanguage(...args) {
3401
- return this.prompts.updateCustomTextByLanguage(...args);
3402
- }
3403
- }
3404
-
3405
- module.exports = ManagementClient;