@wazo/sdk 0.37.35 → 0.37.38

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 (102) hide show
  1. package/README.md +8 -2
  2. package/dist/wazo-sdk.js +2 -2
  3. package/esm/__tests__/api-client.test.js +7 -1
  4. package/esm/__tests__/web-rtc-client.test.js +7 -1
  5. package/esm/api/auth.js +2 -1
  6. package/esm/api/call-logd.js +1 -1
  7. package/esm/api/chatd.js +6 -0
  8. package/esm/api/confd.js +6 -0
  9. package/esm/api-client.js +7 -1
  10. package/esm/checker/Checker.js +7 -1
  11. package/esm/checker/checks/aor.js +7 -1
  12. package/esm/checker/checks/api.js +7 -1
  13. package/esm/checker/checks/index.js +7 -1
  14. package/esm/checker/checks/webrtc-transport.js +7 -1
  15. package/esm/checker/checks/webrtc.js +7 -1
  16. package/esm/domain/AdHocAPIConference.js +16 -6
  17. package/esm/domain/CallLog.js +1 -1
  18. package/esm/domain/CallSession.js +14 -0
  19. package/esm/domain/Features.js +7 -1
  20. package/esm/domain/Phone/CTIPhone.js +21 -1
  21. package/esm/domain/Phone/WebRTCPhone.js +42 -11
  22. package/esm/domain/Profile.js +6 -0
  23. package/esm/domain/SwitchboardCall.js +5 -5
  24. package/esm/domain/__tests__/CallLog.test.js +5 -1
  25. package/esm/domain/__tests__/CallSession.test.js +14 -0
  26. package/esm/domain/__tests__/IndirectTransfer.test.js +14 -0
  27. package/esm/domain/__tests__/Profile.test.js +6 -0
  28. package/esm/domain/__tests__/Room.test.js +14 -0
  29. package/esm/domain/__tests__/Session.test.js +6 -0
  30. package/esm/index.js +83 -29
  31. package/esm/service/CallApi.js +7 -1
  32. package/esm/service/getApiClient.js +7 -1
  33. package/esm/simple/Auth.js +84 -30
  34. package/esm/simple/Configuration.js +83 -29
  35. package/esm/simple/Directory.js +7 -1
  36. package/esm/simple/Phone.js +83 -29
  37. package/esm/simple/index.js +83 -29
  38. package/esm/simple/room/LocalParticipant.js +83 -29
  39. package/esm/simple/room/Participant.js +83 -29
  40. package/esm/simple/room/RemoteParticipant.js +83 -29
  41. package/esm/simple/room/Room.js +83 -29
  42. package/esm/simple/room/SipRoom.js +83 -29
  43. package/esm/simple/room/Stream.js +83 -29
  44. package/esm/simple/room/__tests__/RemoteParticipant.test.js +83 -29
  45. package/esm/simple/utils.js +83 -29
  46. package/esm/web-rtc-client.js +7 -1
  47. package/lib/__tests__/api-client.test.js +7 -1
  48. package/lib/__tests__/web-rtc-client.test.js +7 -1
  49. package/lib/api/auth.js +3 -0
  50. package/lib/api/call-logd.js +1 -1
  51. package/lib/api/chatd.js +6 -0
  52. package/lib/api/confd.js +6 -0
  53. package/lib/api-client.js +7 -1
  54. package/lib/checker/Checker.js +7 -1
  55. package/lib/checker/checks/aor.js +7 -1
  56. package/lib/checker/checks/api.js +7 -1
  57. package/lib/checker/checks/index.js +7 -1
  58. package/lib/checker/checks/webrtc-transport.js +7 -1
  59. package/lib/checker/checks/webrtc.js +7 -1
  60. package/lib/domain/AdHocAPIConference.js +16 -6
  61. package/lib/domain/CallLog.js +1 -1
  62. package/lib/domain/CallSession.js +14 -0
  63. package/lib/domain/Features.js +7 -1
  64. package/lib/domain/Phone/CTIPhone.js +21 -1
  65. package/lib/domain/Phone/WebRTCPhone.js +42 -11
  66. package/lib/domain/Profile.js +6 -0
  67. package/lib/domain/SwitchboardCall.js +5 -5
  68. package/lib/domain/__tests__/CallLog.test.js +5 -1
  69. package/lib/domain/__tests__/CallSession.test.js +14 -0
  70. package/lib/domain/__tests__/IndirectTransfer.test.js +14 -0
  71. package/lib/domain/__tests__/Profile.test.js +6 -0
  72. package/lib/domain/__tests__/Room.test.js +14 -0
  73. package/lib/domain/__tests__/Session.test.js +6 -0
  74. package/lib/index.js +83 -29
  75. package/lib/service/CallApi.js +7 -1
  76. package/lib/service/getApiClient.js +7 -1
  77. package/lib/simple/Auth.js +84 -29
  78. package/lib/simple/Configuration.js +83 -29
  79. package/lib/simple/Directory.js +7 -1
  80. package/lib/simple/Phone.js +83 -29
  81. package/lib/simple/index.js +83 -29
  82. package/lib/simple/room/LocalParticipant.js +83 -29
  83. package/lib/simple/room/Participant.js +83 -29
  84. package/lib/simple/room/RemoteParticipant.js +83 -29
  85. package/lib/simple/room/Room.js +83 -29
  86. package/lib/simple/room/SipRoom.js +83 -29
  87. package/lib/simple/room/Stream.js +83 -29
  88. package/lib/simple/room/__tests__/RemoteParticipant.test.js +83 -29
  89. package/lib/simple/utils.js +83 -29
  90. package/lib/web-rtc-client.js +7 -1
  91. package/package.json +1 -1
  92. package/src/api/auth.js +2 -1
  93. package/src/domain/AdHocAPIConference.js +9 -5
  94. package/src/domain/CallLog.js +1 -1
  95. package/src/domain/CallSession.js +14 -0
  96. package/src/domain/Phone/WebRTCPhone.js +28 -11
  97. package/src/domain/Profile.js +6 -0
  98. package/src/domain/SwitchboardCall.js +5 -5
  99. package/src/domain/__tests__/CallLog.test.js +4 -0
  100. package/src/simple/Auth.js +13 -2
  101. package/src/simple/Phone.js +6 -6
  102. 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 ) => ({
@@ -3730,7 +3751,7 @@ class Recording {
3730
3751
 
3731
3752
 
3732
3753
 
3733
-
3754
+
3734
3755
 
3735
3756
 
3736
3757
 
@@ -5620,7 +5641,7 @@ var getApiClient = (forServer ) => {
5620
5641
 
5621
5642
 
5622
5643
 
5623
-
5644
+
5624
5645
 
5625
5646
 
5626
5647
 
@@ -5640,7 +5661,7 @@ class AdHocAPIConference {
5640
5661
 
5641
5662
 
5642
5663
 
5643
-
5664
+
5644
5665
 
5645
5666
 
5646
5667
 
@@ -5652,7 +5673,7 @@ class AdHocAPIConference {
5652
5673
  participants,
5653
5674
  started,
5654
5675
  finished,
5655
- startTime,
5676
+ answerTime,
5656
5677
  conferenceId,
5657
5678
  muted,
5658
5679
  paused,
@@ -5662,16 +5683,20 @@ class AdHocAPIConference {
5662
5683
  this.participants = participants || {};
5663
5684
  this.started = started || false;
5664
5685
  this.finished = finished || false;
5665
- this.startTime = startTime;
5686
+ this.answerTime = answerTime;
5666
5687
  this.conferenceId = conferenceId || '';
5667
5688
  this.muted = muted || false;
5668
5689
  this.paused = paused || false;
5690
+
5691
+ if (this.host) {
5692
+ this.host.setIsConference(true);
5693
+ }
5669
5694
  }
5670
5695
 
5671
5696
  async start() {
5672
5697
  this.started = true;
5673
5698
  // $FlowFixMe
5674
- this.startTime = Object.values(this.participants).length ? Object.values(this.participants)[0].startTime : null;
5699
+ this.answerTime = Object.values(this.participants).length ? Object.values(this.participants)[0].answerTime : null;
5675
5700
 
5676
5701
  const participantIds = Object.keys(this.participants);
5677
5702
  const conference = await getApiClient().calld.createAdHocConference(this.host.callId, participantIds);
@@ -9375,7 +9400,11 @@ class WebRTCPhone extends Emitter {
9375
9400
  accept(callSession , cameraEnabled ) {
9376
9401
  logger$8.info('WebRTC phone - accept call', { id: callSession ? callSession.getId() : 'n/a', cameraEnabled });
9377
9402
  if (this.currentSipSession) {
9378
- this.holdSipSession(this.currentSipSession, this.currentCallSession, true);
9403
+ this.holdSipSession(
9404
+ this.currentSipSession,
9405
+ this.currentCallSession,
9406
+ true,
9407
+ );
9379
9408
  }
9380
9409
 
9381
9410
  if (!callSession) {
@@ -9468,22 +9497,22 @@ class WebRTCPhone extends Emitter {
9468
9497
  }
9469
9498
  }
9470
9499
 
9471
- hold(callSession , withEvent = true, isConference = false) {
9500
+ hold(callSession , withEvent = true) {
9472
9501
  logger$8.info('WebRTC hold', { id: callSession.getId() });
9473
9502
 
9474
9503
  const sipSession = this.findSipSession(callSession);
9475
9504
 
9476
- return sipSession ? this.holdSipSession(sipSession, callSession, withEvent, isConference) : null;
9505
+ return sipSession ? this.holdSipSession(sipSession, callSession, withEvent) : null;
9477
9506
  }
9478
9507
 
9479
9508
  // @Deprecated
9480
- unhold(callSession , withEvent = true, isConference = false) {
9509
+ unhold(callSession , withEvent = true) {
9481
9510
  console.warn('Please note that `phone.unhold()` is being deprecated; `phone.resume()` is the preferred method');
9482
9511
 
9483
- return this.resume(callSession, isConference, withEvent);
9512
+ return this.resume(callSession, withEvent);
9484
9513
  }
9485
9514
 
9486
- resume(callSession , isConference = false, withEvent = true) {
9515
+ resume(callSession , withEvent = true) {
9487
9516
  logger$8.info('WebRTC resume called', { id: callSession ? callSession.getId() : null });
9488
9517
 
9489
9518
  const sipSession = this.findSipSession(callSession);
@@ -9496,10 +9525,14 @@ class WebRTCPhone extends Emitter {
9496
9525
  // Hold current session if different from the current one (we don't want 2 sessions active at the same time).
9497
9526
  if (this.currentSipSession && this.currentSipSession.id !== sipSession.id) {
9498
9527
  logger$8.info('WebRTC hold call after resume', { id: this.currentSipSession.id });
9499
- this.holdSipSession(this.currentSipSession, this.currentCallSession);
9528
+ this.holdSipSession(
9529
+ this.currentSipSession,
9530
+ this.currentCallSession,
9531
+ withEvent,
9532
+ );
9500
9533
  }
9501
9534
 
9502
- const promise = this.unholdSipSession(sipSession, callSession, withEvent, isConference);
9535
+ const promise = this.unholdSipSession(sipSession, callSession, withEvent);
9503
9536
  this.currentSipSession = sipSession;
9504
9537
  if (callSession) {
9505
9538
  this.currentCallSession = callSession;
@@ -9512,7 +9545,6 @@ class WebRTCPhone extends Emitter {
9512
9545
  sipSession ,
9513
9546
  callSession ,
9514
9547
  withEvent = true,
9515
- isConference = false,
9516
9548
  ) {
9517
9549
  if (!sipSession) {
9518
9550
  return new Promise((resolve, reject) => reject(new Error('No session to hold')));
@@ -9533,6 +9565,8 @@ class WebRTCPhone extends Emitter {
9533
9565
  await this.client.downgradeToAudio(sipSession);
9534
9566
  }
9535
9567
 
9568
+ const isConference = !!callSession && callSession.isConference();
9569
+
9536
9570
  const promise = this.client.hold(sipSession, isConference, hasVideo);
9537
9571
  if (withEvent) {
9538
9572
  this.eventEmitter.emit(ON_CALL_HELD, this._createCallSession(sipSession, callSession));
@@ -9545,11 +9579,13 @@ class WebRTCPhone extends Emitter {
9545
9579
  sipSession ,
9546
9580
  callSession ,
9547
9581
  withEvent = true,
9548
- isConference = false,
9549
9582
  ) {
9550
9583
  if (!sipSession) {
9551
9584
  return new Promise((resolve, reject) => reject(new Error('No session to unhold')));
9552
9585
  }
9586
+
9587
+ const isConference = !!callSession && callSession.isConference();
9588
+
9553
9589
  const sessionId = this.getSipSessionId(sipSession);
9554
9590
  logger$8.info('WebRTC unhold sip session', { sessionId, isConference });
9555
9591
 
@@ -9691,7 +9727,11 @@ class WebRTCPhone extends Emitter {
9691
9727
  await this.client.register();
9692
9728
  }
9693
9729
  if (this.currentSipSession) {
9694
- this.holdSipSession(this.currentSipSession, this.currentCallSession, true).catch(e => {
9730
+ this.holdSipSession(
9731
+ this.currentSipSession,
9732
+ this.currentCallSession,
9733
+ true,
9734
+ ).catch(e => {
9695
9735
  logger$8.warn('Unable to hold current session when making another call', e);
9696
9736
  });
9697
9737
  }
@@ -9706,6 +9746,7 @@ class WebRTCPhone extends Emitter {
9706
9746
  return Promise.resolve(null);
9707
9747
  }
9708
9748
  const callSession = this._createOutgoingCallSession(sipSession, cameraEnabled || false);
9749
+ callSession.setIsConference(conference);
9709
9750
  callSession.creationTime = new Date();
9710
9751
  this._updateCallSession(callSession);
9711
9752
 
@@ -10284,6 +10325,7 @@ class WebRTCPhone extends Emitter {
10284
10325
  recording: fromSession ? fromSession.isRecording() : false,
10285
10326
  recordingPaused: false, // @TODO
10286
10327
  sipSession,
10328
+ conference: !!fromSession && fromSession.isConference(),
10287
10329
  ...extra,
10288
10330
  });
10289
10331
 
@@ -10346,6 +10388,7 @@ var PHONE_EVENTS = /*#__PURE__*/Object.freeze({
10346
10388
 
10347
10389
  class InvalidSubscription extends Error {}
10348
10390
  class InvalidAuthorization extends Error {}
10391
+ class NoTenantIdError extends Error {}
10349
10392
 
10350
10393
  const logger$7 = IssueReporter$1.loggerFor('simple-auth');
10351
10394
 
@@ -10359,11 +10402,15 @@ class Auth {
10359
10402
 
10360
10403
 
10361
10404
 
10405
+
10406
+
10362
10407
 
10363
10408
  constructor() {
10364
10409
  this.expiration = DETAULT_EXPIRATION;
10365
10410
  this.authenticated = false;
10366
10411
  this.minSubscriptionType = null;
10412
+ this.BACKEND_WAZO = DEFAULT_BACKEND_USER;
10413
+ this.BACKEND_LDAP = BACKEND_LDAP_USER;
10367
10414
  }
10368
10415
 
10369
10416
  init(clientId ,
@@ -10396,12 +10443,18 @@ class Auth {
10396
10443
  setFetchOptions(options);
10397
10444
  }
10398
10445
 
10399
- 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
+
10400
10451
  this.authenticated = false;
10401
10452
  this.session = null;
10402
10453
  const rawSession = await getApiClient().auth.logIn({
10403
10454
  username,
10404
10455
  password,
10456
+ backend,
10457
+ tenantId,
10405
10458
  expiration: this.expiration,
10406
10459
  mobile: this.mobile,
10407
10460
  });
@@ -12802,7 +12855,7 @@ class Room {
12802
12855
 
12803
12856
 
12804
12857
 
12805
-
12858
+
12806
12859
 
12807
12860
 
12808
12861
 
@@ -12828,7 +12881,7 @@ class SwitchboardCall {
12828
12881
 
12829
12882
 
12830
12883
 
12831
-
12884
+
12832
12885
 
12833
12886
 
12834
12887
 
@@ -12842,7 +12895,7 @@ class SwitchboardCall {
12842
12895
  callerIdName: plain.caller_id_name || null,
12843
12896
  callerIdNumber: plain.caller_id_number || null,
12844
12897
  participantId: plain.participantId || null,
12845
- startTime: plain.startTime,
12898
+ answerTime: plain.startTime,
12846
12899
  state: plain.state,
12847
12900
  switchboardName: plain.switchboardName,
12848
12901
  switchboardUuid: plain.switchboardUuid,
@@ -12855,7 +12908,7 @@ class SwitchboardCall {
12855
12908
  callerIdName,
12856
12909
  callerIdNumber,
12857
12910
  participantId,
12858
- startTime,
12911
+ answerTime,
12859
12912
  state,
12860
12913
  switchboardName,
12861
12914
  switchboardUuid,
@@ -12865,7 +12918,7 @@ class SwitchboardCall {
12865
12918
  this.callerIdName = callerIdName;
12866
12919
  this.callerIdNumber = callerIdNumber;
12867
12920
  this.participantId = participantId;
12868
- this.startTime = startTime;
12921
+ this.answerTime = answerTime;
12869
12922
  this.state = state;
12870
12923
  this.switchboardName = switchboardName;
12871
12924
  this.switchboardUuid = switchboardUuid;
@@ -13502,6 +13555,7 @@ const Wazo = {
13502
13555
  InvalidAuthorization,
13503
13556
  CanceledCallError,
13504
13557
  SFUNotAvailableError,
13558
+ NoTenantIdError,
13505
13559
  };
13506
13560
 
13507
13561
  if (window) {
@@ -13701,16 +13755,16 @@ class Phone extends Emitter {
13701
13755
  }
13702
13756
  }
13703
13757
 
13704
- hold(callSession , isConference = false) {
13705
- return this.phone && this.phone.hold(callSession, true, isConference);
13758
+ hold(callSession ) {
13759
+ return this.phone && this.phone.hold(callSession, true);
13706
13760
  }
13707
13761
 
13708
- unhold(callSession , isConference = false) {
13709
- return this.phone && this.phone.unhold(callSession, true, isConference);
13762
+ unhold(callSession ) {
13763
+ return this.phone && this.phone.unhold(callSession, true);
13710
13764
  }
13711
13765
 
13712
- resume(callSession , isConference = false) {
13713
- return this.phone && this.phone.resume(callSession, isConference);
13766
+ resume(callSession ) {
13767
+ return this.phone && this.phone.resume(callSession);
13714
13768
  }
13715
13769
 
13716
13770
  reject(callSession ) {