@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
@@ -1083,6 +1083,7 @@ const LINE_STATE = {
1083
1083
 
1084
1084
 
1085
1085
 
1086
+
1086
1087
 
1087
1088
 
1088
1089
 
@@ -1119,6 +1120,7 @@ const LINE_STATE = {
1119
1120
 
1120
1121
 
1121
1122
 
1123
+
1122
1124
 
1123
1125
 
1124
1126
 
@@ -1150,6 +1152,7 @@ class Profile {
1150
1152
 
1151
1153
 
1152
1154
 
1155
+
1153
1156
 
1154
1157
 
1155
1158
 
@@ -1166,6 +1169,7 @@ class Profile {
1166
1169
  lines: plain.lines.map(line => Line.parse(line)),
1167
1170
  username: plain.username,
1168
1171
  mobileNumber: plain.mobile_phone_number || '',
1172
+ ringSeconds: plain.ring_seconds,
1169
1173
  forwards: [
1170
1174
  ForwardOption.parse(plain.forwards.unconditional, FORWARD_KEYS.UNCONDITIONAL),
1171
1175
  ForwardOption.parse(plain.forwards.noanswer, FORWARD_KEYS.NO_ANSWER),
@@ -1202,6 +1206,7 @@ class Profile {
1202
1206
  switchboards,
1203
1207
  agent,
1204
1208
  status,
1209
+ ringSeconds,
1205
1210
  sipLines,
1206
1211
  callPickupTargetUsers,
1207
1212
  onlineCallRecordEnabled,
@@ -1223,6 +1228,7 @@ class Profile {
1223
1228
  this.status = status;
1224
1229
  this.callPickupTargetUsers = callPickupTargetUsers;
1225
1230
  this.onlineCallRecordEnabled = onlineCallRecordEnabled;
1231
+ this.ringSeconds = ringSeconds;
1226
1232
 
1227
1233
  this.sipLines = sipLines || [];
1228
1234
  }
@@ -2214,6 +2220,7 @@ class Session {
2214
2220
  /* */
2215
2221
 
2216
2222
  const DEFAULT_BACKEND_USER = 'wazo_user';
2223
+ const BACKEND_LDAP_USER = 'ldap_user';
2217
2224
  const DETAULT_EXPIRATION = 3600;
2218
2225
 
2219
2226
  var authMethods = (client , baseUrl ) => ({
@@ -3292,6 +3299,7 @@ var updateFrom = (instance , from ) => {
3292
3299
 
3293
3300
 
3294
3301
 
3302
+
3295
3303
 
3296
3304
 
3297
3305
  class CallSession {
@@ -3354,6 +3362,8 @@ class CallSession {
3354
3362
 
3355
3363
 
3356
3364
 
3365
+
3366
+
3357
3367
 
3358
3368
 
3359
3369
 
@@ -3385,6 +3395,7 @@ class CallSession {
3385
3395
  videoRemotelyDowngraded,
3386
3396
  sipSession,
3387
3397
  answerTime,
3398
+ conference,
3388
3399
  } ) {
3389
3400
  this.callId = callId;
3390
3401
  this.sipCallId = sipCallId;
@@ -3413,6 +3424,7 @@ class CallSession {
3413
3424
  this.videoRemotelyDowngraded = videoRemotelyDowngraded;
3414
3425
  this.sipSession = sipSession;
3415
3426
  this.answerTime = answerTime || this.answerTime;
3427
+ this.conference = conference;
3416
3428
 
3417
3429
  // Useful to compare instead of instanceof with minified code
3418
3430
  this.type = 'CallSession';
@@ -3470,6 +3482,10 @@ class CallSession {
3470
3482
  this.screensharing = false;
3471
3483
  }
3472
3484
 
3485
+ setIsConference(conference ) {
3486
+ this.conference = conference;
3487
+ }
3488
+
3473
3489
  isIncoming() {
3474
3490
  return !this.isCaller && !this.answered;
3475
3491
  }
@@ -3546,6 +3562,10 @@ class CallSession {
3546
3562
  return this.sipStatus === sessionState.SessionState.Terminated;
3547
3563
  }
3548
3564
 
3565
+ isConference() {
3566
+ return this.conference;
3567
+ }
3568
+
3549
3569
  getElapsedTimeInSeconds() {
3550
3570
  if (!this.startTime) {
3551
3571
  return 0;
@@ -3637,6 +3657,7 @@ class CallSession {
3637
3657
  cameraEnabled: false,
3638
3658
  dialedExtension: call.dialedExtension,
3639
3659
  call,
3660
+ conference: false, // @FIXME?
3640
3661
  });
3641
3662
  }
3642
3663
  }
@@ -3732,7 +3753,7 @@ class Recording {
3732
3753
 
3733
3754
 
3734
3755
 
3735
-
3756
+
3736
3757
 
3737
3758
 
3738
3759
 
@@ -5601,6 +5622,7 @@ var getApiClient = (forServer ) => {
5601
5622
 
5602
5623
  class InvalidSubscription extends Error {}
5603
5624
  class InvalidAuthorization extends Error {}
5625
+ class NoTenantIdError extends Error {}
5604
5626
 
5605
5627
  const logger$9 = IssueReporter$1.loggerFor('simple-auth');
5606
5628
 
@@ -5614,11 +5636,15 @@ class Auth {
5614
5636
 
5615
5637
 
5616
5638
 
5639
+
5640
+
5617
5641
 
5618
5642
  constructor() {
5619
5643
  this.expiration = DETAULT_EXPIRATION;
5620
5644
  this.authenticated = false;
5621
5645
  this.minSubscriptionType = null;
5646
+ this.BACKEND_WAZO = DEFAULT_BACKEND_USER;
5647
+ this.BACKEND_LDAP = BACKEND_LDAP_USER;
5622
5648
  }
5623
5649
 
5624
5650
  init(clientId ,
@@ -5651,12 +5677,18 @@ class Auth {
5651
5677
  setFetchOptions(options);
5652
5678
  }
5653
5679
 
5654
- async logIn(username , password ) {
5680
+ async logIn(username , password , backend , tenantId ) {
5681
+ if (backend && backend !== this.BACKEND_WAZO && !tenantId) {
5682
+ throw new NoTenantIdError('No tenant id');
5683
+ }
5684
+
5655
5685
  this.authenticated = false;
5656
5686
  this.session = null;
5657
5687
  const rawSession = await getApiClient().auth.logIn({
5658
5688
  username,
5659
5689
  password,
5690
+ backend,
5691
+ tenantId,
5660
5692
  expiration: this.expiration,
5661
5693
  mobile: this.mobile,
5662
5694
  });
@@ -5886,7 +5918,7 @@ var Auth$1 = global.wazoAuthInstance;
5886
5918
 
5887
5919
 
5888
5920
 
5889
-
5921
+
5890
5922
 
5891
5923
 
5892
5924
 
@@ -5906,7 +5938,7 @@ class AdHocAPIConference {
5906
5938
 
5907
5939
 
5908
5940
 
5909
-
5941
+
5910
5942
 
5911
5943
 
5912
5944
 
@@ -5918,7 +5950,7 @@ class AdHocAPIConference {
5918
5950
  participants,
5919
5951
  started,
5920
5952
  finished,
5921
- startTime,
5953
+ answerTime,
5922
5954
  conferenceId,
5923
5955
  muted,
5924
5956
  paused,
@@ -5928,16 +5960,20 @@ class AdHocAPIConference {
5928
5960
  this.participants = participants || {};
5929
5961
  this.started = started || false;
5930
5962
  this.finished = finished || false;
5931
- this.startTime = startTime;
5963
+ this.answerTime = answerTime;
5932
5964
  this.conferenceId = conferenceId || '';
5933
5965
  this.muted = muted || false;
5934
5966
  this.paused = paused || false;
5967
+
5968
+ if (this.host) {
5969
+ this.host.setIsConference(true);
5970
+ }
5935
5971
  }
5936
5972
 
5937
5973
  async start() {
5938
5974
  this.started = true;
5939
5975
  // $FlowFixMe
5940
- this.startTime = Object.values(this.participants).length ? Object.values(this.participants)[0].startTime : null;
5976
+ this.answerTime = Object.values(this.participants).length ? Object.values(this.participants)[0].answerTime : null;
5941
5977
 
5942
5978
  const participantIds = Object.keys(this.participants);
5943
5979
  const conference = await getApiClient().calld.createAdHocConference(this.host.callId, participantIds);
@@ -9641,7 +9677,11 @@ class WebRTCPhone extends Emitter {
9641
9677
  accept(callSession , cameraEnabled ) {
9642
9678
  logger$7.info('WebRTC phone - accept call', { id: callSession ? callSession.getId() : 'n/a', cameraEnabled });
9643
9679
  if (this.currentSipSession) {
9644
- this.holdSipSession(this.currentSipSession, this.currentCallSession, true);
9680
+ this.holdSipSession(
9681
+ this.currentSipSession,
9682
+ this.currentCallSession,
9683
+ true,
9684
+ );
9645
9685
  }
9646
9686
 
9647
9687
  if (!callSession) {
@@ -9734,22 +9774,22 @@ class WebRTCPhone extends Emitter {
9734
9774
  }
9735
9775
  }
9736
9776
 
9737
- hold(callSession , withEvent = true, isConference = false) {
9777
+ hold(callSession , withEvent = true) {
9738
9778
  logger$7.info('WebRTC hold', { id: callSession.getId() });
9739
9779
 
9740
9780
  const sipSession = this.findSipSession(callSession);
9741
9781
 
9742
- return sipSession ? this.holdSipSession(sipSession, callSession, withEvent, isConference) : null;
9782
+ return sipSession ? this.holdSipSession(sipSession, callSession, withEvent) : null;
9743
9783
  }
9744
9784
 
9745
9785
  // @Deprecated
9746
- unhold(callSession , withEvent = true, isConference = false) {
9786
+ unhold(callSession , withEvent = true) {
9747
9787
  console.warn('Please note that `phone.unhold()` is being deprecated; `phone.resume()` is the preferred method');
9748
9788
 
9749
- return this.resume(callSession, isConference, withEvent);
9789
+ return this.resume(callSession, withEvent);
9750
9790
  }
9751
9791
 
9752
- resume(callSession , isConference = false, withEvent = true) {
9792
+ resume(callSession , withEvent = true) {
9753
9793
  logger$7.info('WebRTC resume called', { id: callSession ? callSession.getId() : null });
9754
9794
 
9755
9795
  const sipSession = this.findSipSession(callSession);
@@ -9762,10 +9802,14 @@ class WebRTCPhone extends Emitter {
9762
9802
  // Hold current session if different from the current one (we don't want 2 sessions active at the same time).
9763
9803
  if (this.currentSipSession && this.currentSipSession.id !== sipSession.id) {
9764
9804
  logger$7.info('WebRTC hold call after resume', { id: this.currentSipSession.id });
9765
- this.holdSipSession(this.currentSipSession, this.currentCallSession);
9805
+ this.holdSipSession(
9806
+ this.currentSipSession,
9807
+ this.currentCallSession,
9808
+ withEvent,
9809
+ );
9766
9810
  }
9767
9811
 
9768
- const promise = this.unholdSipSession(sipSession, callSession, withEvent, isConference);
9812
+ const promise = this.unholdSipSession(sipSession, callSession, withEvent);
9769
9813
  this.currentSipSession = sipSession;
9770
9814
  if (callSession) {
9771
9815
  this.currentCallSession = callSession;
@@ -9778,7 +9822,6 @@ class WebRTCPhone extends Emitter {
9778
9822
  sipSession ,
9779
9823
  callSession ,
9780
9824
  withEvent = true,
9781
- isConference = false,
9782
9825
  ) {
9783
9826
  if (!sipSession) {
9784
9827
  return new Promise((resolve, reject) => reject(new Error('No session to hold')));
@@ -9799,6 +9842,8 @@ class WebRTCPhone extends Emitter {
9799
9842
  await this.client.downgradeToAudio(sipSession);
9800
9843
  }
9801
9844
 
9845
+ const isConference = !!callSession && callSession.isConference();
9846
+
9802
9847
  const promise = this.client.hold(sipSession, isConference, hasVideo);
9803
9848
  if (withEvent) {
9804
9849
  this.eventEmitter.emit(ON_CALL_HELD, this._createCallSession(sipSession, callSession));
@@ -9811,11 +9856,13 @@ class WebRTCPhone extends Emitter {
9811
9856
  sipSession ,
9812
9857
  callSession ,
9813
9858
  withEvent = true,
9814
- isConference = false,
9815
9859
  ) {
9816
9860
  if (!sipSession) {
9817
9861
  return new Promise((resolve, reject) => reject(new Error('No session to unhold')));
9818
9862
  }
9863
+
9864
+ const isConference = !!callSession && callSession.isConference();
9865
+
9819
9866
  const sessionId = this.getSipSessionId(sipSession);
9820
9867
  logger$7.info('WebRTC unhold sip session', { sessionId, isConference });
9821
9868
 
@@ -9957,7 +10004,11 @@ class WebRTCPhone extends Emitter {
9957
10004
  await this.client.register();
9958
10005
  }
9959
10006
  if (this.currentSipSession) {
9960
- this.holdSipSession(this.currentSipSession, this.currentCallSession, true).catch(e => {
10007
+ this.holdSipSession(
10008
+ this.currentSipSession,
10009
+ this.currentCallSession,
10010
+ true,
10011
+ ).catch(e => {
9961
10012
  logger$7.warn('Unable to hold current session when making another call', e);
9962
10013
  });
9963
10014
  }
@@ -9972,6 +10023,7 @@ class WebRTCPhone extends Emitter {
9972
10023
  return Promise.resolve(null);
9973
10024
  }
9974
10025
  const callSession = this._createOutgoingCallSession(sipSession, cameraEnabled || false);
10026
+ callSession.setIsConference(conference);
9975
10027
  callSession.creationTime = new Date();
9976
10028
  this._updateCallSession(callSession);
9977
10029
 
@@ -10550,6 +10602,7 @@ class WebRTCPhone extends Emitter {
10550
10602
  recording: fromSession ? fromSession.isRecording() : false,
10551
10603
  recordingPaused: false, // @TODO
10552
10604
  sipSession,
10605
+ conference: !!fromSession && fromSession.isConference(),
10553
10606
  ...extra,
10554
10607
  });
10555
10608
 
@@ -10806,16 +10859,16 @@ class Phone extends Emitter {
10806
10859
  }
10807
10860
  }
10808
10861
 
10809
- hold(callSession , isConference = false) {
10810
- return this.phone && this.phone.hold(callSession, true, isConference);
10862
+ hold(callSession ) {
10863
+ return this.phone && this.phone.hold(callSession, true);
10811
10864
  }
10812
10865
 
10813
- unhold(callSession , isConference = false) {
10814
- return this.phone && this.phone.unhold(callSession, true, isConference);
10866
+ unhold(callSession ) {
10867
+ return this.phone && this.phone.unhold(callSession, true);
10815
10868
  }
10816
10869
 
10817
- resume(callSession , isConference = false) {
10818
- return this.phone && this.phone.resume(callSession, isConference);
10870
+ resume(callSession ) {
10871
+ return this.phone && this.phone.resume(callSession);
10819
10872
  }
10820
10873
 
10821
10874
  reject(callSession ) {
@@ -12378,7 +12431,7 @@ class Room$1 {
12378
12431
 
12379
12432
 
12380
12433
 
12381
-
12434
+
12382
12435
 
12383
12436
 
12384
12437
 
@@ -12404,7 +12457,7 @@ class SwitchboardCall {
12404
12457
 
12405
12458
 
12406
12459
 
12407
-
12460
+
12408
12461
 
12409
12462
 
12410
12463
 
@@ -12418,7 +12471,7 @@ class SwitchboardCall {
12418
12471
  callerIdName: plain.caller_id_name || null,
12419
12472
  callerIdNumber: plain.caller_id_number || null,
12420
12473
  participantId: plain.participantId || null,
12421
- startTime: plain.startTime,
12474
+ answerTime: plain.startTime,
12422
12475
  state: plain.state,
12423
12476
  switchboardName: plain.switchboardName,
12424
12477
  switchboardUuid: plain.switchboardUuid,
@@ -12431,7 +12484,7 @@ class SwitchboardCall {
12431
12484
  callerIdName,
12432
12485
  callerIdNumber,
12433
12486
  participantId,
12434
- startTime,
12487
+ answerTime,
12435
12488
  state,
12436
12489
  switchboardName,
12437
12490
  switchboardUuid,
@@ -12441,7 +12494,7 @@ class SwitchboardCall {
12441
12494
  this.callerIdName = callerIdName;
12442
12495
  this.callerIdNumber = callerIdNumber;
12443
12496
  this.participantId = participantId;
12444
- this.startTime = startTime;
12497
+ this.answerTime = answerTime;
12445
12498
  this.state = state;
12446
12499
  this.switchboardName = switchboardName;
12447
12500
  this.switchboardUuid = switchboardUuid;
@@ -13078,6 +13131,7 @@ const Wazo = {
13078
13131
  InvalidAuthorization,
13079
13132
  CanceledCallError,
13080
13133
  SFUNotAvailableError,
13134
+ NoTenantIdError,
13081
13135
  };
13082
13136
 
13083
13137
  if (window) {