@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
@@ -1107,6 +1107,7 @@ const LINE_STATE = {
1107
1107
 
1108
1108
 
1109
1109
 
1110
+
1110
1111
 
1111
1112
 
1112
1113
 
@@ -1143,6 +1144,7 @@ const LINE_STATE = {
1143
1144
 
1144
1145
 
1145
1146
 
1147
+
1146
1148
 
1147
1149
 
1148
1150
 
@@ -1174,6 +1176,7 @@ class Profile {
1174
1176
 
1175
1177
 
1176
1178
 
1179
+
1177
1180
 
1178
1181
 
1179
1182
 
@@ -1190,6 +1193,7 @@ class Profile {
1190
1193
  lines: plain.lines.map(line => Line.parse(line)),
1191
1194
  username: plain.username,
1192
1195
  mobileNumber: plain.mobile_phone_number || '',
1196
+ ringSeconds: plain.ring_seconds,
1193
1197
  forwards: [
1194
1198
  ForwardOption.parse(plain.forwards.unconditional, FORWARD_KEYS.UNCONDITIONAL),
1195
1199
  ForwardOption.parse(plain.forwards.noanswer, FORWARD_KEYS.NO_ANSWER),
@@ -1226,6 +1230,7 @@ class Profile {
1226
1230
  switchboards,
1227
1231
  agent,
1228
1232
  status,
1233
+ ringSeconds,
1229
1234
  sipLines,
1230
1235
  callPickupTargetUsers,
1231
1236
  onlineCallRecordEnabled,
@@ -1247,6 +1252,7 @@ class Profile {
1247
1252
  this.status = status;
1248
1253
  this.callPickupTargetUsers = callPickupTargetUsers;
1249
1254
  this.onlineCallRecordEnabled = onlineCallRecordEnabled;
1255
+ this.ringSeconds = ringSeconds;
1250
1256
 
1251
1257
  this.sipLines = sipLines || [];
1252
1258
  }
@@ -2238,6 +2244,7 @@ class Session {
2238
2244
  /* */
2239
2245
 
2240
2246
  const DEFAULT_BACKEND_USER = 'wazo_user';
2247
+ const BACKEND_LDAP_USER = 'ldap_user';
2241
2248
  const DETAULT_EXPIRATION = 3600;
2242
2249
 
2243
2250
  var authMethods = (client , baseUrl ) => ({
@@ -3316,6 +3323,7 @@ var updateFrom = (instance , from ) => {
3316
3323
 
3317
3324
 
3318
3325
 
3326
+
3319
3327
 
3320
3328
 
3321
3329
  class CallSession {
@@ -3378,6 +3386,8 @@ class CallSession {
3378
3386
 
3379
3387
 
3380
3388
 
3389
+
3390
+
3381
3391
 
3382
3392
 
3383
3393
 
@@ -3409,6 +3419,7 @@ class CallSession {
3409
3419
  videoRemotelyDowngraded,
3410
3420
  sipSession,
3411
3421
  answerTime,
3422
+ conference,
3412
3423
  } ) {
3413
3424
  this.callId = callId;
3414
3425
  this.sipCallId = sipCallId;
@@ -3437,6 +3448,7 @@ class CallSession {
3437
3448
  this.videoRemotelyDowngraded = videoRemotelyDowngraded;
3438
3449
  this.sipSession = sipSession;
3439
3450
  this.answerTime = answerTime || this.answerTime;
3451
+ this.conference = conference;
3440
3452
 
3441
3453
  // Useful to compare instead of instanceof with minified code
3442
3454
  this.type = 'CallSession';
@@ -3494,6 +3506,10 @@ class CallSession {
3494
3506
  this.screensharing = false;
3495
3507
  }
3496
3508
 
3509
+ setIsConference(conference ) {
3510
+ this.conference = conference;
3511
+ }
3512
+
3497
3513
  isIncoming() {
3498
3514
  return !this.isCaller && !this.answered;
3499
3515
  }
@@ -3570,6 +3586,10 @@ class CallSession {
3570
3586
  return this.sipStatus === sessionState.SessionState.Terminated;
3571
3587
  }
3572
3588
 
3589
+ isConference() {
3590
+ return this.conference;
3591
+ }
3592
+
3573
3593
  getElapsedTimeInSeconds() {
3574
3594
  if (!this.startTime) {
3575
3595
  return 0;
@@ -3661,6 +3681,7 @@ class CallSession {
3661
3681
  cameraEnabled: false,
3662
3682
  dialedExtension: call.dialedExtension,
3663
3683
  call,
3684
+ conference: false, // @FIXME?
3664
3685
  });
3665
3686
  }
3666
3687
  }
@@ -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 ) {
@@ -12086,7 +12139,7 @@ class Room$1 {
12086
12139
 
12087
12140
 
12088
12141
 
12089
-
12142
+
12090
12143
 
12091
12144
 
12092
12145
 
@@ -12112,7 +12165,7 @@ class SwitchboardCall {
12112
12165
 
12113
12166
 
12114
12167
 
12115
-
12168
+
12116
12169
 
12117
12170
 
12118
12171
 
@@ -12126,7 +12179,7 @@ class SwitchboardCall {
12126
12179
  callerIdName: plain.caller_id_name || null,
12127
12180
  callerIdNumber: plain.caller_id_number || null,
12128
12181
  participantId: plain.participantId || null,
12129
- startTime: plain.startTime,
12182
+ answerTime: plain.startTime,
12130
12183
  state: plain.state,
12131
12184
  switchboardName: plain.switchboardName,
12132
12185
  switchboardUuid: plain.switchboardUuid,
@@ -12139,7 +12192,7 @@ class SwitchboardCall {
12139
12192
  callerIdName,
12140
12193
  callerIdNumber,
12141
12194
  participantId,
12142
- startTime,
12195
+ answerTime,
12143
12196
  state,
12144
12197
  switchboardName,
12145
12198
  switchboardUuid,
@@ -12149,7 +12202,7 @@ class SwitchboardCall {
12149
12202
  this.callerIdName = callerIdName;
12150
12203
  this.callerIdNumber = callerIdNumber;
12151
12204
  this.participantId = participantId;
12152
- this.startTime = startTime;
12205
+ this.answerTime = answerTime;
12153
12206
  this.state = state;
12154
12207
  this.switchboardName = switchboardName;
12155
12208
  this.switchboardUuid = switchboardUuid;
@@ -12786,6 +12839,7 @@ const Wazo = {
12786
12839
  InvalidAuthorization,
12787
12840
  CanceledCallError,
12788
12841
  SFUNotAvailableError,
12842
+ NoTenantIdError,
12789
12843
  };
12790
12844
 
12791
12845
  if (window) {