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,721 +0,0 @@
1
- const { ArgumentError } = require('rest-facade');
2
- const BaseManager = require('./BaseManager');
3
-
4
- /**
5
- * The organizations class provides a simple abstraction for performing CRUD operations
6
- * on Auth0 OrganizationsManager.
7
- */
8
- class OrganizationsManager extends BaseManager {
9
- /**
10
- * @param {object} options The client options.
11
- * @param {string} options.baseUrl The URL of the API.
12
- * @param {object} [options.headers] Headers to be included in all requests.
13
- * @param {object} [options.retry] Retry Policy Config
14
- */
15
- constructor(options) {
16
- super(options);
17
-
18
- /**
19
- * Provides an abstraction layer for performing CRUD operations on
20
- * {@link https://auth0.com/docs/api/v2}.
21
- *
22
- * @type {external:RestClient}
23
- */
24
- this.organizations = this._getRestClient('/organizations/:id');
25
-
26
- this.connections = this._getRestClient('/organizations/:id/enabled_connections/:connection_id');
27
-
28
- this.members = this._getRestClient('/organizations/:id/members/:user_id');
29
-
30
- this.invitations = this._getRestClient('/organizations/:id/invitations/:invitation_id');
31
-
32
- this.roles = this._getRestClient('/organizations/:id/members/:user_id/roles');
33
-
34
- this.organizationsByName = this._getRestClient('/organizations/name/:name');
35
- }
36
-
37
- /**
38
- * Create a new organization.
39
- *
40
- * @example
41
- * management.organizations.create(data, function (err) {
42
- * if (err) {
43
- * // Handle error.
44
- * }
45
- *
46
- * // Organization created.
47
- * });
48
- * @param {object} data Organization data object.
49
- * @param {Function} [cb] Callback function.
50
- * @returns {Promise|undefined}
51
- */
52
- create(...args) {
53
- return this.organizations.create(...args);
54
- }
55
-
56
- /**
57
- * Get all organizations.
58
- *
59
- * @example <caption>
60
- * This method takes an optional object as first argument that may be used to
61
- * specify pagination settings. If pagination options are not present,
62
- * the first page of a limited number of results will be returned.
63
- * </caption>
64
- *
65
- * // Pagination settings.
66
- * var params = {
67
- * per_page: 10,
68
- * page: 0
69
- * };
70
- *
71
- * management.organizations.getAll(params, function (err, organizations) {
72
- * console.log(organizations.length);
73
- * });
74
- * @param {object} [params] Organizations parameters.
75
- * @param {number} [params.per_page] Number of results per page.
76
- * @param {number} [params.page] Page number, zero indexed.
77
- * @param {string} [params.from] For checkpoint pagination, the Id from which to start selection from.
78
- * @param {number} [params.take] For checkpoint pagination, the number of entries to retrieve. Default 50.
79
- * @param {Function} [cb] Callback function.
80
- * @returns {Promise|undefined}
81
- */
82
- getAll(...args) {
83
- return this.organizations.getAll(...args);
84
- }
85
-
86
- /**
87
- * Get an Auth0 organization.
88
- *
89
- * @example
90
- * management.organizations.getByID({ id: ORGANIZATION_ID }, function (err, role) {
91
- * if (err) {
92
- * // Handle error.
93
- * }
94
- *
95
- * console.log(organization);
96
- * });
97
- * @param {object} params Organization parameters.
98
- * @param {string} params.id Organization ID.
99
- * @param {Function} [cb] Callback function.
100
- * @returns {Promise|undefined}
101
- */
102
- getByID(...args) {
103
- return this.organizations.get(...args);
104
- }
105
-
106
- /**
107
- * Get an Auth0 organization.
108
- *
109
- * @example
110
- * management.organizations.getByName({ name: ORGANIZATION_NAME}, function (err, role) {
111
- * if (err) {
112
- * // Handle error.
113
- * }
114
- *
115
- * console.log(organization);
116
- * });
117
- * @param {object} params Organization parameters.
118
- * @param {string} params.name Organization name.
119
- * @param {Function} [cb] Callback function.
120
- * @returns {Promise|undefined}
121
- */
122
- getByName(...args) {
123
- return this.organizationsByName.get(...args);
124
- }
125
-
126
- /**
127
- * Update an existing organization.
128
- *
129
- * @example
130
- * var data = { display_name: 'New name' };
131
- * var params = { id: ORGANIZATION_ID };
132
- *
133
- * management.organizations.update(params, data, function (err, organization) {
134
- * if (err) {
135
- * // Handle error.
136
- * }
137
- *
138
- * console.log(organization.name); // 'New name'
139
- * });
140
- * @param {object} params Organization parameters.
141
- * @param {string} params.id Organization ID.
142
- * @param {object} data Updated organization data.
143
- * @param {Function} [cb] Callback function.
144
- * @returns {Promise|undefined}
145
- */
146
- update(...args) {
147
- return this.organizations.patch(...args);
148
- }
149
-
150
- /**
151
- * Delete an existing organization.
152
- *
153
- * @example
154
- * management.organizations.delete({ id: ORGANIZATION_ID }, function (err) {
155
- * if (err) {
156
- * // Handle error.
157
- * }
158
- *
159
- * // Organization deleted.
160
- * });
161
- * @param {object} params Organization parameters.
162
- * @param {string} params.id Organization ID.
163
- * @param {Function} [cb] Callback function.
164
- * @returns {Promise|undefined}
165
- */
166
- delete(...args) {
167
- return this.organizations.delete(...args);
168
- }
169
-
170
- /**
171
- *Organization Connections
172
- */
173
-
174
- /**
175
- * Get Enabled Connections in a Organization
176
- *
177
- * @example <caption>
178
- * This method takes an organization ID and returns the enabled connections in an Organization
179
- * </caption>
180
- * var params = {id : 'ORGANIZATION_ID'}
181
- *
182
- * management.organizations.getEnabledConnections( {id : 'ORGANIZATION_ID'}, function (err, enabled_connections) {
183
- * console.log(enabled_connections);
184
- * });
185
- * @param {object} params Organization parameters.
186
- * @param {string} params.id Organization ID.
187
- * @param {Function} [cb] Callback function.
188
- * @returns {Promise|undefined}
189
- */
190
- getEnabledConnections(params, callback) {
191
- return this.connections.getAll(params, callback);
192
- }
193
-
194
- /**
195
- * Get Enabled Connection in a Organization
196
- *
197
- * @example <caption>
198
- * This methods takes the organization ID and connection ID and returns the enabled connection
199
- * </caption>
200
- * var params = {id : 'ORGANIZATION_ID', connection_id: 'CONNECTION_ID'}
201
- *
202
- * management.organizations.getEnabledConnections( {id : 'ORGANIZATION_ID', connection_id: 'CONNECTION_ID'}, function (err, enabled_connection) {
203
- * console.log(enabled_connection);
204
- * });
205
- * @param {object} params Organization parameters.
206
- * @param {string} params.id Organization ID.
207
- * @param {string} params.connection_id Connection ID.
208
- * @param {Function} [callback] Callback function.
209
- * @returns {Promise|undefined}
210
- */
211
- getEnabledConnection(params, callback) {
212
- return this.connections.get(params, callback);
213
- }
214
-
215
- /**
216
- * Add an enabled connection for an organization
217
- *
218
- * @example
219
- * var params = { id :'ORGANIZATION_ID'};
220
- * var data = { "connection_id" : "CONNECTION_ID", assign_membership_on_login: false };
221
- *
222
- * management.organizations.addEnabledConnection(params, data, function (err) {
223
- * if (err) {
224
- * // Handle error.
225
- * }
226
- * });
227
- * @param {object} params Organization parameters
228
- * @param {string} params.id ID of the Organization.
229
- * @param {object} data enable connection data
230
- * @param {string} data.connection_id connection ID to enable
231
- * @param {boolean} data.assign_membership_on_login flag to allow assign membership on login
232
- * @param {Function} [cb] Callback function.
233
- * @returns {Promise|undefined}
234
- */
235
-
236
- addEnabledConnection(params, data, cb) {
237
- data = data || {};
238
- params = params || {};
239
-
240
- if (!params.id) {
241
- throw new ArgumentError('The organization ID passed in params cannot be null or undefined');
242
- }
243
- if (typeof params.id !== 'string') {
244
- throw new ArgumentError('The organization ID has to be a string');
245
- }
246
-
247
- if (cb && cb instanceof Function) {
248
- return this.connections.create(params, data, cb);
249
- }
250
-
251
- return this.connections.create(params, data);
252
- }
253
-
254
- /**
255
- * Remove an enabled connection from an organization
256
- *
257
- * @example
258
- * var params = { id :'ORGANIZATION_ID', connection_id: 'CONNECTION_ID' };
259
- *
260
- * management.organizations.removeEnabledConnection(params, function (err) {
261
- * if (err) {
262
- * // Handle error.
263
- * }
264
- * });
265
- * @param {object} params Organization parameters
266
- * @param {string} params.id ID of the Organization.
267
- * @param {string} params.connection_id ID of the Connection.
268
- * @param {Function} [cb] Callback function.
269
- * @returns {Promise|undefined}
270
- */
271
-
272
- removeEnabledConnection(params, cb) {
273
- params = params || {};
274
-
275
- if (!params.id) {
276
- throw new ArgumentError('The organization ID passed in params cannot be null or undefined');
277
- }
278
- if (typeof params.id !== 'string') {
279
- throw new ArgumentError('The organization ID has to be a string');
280
- }
281
-
282
- if (!params.connection_id) {
283
- throw new ArgumentError('The connection ID passed in params cannot be null or undefined');
284
- }
285
- if (typeof params.connection_id !== 'string') {
286
- throw new ArgumentError('The connection ID has to be a string');
287
- }
288
-
289
- if (cb && cb instanceof Function) {
290
- return this.connections.delete(params, {}, cb);
291
- }
292
-
293
- return this.connections.delete(params, {});
294
- }
295
-
296
- /**
297
- * Update an enabled connection from an organization
298
- *
299
- * @example
300
- * var params = { id :'ORGANIZATION_ID', connection_id: 'CONNECTION_ID' };
301
- * var data = { assign_membership_on_login: true };
302
- *
303
- * management.organizations.updateEnabledConnection(params, data, function (err) {
304
- * if (err) {
305
- * // Handle error.
306
- * }
307
- * });
308
- * @param {object} params Organization parameters
309
- * @param {string} params.id ID of the Organization.
310
- * @param {string} params.connection_id ID of the Connection.
311
- * @param {object} data Updated connection.
312
- * @param {Function} [cb] Callback function.
313
- * @returns {Promise|undefined}
314
- */
315
-
316
- updateEnabledConnection(params, data, cb) {
317
- data = data || {};
318
- params = params || {};
319
-
320
- if (!params.id) {
321
- throw new ArgumentError('The organization ID passed in params cannot be null or undefined');
322
- }
323
- if (typeof params.id !== 'string') {
324
- throw new ArgumentError('The organization ID has to be a string');
325
- }
326
-
327
- if (!params.connection_id) {
328
- throw new ArgumentError('The connection ID passed in params cannot be null or undefined');
329
- }
330
- if (typeof params.connection_id !== 'string') {
331
- throw new ArgumentError('The connection ID has to be a string');
332
- }
333
-
334
- if (cb && cb instanceof Function) {
335
- return this.connections.patch(params, data, cb);
336
- }
337
-
338
- return this.connections.patch(params, data);
339
- }
340
-
341
- /**
342
- *Organization Members
343
- */
344
-
345
- /**
346
- * Get Members in a Organization
347
- *
348
- * @example <caption>
349
- * This method takes an organization ID and returns the members in an Organization
350
- * </caption>
351
- *
352
- * var params = {id : 'ORGANIZATION_ID'}
353
- *
354
- * management.organizations.getMembers( {id : 'ORGANIZATION_ID'}, function (err, members) {
355
- * console.log(members);
356
- * });
357
- * @param {object} params Organization parameters
358
- * @param {string} params.id Organization ID
359
- * @param {string} [params.from] For checkpoint pagination, the Id from which to start selection from.
360
- * @param {number} [params.take] For checkpoint pagination, the number of entries to retrieve. Default 50.
361
- * @param {Function} [cb] Callback function.
362
- * @returns {Promise|undefined}
363
- */
364
- getMembers(params, callback) {
365
- return this.members.getAll(params, callback);
366
- }
367
-
368
- /**
369
- * Add members in an organization
370
- *
371
- * @example
372
- * var params = { id :'ORGANIZATION_ID'};
373
- * var data = { members: [ 'USER_ID1', 'USER_ID2' ] }
374
- * management.organizations.addMembers(params, data, function (err) {
375
- * if (err) {
376
- * // Handle error.
377
- * }
378
- * });
379
- * @param {object} params Organization parameters
380
- * @param {string} params.id ID of the Organization.
381
- * @param {object} data add members data
382
- * @param {Array} data.members Array of user IDs
383
- * @param {Function} [cb] Callback function.
384
- * @returns {Promise|undefined}
385
- */
386
- addMembers(params, data, cb) {
387
- data = data || {};
388
- params = params || {};
389
-
390
- if (!params.id) {
391
- throw new ArgumentError('The organization ID passed in params cannot be null or undefined');
392
- }
393
- if (typeof params.id !== 'string') {
394
- throw new ArgumentError('The organization ID has to be a string');
395
- }
396
-
397
- if (cb && cb instanceof Function) {
398
- return this.members.create(params, data, cb);
399
- }
400
-
401
- return this.members.create(params, data);
402
- }
403
-
404
- /**
405
- * Remove members from an organization
406
- *
407
- * @example
408
- * var params = { id :'ORGANIZATION_ID' };
409
- * var data = { members: [ 'USER_ID1', 'USER_ID2' ] }
410
- *
411
- * management.organizations.removeMembers(params, data, function (err) {
412
- * if (err) {
413
- * // Handle error.
414
- * }
415
- * });
416
- * @param {object} params Organization parameters
417
- * @param {string} params.id ID of the Organization.
418
- * @param {object} data add members data
419
- * @param {Array} data.members Array of user IDs
420
- * @param {Function} [cb] Callback function.
421
- * @returns {Promise|undefined}
422
- */
423
- removeMembers(params, data, cb) {
424
- data = data || {};
425
- params = params || {};
426
-
427
- if (!params.id) {
428
- throw new ArgumentError('The organization ID passed in params cannot be null or undefined');
429
- }
430
- if (typeof params.id !== 'string') {
431
- throw new ArgumentError('The organization ID has to be a string');
432
- }
433
-
434
- if (cb && cb instanceof Function) {
435
- return this.members.delete(params, data, cb);
436
- }
437
-
438
- return this.members.delete(params, data);
439
- }
440
-
441
- /**
442
- *Organization Invites
443
- */
444
-
445
- /**
446
- * Get Invites in a Organization
447
- *
448
- * @example
449
- * var params = {id : 'ORGANIZATION_ID'}
450
- * @example <caption>
451
- * This method takes an organization ID and returns the invites in an Organization
452
- * </caption>
453
- *
454
- * management.organizations.getInvitations( {id : 'ORGANIZATION_ID'}, function (err, invites) {
455
- * console.log(invites);
456
- * @param callback
457
- * });
458
- * @param {object} params Organization parameters
459
- * @param {string} params.id Organization ID
460
- * @param {number} [params.per_page] Number of results per page.
461
- * @param {number} [params.page] Page number, zero indexed.
462
- * @param {string} [params.from] For checkpoint pagination, the Id from which to start selection from.
463
- * @param {number} [params.take] For checkpoint pagination, the number of entries to retrieve. Default 50.
464
- * @param {string} [params.fields] Comma-separated list of fields to include or exclude (based on value provided for include_fields) in the result. Leave empty to retrieve all fields.
465
- * @param {boolean} [params.include_fields] Whether specified fields are to be included (true) or excluded (false). Defaults to true.
466
- * @param {string} [params.sort] Field to sort by. Use field:order where order is 1 for ascending and -1 for descending Defaults to created_at:-1.
467
- * @param {Function} [cb] Callback function.
468
- * @returns {Promise|undefined}
469
- */
470
- getInvitations(params, callback) {
471
- return this.invitations.getAll(params, callback);
472
- }
473
-
474
- /**
475
- * Get an Invitation in a Organization
476
- *
477
- * @example
478
- * var params = {id : 'ORGANIZATION_ID', invitation_id: 'INVITATION_ID'}
479
- * @param callback
480
- * @example <caption>
481
- * This methods takes the organization ID and user ID and returns the invitation
482
- * </caption>
483
- *
484
- * management.organizations.getInvitation({id : 'ORGANIZATION_ID', invitation_id: 'INVITATION_ID'}, function (err, invite) {
485
- * console.log(invite);
486
- * });
487
- * @param {object} params Organization parameters
488
- * @param {string} params.id Organization ID
489
- * @param {string} params.invitation_id Invitation ID
490
- * @param {Function} [cb] Callback function.
491
- * @returns {Promise|undefined}
492
- */
493
- getInvitation(params, callback) {
494
- if (!params.id) {
495
- throw new ArgumentError('The organization ID passed in params cannot be null or undefined');
496
- }
497
- if (typeof params.id !== 'string') {
498
- throw new ArgumentError('The organization ID has to be a string');
499
- }
500
-
501
- if (!params.invitation_id) {
502
- throw new ArgumentError('The invitation ID passed in params cannot be null or undefined');
503
- }
504
- if (typeof params.invitation_id !== 'string') {
505
- throw new ArgumentError('The invitation ID has to be a string');
506
- }
507
-
508
- return this.invitations.get(params, callback);
509
- }
510
-
511
- /**
512
- * Create an invitation in an organization
513
- *
514
- * @example
515
- * var params = { id :'ORGANIZATION_ID'};
516
- * var data = {
517
- * client_id: CLIENT_ID,
518
- * invitee: { email: 'invitee@example.com' },
519
- * inviter: { name: 'John Doe' }
520
- * };
521
- *
522
- * management.organizations.createInvitation(params, data, function (err) {
523
- * if (err) {
524
- * // Handle error.
525
- * }
526
- * });
527
- * @param {object} params Organization parameters
528
- * @param {string} params.id ID of the Organization.
529
- * @param {Array} data Invitation data
530
- * @param {object} data.inviter The person who is sending the invite.
531
- * @param {string} data.inviter.name Name of the person who is sending the invite
532
- * @param {object} data.invitee Invitee to whom invitation is intended for
533
- * @param {object} data.invitee.email Email of the invitee to whom invitation is intended for
534
- * @param {string} data.client_id Auth0 client used to resolve the default application login URI. This endpoint must expect &invitation=... and &organization=... parameters (added by API2) to continue the flow with /authorize. If client_id does not have configured login URI, use the tenant level default login route if configured, otherwise return 400
535
- * @param {string} [data.connection_id] Force user to authenticate against a specific identity provider.
536
- * @param {object} [data.app_metadata] Application metadata to be assigned to the user after accept the invitation.
537
- * @param {object} [data.user_metadata] User metadata to be assigned to the user after accept the invitation.
538
- * @param {Array} [data.roles] List of roles to be assigned to the user
539
- * @param {number} [data.ttl_sec] Number of seconds for which the invitation is valid before expiration. If unspecified or set to 0, this value defaults to 604800 seconds (7 days). Upper limit on ttl_sec is 30 days.
540
- * @param {boolean} [data.send_invitation_email] Whether the user will receive an invitation email (true) or no email (false). Default is true.
541
- * @param {Function} [cb] Callback function.
542
- * @returns {Promise|undefined}
543
- */
544
- createInvitation(params, data, cb) {
545
- data = data || [];
546
- params = params || {};
547
-
548
- if (!params.id) {
549
- throw new ArgumentError('The organization ID passed in params cannot be null or undefined');
550
- }
551
- if (typeof params.id !== 'string') {
552
- throw new ArgumentError('The organization ID has to be a string');
553
- }
554
-
555
- if (cb && cb instanceof Function) {
556
- return this.invitations.create(params, data, cb);
557
- }
558
-
559
- return this.invitations.create(params, data);
560
- }
561
-
562
- /**
563
- * Delete an invitation from an organization
564
- *
565
- * @example
566
- * var params = { id :'ORGANIZATION_ID', invitation_id: 'INVITATION_ID };
567
- *
568
- * management.organizations.deleteInvitation(params, function (err) {
569
- * if (err) {
570
- * // Handle error.
571
- * }
572
- * });
573
- * @param {object} params Organization parameters
574
- * @param {string} params.id ID of the Organization.
575
- * @param {string} params.invitation_id Invitation ID
576
- * @param {Function} [cb] Callback function.
577
- * @returns {Promise|undefined}
578
- */
579
- deleteInvitation(params, cb) {
580
- params = params || {};
581
-
582
- if (!params.id) {
583
- throw new ArgumentError('The organization ID passed in params cannot be null or undefined');
584
- }
585
- if (typeof params.id !== 'string') {
586
- throw new ArgumentError('The organization ID has to be a string');
587
- }
588
-
589
- if (!params.invitation_id) {
590
- throw new ArgumentError('The invitation ID passed in params cannot be null or undefined');
591
- }
592
- if (typeof params.invitation_id !== 'string') {
593
- throw new ArgumentError('The invitation ID has to be a string');
594
- }
595
-
596
- if (cb && cb instanceof Function) {
597
- return this.invitations.delete(params, {}, cb);
598
- }
599
-
600
- return this.invitations.delete(params, {});
601
- }
602
-
603
- /**
604
- *Organization Roles Membership
605
- */
606
-
607
- /**
608
- * Get Roles from a Member in a Organization
609
- *
610
- * @example
611
- * var params = {id : 'ORGANIZATION_ID', user_id: 'user_id'}
612
- * @param callback
613
- * @example <caption>
614
- * This methods takes the organization ID and user ID and returns the roles
615
- * </caption>
616
- *
617
- * management.organizations.getMemberRoles( {id : 'ORGANIZATION_ID', user_id: 'user_id'}, function (err, roles) {
618
- * console.log(roles);
619
- * });
620
- * @param {object} params Organization parameters
621
- * @param {string} params.id ID of the Organization.
622
- * @param {string} params.user_id ID of the user.
623
- * @param {Function} [cb] Callback function.
624
- * @returns {Promise|undefined}
625
- */
626
- getMemberRoles(params, callback) {
627
- return this.roles.getAll(params, callback);
628
- }
629
-
630
- /**
631
- * Add a Role to a Member in an organization
632
- *
633
- * @example
634
- * var params = {id : 'ORGANIZATION_ID', user_id: 'user_id'};
635
- * var data = { roles: ["ROLE_ID_1", "ROLE_ID_2"]}
636
- *
637
- * management.organizations.addMemberRoles(params, data, function (err) {
638
- * if (err) {
639
- * // Handle error.
640
- * }
641
- * });
642
- * @param {object} params Organization parameters
643
- * @param {string} params.id ID of the Organization.
644
- * @param {string} params.user_id ID of the user.
645
- * @param {object} data Add member roles data.
646
- * @param {Array} data.roles Array of role IDs.
647
- * @param {Function} [cb] Callback function.
648
- * @returns {Promise|undefined}
649
- */
650
- addMemberRoles(params, data, cb) {
651
- data = data || {};
652
- params = params || {};
653
-
654
- if (!params.id) {
655
- throw new ArgumentError('The organization ID passed in params cannot be null or undefined');
656
- }
657
- if (typeof params.id !== 'string') {
658
- throw new ArgumentError('The organization ID has to be a string');
659
- }
660
-
661
- if (!params.user_id) {
662
- throw new ArgumentError('The user ID passed in params cannot be null or undefined');
663
- }
664
- if (typeof params.user_id !== 'string') {
665
- throw new ArgumentError('The user ID has to be a string');
666
- }
667
-
668
- if (cb && cb instanceof Function) {
669
- return this.roles.create(params, data, cb);
670
- }
671
-
672
- return this.roles.create(params, data);
673
- }
674
-
675
- /**
676
- * Remove Roles from a Member of an organization
677
- *
678
- * @example
679
- * var params = { id :'ORGANIZATION_ID', user_id: 'USER_ID };
680
- * var data = { roles: ["ROLE_ID_1", "ROLE_ID_2"]}
681
- *
682
- * management.organizations.removeMemberRoles(params, data, function (err) {
683
- * if (err) {
684
- * // Handle error.
685
- * }
686
- * });
687
- * @param {object} params Organization parameters
688
- * @param {string} params.id ID of the Organization.
689
- * @param {string} params.user_id Id of the User
690
- * @param {object} data Remove member roles data.
691
- * @param {Array} data.roles Array of role IDs.
692
- * @param {Function} [cb] Callback function.
693
- * @returns {Promise|undefined}
694
- */
695
- removeMemberRoles(params, data, cb) {
696
- data = data || {};
697
- params = params || {};
698
-
699
- if (!params.id) {
700
- throw new ArgumentError('The organization ID passed in params cannot be null or undefined');
701
- }
702
- if (typeof params.id !== 'string') {
703
- throw new ArgumentError('The organization ID has to be a string');
704
- }
705
-
706
- if (!params.user_id) {
707
- throw new ArgumentError('The user ID passed in params cannot be null or undefined');
708
- }
709
- if (typeof params.user_id !== 'string') {
710
- throw new ArgumentError('The user ID has to be a string');
711
- }
712
-
713
- if (cb && cb instanceof Function) {
714
- return this.roles.delete(params, data, cb);
715
- }
716
-
717
- return this.roles.delete(params, data);
718
- }
719
- }
720
-
721
- module.exports = OrganizationsManager;