@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
@@ -384,6 +384,7 @@ const LINE_STATE = {
384
384
 
385
385
 
386
386
 
387
+
387
388
 
388
389
 
389
390
 
@@ -420,6 +421,7 @@ const LINE_STATE = {
420
421
 
421
422
 
422
423
 
424
+
423
425
 
424
426
 
425
427
 
@@ -451,6 +453,7 @@ class Profile {
451
453
 
452
454
 
453
455
 
456
+
454
457
 
455
458
 
456
459
 
@@ -467,6 +470,7 @@ class Profile {
467
470
  lines: plain.lines.map(line => Line.parse(line)),
468
471
  username: plain.username,
469
472
  mobileNumber: plain.mobile_phone_number || '',
473
+ ringSeconds: plain.ring_seconds,
470
474
  forwards: [
471
475
  ForwardOption.parse(plain.forwards.unconditional, FORWARD_KEYS.UNCONDITIONAL),
472
476
  ForwardOption.parse(plain.forwards.noanswer, FORWARD_KEYS.NO_ANSWER),
@@ -503,6 +507,7 @@ class Profile {
503
507
  switchboards,
504
508
  agent,
505
509
  status,
510
+ ringSeconds,
506
511
  sipLines,
507
512
  callPickupTargetUsers,
508
513
  onlineCallRecordEnabled,
@@ -524,6 +529,7 @@ class Profile {
524
529
  this.status = status;
525
530
  this.callPickupTargetUsers = callPickupTargetUsers;
526
531
  this.onlineCallRecordEnabled = onlineCallRecordEnabled;
532
+ this.ringSeconds = ringSeconds;
527
533
 
528
534
  this.sipLines = sipLines || [];
529
535
  }
@@ -2202,6 +2208,7 @@ class ApiRequester {
2202
2208
  /* */
2203
2209
 
2204
2210
  const DEFAULT_BACKEND_USER = 'wazo_user';
2211
+ const BACKEND_LDAP_USER = 'ldap_user';
2205
2212
  const DETAULT_EXPIRATION = 3600;
2206
2213
 
2207
2214
  var authMethods = (client , baseUrl ) => ({
@@ -3280,6 +3287,7 @@ var updateFrom = (instance , from ) => {
3280
3287
 
3281
3288
 
3282
3289
 
3290
+
3283
3291
 
3284
3292
 
3285
3293
  class CallSession {
@@ -3342,6 +3350,8 @@ class CallSession {
3342
3350
 
3343
3351
 
3344
3352
 
3353
+
3354
+
3345
3355
 
3346
3356
 
3347
3357
 
@@ -3373,6 +3383,7 @@ class CallSession {
3373
3383
  videoRemotelyDowngraded,
3374
3384
  sipSession,
3375
3385
  answerTime,
3386
+ conference,
3376
3387
  } ) {
3377
3388
  this.callId = callId;
3378
3389
  this.sipCallId = sipCallId;
@@ -3401,6 +3412,7 @@ class CallSession {
3401
3412
  this.videoRemotelyDowngraded = videoRemotelyDowngraded;
3402
3413
  this.sipSession = sipSession;
3403
3414
  this.answerTime = answerTime || this.answerTime;
3415
+ this.conference = conference;
3404
3416
 
3405
3417
  // Useful to compare instead of instanceof with minified code
3406
3418
  this.type = 'CallSession';
@@ -3458,6 +3470,10 @@ class CallSession {
3458
3470
  this.screensharing = false;
3459
3471
  }
3460
3472
 
3473
+ setIsConference(conference ) {
3474
+ this.conference = conference;
3475
+ }
3476
+
3461
3477
  isIncoming() {
3462
3478
  return !this.isCaller && !this.answered;
3463
3479
  }
@@ -3534,6 +3550,10 @@ class CallSession {
3534
3550
  return this.sipStatus === SessionState.Terminated;
3535
3551
  }
3536
3552
 
3553
+ isConference() {
3554
+ return this.conference;
3555
+ }
3556
+
3537
3557
  getElapsedTimeInSeconds() {
3538
3558
  if (!this.startTime) {
3539
3559
  return 0;
@@ -3625,6 +3645,7 @@ class CallSession {
3625
3645
  cameraEnabled: false,
3626
3646
  dialedExtension: call.dialedExtension,
3627
3647
  call,
3648
+ conference: false, // @FIXME?
3628
3649
  });
3629
3650
  }
3630
3651
  }
@@ -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 ) {
@@ -13144,7 +13197,7 @@ class Room {
13144
13197
 
13145
13198
 
13146
13199
 
13147
-
13200
+
13148
13201
 
13149
13202
 
13150
13203
 
@@ -13170,7 +13223,7 @@ class SwitchboardCall {
13170
13223
 
13171
13224
 
13172
13225
 
13173
-
13226
+
13174
13227
 
13175
13228
 
13176
13229
 
@@ -13184,7 +13237,7 @@ class SwitchboardCall {
13184
13237
  callerIdName: plain.caller_id_name || null,
13185
13238
  callerIdNumber: plain.caller_id_number || null,
13186
13239
  participantId: plain.participantId || null,
13187
- startTime: plain.startTime,
13240
+ answerTime: plain.startTime,
13188
13241
  state: plain.state,
13189
13242
  switchboardName: plain.switchboardName,
13190
13243
  switchboardUuid: plain.switchboardUuid,
@@ -13197,7 +13250,7 @@ class SwitchboardCall {
13197
13250
  callerIdName,
13198
13251
  callerIdNumber,
13199
13252
  participantId,
13200
- startTime,
13253
+ answerTime,
13201
13254
  state,
13202
13255
  switchboardName,
13203
13256
  switchboardUuid,
@@ -13207,7 +13260,7 @@ class SwitchboardCall {
13207
13260
  this.callerIdName = callerIdName;
13208
13261
  this.callerIdNumber = callerIdNumber;
13209
13262
  this.participantId = participantId;
13210
- this.startTime = startTime;
13263
+ this.answerTime = answerTime;
13211
13264
  this.state = state;
13212
13265
  this.switchboardName = switchboardName;
13213
13266
  this.switchboardUuid = switchboardUuid;
@@ -13844,6 +13897,7 @@ const Wazo = {
13844
13897
  InvalidAuthorization,
13845
13898
  CanceledCallError,
13846
13899
  SFUNotAvailableError,
13900
+ NoTenantIdError,
13847
13901
  };
13848
13902
 
13849
13903
  if (window) {