@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
@@ -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 ) => ({
@@ -2228,6 +2235,7 @@ var authMethods = (client , baseUrl ) => ({
2228
2235
 
2229
2236
 
2230
2237
 
2238
+
2231
2239
  ) {
2232
2240
  const body = {
2233
2241
  backend: params.backend || DEFAULT_BACKEND_USER,
@@ -2247,6 +2255,10 @@ var authMethods = (client , baseUrl ) => ({
2247
2255
  headers['Wazo-Session-Type'] = 'mobile';
2248
2256
  }
2249
2257
 
2258
+ if (params.tenantId) {
2259
+ body.tenant_id = params.tenantId;
2260
+ }
2261
+
2250
2262
  return client.post(`${baseUrl}/token`, body, headers).then(response => Session.parse(response));
2251
2263
  },
2252
2264
 
@@ -3287,6 +3299,7 @@ var updateFrom = (instance , from ) => {
3287
3299
 
3288
3300
 
3289
3301
 
3302
+
3290
3303
 
3291
3304
 
3292
3305
  class CallSession {
@@ -3349,6 +3362,8 @@ class CallSession {
3349
3362
 
3350
3363
 
3351
3364
 
3365
+
3366
+
3352
3367
 
3353
3368
 
3354
3369
 
@@ -3380,6 +3395,7 @@ class CallSession {
3380
3395
  videoRemotelyDowngraded,
3381
3396
  sipSession,
3382
3397
  answerTime,
3398
+ conference,
3383
3399
  } ) {
3384
3400
  this.callId = callId;
3385
3401
  this.sipCallId = sipCallId;
@@ -3408,6 +3424,7 @@ class CallSession {
3408
3424
  this.videoRemotelyDowngraded = videoRemotelyDowngraded;
3409
3425
  this.sipSession = sipSession;
3410
3426
  this.answerTime = answerTime || this.answerTime;
3427
+ this.conference = conference;
3411
3428
 
3412
3429
  // Useful to compare instead of instanceof with minified code
3413
3430
  this.type = 'CallSession';
@@ -3465,6 +3482,10 @@ class CallSession {
3465
3482
  this.screensharing = false;
3466
3483
  }
3467
3484
 
3485
+ setIsConference(conference ) {
3486
+ this.conference = conference;
3487
+ }
3488
+
3468
3489
  isIncoming() {
3469
3490
  return !this.isCaller && !this.answered;
3470
3491
  }
@@ -3541,6 +3562,10 @@ class CallSession {
3541
3562
  return this.sipStatus === sessionState.SessionState.Terminated;
3542
3563
  }
3543
3564
 
3565
+ isConference() {
3566
+ return this.conference;
3567
+ }
3568
+
3544
3569
  getElapsedTimeInSeconds() {
3545
3570
  if (!this.startTime) {
3546
3571
  return 0;
@@ -3632,6 +3657,7 @@ class CallSession {
3632
3657
  cameraEnabled: false,
3633
3658
  dialedExtension: call.dialedExtension,
3634
3659
  call,
3660
+ conference: false, // @FIXME?
3635
3661
  });
3636
3662
  }
3637
3663
  }
@@ -3721,11 +3747,13 @@ class Recording {
3721
3747
 
3722
3748
 
3723
3749
 
3750
+
3724
3751
 
3725
3752
 
3726
3753
 
3727
3754
 
3728
3755
 
3756
+
3729
3757
 
3730
3758
 
3731
3759
 
@@ -3746,10 +3774,12 @@ class Recording {
3746
3774
 
3747
3775
 
3748
3776
 
3777
+
3749
3778
 
3750
3779
 
3751
3780
 
3752
3781
 
3782
+
3753
3783
 
3754
3784
 
3755
3785
 
@@ -3811,10 +3841,12 @@ class CallLog {
3811
3841
  || plain.destination_extension
3812
3842
  || `meeting-${plain.requested_name || plain.destination_name || ''}`,
3813
3843
  name: plain.requested_name || plain.destination_name || '',
3844
+ uuid: plain.destination_user_uuid,
3814
3845
  },
3815
3846
  source: {
3816
3847
  extension: plain.source_extension,
3817
3848
  name: plain.source_name,
3849
+ uuid: plain.source_user_uuid,
3818
3850
  },
3819
3851
  id: plain.id,
3820
3852
  duration: (plain.duration || 0) * 1000, // duration is in seconds
@@ -5590,6 +5622,7 @@ var getApiClient = (forServer ) => {
5590
5622
 
5591
5623
  class InvalidSubscription extends Error {}
5592
5624
  class InvalidAuthorization extends Error {}
5625
+ class NoTenantIdError extends Error {}
5593
5626
 
5594
5627
  const logger$9 = IssueReporter$1.loggerFor('simple-auth');
5595
5628
 
@@ -5603,11 +5636,15 @@ class Auth {
5603
5636
 
5604
5637
 
5605
5638
 
5639
+
5640
+
5606
5641
 
5607
5642
  constructor() {
5608
5643
  this.expiration = DETAULT_EXPIRATION;
5609
5644
  this.authenticated = false;
5610
5645
  this.minSubscriptionType = null;
5646
+ this.BACKEND_WAZO = DEFAULT_BACKEND_USER;
5647
+ this.BACKEND_LDAP = BACKEND_LDAP_USER;
5611
5648
  }
5612
5649
 
5613
5650
  init(clientId ,
@@ -5640,12 +5677,18 @@ class Auth {
5640
5677
  setFetchOptions(options);
5641
5678
  }
5642
5679
 
5643
- 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
+
5644
5685
  this.authenticated = false;
5645
5686
  this.session = null;
5646
5687
  const rawSession = await getApiClient().auth.logIn({
5647
5688
  username,
5648
5689
  password,
5690
+ backend,
5691
+ tenantId,
5649
5692
  expiration: this.expiration,
5650
5693
  mobile: this.mobile,
5651
5694
  });
@@ -5921,6 +5964,10 @@ class AdHocAPIConference {
5921
5964
  this.conferenceId = conferenceId || '';
5922
5965
  this.muted = muted || false;
5923
5966
  this.paused = paused || false;
5967
+
5968
+ if (this.host) {
5969
+ this.host.setIsConference(true);
5970
+ }
5924
5971
  }
5925
5972
 
5926
5973
  async start() {
@@ -9630,7 +9677,11 @@ class WebRTCPhone extends Emitter {
9630
9677
  accept(callSession , cameraEnabled ) {
9631
9678
  logger$7.info('WebRTC phone - accept call', { id: callSession ? callSession.getId() : 'n/a', cameraEnabled });
9632
9679
  if (this.currentSipSession) {
9633
- this.holdSipSession(this.currentSipSession, this.currentCallSession, true);
9680
+ this.holdSipSession(
9681
+ this.currentSipSession,
9682
+ this.currentCallSession,
9683
+ true,
9684
+ );
9634
9685
  }
9635
9686
 
9636
9687
  if (!callSession) {
@@ -9723,22 +9774,22 @@ class WebRTCPhone extends Emitter {
9723
9774
  }
9724
9775
  }
9725
9776
 
9726
- hold(callSession , withEvent = true, isConference = false) {
9777
+ hold(callSession , withEvent = true) {
9727
9778
  logger$7.info('WebRTC hold', { id: callSession.getId() });
9728
9779
 
9729
9780
  const sipSession = this.findSipSession(callSession);
9730
9781
 
9731
- return sipSession ? this.holdSipSession(sipSession, callSession, withEvent, isConference) : null;
9782
+ return sipSession ? this.holdSipSession(sipSession, callSession, withEvent) : null;
9732
9783
  }
9733
9784
 
9734
9785
  // @Deprecated
9735
- unhold(callSession , withEvent = true, isConference = false) {
9786
+ unhold(callSession , withEvent = true) {
9736
9787
  console.warn('Please note that `phone.unhold()` is being deprecated; `phone.resume()` is the preferred method');
9737
9788
 
9738
- return this.resume(callSession, isConference, withEvent);
9789
+ return this.resume(callSession, withEvent);
9739
9790
  }
9740
9791
 
9741
- resume(callSession , isConference = false, withEvent = true) {
9792
+ resume(callSession , withEvent = true) {
9742
9793
  logger$7.info('WebRTC resume called', { id: callSession ? callSession.getId() : null });
9743
9794
 
9744
9795
  const sipSession = this.findSipSession(callSession);
@@ -9751,10 +9802,14 @@ class WebRTCPhone extends Emitter {
9751
9802
  // Hold current session if different from the current one (we don't want 2 sessions active at the same time).
9752
9803
  if (this.currentSipSession && this.currentSipSession.id !== sipSession.id) {
9753
9804
  logger$7.info('WebRTC hold call after resume', { id: this.currentSipSession.id });
9754
- this.holdSipSession(this.currentSipSession, this.currentCallSession);
9805
+ this.holdSipSession(
9806
+ this.currentSipSession,
9807
+ this.currentCallSession,
9808
+ withEvent,
9809
+ );
9755
9810
  }
9756
9811
 
9757
- const promise = this.unholdSipSession(sipSession, callSession, withEvent, isConference);
9812
+ const promise = this.unholdSipSession(sipSession, callSession, withEvent);
9758
9813
  this.currentSipSession = sipSession;
9759
9814
  if (callSession) {
9760
9815
  this.currentCallSession = callSession;
@@ -9767,7 +9822,6 @@ class WebRTCPhone extends Emitter {
9767
9822
  sipSession ,
9768
9823
  callSession ,
9769
9824
  withEvent = true,
9770
- isConference = false,
9771
9825
  ) {
9772
9826
  if (!sipSession) {
9773
9827
  return new Promise((resolve, reject) => reject(new Error('No session to hold')));
@@ -9788,6 +9842,8 @@ class WebRTCPhone extends Emitter {
9788
9842
  await this.client.downgradeToAudio(sipSession);
9789
9843
  }
9790
9844
 
9845
+ const isConference = !!callSession && callSession.isConference();
9846
+
9791
9847
  const promise = this.client.hold(sipSession, isConference, hasVideo);
9792
9848
  if (withEvent) {
9793
9849
  this.eventEmitter.emit(ON_CALL_HELD, this._createCallSession(sipSession, callSession));
@@ -9800,11 +9856,13 @@ class WebRTCPhone extends Emitter {
9800
9856
  sipSession ,
9801
9857
  callSession ,
9802
9858
  withEvent = true,
9803
- isConference = false,
9804
9859
  ) {
9805
9860
  if (!sipSession) {
9806
9861
  return new Promise((resolve, reject) => reject(new Error('No session to unhold')));
9807
9862
  }
9863
+
9864
+ const isConference = !!callSession && callSession.isConference();
9865
+
9808
9866
  const sessionId = this.getSipSessionId(sipSession);
9809
9867
  logger$7.info('WebRTC unhold sip session', { sessionId, isConference });
9810
9868
 
@@ -9946,7 +10004,11 @@ class WebRTCPhone extends Emitter {
9946
10004
  await this.client.register();
9947
10005
  }
9948
10006
  if (this.currentSipSession) {
9949
- this.holdSipSession(this.currentSipSession, this.currentCallSession, true).catch(e => {
10007
+ this.holdSipSession(
10008
+ this.currentSipSession,
10009
+ this.currentCallSession,
10010
+ true,
10011
+ ).catch(e => {
9950
10012
  logger$7.warn('Unable to hold current session when making another call', e);
9951
10013
  });
9952
10014
  }
@@ -9961,6 +10023,7 @@ class WebRTCPhone extends Emitter {
9961
10023
  return Promise.resolve(null);
9962
10024
  }
9963
10025
  const callSession = this._createOutgoingCallSession(sipSession, cameraEnabled || false);
10026
+ callSession.setIsConference(conference);
9964
10027
  callSession.creationTime = new Date();
9965
10028
  this._updateCallSession(callSession);
9966
10029
 
@@ -10539,6 +10602,7 @@ class WebRTCPhone extends Emitter {
10539
10602
  recording: fromSession ? fromSession.isRecording() : false,
10540
10603
  recordingPaused: false, // @TODO
10541
10604
  sipSession,
10605
+ conference: !!fromSession && fromSession.isConference(),
10542
10606
  ...extra,
10543
10607
  });
10544
10608
 
@@ -10795,16 +10859,16 @@ class Phone extends Emitter {
10795
10859
  }
10796
10860
  }
10797
10861
 
10798
- hold(callSession , isConference = false) {
10799
- return this.phone && this.phone.hold(callSession, true, isConference);
10862
+ hold(callSession ) {
10863
+ return this.phone && this.phone.hold(callSession, true);
10800
10864
  }
10801
10865
 
10802
- unhold(callSession , isConference = false) {
10803
- return this.phone && this.phone.unhold(callSession, true, isConference);
10866
+ unhold(callSession ) {
10867
+ return this.phone && this.phone.unhold(callSession, true);
10804
10868
  }
10805
10869
 
10806
- resume(callSession , isConference = false) {
10807
- return this.phone && this.phone.resume(callSession, isConference);
10870
+ resume(callSession ) {
10871
+ return this.phone && this.phone.resume(callSession);
10808
10872
  }
10809
10873
 
10810
10874
  reject(callSession ) {
@@ -13067,6 +13131,7 @@ const Wazo = {
13067
13131
  InvalidAuthorization,
13068
13132
  CanceledCallError,
13069
13133
  SFUNotAvailableError,
13134
+ NoTenantIdError,
13070
13135
  };
13071
13136
 
13072
13137
  if (window) {