@wazo/sdk 0.37.34 → 0.37.37

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 (99) hide show
  1. package/README.md +8 -2
  2. package/dist/wazo-sdk.js +2 -2
  3. package/esm/__tests__/api-client.test.js +17 -0
  4. package/esm/__tests__/web-rtc-client.test.js +17 -0
  5. package/esm/api/auth.js +7 -1
  6. package/esm/api/call-logd.js +6 -0
  7. package/esm/api/chatd.js +6 -0
  8. package/esm/api/confd.js +6 -0
  9. package/esm/api-client.js +17 -0
  10. package/esm/checker/Checker.js +17 -0
  11. package/esm/checker/checks/aor.js +17 -0
  12. package/esm/checker/checks/api.js +17 -0
  13. package/esm/checker/checks/index.js +17 -0
  14. package/esm/checker/checks/webrtc-transport.js +17 -0
  15. package/esm/checker/checks/webrtc.js +17 -0
  16. package/esm/domain/AdHocAPIConference.js +21 -0
  17. package/esm/domain/CallLog.js +6 -0
  18. package/esm/domain/CallSession.js +14 -0
  19. package/esm/domain/Features.js +17 -0
  20. package/esm/domain/Phone/CTIPhone.js +31 -0
  21. package/esm/domain/Phone/WebRTCPhone.js +42 -11
  22. package/esm/domain/Profile.js +6 -0
  23. package/esm/domain/__tests__/CallLog.test.js +10 -0
  24. package/esm/domain/__tests__/CallSession.test.js +14 -0
  25. package/esm/domain/__tests__/IndirectTransfer.test.js +14 -0
  26. package/esm/domain/__tests__/Profile.test.js +6 -0
  27. package/esm/domain/__tests__/Room.test.js +14 -0
  28. package/esm/domain/__tests__/Session.test.js +6 -0
  29. package/esm/index.js +83 -18
  30. package/esm/service/CallApi.js +17 -0
  31. package/esm/service/getApiClient.js +17 -0
  32. package/esm/simple/Auth.js +84 -19
  33. package/esm/simple/Configuration.js +83 -18
  34. package/esm/simple/Directory.js +17 -0
  35. package/esm/simple/Phone.js +83 -18
  36. package/esm/simple/index.js +83 -18
  37. package/esm/simple/room/LocalParticipant.js +83 -18
  38. package/esm/simple/room/Participant.js +83 -18
  39. package/esm/simple/room/RemoteParticipant.js +83 -18
  40. package/esm/simple/room/Room.js +83 -18
  41. package/esm/simple/room/SipRoom.js +83 -18
  42. package/esm/simple/room/Stream.js +83 -18
  43. package/esm/simple/room/__tests__/RemoteParticipant.test.js +83 -18
  44. package/esm/simple/utils.js +83 -18
  45. package/esm/web-rtc-client.js +17 -0
  46. package/lib/__tests__/api-client.test.js +17 -0
  47. package/lib/__tests__/web-rtc-client.test.js +17 -0
  48. package/lib/api/auth.js +8 -0
  49. package/lib/api/call-logd.js +6 -0
  50. package/lib/api/chatd.js +6 -0
  51. package/lib/api/confd.js +6 -0
  52. package/lib/api-client.js +17 -0
  53. package/lib/checker/Checker.js +17 -0
  54. package/lib/checker/checks/aor.js +17 -0
  55. package/lib/checker/checks/api.js +17 -0
  56. package/lib/checker/checks/index.js +17 -0
  57. package/lib/checker/checks/webrtc-transport.js +17 -0
  58. package/lib/checker/checks/webrtc.js +17 -0
  59. package/lib/domain/AdHocAPIConference.js +21 -0
  60. package/lib/domain/CallLog.js +6 -0
  61. package/lib/domain/CallSession.js +14 -0
  62. package/lib/domain/Features.js +17 -0
  63. package/lib/domain/Phone/CTIPhone.js +31 -0
  64. package/lib/domain/Phone/WebRTCPhone.js +42 -11
  65. package/lib/domain/Profile.js +6 -0
  66. package/lib/domain/__tests__/CallLog.test.js +10 -0
  67. package/lib/domain/__tests__/CallSession.test.js +14 -0
  68. package/lib/domain/__tests__/IndirectTransfer.test.js +14 -0
  69. package/lib/domain/__tests__/Profile.test.js +6 -0
  70. package/lib/domain/__tests__/Room.test.js +14 -0
  71. package/lib/domain/__tests__/Session.test.js +6 -0
  72. package/lib/index.js +83 -18
  73. package/lib/service/CallApi.js +17 -0
  74. package/lib/service/getApiClient.js +17 -0
  75. package/lib/simple/Auth.js +84 -18
  76. package/lib/simple/Configuration.js +83 -18
  77. package/lib/simple/Directory.js +17 -0
  78. package/lib/simple/Phone.js +83 -18
  79. package/lib/simple/index.js +83 -18
  80. package/lib/simple/room/LocalParticipant.js +83 -18
  81. package/lib/simple/room/Participant.js +83 -18
  82. package/lib/simple/room/RemoteParticipant.js +83 -18
  83. package/lib/simple/room/Room.js +83 -18
  84. package/lib/simple/room/SipRoom.js +83 -18
  85. package/lib/simple/room/Stream.js +83 -18
  86. package/lib/simple/room/__tests__/RemoteParticipant.test.js +83 -18
  87. package/lib/simple/utils.js +83 -18
  88. package/lib/web-rtc-client.js +17 -0
  89. package/package.json +1 -1
  90. package/src/api/auth.js +7 -1
  91. package/src/domain/AdHocAPIConference.js +4 -0
  92. package/src/domain/CallLog.js +6 -0
  93. package/src/domain/CallSession.js +14 -0
  94. package/src/domain/Phone/WebRTCPhone.js +28 -11
  95. package/src/domain/Profile.js +6 -0
  96. package/src/domain/__tests__/CallLog.test.js +4 -0
  97. package/src/simple/Auth.js +13 -2
  98. package/src/simple/Phone.js +6 -6
  99. package/src/simple/index.js +2 -1
@@ -285,6 +285,7 @@ var updateFrom = (instance , from ) => {
285
285
 
286
286
 
287
287
 
288
+
288
289
 
289
290
 
290
291
  class CallSession {
@@ -347,6 +348,8 @@ class CallSession {
347
348
 
348
349
 
349
350
 
351
+
352
+
350
353
 
351
354
 
352
355
 
@@ -378,6 +381,7 @@ class CallSession {
378
381
  videoRemotelyDowngraded,
379
382
  sipSession,
380
383
  answerTime,
384
+ conference,
381
385
  } ) {
382
386
  this.callId = callId;
383
387
  this.sipCallId = sipCallId;
@@ -406,6 +410,7 @@ class CallSession {
406
410
  this.videoRemotelyDowngraded = videoRemotelyDowngraded;
407
411
  this.sipSession = sipSession;
408
412
  this.answerTime = answerTime || this.answerTime;
413
+ this.conference = conference;
409
414
 
410
415
  // Useful to compare instead of instanceof with minified code
411
416
  this.type = 'CallSession';
@@ -463,6 +468,10 @@ class CallSession {
463
468
  this.screensharing = false;
464
469
  }
465
470
 
471
+ setIsConference(conference ) {
472
+ this.conference = conference;
473
+ }
474
+
466
475
  isIncoming() {
467
476
  return !this.isCaller && !this.answered;
468
477
  }
@@ -539,6 +548,10 @@ class CallSession {
539
548
  return this.sipStatus === sessionState.SessionState.Terminated;
540
549
  }
541
550
 
551
+ isConference() {
552
+ return this.conference;
553
+ }
554
+
542
555
  getElapsedTimeInSeconds() {
543
556
  if (!this.startTime) {
544
557
  return 0;
@@ -630,6 +643,7 @@ class CallSession {
630
643
  cameraEnabled: false,
631
644
  dialedExtension: call.dialedExtension,
632
645
  call,
646
+ conference: false, // @FIXME?
633
647
  });
634
648
  }
635
649
  }
@@ -1670,6 +1684,7 @@ const LINE_STATE = {
1670
1684
 
1671
1685
 
1672
1686
 
1687
+
1673
1688
 
1674
1689
 
1675
1690
 
@@ -1706,6 +1721,7 @@ const LINE_STATE = {
1706
1721
 
1707
1722
 
1708
1723
 
1724
+
1709
1725
 
1710
1726
 
1711
1727
 
@@ -1737,6 +1753,7 @@ class Profile {
1737
1753
 
1738
1754
 
1739
1755
 
1756
+
1740
1757
 
1741
1758
 
1742
1759
 
@@ -1753,6 +1770,7 @@ class Profile {
1753
1770
  lines: plain.lines.map(line => Line.parse(line)),
1754
1771
  username: plain.username,
1755
1772
  mobileNumber: plain.mobile_phone_number || '',
1773
+ ringSeconds: plain.ring_seconds,
1756
1774
  forwards: [
1757
1775
  ForwardOption.parse(plain.forwards.unconditional, FORWARD_KEYS.UNCONDITIONAL),
1758
1776
  ForwardOption.parse(plain.forwards.noanswer, FORWARD_KEYS.NO_ANSWER),
@@ -1789,6 +1807,7 @@ class Profile {
1789
1807
  switchboards,
1790
1808
  agent,
1791
1809
  status,
1810
+ ringSeconds,
1792
1811
  sipLines,
1793
1812
  callPickupTargetUsers,
1794
1813
  onlineCallRecordEnabled,
@@ -1810,6 +1829,7 @@ class Profile {
1810
1829
  this.status = status;
1811
1830
  this.callPickupTargetUsers = callPickupTargetUsers;
1812
1831
  this.onlineCallRecordEnabled = onlineCallRecordEnabled;
1832
+ this.ringSeconds = ringSeconds;
1813
1833
 
1814
1834
  this.sipLines = sipLines || [];
1815
1835
  }
@@ -2801,6 +2821,7 @@ class Session {
2801
2821
  /* */
2802
2822
 
2803
2823
  const DEFAULT_BACKEND_USER = 'wazo_user';
2824
+ const BACKEND_LDAP_USER = 'ldap_user';
2804
2825
  const DETAULT_EXPIRATION = 3600;
2805
2826
 
2806
2827
  var authMethods = (client , baseUrl ) => ({
@@ -2815,6 +2836,7 @@ var authMethods = (client , baseUrl ) => ({
2815
2836
 
2816
2837
 
2817
2838
 
2839
+
2818
2840
  ) {
2819
2841
  const body = {
2820
2842
  backend: params.backend || DEFAULT_BACKEND_USER,
@@ -2834,6 +2856,10 @@ var authMethods = (client , baseUrl ) => ({
2834
2856
  headers['Wazo-Session-Type'] = 'mobile';
2835
2857
  }
2836
2858
 
2859
+ if (params.tenantId) {
2860
+ body.tenant_id = params.tenantId;
2861
+ }
2862
+
2837
2863
  return client.post(`${baseUrl}/token`, body, headers).then(response => Session.parse(response));
2838
2864
  },
2839
2865
 
@@ -3719,11 +3745,13 @@ class Recording {
3719
3745
 
3720
3746
 
3721
3747
 
3748
+
3722
3749
 
3723
3750
 
3724
3751
 
3725
3752
 
3726
3753
 
3754
+
3727
3755
 
3728
3756
 
3729
3757
 
@@ -3744,10 +3772,12 @@ class Recording {
3744
3772
 
3745
3773
 
3746
3774
 
3775
+
3747
3776
 
3748
3777
 
3749
3778
 
3750
3779
 
3780
+
3751
3781
 
3752
3782
 
3753
3783
 
@@ -3809,10 +3839,12 @@ class CallLog {
3809
3839
  || plain.destination_extension
3810
3840
  || `meeting-${plain.requested_name || plain.destination_name || ''}`,
3811
3841
  name: plain.requested_name || plain.destination_name || '',
3842
+ uuid: plain.destination_user_uuid,
3812
3843
  },
3813
3844
  source: {
3814
3845
  extension: plain.source_extension,
3815
3846
  name: plain.source_name,
3847
+ uuid: plain.source_user_uuid,
3816
3848
  },
3817
3849
  id: plain.id,
3818
3850
  duration: (plain.duration || 0) * 1000, // duration is in seconds
@@ -5655,6 +5687,10 @@ class AdHocAPIConference {
5655
5687
  this.conferenceId = conferenceId || '';
5656
5688
  this.muted = muted || false;
5657
5689
  this.paused = paused || false;
5690
+
5691
+ if (this.host) {
5692
+ this.host.setIsConference(true);
5693
+ }
5658
5694
  }
5659
5695
 
5660
5696
  async start() {
@@ -9364,7 +9400,11 @@ class WebRTCPhone extends Emitter {
9364
9400
  accept(callSession , cameraEnabled ) {
9365
9401
  logger$8.info('WebRTC phone - accept call', { id: callSession ? callSession.getId() : 'n/a', cameraEnabled });
9366
9402
  if (this.currentSipSession) {
9367
- this.holdSipSession(this.currentSipSession, this.currentCallSession, true);
9403
+ this.holdSipSession(
9404
+ this.currentSipSession,
9405
+ this.currentCallSession,
9406
+ true,
9407
+ );
9368
9408
  }
9369
9409
 
9370
9410
  if (!callSession) {
@@ -9457,22 +9497,22 @@ class WebRTCPhone extends Emitter {
9457
9497
  }
9458
9498
  }
9459
9499
 
9460
- hold(callSession , withEvent = true, isConference = false) {
9500
+ hold(callSession , withEvent = true) {
9461
9501
  logger$8.info('WebRTC hold', { id: callSession.getId() });
9462
9502
 
9463
9503
  const sipSession = this.findSipSession(callSession);
9464
9504
 
9465
- return sipSession ? this.holdSipSession(sipSession, callSession, withEvent, isConference) : null;
9505
+ return sipSession ? this.holdSipSession(sipSession, callSession, withEvent) : null;
9466
9506
  }
9467
9507
 
9468
9508
  // @Deprecated
9469
- unhold(callSession , withEvent = true, isConference = false) {
9509
+ unhold(callSession , withEvent = true) {
9470
9510
  console.warn('Please note that `phone.unhold()` is being deprecated; `phone.resume()` is the preferred method');
9471
9511
 
9472
- return this.resume(callSession, isConference, withEvent);
9512
+ return this.resume(callSession, withEvent);
9473
9513
  }
9474
9514
 
9475
- resume(callSession , isConference = false, withEvent = true) {
9515
+ resume(callSession , withEvent = true) {
9476
9516
  logger$8.info('WebRTC resume called', { id: callSession ? callSession.getId() : null });
9477
9517
 
9478
9518
  const sipSession = this.findSipSession(callSession);
@@ -9485,10 +9525,14 @@ class WebRTCPhone extends Emitter {
9485
9525
  // Hold current session if different from the current one (we don't want 2 sessions active at the same time).
9486
9526
  if (this.currentSipSession && this.currentSipSession.id !== sipSession.id) {
9487
9527
  logger$8.info('WebRTC hold call after resume', { id: this.currentSipSession.id });
9488
- this.holdSipSession(this.currentSipSession, this.currentCallSession);
9528
+ this.holdSipSession(
9529
+ this.currentSipSession,
9530
+ this.currentCallSession,
9531
+ withEvent,
9532
+ );
9489
9533
  }
9490
9534
 
9491
- const promise = this.unholdSipSession(sipSession, callSession, withEvent, isConference);
9535
+ const promise = this.unholdSipSession(sipSession, callSession, withEvent);
9492
9536
  this.currentSipSession = sipSession;
9493
9537
  if (callSession) {
9494
9538
  this.currentCallSession = callSession;
@@ -9501,7 +9545,6 @@ class WebRTCPhone extends Emitter {
9501
9545
  sipSession ,
9502
9546
  callSession ,
9503
9547
  withEvent = true,
9504
- isConference = false,
9505
9548
  ) {
9506
9549
  if (!sipSession) {
9507
9550
  return new Promise((resolve, reject) => reject(new Error('No session to hold')));
@@ -9522,6 +9565,8 @@ class WebRTCPhone extends Emitter {
9522
9565
  await this.client.downgradeToAudio(sipSession);
9523
9566
  }
9524
9567
 
9568
+ const isConference = !!callSession && callSession.isConference();
9569
+
9525
9570
  const promise = this.client.hold(sipSession, isConference, hasVideo);
9526
9571
  if (withEvent) {
9527
9572
  this.eventEmitter.emit(ON_CALL_HELD, this._createCallSession(sipSession, callSession));
@@ -9534,11 +9579,13 @@ class WebRTCPhone extends Emitter {
9534
9579
  sipSession ,
9535
9580
  callSession ,
9536
9581
  withEvent = true,
9537
- isConference = false,
9538
9582
  ) {
9539
9583
  if (!sipSession) {
9540
9584
  return new Promise((resolve, reject) => reject(new Error('No session to unhold')));
9541
9585
  }
9586
+
9587
+ const isConference = !!callSession && callSession.isConference();
9588
+
9542
9589
  const sessionId = this.getSipSessionId(sipSession);
9543
9590
  logger$8.info('WebRTC unhold sip session', { sessionId, isConference });
9544
9591
 
@@ -9680,7 +9727,11 @@ class WebRTCPhone extends Emitter {
9680
9727
  await this.client.register();
9681
9728
  }
9682
9729
  if (this.currentSipSession) {
9683
- this.holdSipSession(this.currentSipSession, this.currentCallSession, true).catch(e => {
9730
+ this.holdSipSession(
9731
+ this.currentSipSession,
9732
+ this.currentCallSession,
9733
+ true,
9734
+ ).catch(e => {
9684
9735
  logger$8.warn('Unable to hold current session when making another call', e);
9685
9736
  });
9686
9737
  }
@@ -9695,6 +9746,7 @@ class WebRTCPhone extends Emitter {
9695
9746
  return Promise.resolve(null);
9696
9747
  }
9697
9748
  const callSession = this._createOutgoingCallSession(sipSession, cameraEnabled || false);
9749
+ callSession.setIsConference(conference);
9698
9750
  callSession.creationTime = new Date();
9699
9751
  this._updateCallSession(callSession);
9700
9752
 
@@ -10273,6 +10325,7 @@ class WebRTCPhone extends Emitter {
10273
10325
  recording: fromSession ? fromSession.isRecording() : false,
10274
10326
  recordingPaused: false, // @TODO
10275
10327
  sipSession,
10328
+ conference: !!fromSession && fromSession.isConference(),
10276
10329
  ...extra,
10277
10330
  });
10278
10331
 
@@ -10335,6 +10388,7 @@ var PHONE_EVENTS = /*#__PURE__*/Object.freeze({
10335
10388
 
10336
10389
  class InvalidSubscription extends Error {}
10337
10390
  class InvalidAuthorization extends Error {}
10391
+ class NoTenantIdError extends Error {}
10338
10392
 
10339
10393
  const logger$7 = IssueReporter$1.loggerFor('simple-auth');
10340
10394
 
@@ -10348,11 +10402,15 @@ class Auth {
10348
10402
 
10349
10403
 
10350
10404
 
10405
+
10406
+
10351
10407
 
10352
10408
  constructor() {
10353
10409
  this.expiration = DETAULT_EXPIRATION;
10354
10410
  this.authenticated = false;
10355
10411
  this.minSubscriptionType = null;
10412
+ this.BACKEND_WAZO = DEFAULT_BACKEND_USER;
10413
+ this.BACKEND_LDAP = BACKEND_LDAP_USER;
10356
10414
  }
10357
10415
 
10358
10416
  init(clientId ,
@@ -10385,12 +10443,18 @@ class Auth {
10385
10443
  setFetchOptions(options);
10386
10444
  }
10387
10445
 
10388
- async logIn(username , password ) {
10446
+ async logIn(username , password , backend , tenantId ) {
10447
+ if (backend && backend !== this.BACKEND_WAZO && !tenantId) {
10448
+ throw new NoTenantIdError('No tenant id');
10449
+ }
10450
+
10389
10451
  this.authenticated = false;
10390
10452
  this.session = null;
10391
10453
  const rawSession = await getApiClient().auth.logIn({
10392
10454
  username,
10393
10455
  password,
10456
+ backend,
10457
+ tenantId,
10394
10458
  expiration: this.expiration,
10395
10459
  mobile: this.mobile,
10396
10460
  });
@@ -13491,6 +13555,7 @@ const Wazo = {
13491
13555
  InvalidAuthorization,
13492
13556
  CanceledCallError,
13493
13557
  SFUNotAvailableError,
13558
+ NoTenantIdError,
13494
13559
  };
13495
13560
 
13496
13561
  if (window) {
@@ -13690,16 +13755,16 @@ class Phone extends Emitter {
13690
13755
  }
13691
13756
  }
13692
13757
 
13693
- hold(callSession , isConference = false) {
13694
- return this.phone && this.phone.hold(callSession, true, isConference);
13758
+ hold(callSession ) {
13759
+ return this.phone && this.phone.hold(callSession, true);
13695
13760
  }
13696
13761
 
13697
- unhold(callSession , isConference = false) {
13698
- return this.phone && this.phone.unhold(callSession, true, isConference);
13762
+ unhold(callSession ) {
13763
+ return this.phone && this.phone.unhold(callSession, true);
13699
13764
  }
13700
13765
 
13701
- resume(callSession , isConference = false) {
13702
- return this.phone && this.phone.resume(callSession, isConference);
13766
+ resume(callSession ) {
13767
+ return this.phone && this.phone.resume(callSession);
13703
13768
  }
13704
13769
 
13705
13770
  reject(callSession ) {