@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
@@ -394,6 +394,7 @@ const LINE_STATE = {
394
394
 
395
395
 
396
396
 
397
+
397
398
 
398
399
 
399
400
 
@@ -430,6 +431,7 @@ const LINE_STATE = {
430
431
 
431
432
 
432
433
 
434
+
433
435
 
434
436
 
435
437
 
@@ -461,6 +463,7 @@ class Profile {
461
463
 
462
464
 
463
465
 
466
+
464
467
 
465
468
 
466
469
 
@@ -477,6 +480,7 @@ class Profile {
477
480
  lines: plain.lines.map(line => Line.parse(line)),
478
481
  username: plain.username,
479
482
  mobileNumber: plain.mobile_phone_number || '',
483
+ ringSeconds: plain.ring_seconds,
480
484
  forwards: [
481
485
  ForwardOption.parse(plain.forwards.unconditional, FORWARD_KEYS.UNCONDITIONAL),
482
486
  ForwardOption.parse(plain.forwards.noanswer, FORWARD_KEYS.NO_ANSWER),
@@ -513,6 +517,7 @@ class Profile {
513
517
  switchboards,
514
518
  agent,
515
519
  status,
520
+ ringSeconds,
516
521
  sipLines,
517
522
  callPickupTargetUsers,
518
523
  onlineCallRecordEnabled,
@@ -534,6 +539,7 @@ class Profile {
534
539
  this.status = status;
535
540
  this.callPickupTargetUsers = callPickupTargetUsers;
536
541
  this.onlineCallRecordEnabled = onlineCallRecordEnabled;
542
+ this.ringSeconds = ringSeconds;
537
543
 
538
544
  this.sipLines = sipLines || [];
539
545
  }
@@ -2212,6 +2218,7 @@ class ApiRequester {
2212
2218
  /* */
2213
2219
 
2214
2220
  const DEFAULT_BACKEND_USER = 'wazo_user';
2221
+ const BACKEND_LDAP_USER = 'ldap_user';
2215
2222
  const DETAULT_EXPIRATION = 3600;
2216
2223
 
2217
2224
  var authMethods = (client , baseUrl ) => ({
@@ -2226,6 +2233,7 @@ var authMethods = (client , baseUrl ) => ({
2226
2233
 
2227
2234
 
2228
2235
 
2236
+
2229
2237
  ) {
2230
2238
  const body = {
2231
2239
  backend: params.backend || DEFAULT_BACKEND_USER,
@@ -2245,6 +2253,10 @@ var authMethods = (client , baseUrl ) => ({
2245
2253
  headers['Wazo-Session-Type'] = 'mobile';
2246
2254
  }
2247
2255
 
2256
+ if (params.tenantId) {
2257
+ body.tenant_id = params.tenantId;
2258
+ }
2259
+
2248
2260
  return client.post(`${baseUrl}/token`, body, headers).then(response => Session.parse(response));
2249
2261
  },
2250
2262
 
@@ -3285,6 +3297,7 @@ var updateFrom = (instance , from ) => {
3285
3297
 
3286
3298
 
3287
3299
 
3300
+
3288
3301
 
3289
3302
 
3290
3303
  class CallSession {
@@ -3347,6 +3360,8 @@ class CallSession {
3347
3360
 
3348
3361
 
3349
3362
 
3363
+
3364
+
3350
3365
 
3351
3366
 
3352
3367
 
@@ -3378,6 +3393,7 @@ class CallSession {
3378
3393
  videoRemotelyDowngraded,
3379
3394
  sipSession,
3380
3395
  answerTime,
3396
+ conference,
3381
3397
  } ) {
3382
3398
  this.callId = callId;
3383
3399
  this.sipCallId = sipCallId;
@@ -3406,6 +3422,7 @@ class CallSession {
3406
3422
  this.videoRemotelyDowngraded = videoRemotelyDowngraded;
3407
3423
  this.sipSession = sipSession;
3408
3424
  this.answerTime = answerTime || this.answerTime;
3425
+ this.conference = conference;
3409
3426
 
3410
3427
  // Useful to compare instead of instanceof with minified code
3411
3428
  this.type = 'CallSession';
@@ -3463,6 +3480,10 @@ class CallSession {
3463
3480
  this.screensharing = false;
3464
3481
  }
3465
3482
 
3483
+ setIsConference(conference ) {
3484
+ this.conference = conference;
3485
+ }
3486
+
3466
3487
  isIncoming() {
3467
3488
  return !this.isCaller && !this.answered;
3468
3489
  }
@@ -3539,6 +3560,10 @@ class CallSession {
3539
3560
  return this.sipStatus === sessionState.SessionState.Terminated;
3540
3561
  }
3541
3562
 
3563
+ isConference() {
3564
+ return this.conference;
3565
+ }
3566
+
3542
3567
  getElapsedTimeInSeconds() {
3543
3568
  if (!this.startTime) {
3544
3569
  return 0;
@@ -3630,6 +3655,7 @@ class CallSession {
3630
3655
  cameraEnabled: false,
3631
3656
  dialedExtension: call.dialedExtension,
3632
3657
  call,
3658
+ conference: false, // @FIXME?
3633
3659
  });
3634
3660
  }
3635
3661
  }
@@ -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 ) {
@@ -13843,6 +13907,7 @@ const Wazo = {
13843
13907
  InvalidAuthorization,
13844
13908
  CanceledCallError,
13845
13909
  SFUNotAvailableError,
13910
+ NoTenantIdError,
13846
13911
  };
13847
13912
 
13848
13913
  if (window) {