@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
@@ -275,6 +275,7 @@ var updateFrom = (instance , from ) => {
275
275
 
276
276
 
277
277
 
278
+
278
279
 
279
280
 
280
281
  class CallSession {
@@ -337,6 +338,8 @@ class CallSession {
337
338
 
338
339
 
339
340
 
341
+
342
+
340
343
 
341
344
 
342
345
 
@@ -368,6 +371,7 @@ class CallSession {
368
371
  videoRemotelyDowngraded,
369
372
  sipSession,
370
373
  answerTime,
374
+ conference,
371
375
  } ) {
372
376
  this.callId = callId;
373
377
  this.sipCallId = sipCallId;
@@ -396,6 +400,7 @@ class CallSession {
396
400
  this.videoRemotelyDowngraded = videoRemotelyDowngraded;
397
401
  this.sipSession = sipSession;
398
402
  this.answerTime = answerTime || this.answerTime;
403
+ this.conference = conference;
399
404
 
400
405
  // Useful to compare instead of instanceof with minified code
401
406
  this.type = 'CallSession';
@@ -453,6 +458,10 @@ class CallSession {
453
458
  this.screensharing = false;
454
459
  }
455
460
 
461
+ setIsConference(conference ) {
462
+ this.conference = conference;
463
+ }
464
+
456
465
  isIncoming() {
457
466
  return !this.isCaller && !this.answered;
458
467
  }
@@ -529,6 +538,10 @@ class CallSession {
529
538
  return this.sipStatus === SessionState.Terminated;
530
539
  }
531
540
 
541
+ isConference() {
542
+ return this.conference;
543
+ }
544
+
532
545
  getElapsedTimeInSeconds() {
533
546
  if (!this.startTime) {
534
547
  return 0;
@@ -620,6 +633,7 @@ class CallSession {
620
633
  cameraEnabled: false,
621
634
  dialedExtension: call.dialedExtension,
622
635
  call,
636
+ conference: false, // @FIXME?
623
637
  });
624
638
  }
625
639
  }
@@ -1660,6 +1674,7 @@ const LINE_STATE = {
1660
1674
 
1661
1675
 
1662
1676
 
1677
+
1663
1678
 
1664
1679
 
1665
1680
 
@@ -1696,6 +1711,7 @@ const LINE_STATE = {
1696
1711
 
1697
1712
 
1698
1713
 
1714
+
1699
1715
 
1700
1716
 
1701
1717
 
@@ -1727,6 +1743,7 @@ class Profile {
1727
1743
 
1728
1744
 
1729
1745
 
1746
+
1730
1747
 
1731
1748
 
1732
1749
 
@@ -1743,6 +1760,7 @@ class Profile {
1743
1760
  lines: plain.lines.map(line => Line.parse(line)),
1744
1761
  username: plain.username,
1745
1762
  mobileNumber: plain.mobile_phone_number || '',
1763
+ ringSeconds: plain.ring_seconds,
1746
1764
  forwards: [
1747
1765
  ForwardOption.parse(plain.forwards.unconditional, FORWARD_KEYS.UNCONDITIONAL),
1748
1766
  ForwardOption.parse(plain.forwards.noanswer, FORWARD_KEYS.NO_ANSWER),
@@ -1779,6 +1797,7 @@ class Profile {
1779
1797
  switchboards,
1780
1798
  agent,
1781
1799
  status,
1800
+ ringSeconds,
1782
1801
  sipLines,
1783
1802
  callPickupTargetUsers,
1784
1803
  onlineCallRecordEnabled,
@@ -1800,6 +1819,7 @@ class Profile {
1800
1819
  this.status = status;
1801
1820
  this.callPickupTargetUsers = callPickupTargetUsers;
1802
1821
  this.onlineCallRecordEnabled = onlineCallRecordEnabled;
1822
+ this.ringSeconds = ringSeconds;
1803
1823
 
1804
1824
  this.sipLines = sipLines || [];
1805
1825
  }
@@ -2791,6 +2811,7 @@ class Session {
2791
2811
  /* */
2792
2812
 
2793
2813
  const DEFAULT_BACKEND_USER = 'wazo_user';
2814
+ const BACKEND_LDAP_USER = 'ldap_user';
2794
2815
  const DETAULT_EXPIRATION = 3600;
2795
2816
 
2796
2817
  var authMethods = (client , baseUrl ) => ({
@@ -3720,7 +3741,7 @@ class Recording {
3720
3741
 
3721
3742
 
3722
3743
 
3723
-
3744
+
3724
3745
 
3725
3746
 
3726
3747
 
@@ -5610,7 +5631,7 @@ var getApiClient = (forServer ) => {
5610
5631
 
5611
5632
 
5612
5633
 
5613
-
5634
+
5614
5635
 
5615
5636
 
5616
5637
 
@@ -5630,7 +5651,7 @@ class AdHocAPIConference {
5630
5651
 
5631
5652
 
5632
5653
 
5633
-
5654
+
5634
5655
 
5635
5656
 
5636
5657
 
@@ -5642,7 +5663,7 @@ class AdHocAPIConference {
5642
5663
  participants,
5643
5664
  started,
5644
5665
  finished,
5645
- startTime,
5666
+ answerTime,
5646
5667
  conferenceId,
5647
5668
  muted,
5648
5669
  paused,
@@ -5652,16 +5673,20 @@ class AdHocAPIConference {
5652
5673
  this.participants = participants || {};
5653
5674
  this.started = started || false;
5654
5675
  this.finished = finished || false;
5655
- this.startTime = startTime;
5676
+ this.answerTime = answerTime;
5656
5677
  this.conferenceId = conferenceId || '';
5657
5678
  this.muted = muted || false;
5658
5679
  this.paused = paused || false;
5680
+
5681
+ if (this.host) {
5682
+ this.host.setIsConference(true);
5683
+ }
5659
5684
  }
5660
5685
 
5661
5686
  async start() {
5662
5687
  this.started = true;
5663
5688
  // $FlowFixMe
5664
- this.startTime = Object.values(this.participants).length ? Object.values(this.participants)[0].startTime : null;
5689
+ this.answerTime = Object.values(this.participants).length ? Object.values(this.participants)[0].answerTime : null;
5665
5690
 
5666
5691
  const participantIds = Object.keys(this.participants);
5667
5692
  const conference = await getApiClient().calld.createAdHocConference(this.host.callId, participantIds);
@@ -9365,7 +9390,11 @@ class WebRTCPhone extends Emitter {
9365
9390
  accept(callSession , cameraEnabled ) {
9366
9391
  logger$8.info('WebRTC phone - accept call', { id: callSession ? callSession.getId() : 'n/a', cameraEnabled });
9367
9392
  if (this.currentSipSession) {
9368
- this.holdSipSession(this.currentSipSession, this.currentCallSession, true);
9393
+ this.holdSipSession(
9394
+ this.currentSipSession,
9395
+ this.currentCallSession,
9396
+ true,
9397
+ );
9369
9398
  }
9370
9399
 
9371
9400
  if (!callSession) {
@@ -9458,22 +9487,22 @@ class WebRTCPhone extends Emitter {
9458
9487
  }
9459
9488
  }
9460
9489
 
9461
- hold(callSession , withEvent = true, isConference = false) {
9490
+ hold(callSession , withEvent = true) {
9462
9491
  logger$8.info('WebRTC hold', { id: callSession.getId() });
9463
9492
 
9464
9493
  const sipSession = this.findSipSession(callSession);
9465
9494
 
9466
- return sipSession ? this.holdSipSession(sipSession, callSession, withEvent, isConference) : null;
9495
+ return sipSession ? this.holdSipSession(sipSession, callSession, withEvent) : null;
9467
9496
  }
9468
9497
 
9469
9498
  // @Deprecated
9470
- unhold(callSession , withEvent = true, isConference = false) {
9499
+ unhold(callSession , withEvent = true) {
9471
9500
  console.warn('Please note that `phone.unhold()` is being deprecated; `phone.resume()` is the preferred method');
9472
9501
 
9473
- return this.resume(callSession, isConference, withEvent);
9502
+ return this.resume(callSession, withEvent);
9474
9503
  }
9475
9504
 
9476
- resume(callSession , isConference = false, withEvent = true) {
9505
+ resume(callSession , withEvent = true) {
9477
9506
  logger$8.info('WebRTC resume called', { id: callSession ? callSession.getId() : null });
9478
9507
 
9479
9508
  const sipSession = this.findSipSession(callSession);
@@ -9486,10 +9515,14 @@ class WebRTCPhone extends Emitter {
9486
9515
  // Hold current session if different from the current one (we don't want 2 sessions active at the same time).
9487
9516
  if (this.currentSipSession && this.currentSipSession.id !== sipSession.id) {
9488
9517
  logger$8.info('WebRTC hold call after resume', { id: this.currentSipSession.id });
9489
- this.holdSipSession(this.currentSipSession, this.currentCallSession);
9518
+ this.holdSipSession(
9519
+ this.currentSipSession,
9520
+ this.currentCallSession,
9521
+ withEvent,
9522
+ );
9490
9523
  }
9491
9524
 
9492
- const promise = this.unholdSipSession(sipSession, callSession, withEvent, isConference);
9525
+ const promise = this.unholdSipSession(sipSession, callSession, withEvent);
9493
9526
  this.currentSipSession = sipSession;
9494
9527
  if (callSession) {
9495
9528
  this.currentCallSession = callSession;
@@ -9502,7 +9535,6 @@ class WebRTCPhone extends Emitter {
9502
9535
  sipSession ,
9503
9536
  callSession ,
9504
9537
  withEvent = true,
9505
- isConference = false,
9506
9538
  ) {
9507
9539
  if (!sipSession) {
9508
9540
  return new Promise((resolve, reject) => reject(new Error('No session to hold')));
@@ -9523,6 +9555,8 @@ class WebRTCPhone extends Emitter {
9523
9555
  await this.client.downgradeToAudio(sipSession);
9524
9556
  }
9525
9557
 
9558
+ const isConference = !!callSession && callSession.isConference();
9559
+
9526
9560
  const promise = this.client.hold(sipSession, isConference, hasVideo);
9527
9561
  if (withEvent) {
9528
9562
  this.eventEmitter.emit(ON_CALL_HELD, this._createCallSession(sipSession, callSession));
@@ -9535,11 +9569,13 @@ class WebRTCPhone extends Emitter {
9535
9569
  sipSession ,
9536
9570
  callSession ,
9537
9571
  withEvent = true,
9538
- isConference = false,
9539
9572
  ) {
9540
9573
  if (!sipSession) {
9541
9574
  return new Promise((resolve, reject) => reject(new Error('No session to unhold')));
9542
9575
  }
9576
+
9577
+ const isConference = !!callSession && callSession.isConference();
9578
+
9543
9579
  const sessionId = this.getSipSessionId(sipSession);
9544
9580
  logger$8.info('WebRTC unhold sip session', { sessionId, isConference });
9545
9581
 
@@ -9681,7 +9717,11 @@ class WebRTCPhone extends Emitter {
9681
9717
  await this.client.register();
9682
9718
  }
9683
9719
  if (this.currentSipSession) {
9684
- this.holdSipSession(this.currentSipSession, this.currentCallSession, true).catch(e => {
9720
+ this.holdSipSession(
9721
+ this.currentSipSession,
9722
+ this.currentCallSession,
9723
+ true,
9724
+ ).catch(e => {
9685
9725
  logger$8.warn('Unable to hold current session when making another call', e);
9686
9726
  });
9687
9727
  }
@@ -9696,6 +9736,7 @@ class WebRTCPhone extends Emitter {
9696
9736
  return Promise.resolve(null);
9697
9737
  }
9698
9738
  const callSession = this._createOutgoingCallSession(sipSession, cameraEnabled || false);
9739
+ callSession.setIsConference(conference);
9699
9740
  callSession.creationTime = new Date();
9700
9741
  this._updateCallSession(callSession);
9701
9742
 
@@ -10274,6 +10315,7 @@ class WebRTCPhone extends Emitter {
10274
10315
  recording: fromSession ? fromSession.isRecording() : false,
10275
10316
  recordingPaused: false, // @TODO
10276
10317
  sipSession,
10318
+ conference: !!fromSession && fromSession.isConference(),
10277
10319
  ...extra,
10278
10320
  });
10279
10321
 
@@ -10336,6 +10378,7 @@ var PHONE_EVENTS = /*#__PURE__*/Object.freeze({
10336
10378
 
10337
10379
  class InvalidSubscription extends Error {}
10338
10380
  class InvalidAuthorization extends Error {}
10381
+ class NoTenantIdError extends Error {}
10339
10382
 
10340
10383
  const logger$7 = IssueReporter$1.loggerFor('simple-auth');
10341
10384
 
@@ -10349,11 +10392,15 @@ class Auth {
10349
10392
 
10350
10393
 
10351
10394
 
10395
+
10396
+
10352
10397
 
10353
10398
  constructor() {
10354
10399
  this.expiration = DETAULT_EXPIRATION;
10355
10400
  this.authenticated = false;
10356
10401
  this.minSubscriptionType = null;
10402
+ this.BACKEND_WAZO = DEFAULT_BACKEND_USER;
10403
+ this.BACKEND_LDAP = BACKEND_LDAP_USER;
10357
10404
  }
10358
10405
 
10359
10406
  init(clientId ,
@@ -10386,12 +10433,18 @@ class Auth {
10386
10433
  setFetchOptions(options);
10387
10434
  }
10388
10435
 
10389
- async logIn(username , password ) {
10436
+ async logIn(username , password , backend , tenantId ) {
10437
+ if (backend && backend !== this.BACKEND_WAZO && !tenantId) {
10438
+ throw new NoTenantIdError('No tenant id');
10439
+ }
10440
+
10390
10441
  this.authenticated = false;
10391
10442
  this.session = null;
10392
10443
  const rawSession = await getApiClient().auth.logIn({
10393
10444
  username,
10394
10445
  password,
10446
+ backend,
10447
+ tenantId,
10395
10448
  expiration: this.expiration,
10396
10449
  mobile: this.mobile,
10397
10450
  });
@@ -12792,7 +12845,7 @@ class Room {
12792
12845
 
12793
12846
 
12794
12847
 
12795
-
12848
+
12796
12849
 
12797
12850
 
12798
12851
 
@@ -12818,7 +12871,7 @@ class SwitchboardCall {
12818
12871
 
12819
12872
 
12820
12873
 
12821
-
12874
+
12822
12875
 
12823
12876
 
12824
12877
 
@@ -12832,7 +12885,7 @@ class SwitchboardCall {
12832
12885
  callerIdName: plain.caller_id_name || null,
12833
12886
  callerIdNumber: plain.caller_id_number || null,
12834
12887
  participantId: plain.participantId || null,
12835
- startTime: plain.startTime,
12888
+ answerTime: plain.startTime,
12836
12889
  state: plain.state,
12837
12890
  switchboardName: plain.switchboardName,
12838
12891
  switchboardUuid: plain.switchboardUuid,
@@ -12845,7 +12898,7 @@ class SwitchboardCall {
12845
12898
  callerIdName,
12846
12899
  callerIdNumber,
12847
12900
  participantId,
12848
- startTime,
12901
+ answerTime,
12849
12902
  state,
12850
12903
  switchboardName,
12851
12904
  switchboardUuid,
@@ -12855,7 +12908,7 @@ class SwitchboardCall {
12855
12908
  this.callerIdName = callerIdName;
12856
12909
  this.callerIdNumber = callerIdNumber;
12857
12910
  this.participantId = participantId;
12858
- this.startTime = startTime;
12911
+ this.answerTime = answerTime;
12859
12912
  this.state = state;
12860
12913
  this.switchboardName = switchboardName;
12861
12914
  this.switchboardUuid = switchboardUuid;
@@ -13492,6 +13545,7 @@ const Wazo = {
13492
13545
  InvalidAuthorization,
13493
13546
  CanceledCallError,
13494
13547
  SFUNotAvailableError,
13548
+ NoTenantIdError,
13495
13549
  };
13496
13550
 
13497
13551
  if (window) {
@@ -13691,16 +13745,16 @@ class Phone extends Emitter {
13691
13745
  }
13692
13746
  }
13693
13747
 
13694
- hold(callSession , isConference = false) {
13695
- return this.phone && this.phone.hold(callSession, true, isConference);
13748
+ hold(callSession ) {
13749
+ return this.phone && this.phone.hold(callSession, true);
13696
13750
  }
13697
13751
 
13698
- unhold(callSession , isConference = false) {
13699
- return this.phone && this.phone.unhold(callSession, true, isConference);
13752
+ unhold(callSession ) {
13753
+ return this.phone && this.phone.unhold(callSession, true);
13700
13754
  }
13701
13755
 
13702
- resume(callSession , isConference = false) {
13703
- return this.phone && this.phone.resume(callSession, isConference);
13756
+ resume(callSession ) {
13757
+ return this.phone && this.phone.resume(callSession);
13704
13758
  }
13705
13759
 
13706
13760
  reject(callSession ) {