@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
@@ -1097,6 +1097,7 @@ const LINE_STATE = {
1097
1097
 
1098
1098
 
1099
1099
 
1100
+
1100
1101
 
1101
1102
 
1102
1103
 
@@ -1133,6 +1134,7 @@ const LINE_STATE = {
1133
1134
 
1134
1135
 
1135
1136
 
1137
+
1136
1138
 
1137
1139
 
1138
1140
 
@@ -1164,6 +1166,7 @@ class Profile {
1164
1166
 
1165
1167
 
1166
1168
 
1169
+
1167
1170
 
1168
1171
 
1169
1172
 
@@ -1180,6 +1183,7 @@ class Profile {
1180
1183
  lines: plain.lines.map(line => Line.parse(line)),
1181
1184
  username: plain.username,
1182
1185
  mobileNumber: plain.mobile_phone_number || '',
1186
+ ringSeconds: plain.ring_seconds,
1183
1187
  forwards: [
1184
1188
  ForwardOption.parse(plain.forwards.unconditional, FORWARD_KEYS.UNCONDITIONAL),
1185
1189
  ForwardOption.parse(plain.forwards.noanswer, FORWARD_KEYS.NO_ANSWER),
@@ -1216,6 +1220,7 @@ class Profile {
1216
1220
  switchboards,
1217
1221
  agent,
1218
1222
  status,
1223
+ ringSeconds,
1219
1224
  sipLines,
1220
1225
  callPickupTargetUsers,
1221
1226
  onlineCallRecordEnabled,
@@ -1237,6 +1242,7 @@ class Profile {
1237
1242
  this.status = status;
1238
1243
  this.callPickupTargetUsers = callPickupTargetUsers;
1239
1244
  this.onlineCallRecordEnabled = onlineCallRecordEnabled;
1245
+ this.ringSeconds = ringSeconds;
1240
1246
 
1241
1247
  this.sipLines = sipLines || [];
1242
1248
  }
@@ -2228,6 +2234,7 @@ class Session {
2228
2234
  /* */
2229
2235
 
2230
2236
  const DEFAULT_BACKEND_USER = 'wazo_user';
2237
+ const BACKEND_LDAP_USER = 'ldap_user';
2231
2238
  const DETAULT_EXPIRATION = 3600;
2232
2239
 
2233
2240
  var authMethods = (client , baseUrl ) => ({
@@ -3306,6 +3313,7 @@ var updateFrom = (instance , from ) => {
3306
3313
 
3307
3314
 
3308
3315
 
3316
+
3309
3317
 
3310
3318
 
3311
3319
  class CallSession {
@@ -3368,6 +3376,8 @@ class CallSession {
3368
3376
 
3369
3377
 
3370
3378
 
3379
+
3380
+
3371
3381
 
3372
3382
 
3373
3383
 
@@ -3399,6 +3409,7 @@ class CallSession {
3399
3409
  videoRemotelyDowngraded,
3400
3410
  sipSession,
3401
3411
  answerTime,
3412
+ conference,
3402
3413
  } ) {
3403
3414
  this.callId = callId;
3404
3415
  this.sipCallId = sipCallId;
@@ -3427,6 +3438,7 @@ class CallSession {
3427
3438
  this.videoRemotelyDowngraded = videoRemotelyDowngraded;
3428
3439
  this.sipSession = sipSession;
3429
3440
  this.answerTime = answerTime || this.answerTime;
3441
+ this.conference = conference;
3430
3442
 
3431
3443
  // Useful to compare instead of instanceof with minified code
3432
3444
  this.type = 'CallSession';
@@ -3484,6 +3496,10 @@ class CallSession {
3484
3496
  this.screensharing = false;
3485
3497
  }
3486
3498
 
3499
+ setIsConference(conference ) {
3500
+ this.conference = conference;
3501
+ }
3502
+
3487
3503
  isIncoming() {
3488
3504
  return !this.isCaller && !this.answered;
3489
3505
  }
@@ -3560,6 +3576,10 @@ class CallSession {
3560
3576
  return this.sipStatus === SessionState.Terminated;
3561
3577
  }
3562
3578
 
3579
+ isConference() {
3580
+ return this.conference;
3581
+ }
3582
+
3563
3583
  getElapsedTimeInSeconds() {
3564
3584
  if (!this.startTime) {
3565
3585
  return 0;
@@ -3651,6 +3671,7 @@ class CallSession {
3651
3671
  cameraEnabled: false,
3652
3672
  dialedExtension: call.dialedExtension,
3653
3673
  call,
3674
+ conference: false, // @FIXME?
3654
3675
  });
3655
3676
  }
3656
3677
  }
@@ -3720,7 +3741,7 @@ class Recording {
3720
3741
 
3721
3742
 
3722
3743
 
3723
-
3744
+
3724
3745
 
3725
3746
 
3726
3747
 
@@ -5589,6 +5610,7 @@ var getApiClient = (forServer ) => {
5589
5610
 
5590
5611
  class InvalidSubscription extends Error {}
5591
5612
  class InvalidAuthorization extends Error {}
5613
+ class NoTenantIdError extends Error {}
5592
5614
 
5593
5615
  const logger$9 = IssueReporter$1.loggerFor('simple-auth');
5594
5616
 
@@ -5602,11 +5624,15 @@ class Auth {
5602
5624
 
5603
5625
 
5604
5626
 
5627
+
5628
+
5605
5629
 
5606
5630
  constructor() {
5607
5631
  this.expiration = DETAULT_EXPIRATION;
5608
5632
  this.authenticated = false;
5609
5633
  this.minSubscriptionType = null;
5634
+ this.BACKEND_WAZO = DEFAULT_BACKEND_USER;
5635
+ this.BACKEND_LDAP = BACKEND_LDAP_USER;
5610
5636
  }
5611
5637
 
5612
5638
  init(clientId ,
@@ -5639,12 +5665,18 @@ class Auth {
5639
5665
  setFetchOptions(options);
5640
5666
  }
5641
5667
 
5642
- async logIn(username , password ) {
5668
+ async logIn(username , password , backend , tenantId ) {
5669
+ if (backend && backend !== this.BACKEND_WAZO && !tenantId) {
5670
+ throw new NoTenantIdError('No tenant id');
5671
+ }
5672
+
5643
5673
  this.authenticated = false;
5644
5674
  this.session = null;
5645
5675
  const rawSession = await getApiClient().auth.logIn({
5646
5676
  username,
5647
5677
  password,
5678
+ backend,
5679
+ tenantId,
5648
5680
  expiration: this.expiration,
5649
5681
  mobile: this.mobile,
5650
5682
  });
@@ -5874,7 +5906,7 @@ var Auth$1 = global.wazoAuthInstance;
5874
5906
 
5875
5907
 
5876
5908
 
5877
-
5909
+
5878
5910
 
5879
5911
 
5880
5912
 
@@ -5894,7 +5926,7 @@ class AdHocAPIConference {
5894
5926
 
5895
5927
 
5896
5928
 
5897
-
5929
+
5898
5930
 
5899
5931
 
5900
5932
 
@@ -5906,7 +5938,7 @@ class AdHocAPIConference {
5906
5938
  participants,
5907
5939
  started,
5908
5940
  finished,
5909
- startTime,
5941
+ answerTime,
5910
5942
  conferenceId,
5911
5943
  muted,
5912
5944
  paused,
@@ -5916,16 +5948,20 @@ class AdHocAPIConference {
5916
5948
  this.participants = participants || {};
5917
5949
  this.started = started || false;
5918
5950
  this.finished = finished || false;
5919
- this.startTime = startTime;
5951
+ this.answerTime = answerTime;
5920
5952
  this.conferenceId = conferenceId || '';
5921
5953
  this.muted = muted || false;
5922
5954
  this.paused = paused || false;
5955
+
5956
+ if (this.host) {
5957
+ this.host.setIsConference(true);
5958
+ }
5923
5959
  }
5924
5960
 
5925
5961
  async start() {
5926
5962
  this.started = true;
5927
5963
  // $FlowFixMe
5928
- this.startTime = Object.values(this.participants).length ? Object.values(this.participants)[0].startTime : null;
5964
+ this.answerTime = Object.values(this.participants).length ? Object.values(this.participants)[0].answerTime : null;
5929
5965
 
5930
5966
  const participantIds = Object.keys(this.participants);
5931
5967
  const conference = await getApiClient().calld.createAdHocConference(this.host.callId, participantIds);
@@ -9629,7 +9665,11 @@ class WebRTCPhone extends Emitter {
9629
9665
  accept(callSession , cameraEnabled ) {
9630
9666
  logger$7.info('WebRTC phone - accept call', { id: callSession ? callSession.getId() : 'n/a', cameraEnabled });
9631
9667
  if (this.currentSipSession) {
9632
- this.holdSipSession(this.currentSipSession, this.currentCallSession, true);
9668
+ this.holdSipSession(
9669
+ this.currentSipSession,
9670
+ this.currentCallSession,
9671
+ true,
9672
+ );
9633
9673
  }
9634
9674
 
9635
9675
  if (!callSession) {
@@ -9722,22 +9762,22 @@ class WebRTCPhone extends Emitter {
9722
9762
  }
9723
9763
  }
9724
9764
 
9725
- hold(callSession , withEvent = true, isConference = false) {
9765
+ hold(callSession , withEvent = true) {
9726
9766
  logger$7.info('WebRTC hold', { id: callSession.getId() });
9727
9767
 
9728
9768
  const sipSession = this.findSipSession(callSession);
9729
9769
 
9730
- return sipSession ? this.holdSipSession(sipSession, callSession, withEvent, isConference) : null;
9770
+ return sipSession ? this.holdSipSession(sipSession, callSession, withEvent) : null;
9731
9771
  }
9732
9772
 
9733
9773
  // @Deprecated
9734
- unhold(callSession , withEvent = true, isConference = false) {
9774
+ unhold(callSession , withEvent = true) {
9735
9775
  console.warn('Please note that `phone.unhold()` is being deprecated; `phone.resume()` is the preferred method');
9736
9776
 
9737
- return this.resume(callSession, isConference, withEvent);
9777
+ return this.resume(callSession, withEvent);
9738
9778
  }
9739
9779
 
9740
- resume(callSession , isConference = false, withEvent = true) {
9780
+ resume(callSession , withEvent = true) {
9741
9781
  logger$7.info('WebRTC resume called', { id: callSession ? callSession.getId() : null });
9742
9782
 
9743
9783
  const sipSession = this.findSipSession(callSession);
@@ -9750,10 +9790,14 @@ class WebRTCPhone extends Emitter {
9750
9790
  // Hold current session if different from the current one (we don't want 2 sessions active at the same time).
9751
9791
  if (this.currentSipSession && this.currentSipSession.id !== sipSession.id) {
9752
9792
  logger$7.info('WebRTC hold call after resume', { id: this.currentSipSession.id });
9753
- this.holdSipSession(this.currentSipSession, this.currentCallSession);
9793
+ this.holdSipSession(
9794
+ this.currentSipSession,
9795
+ this.currentCallSession,
9796
+ withEvent,
9797
+ );
9754
9798
  }
9755
9799
 
9756
- const promise = this.unholdSipSession(sipSession, callSession, withEvent, isConference);
9800
+ const promise = this.unholdSipSession(sipSession, callSession, withEvent);
9757
9801
  this.currentSipSession = sipSession;
9758
9802
  if (callSession) {
9759
9803
  this.currentCallSession = callSession;
@@ -9766,7 +9810,6 @@ class WebRTCPhone extends Emitter {
9766
9810
  sipSession ,
9767
9811
  callSession ,
9768
9812
  withEvent = true,
9769
- isConference = false,
9770
9813
  ) {
9771
9814
  if (!sipSession) {
9772
9815
  return new Promise((resolve, reject) => reject(new Error('No session to hold')));
@@ -9787,6 +9830,8 @@ class WebRTCPhone extends Emitter {
9787
9830
  await this.client.downgradeToAudio(sipSession);
9788
9831
  }
9789
9832
 
9833
+ const isConference = !!callSession && callSession.isConference();
9834
+
9790
9835
  const promise = this.client.hold(sipSession, isConference, hasVideo);
9791
9836
  if (withEvent) {
9792
9837
  this.eventEmitter.emit(ON_CALL_HELD, this._createCallSession(sipSession, callSession));
@@ -9799,11 +9844,13 @@ class WebRTCPhone extends Emitter {
9799
9844
  sipSession ,
9800
9845
  callSession ,
9801
9846
  withEvent = true,
9802
- isConference = false,
9803
9847
  ) {
9804
9848
  if (!sipSession) {
9805
9849
  return new Promise((resolve, reject) => reject(new Error('No session to unhold')));
9806
9850
  }
9851
+
9852
+ const isConference = !!callSession && callSession.isConference();
9853
+
9807
9854
  const sessionId = this.getSipSessionId(sipSession);
9808
9855
  logger$7.info('WebRTC unhold sip session', { sessionId, isConference });
9809
9856
 
@@ -9945,7 +9992,11 @@ class WebRTCPhone extends Emitter {
9945
9992
  await this.client.register();
9946
9993
  }
9947
9994
  if (this.currentSipSession) {
9948
- this.holdSipSession(this.currentSipSession, this.currentCallSession, true).catch(e => {
9995
+ this.holdSipSession(
9996
+ this.currentSipSession,
9997
+ this.currentCallSession,
9998
+ true,
9999
+ ).catch(e => {
9949
10000
  logger$7.warn('Unable to hold current session when making another call', e);
9950
10001
  });
9951
10002
  }
@@ -9960,6 +10011,7 @@ class WebRTCPhone extends Emitter {
9960
10011
  return Promise.resolve(null);
9961
10012
  }
9962
10013
  const callSession = this._createOutgoingCallSession(sipSession, cameraEnabled || false);
10014
+ callSession.setIsConference(conference);
9963
10015
  callSession.creationTime = new Date();
9964
10016
  this._updateCallSession(callSession);
9965
10017
 
@@ -10538,6 +10590,7 @@ class WebRTCPhone extends Emitter {
10538
10590
  recording: fromSession ? fromSession.isRecording() : false,
10539
10591
  recordingPaused: false, // @TODO
10540
10592
  sipSession,
10593
+ conference: !!fromSession && fromSession.isConference(),
10541
10594
  ...extra,
10542
10595
  });
10543
10596
 
@@ -10794,16 +10847,16 @@ class Phone extends Emitter {
10794
10847
  }
10795
10848
  }
10796
10849
 
10797
- hold(callSession , isConference = false) {
10798
- return this.phone && this.phone.hold(callSession, true, isConference);
10850
+ hold(callSession ) {
10851
+ return this.phone && this.phone.hold(callSession, true);
10799
10852
  }
10800
10853
 
10801
- unhold(callSession , isConference = false) {
10802
- return this.phone && this.phone.unhold(callSession, true, isConference);
10854
+ unhold(callSession ) {
10855
+ return this.phone && this.phone.unhold(callSession, true);
10803
10856
  }
10804
10857
 
10805
- resume(callSession , isConference = false) {
10806
- return this.phone && this.phone.resume(callSession, isConference);
10858
+ resume(callSession ) {
10859
+ return this.phone && this.phone.resume(callSession);
10807
10860
  }
10808
10861
 
10809
10862
  reject(callSession ) {
@@ -12076,7 +12129,7 @@ class Room$1 {
12076
12129
 
12077
12130
 
12078
12131
 
12079
-
12132
+
12080
12133
 
12081
12134
 
12082
12135
 
@@ -12102,7 +12155,7 @@ class SwitchboardCall {
12102
12155
 
12103
12156
 
12104
12157
 
12105
-
12158
+
12106
12159
 
12107
12160
 
12108
12161
 
@@ -12116,7 +12169,7 @@ class SwitchboardCall {
12116
12169
  callerIdName: plain.caller_id_name || null,
12117
12170
  callerIdNumber: plain.caller_id_number || null,
12118
12171
  participantId: plain.participantId || null,
12119
- startTime: plain.startTime,
12172
+ answerTime: plain.startTime,
12120
12173
  state: plain.state,
12121
12174
  switchboardName: plain.switchboardName,
12122
12175
  switchboardUuid: plain.switchboardUuid,
@@ -12129,7 +12182,7 @@ class SwitchboardCall {
12129
12182
  callerIdName,
12130
12183
  callerIdNumber,
12131
12184
  participantId,
12132
- startTime,
12185
+ answerTime,
12133
12186
  state,
12134
12187
  switchboardName,
12135
12188
  switchboardUuid,
@@ -12139,7 +12192,7 @@ class SwitchboardCall {
12139
12192
  this.callerIdName = callerIdName;
12140
12193
  this.callerIdNumber = callerIdNumber;
12141
12194
  this.participantId = participantId;
12142
- this.startTime = startTime;
12195
+ this.answerTime = answerTime;
12143
12196
  this.state = state;
12144
12197
  this.switchboardName = switchboardName;
12145
12198
  this.switchboardUuid = switchboardUuid;
@@ -12776,6 +12829,7 @@ const Wazo = {
12776
12829
  InvalidAuthorization,
12777
12830
  CanceledCallError,
12778
12831
  SFUNotAvailableError,
12832
+ NoTenantIdError,
12779
12833
  };
12780
12834
 
12781
12835
  if (window) {