@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
@@ -394,6 +394,7 @@ const LINE_STATE = {
394
394
 
395
395
 
396
396
 
397
+
397
398
 
398
399
 
399
400
 
@@ -430,6 +431,7 @@ const LINE_STATE = {
430
431
 
431
432
 
432
433
 
434
+
433
435
 
434
436
 
435
437
 
@@ -461,6 +463,7 @@ class Profile {
461
463
 
462
464
 
463
465
 
466
+
464
467
 
465
468
 
466
469
 
@@ -477,6 +480,7 @@ class Profile {
477
480
  lines: plain.lines.map(line => Line.parse(line)),
478
481
  username: plain.username,
479
482
  mobileNumber: plain.mobile_phone_number || '',
483
+ ringSeconds: plain.ring_seconds,
480
484
  forwards: [
481
485
  ForwardOption.parse(plain.forwards.unconditional, FORWARD_KEYS.UNCONDITIONAL),
482
486
  ForwardOption.parse(plain.forwards.noanswer, FORWARD_KEYS.NO_ANSWER),
@@ -513,6 +517,7 @@ class Profile {
513
517
  switchboards,
514
518
  agent,
515
519
  status,
520
+ ringSeconds,
516
521
  sipLines,
517
522
  callPickupTargetUsers,
518
523
  onlineCallRecordEnabled,
@@ -534,6 +539,7 @@ class Profile {
534
539
  this.status = status;
535
540
  this.callPickupTargetUsers = callPickupTargetUsers;
536
541
  this.onlineCallRecordEnabled = onlineCallRecordEnabled;
542
+ this.ringSeconds = ringSeconds;
537
543
 
538
544
  this.sipLines = sipLines || [];
539
545
  }
@@ -2212,6 +2218,7 @@ class ApiRequester {
2212
2218
  /* */
2213
2219
 
2214
2220
  const DEFAULT_BACKEND_USER = 'wazo_user';
2221
+ const BACKEND_LDAP_USER = 'ldap_user';
2215
2222
  const DETAULT_EXPIRATION = 3600;
2216
2223
 
2217
2224
  var authMethods = (client , baseUrl ) => ({
@@ -3290,6 +3297,7 @@ var updateFrom = (instance , from ) => {
3290
3297
 
3291
3298
 
3292
3299
 
3300
+
3293
3301
 
3294
3302
 
3295
3303
  class CallSession {
@@ -3352,6 +3360,8 @@ class CallSession {
3352
3360
 
3353
3361
 
3354
3362
 
3363
+
3364
+
3355
3365
 
3356
3366
 
3357
3367
 
@@ -3383,6 +3393,7 @@ class CallSession {
3383
3393
  videoRemotelyDowngraded,
3384
3394
  sipSession,
3385
3395
  answerTime,
3396
+ conference,
3386
3397
  } ) {
3387
3398
  this.callId = callId;
3388
3399
  this.sipCallId = sipCallId;
@@ -3411,6 +3422,7 @@ class CallSession {
3411
3422
  this.videoRemotelyDowngraded = videoRemotelyDowngraded;
3412
3423
  this.sipSession = sipSession;
3413
3424
  this.answerTime = answerTime || this.answerTime;
3425
+ this.conference = conference;
3414
3426
 
3415
3427
  // Useful to compare instead of instanceof with minified code
3416
3428
  this.type = 'CallSession';
@@ -3468,6 +3480,10 @@ class CallSession {
3468
3480
  this.screensharing = false;
3469
3481
  }
3470
3482
 
3483
+ setIsConference(conference ) {
3484
+ this.conference = conference;
3485
+ }
3486
+
3471
3487
  isIncoming() {
3472
3488
  return !this.isCaller && !this.answered;
3473
3489
  }
@@ -3544,6 +3560,10 @@ class CallSession {
3544
3560
  return this.sipStatus === sessionState.SessionState.Terminated;
3545
3561
  }
3546
3562
 
3563
+ isConference() {
3564
+ return this.conference;
3565
+ }
3566
+
3547
3567
  getElapsedTimeInSeconds() {
3548
3568
  if (!this.startTime) {
3549
3569
  return 0;
@@ -3635,6 +3655,7 @@ class CallSession {
3635
3655
  cameraEnabled: false,
3636
3656
  dialedExtension: call.dialedExtension,
3637
3657
  call,
3658
+ conference: false, // @FIXME?
3638
3659
  });
3639
3660
  }
3640
3661
  }
@@ -3730,7 +3751,7 @@ class Recording {
3730
3751
 
3731
3752
 
3732
3753
 
3733
-
3754
+
3734
3755
 
3735
3756
 
3736
3757
 
@@ -5599,6 +5620,7 @@ var getApiClient = (forServer ) => {
5599
5620
 
5600
5621
  class InvalidSubscription extends Error {}
5601
5622
  class InvalidAuthorization extends Error {}
5623
+ class NoTenantIdError extends Error {}
5602
5624
 
5603
5625
  const logger$9 = IssueReporter$1.loggerFor('simple-auth');
5604
5626
 
@@ -5612,11 +5634,15 @@ class Auth {
5612
5634
 
5613
5635
 
5614
5636
 
5637
+
5638
+
5615
5639
 
5616
5640
  constructor() {
5617
5641
  this.expiration = DETAULT_EXPIRATION;
5618
5642
  this.authenticated = false;
5619
5643
  this.minSubscriptionType = null;
5644
+ this.BACKEND_WAZO = DEFAULT_BACKEND_USER;
5645
+ this.BACKEND_LDAP = BACKEND_LDAP_USER;
5620
5646
  }
5621
5647
 
5622
5648
  init(clientId ,
@@ -5649,12 +5675,18 @@ class Auth {
5649
5675
  setFetchOptions(options);
5650
5676
  }
5651
5677
 
5652
- async logIn(username , password ) {
5678
+ async logIn(username , password , backend , tenantId ) {
5679
+ if (backend && backend !== this.BACKEND_WAZO && !tenantId) {
5680
+ throw new NoTenantIdError('No tenant id');
5681
+ }
5682
+
5653
5683
  this.authenticated = false;
5654
5684
  this.session = null;
5655
5685
  const rawSession = await getApiClient().auth.logIn({
5656
5686
  username,
5657
5687
  password,
5688
+ backend,
5689
+ tenantId,
5658
5690
  expiration: this.expiration,
5659
5691
  mobile: this.mobile,
5660
5692
  });
@@ -5884,7 +5916,7 @@ var Auth$1 = global.wazoAuthInstance;
5884
5916
 
5885
5917
 
5886
5918
 
5887
-
5919
+
5888
5920
 
5889
5921
 
5890
5922
 
@@ -5904,7 +5936,7 @@ class AdHocAPIConference {
5904
5936
 
5905
5937
 
5906
5938
 
5907
-
5939
+
5908
5940
 
5909
5941
 
5910
5942
 
@@ -5916,7 +5948,7 @@ class AdHocAPIConference {
5916
5948
  participants,
5917
5949
  started,
5918
5950
  finished,
5919
- startTime,
5951
+ answerTime,
5920
5952
  conferenceId,
5921
5953
  muted,
5922
5954
  paused,
@@ -5926,16 +5958,20 @@ class AdHocAPIConference {
5926
5958
  this.participants = participants || {};
5927
5959
  this.started = started || false;
5928
5960
  this.finished = finished || false;
5929
- this.startTime = startTime;
5961
+ this.answerTime = answerTime;
5930
5962
  this.conferenceId = conferenceId || '';
5931
5963
  this.muted = muted || false;
5932
5964
  this.paused = paused || false;
5965
+
5966
+ if (this.host) {
5967
+ this.host.setIsConference(true);
5968
+ }
5933
5969
  }
5934
5970
 
5935
5971
  async start() {
5936
5972
  this.started = true;
5937
5973
  // $FlowFixMe
5938
- this.startTime = Object.values(this.participants).length ? Object.values(this.participants)[0].startTime : null;
5974
+ this.answerTime = Object.values(this.participants).length ? Object.values(this.participants)[0].answerTime : null;
5939
5975
 
5940
5976
  const participantIds = Object.keys(this.participants);
5941
5977
  const conference = await getApiClient().calld.createAdHocConference(this.host.callId, participantIds);
@@ -9639,7 +9675,11 @@ class WebRTCPhone extends Emitter {
9639
9675
  accept(callSession , cameraEnabled ) {
9640
9676
  logger$7.info('WebRTC phone - accept call', { id: callSession ? callSession.getId() : 'n/a', cameraEnabled });
9641
9677
  if (this.currentSipSession) {
9642
- this.holdSipSession(this.currentSipSession, this.currentCallSession, true);
9678
+ this.holdSipSession(
9679
+ this.currentSipSession,
9680
+ this.currentCallSession,
9681
+ true,
9682
+ );
9643
9683
  }
9644
9684
 
9645
9685
  if (!callSession) {
@@ -9732,22 +9772,22 @@ class WebRTCPhone extends Emitter {
9732
9772
  }
9733
9773
  }
9734
9774
 
9735
- hold(callSession , withEvent = true, isConference = false) {
9775
+ hold(callSession , withEvent = true) {
9736
9776
  logger$7.info('WebRTC hold', { id: callSession.getId() });
9737
9777
 
9738
9778
  const sipSession = this.findSipSession(callSession);
9739
9779
 
9740
- return sipSession ? this.holdSipSession(sipSession, callSession, withEvent, isConference) : null;
9780
+ return sipSession ? this.holdSipSession(sipSession, callSession, withEvent) : null;
9741
9781
  }
9742
9782
 
9743
9783
  // @Deprecated
9744
- unhold(callSession , withEvent = true, isConference = false) {
9784
+ unhold(callSession , withEvent = true) {
9745
9785
  console.warn('Please note that `phone.unhold()` is being deprecated; `phone.resume()` is the preferred method');
9746
9786
 
9747
- return this.resume(callSession, isConference, withEvent);
9787
+ return this.resume(callSession, withEvent);
9748
9788
  }
9749
9789
 
9750
- resume(callSession , isConference = false, withEvent = true) {
9790
+ resume(callSession , withEvent = true) {
9751
9791
  logger$7.info('WebRTC resume called', { id: callSession ? callSession.getId() : null });
9752
9792
 
9753
9793
  const sipSession = this.findSipSession(callSession);
@@ -9760,10 +9800,14 @@ class WebRTCPhone extends Emitter {
9760
9800
  // Hold current session if different from the current one (we don't want 2 sessions active at the same time).
9761
9801
  if (this.currentSipSession && this.currentSipSession.id !== sipSession.id) {
9762
9802
  logger$7.info('WebRTC hold call after resume', { id: this.currentSipSession.id });
9763
- this.holdSipSession(this.currentSipSession, this.currentCallSession);
9803
+ this.holdSipSession(
9804
+ this.currentSipSession,
9805
+ this.currentCallSession,
9806
+ withEvent,
9807
+ );
9764
9808
  }
9765
9809
 
9766
- const promise = this.unholdSipSession(sipSession, callSession, withEvent, isConference);
9810
+ const promise = this.unholdSipSession(sipSession, callSession, withEvent);
9767
9811
  this.currentSipSession = sipSession;
9768
9812
  if (callSession) {
9769
9813
  this.currentCallSession = callSession;
@@ -9776,7 +9820,6 @@ class WebRTCPhone extends Emitter {
9776
9820
  sipSession ,
9777
9821
  callSession ,
9778
9822
  withEvent = true,
9779
- isConference = false,
9780
9823
  ) {
9781
9824
  if (!sipSession) {
9782
9825
  return new Promise((resolve, reject) => reject(new Error('No session to hold')));
@@ -9797,6 +9840,8 @@ class WebRTCPhone extends Emitter {
9797
9840
  await this.client.downgradeToAudio(sipSession);
9798
9841
  }
9799
9842
 
9843
+ const isConference = !!callSession && callSession.isConference();
9844
+
9800
9845
  const promise = this.client.hold(sipSession, isConference, hasVideo);
9801
9846
  if (withEvent) {
9802
9847
  this.eventEmitter.emit(ON_CALL_HELD, this._createCallSession(sipSession, callSession));
@@ -9809,11 +9854,13 @@ class WebRTCPhone extends Emitter {
9809
9854
  sipSession ,
9810
9855
  callSession ,
9811
9856
  withEvent = true,
9812
- isConference = false,
9813
9857
  ) {
9814
9858
  if (!sipSession) {
9815
9859
  return new Promise((resolve, reject) => reject(new Error('No session to unhold')));
9816
9860
  }
9861
+
9862
+ const isConference = !!callSession && callSession.isConference();
9863
+
9817
9864
  const sessionId = this.getSipSessionId(sipSession);
9818
9865
  logger$7.info('WebRTC unhold sip session', { sessionId, isConference });
9819
9866
 
@@ -9955,7 +10002,11 @@ class WebRTCPhone extends Emitter {
9955
10002
  await this.client.register();
9956
10003
  }
9957
10004
  if (this.currentSipSession) {
9958
- this.holdSipSession(this.currentSipSession, this.currentCallSession, true).catch(e => {
10005
+ this.holdSipSession(
10006
+ this.currentSipSession,
10007
+ this.currentCallSession,
10008
+ true,
10009
+ ).catch(e => {
9959
10010
  logger$7.warn('Unable to hold current session when making another call', e);
9960
10011
  });
9961
10012
  }
@@ -9970,6 +10021,7 @@ class WebRTCPhone extends Emitter {
9970
10021
  return Promise.resolve(null);
9971
10022
  }
9972
10023
  const callSession = this._createOutgoingCallSession(sipSession, cameraEnabled || false);
10024
+ callSession.setIsConference(conference);
9973
10025
  callSession.creationTime = new Date();
9974
10026
  this._updateCallSession(callSession);
9975
10027
 
@@ -10548,6 +10600,7 @@ class WebRTCPhone extends Emitter {
10548
10600
  recording: fromSession ? fromSession.isRecording() : false,
10549
10601
  recordingPaused: false, // @TODO
10550
10602
  sipSession,
10603
+ conference: !!fromSession && fromSession.isConference(),
10551
10604
  ...extra,
10552
10605
  });
10553
10606
 
@@ -10804,16 +10857,16 @@ class Phone extends Emitter {
10804
10857
  }
10805
10858
  }
10806
10859
 
10807
- hold(callSession , isConference = false) {
10808
- return this.phone && this.phone.hold(callSession, true, isConference);
10860
+ hold(callSession ) {
10861
+ return this.phone && this.phone.hold(callSession, true);
10809
10862
  }
10810
10863
 
10811
- unhold(callSession , isConference = false) {
10812
- return this.phone && this.phone.unhold(callSession, true, isConference);
10864
+ unhold(callSession ) {
10865
+ return this.phone && this.phone.unhold(callSession, true);
10813
10866
  }
10814
10867
 
10815
- resume(callSession , isConference = false) {
10816
- return this.phone && this.phone.resume(callSession, isConference);
10868
+ resume(callSession ) {
10869
+ return this.phone && this.phone.resume(callSession);
10817
10870
  }
10818
10871
 
10819
10872
  reject(callSession ) {
@@ -13212,7 +13265,7 @@ class Room {
13212
13265
 
13213
13266
 
13214
13267
 
13215
-
13268
+
13216
13269
 
13217
13270
 
13218
13271
 
@@ -13238,7 +13291,7 @@ class SwitchboardCall {
13238
13291
 
13239
13292
 
13240
13293
 
13241
-
13294
+
13242
13295
 
13243
13296
 
13244
13297
 
@@ -13252,7 +13305,7 @@ class SwitchboardCall {
13252
13305
  callerIdName: plain.caller_id_name || null,
13253
13306
  callerIdNumber: plain.caller_id_number || null,
13254
13307
  participantId: plain.participantId || null,
13255
- startTime: plain.startTime,
13308
+ answerTime: plain.startTime,
13256
13309
  state: plain.state,
13257
13310
  switchboardName: plain.switchboardName,
13258
13311
  switchboardUuid: plain.switchboardUuid,
@@ -13265,7 +13318,7 @@ class SwitchboardCall {
13265
13318
  callerIdName,
13266
13319
  callerIdNumber,
13267
13320
  participantId,
13268
- startTime,
13321
+ answerTime,
13269
13322
  state,
13270
13323
  switchboardName,
13271
13324
  switchboardUuid,
@@ -13275,7 +13328,7 @@ class SwitchboardCall {
13275
13328
  this.callerIdName = callerIdName;
13276
13329
  this.callerIdNumber = callerIdNumber;
13277
13330
  this.participantId = participantId;
13278
- this.startTime = startTime;
13331
+ this.answerTime = answerTime;
13279
13332
  this.state = state;
13280
13333
  this.switchboardName = switchboardName;
13281
13334
  this.switchboardUuid = switchboardUuid;
@@ -13912,6 +13965,7 @@ const Wazo = {
13912
13965
  InvalidAuthorization,
13913
13966
  CanceledCallError,
13914
13967
  SFUNotAvailableError,
13968
+ NoTenantIdError,
13915
13969
  };
13916
13970
 
13917
13971
  if (window) {