@wazo/sdk 0.37.34 → 0.37.37

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 (99) hide show
  1. package/README.md +8 -2
  2. package/dist/wazo-sdk.js +2 -2
  3. package/esm/__tests__/api-client.test.js +17 -0
  4. package/esm/__tests__/web-rtc-client.test.js +17 -0
  5. package/esm/api/auth.js +7 -1
  6. package/esm/api/call-logd.js +6 -0
  7. package/esm/api/chatd.js +6 -0
  8. package/esm/api/confd.js +6 -0
  9. package/esm/api-client.js +17 -0
  10. package/esm/checker/Checker.js +17 -0
  11. package/esm/checker/checks/aor.js +17 -0
  12. package/esm/checker/checks/api.js +17 -0
  13. package/esm/checker/checks/index.js +17 -0
  14. package/esm/checker/checks/webrtc-transport.js +17 -0
  15. package/esm/checker/checks/webrtc.js +17 -0
  16. package/esm/domain/AdHocAPIConference.js +21 -0
  17. package/esm/domain/CallLog.js +6 -0
  18. package/esm/domain/CallSession.js +14 -0
  19. package/esm/domain/Features.js +17 -0
  20. package/esm/domain/Phone/CTIPhone.js +31 -0
  21. package/esm/domain/Phone/WebRTCPhone.js +42 -11
  22. package/esm/domain/Profile.js +6 -0
  23. package/esm/domain/__tests__/CallLog.test.js +10 -0
  24. package/esm/domain/__tests__/CallSession.test.js +14 -0
  25. package/esm/domain/__tests__/IndirectTransfer.test.js +14 -0
  26. package/esm/domain/__tests__/Profile.test.js +6 -0
  27. package/esm/domain/__tests__/Room.test.js +14 -0
  28. package/esm/domain/__tests__/Session.test.js +6 -0
  29. package/esm/index.js +83 -18
  30. package/esm/service/CallApi.js +17 -0
  31. package/esm/service/getApiClient.js +17 -0
  32. package/esm/simple/Auth.js +84 -19
  33. package/esm/simple/Configuration.js +83 -18
  34. package/esm/simple/Directory.js +17 -0
  35. package/esm/simple/Phone.js +83 -18
  36. package/esm/simple/index.js +83 -18
  37. package/esm/simple/room/LocalParticipant.js +83 -18
  38. package/esm/simple/room/Participant.js +83 -18
  39. package/esm/simple/room/RemoteParticipant.js +83 -18
  40. package/esm/simple/room/Room.js +83 -18
  41. package/esm/simple/room/SipRoom.js +83 -18
  42. package/esm/simple/room/Stream.js +83 -18
  43. package/esm/simple/room/__tests__/RemoteParticipant.test.js +83 -18
  44. package/esm/simple/utils.js +83 -18
  45. package/esm/web-rtc-client.js +17 -0
  46. package/lib/__tests__/api-client.test.js +17 -0
  47. package/lib/__tests__/web-rtc-client.test.js +17 -0
  48. package/lib/api/auth.js +8 -0
  49. package/lib/api/call-logd.js +6 -0
  50. package/lib/api/chatd.js +6 -0
  51. package/lib/api/confd.js +6 -0
  52. package/lib/api-client.js +17 -0
  53. package/lib/checker/Checker.js +17 -0
  54. package/lib/checker/checks/aor.js +17 -0
  55. package/lib/checker/checks/api.js +17 -0
  56. package/lib/checker/checks/index.js +17 -0
  57. package/lib/checker/checks/webrtc-transport.js +17 -0
  58. package/lib/checker/checks/webrtc.js +17 -0
  59. package/lib/domain/AdHocAPIConference.js +21 -0
  60. package/lib/domain/CallLog.js +6 -0
  61. package/lib/domain/CallSession.js +14 -0
  62. package/lib/domain/Features.js +17 -0
  63. package/lib/domain/Phone/CTIPhone.js +31 -0
  64. package/lib/domain/Phone/WebRTCPhone.js +42 -11
  65. package/lib/domain/Profile.js +6 -0
  66. package/lib/domain/__tests__/CallLog.test.js +10 -0
  67. package/lib/domain/__tests__/CallSession.test.js +14 -0
  68. package/lib/domain/__tests__/IndirectTransfer.test.js +14 -0
  69. package/lib/domain/__tests__/Profile.test.js +6 -0
  70. package/lib/domain/__tests__/Room.test.js +14 -0
  71. package/lib/domain/__tests__/Session.test.js +6 -0
  72. package/lib/index.js +83 -18
  73. package/lib/service/CallApi.js +17 -0
  74. package/lib/service/getApiClient.js +17 -0
  75. package/lib/simple/Auth.js +84 -18
  76. package/lib/simple/Configuration.js +83 -18
  77. package/lib/simple/Directory.js +17 -0
  78. package/lib/simple/Phone.js +83 -18
  79. package/lib/simple/index.js +83 -18
  80. package/lib/simple/room/LocalParticipant.js +83 -18
  81. package/lib/simple/room/Participant.js +83 -18
  82. package/lib/simple/room/RemoteParticipant.js +83 -18
  83. package/lib/simple/room/Room.js +83 -18
  84. package/lib/simple/room/SipRoom.js +83 -18
  85. package/lib/simple/room/Stream.js +83 -18
  86. package/lib/simple/room/__tests__/RemoteParticipant.test.js +83 -18
  87. package/lib/simple/utils.js +83 -18
  88. package/lib/web-rtc-client.js +17 -0
  89. package/package.json +1 -1
  90. package/src/api/auth.js +7 -1
  91. package/src/domain/AdHocAPIConference.js +4 -0
  92. package/src/domain/CallLog.js +6 -0
  93. package/src/domain/CallSession.js +14 -0
  94. package/src/domain/Phone/WebRTCPhone.js +28 -11
  95. package/src/domain/Profile.js +6 -0
  96. package/src/domain/__tests__/CallLog.test.js +4 -0
  97. package/src/simple/Auth.js +13 -2
  98. package/src/simple/Phone.js +6 -6
  99. 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 ) => ({
@@ -2252,6 +2259,7 @@ var authMethods = (client , baseUrl ) => ({
2252
2259
 
2253
2260
 
2254
2261
 
2262
+
2255
2263
  ) {
2256
2264
  const body = {
2257
2265
  backend: params.backend || DEFAULT_BACKEND_USER,
@@ -2271,6 +2279,10 @@ var authMethods = (client , baseUrl ) => ({
2271
2279
  headers['Wazo-Session-Type'] = 'mobile';
2272
2280
  }
2273
2281
 
2282
+ if (params.tenantId) {
2283
+ body.tenant_id = params.tenantId;
2284
+ }
2285
+
2274
2286
  return client.post(`${baseUrl}/token`, body, headers).then(response => Session.parse(response));
2275
2287
  },
2276
2288
 
@@ -3311,6 +3323,7 @@ var updateFrom = (instance , from ) => {
3311
3323
 
3312
3324
 
3313
3325
 
3326
+
3314
3327
 
3315
3328
 
3316
3329
  class CallSession {
@@ -3373,6 +3386,8 @@ class CallSession {
3373
3386
 
3374
3387
 
3375
3388
 
3389
+
3390
+
3376
3391
 
3377
3392
 
3378
3393
 
@@ -3404,6 +3419,7 @@ class CallSession {
3404
3419
  videoRemotelyDowngraded,
3405
3420
  sipSession,
3406
3421
  answerTime,
3422
+ conference,
3407
3423
  } ) {
3408
3424
  this.callId = callId;
3409
3425
  this.sipCallId = sipCallId;
@@ -3432,6 +3448,7 @@ class CallSession {
3432
3448
  this.videoRemotelyDowngraded = videoRemotelyDowngraded;
3433
3449
  this.sipSession = sipSession;
3434
3450
  this.answerTime = answerTime || this.answerTime;
3451
+ this.conference = conference;
3435
3452
 
3436
3453
  // Useful to compare instead of instanceof with minified code
3437
3454
  this.type = 'CallSession';
@@ -3489,6 +3506,10 @@ class CallSession {
3489
3506
  this.screensharing = false;
3490
3507
  }
3491
3508
 
3509
+ setIsConference(conference ) {
3510
+ this.conference = conference;
3511
+ }
3512
+
3492
3513
  isIncoming() {
3493
3514
  return !this.isCaller && !this.answered;
3494
3515
  }
@@ -3565,6 +3586,10 @@ class CallSession {
3565
3586
  return this.sipStatus === sessionState.SessionState.Terminated;
3566
3587
  }
3567
3588
 
3589
+ isConference() {
3590
+ return this.conference;
3591
+ }
3592
+
3568
3593
  getElapsedTimeInSeconds() {
3569
3594
  if (!this.startTime) {
3570
3595
  return 0;
@@ -3656,6 +3681,7 @@ class CallSession {
3656
3681
  cameraEnabled: false,
3657
3682
  dialedExtension: call.dialedExtension,
3658
3683
  call,
3684
+ conference: false, // @FIXME?
3659
3685
  });
3660
3686
  }
3661
3687
  }
@@ -3719,11 +3745,13 @@ class Recording {
3719
3745
 
3720
3746
 
3721
3747
 
3748
+
3722
3749
 
3723
3750
 
3724
3751
 
3725
3752
 
3726
3753
 
3754
+
3727
3755
 
3728
3756
 
3729
3757
 
@@ -3744,10 +3772,12 @@ class Recording {
3744
3772
 
3745
3773
 
3746
3774
 
3775
+
3747
3776
 
3748
3777
 
3749
3778
 
3750
3779
 
3780
+
3751
3781
 
3752
3782
 
3753
3783
 
@@ -3809,10 +3839,12 @@ class CallLog {
3809
3839
  || plain.destination_extension
3810
3840
  || `meeting-${plain.requested_name || plain.destination_name || ''}`,
3811
3841
  name: plain.requested_name || plain.destination_name || '',
3842
+ uuid: plain.destination_user_uuid,
3812
3843
  },
3813
3844
  source: {
3814
3845
  extension: plain.source_extension,
3815
3846
  name: plain.source_name,
3847
+ uuid: plain.source_user_uuid,
3816
3848
  },
3817
3849
  id: plain.id,
3818
3850
  duration: (plain.duration || 0) * 1000, // duration is in seconds
@@ -5588,6 +5620,7 @@ var getApiClient = (forServer ) => {
5588
5620
 
5589
5621
  class InvalidSubscription extends Error {}
5590
5622
  class InvalidAuthorization extends Error {}
5623
+ class NoTenantIdError extends Error {}
5591
5624
 
5592
5625
  const logger$9 = IssueReporter$1.loggerFor('simple-auth');
5593
5626
 
@@ -5601,11 +5634,15 @@ class Auth {
5601
5634
 
5602
5635
 
5603
5636
 
5637
+
5638
+
5604
5639
 
5605
5640
  constructor() {
5606
5641
  this.expiration = DETAULT_EXPIRATION;
5607
5642
  this.authenticated = false;
5608
5643
  this.minSubscriptionType = null;
5644
+ this.BACKEND_WAZO = DEFAULT_BACKEND_USER;
5645
+ this.BACKEND_LDAP = BACKEND_LDAP_USER;
5609
5646
  }
5610
5647
 
5611
5648
  init(clientId ,
@@ -5638,12 +5675,18 @@ class Auth {
5638
5675
  setFetchOptions(options);
5639
5676
  }
5640
5677
 
5641
- 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
+
5642
5683
  this.authenticated = false;
5643
5684
  this.session = null;
5644
5685
  const rawSession = await getApiClient().auth.logIn({
5645
5686
  username,
5646
5687
  password,
5688
+ backend,
5689
+ tenantId,
5647
5690
  expiration: this.expiration,
5648
5691
  mobile: this.mobile,
5649
5692
  });
@@ -5919,6 +5962,10 @@ class AdHocAPIConference {
5919
5962
  this.conferenceId = conferenceId || '';
5920
5963
  this.muted = muted || false;
5921
5964
  this.paused = paused || false;
5965
+
5966
+ if (this.host) {
5967
+ this.host.setIsConference(true);
5968
+ }
5922
5969
  }
5923
5970
 
5924
5971
  async start() {
@@ -9628,7 +9675,11 @@ class WebRTCPhone extends Emitter {
9628
9675
  accept(callSession , cameraEnabled ) {
9629
9676
  logger$7.info('WebRTC phone - accept call', { id: callSession ? callSession.getId() : 'n/a', cameraEnabled });
9630
9677
  if (this.currentSipSession) {
9631
- this.holdSipSession(this.currentSipSession, this.currentCallSession, true);
9678
+ this.holdSipSession(
9679
+ this.currentSipSession,
9680
+ this.currentCallSession,
9681
+ true,
9682
+ );
9632
9683
  }
9633
9684
 
9634
9685
  if (!callSession) {
@@ -9721,22 +9772,22 @@ class WebRTCPhone extends Emitter {
9721
9772
  }
9722
9773
  }
9723
9774
 
9724
- hold(callSession , withEvent = true, isConference = false) {
9775
+ hold(callSession , withEvent = true) {
9725
9776
  logger$7.info('WebRTC hold', { id: callSession.getId() });
9726
9777
 
9727
9778
  const sipSession = this.findSipSession(callSession);
9728
9779
 
9729
- return sipSession ? this.holdSipSession(sipSession, callSession, withEvent, isConference) : null;
9780
+ return sipSession ? this.holdSipSession(sipSession, callSession, withEvent) : null;
9730
9781
  }
9731
9782
 
9732
9783
  // @Deprecated
9733
- unhold(callSession , withEvent = true, isConference = false) {
9784
+ unhold(callSession , withEvent = true) {
9734
9785
  console.warn('Please note that `phone.unhold()` is being deprecated; `phone.resume()` is the preferred method');
9735
9786
 
9736
- return this.resume(callSession, isConference, withEvent);
9787
+ return this.resume(callSession, withEvent);
9737
9788
  }
9738
9789
 
9739
- resume(callSession , isConference = false, withEvent = true) {
9790
+ resume(callSession , withEvent = true) {
9740
9791
  logger$7.info('WebRTC resume called', { id: callSession ? callSession.getId() : null });
9741
9792
 
9742
9793
  const sipSession = this.findSipSession(callSession);
@@ -9749,10 +9800,14 @@ class WebRTCPhone extends Emitter {
9749
9800
  // Hold current session if different from the current one (we don't want 2 sessions active at the same time).
9750
9801
  if (this.currentSipSession && this.currentSipSession.id !== sipSession.id) {
9751
9802
  logger$7.info('WebRTC hold call after resume', { id: this.currentSipSession.id });
9752
- this.holdSipSession(this.currentSipSession, this.currentCallSession);
9803
+ this.holdSipSession(
9804
+ this.currentSipSession,
9805
+ this.currentCallSession,
9806
+ withEvent,
9807
+ );
9753
9808
  }
9754
9809
 
9755
- const promise = this.unholdSipSession(sipSession, callSession, withEvent, isConference);
9810
+ const promise = this.unholdSipSession(sipSession, callSession, withEvent);
9756
9811
  this.currentSipSession = sipSession;
9757
9812
  if (callSession) {
9758
9813
  this.currentCallSession = callSession;
@@ -9765,7 +9820,6 @@ class WebRTCPhone extends Emitter {
9765
9820
  sipSession ,
9766
9821
  callSession ,
9767
9822
  withEvent = true,
9768
- isConference = false,
9769
9823
  ) {
9770
9824
  if (!sipSession) {
9771
9825
  return new Promise((resolve, reject) => reject(new Error('No session to hold')));
@@ -9786,6 +9840,8 @@ class WebRTCPhone extends Emitter {
9786
9840
  await this.client.downgradeToAudio(sipSession);
9787
9841
  }
9788
9842
 
9843
+ const isConference = !!callSession && callSession.isConference();
9844
+
9789
9845
  const promise = this.client.hold(sipSession, isConference, hasVideo);
9790
9846
  if (withEvent) {
9791
9847
  this.eventEmitter.emit(ON_CALL_HELD, this._createCallSession(sipSession, callSession));
@@ -9798,11 +9854,13 @@ class WebRTCPhone extends Emitter {
9798
9854
  sipSession ,
9799
9855
  callSession ,
9800
9856
  withEvent = true,
9801
- isConference = false,
9802
9857
  ) {
9803
9858
  if (!sipSession) {
9804
9859
  return new Promise((resolve, reject) => reject(new Error('No session to unhold')));
9805
9860
  }
9861
+
9862
+ const isConference = !!callSession && callSession.isConference();
9863
+
9806
9864
  const sessionId = this.getSipSessionId(sipSession);
9807
9865
  logger$7.info('WebRTC unhold sip session', { sessionId, isConference });
9808
9866
 
@@ -9944,7 +10002,11 @@ class WebRTCPhone extends Emitter {
9944
10002
  await this.client.register();
9945
10003
  }
9946
10004
  if (this.currentSipSession) {
9947
- this.holdSipSession(this.currentSipSession, this.currentCallSession, true).catch(e => {
10005
+ this.holdSipSession(
10006
+ this.currentSipSession,
10007
+ this.currentCallSession,
10008
+ true,
10009
+ ).catch(e => {
9948
10010
  logger$7.warn('Unable to hold current session when making another call', e);
9949
10011
  });
9950
10012
  }
@@ -9959,6 +10021,7 @@ class WebRTCPhone extends Emitter {
9959
10021
  return Promise.resolve(null);
9960
10022
  }
9961
10023
  const callSession = this._createOutgoingCallSession(sipSession, cameraEnabled || false);
10024
+ callSession.setIsConference(conference);
9962
10025
  callSession.creationTime = new Date();
9963
10026
  this._updateCallSession(callSession);
9964
10027
 
@@ -10537,6 +10600,7 @@ class WebRTCPhone extends Emitter {
10537
10600
  recording: fromSession ? fromSession.isRecording() : false,
10538
10601
  recordingPaused: false, // @TODO
10539
10602
  sipSession,
10603
+ conference: !!fromSession && fromSession.isConference(),
10540
10604
  ...extra,
10541
10605
  });
10542
10606
 
@@ -10793,16 +10857,16 @@ class Phone extends Emitter {
10793
10857
  }
10794
10858
  }
10795
10859
 
10796
- hold(callSession , isConference = false) {
10797
- return this.phone && this.phone.hold(callSession, true, isConference);
10860
+ hold(callSession ) {
10861
+ return this.phone && this.phone.hold(callSession, true);
10798
10862
  }
10799
10863
 
10800
- unhold(callSession , isConference = false) {
10801
- return this.phone && this.phone.unhold(callSession, true, isConference);
10864
+ unhold(callSession ) {
10865
+ return this.phone && this.phone.unhold(callSession, true);
10802
10866
  }
10803
10867
 
10804
- resume(callSession , isConference = false) {
10805
- return this.phone && this.phone.resume(callSession, isConference);
10868
+ resume(callSession ) {
10869
+ return this.phone && this.phone.resume(callSession);
10806
10870
  }
10807
10871
 
10808
10872
  reject(callSession ) {
@@ -12770,6 +12834,7 @@ const Wazo = {
12770
12834
  InvalidAuthorization,
12771
12835
  CanceledCallError,
12772
12836
  SFUNotAvailableError,
12837
+ NoTenantIdError,
12773
12838
  };
12774
12839
 
12775
12840
  if (window) {