@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
@@ -396,6 +396,7 @@ const LINE_STATE = {
396
396
 
397
397
 
398
398
 
399
+
399
400
 
400
401
 
401
402
 
@@ -432,6 +433,7 @@ const LINE_STATE = {
432
433
 
433
434
 
434
435
 
436
+
435
437
 
436
438
 
437
439
 
@@ -463,6 +465,7 @@ class Profile {
463
465
 
464
466
 
465
467
 
468
+
466
469
 
467
470
 
468
471
 
@@ -479,6 +482,7 @@ class Profile {
479
482
  lines: plain.lines.map(line => Line.parse(line)),
480
483
  username: plain.username,
481
484
  mobileNumber: plain.mobile_phone_number || '',
485
+ ringSeconds: plain.ring_seconds,
482
486
  forwards: [
483
487
  ForwardOption.parse(plain.forwards.unconditional, FORWARD_KEYS.UNCONDITIONAL),
484
488
  ForwardOption.parse(plain.forwards.noanswer, FORWARD_KEYS.NO_ANSWER),
@@ -515,6 +519,7 @@ class Profile {
515
519
  switchboards,
516
520
  agent,
517
521
  status,
522
+ ringSeconds,
518
523
  sipLines,
519
524
  callPickupTargetUsers,
520
525
  onlineCallRecordEnabled,
@@ -536,6 +541,7 @@ class Profile {
536
541
  this.status = status;
537
542
  this.callPickupTargetUsers = callPickupTargetUsers;
538
543
  this.onlineCallRecordEnabled = onlineCallRecordEnabled;
544
+ this.ringSeconds = ringSeconds;
539
545
 
540
546
  this.sipLines = sipLines || [];
541
547
  }
@@ -2214,6 +2220,7 @@ class ApiRequester {
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
@@ -5657,6 +5689,10 @@ class AdHocAPIConference {
5657
5689
  this.conferenceId = conferenceId || '';
5658
5690
  this.muted = muted || false;
5659
5691
  this.paused = paused || false;
5692
+
5693
+ if (this.host) {
5694
+ this.host.setIsConference(true);
5695
+ }
5660
5696
  }
5661
5697
 
5662
5698
  async start() {
@@ -9366,7 +9402,11 @@ class WebRTCPhone extends Emitter {
9366
9402
  accept(callSession , cameraEnabled ) {
9367
9403
  logger$8.info('WebRTC phone - accept call', { id: callSession ? callSession.getId() : 'n/a', cameraEnabled });
9368
9404
  if (this.currentSipSession) {
9369
- this.holdSipSession(this.currentSipSession, this.currentCallSession, true);
9405
+ this.holdSipSession(
9406
+ this.currentSipSession,
9407
+ this.currentCallSession,
9408
+ true,
9409
+ );
9370
9410
  }
9371
9411
 
9372
9412
  if (!callSession) {
@@ -9459,22 +9499,22 @@ class WebRTCPhone extends Emitter {
9459
9499
  }
9460
9500
  }
9461
9501
 
9462
- hold(callSession , withEvent = true, isConference = false) {
9502
+ hold(callSession , withEvent = true) {
9463
9503
  logger$8.info('WebRTC hold', { id: callSession.getId() });
9464
9504
 
9465
9505
  const sipSession = this.findSipSession(callSession);
9466
9506
 
9467
- return sipSession ? this.holdSipSession(sipSession, callSession, withEvent, isConference) : null;
9507
+ return sipSession ? this.holdSipSession(sipSession, callSession, withEvent) : null;
9468
9508
  }
9469
9509
 
9470
9510
  // @Deprecated
9471
- unhold(callSession , withEvent = true, isConference = false) {
9511
+ unhold(callSession , withEvent = true) {
9472
9512
  console.warn('Please note that `phone.unhold()` is being deprecated; `phone.resume()` is the preferred method');
9473
9513
 
9474
- return this.resume(callSession, isConference, withEvent);
9514
+ return this.resume(callSession, withEvent);
9475
9515
  }
9476
9516
 
9477
- resume(callSession , isConference = false, withEvent = true) {
9517
+ resume(callSession , withEvent = true) {
9478
9518
  logger$8.info('WebRTC resume called', { id: callSession ? callSession.getId() : null });
9479
9519
 
9480
9520
  const sipSession = this.findSipSession(callSession);
@@ -9487,10 +9527,14 @@ class WebRTCPhone extends Emitter {
9487
9527
  // Hold current session if different from the current one (we don't want 2 sessions active at the same time).
9488
9528
  if (this.currentSipSession && this.currentSipSession.id !== sipSession.id) {
9489
9529
  logger$8.info('WebRTC hold call after resume', { id: this.currentSipSession.id });
9490
- this.holdSipSession(this.currentSipSession, this.currentCallSession);
9530
+ this.holdSipSession(
9531
+ this.currentSipSession,
9532
+ this.currentCallSession,
9533
+ withEvent,
9534
+ );
9491
9535
  }
9492
9536
 
9493
- const promise = this.unholdSipSession(sipSession, callSession, withEvent, isConference);
9537
+ const promise = this.unholdSipSession(sipSession, callSession, withEvent);
9494
9538
  this.currentSipSession = sipSession;
9495
9539
  if (callSession) {
9496
9540
  this.currentCallSession = callSession;
@@ -9503,7 +9547,6 @@ class WebRTCPhone extends Emitter {
9503
9547
  sipSession ,
9504
9548
  callSession ,
9505
9549
  withEvent = true,
9506
- isConference = false,
9507
9550
  ) {
9508
9551
  if (!sipSession) {
9509
9552
  return new Promise((resolve, reject) => reject(new Error('No session to hold')));
@@ -9524,6 +9567,8 @@ class WebRTCPhone extends Emitter {
9524
9567
  await this.client.downgradeToAudio(sipSession);
9525
9568
  }
9526
9569
 
9570
+ const isConference = !!callSession && callSession.isConference();
9571
+
9527
9572
  const promise = this.client.hold(sipSession, isConference, hasVideo);
9528
9573
  if (withEvent) {
9529
9574
  this.eventEmitter.emit(ON_CALL_HELD, this._createCallSession(sipSession, callSession));
@@ -9536,11 +9581,13 @@ class WebRTCPhone extends Emitter {
9536
9581
  sipSession ,
9537
9582
  callSession ,
9538
9583
  withEvent = true,
9539
- isConference = false,
9540
9584
  ) {
9541
9585
  if (!sipSession) {
9542
9586
  return new Promise((resolve, reject) => reject(new Error('No session to unhold')));
9543
9587
  }
9588
+
9589
+ const isConference = !!callSession && callSession.isConference();
9590
+
9544
9591
  const sessionId = this.getSipSessionId(sipSession);
9545
9592
  logger$8.info('WebRTC unhold sip session', { sessionId, isConference });
9546
9593
 
@@ -9682,7 +9729,11 @@ class WebRTCPhone extends Emitter {
9682
9729
  await this.client.register();
9683
9730
  }
9684
9731
  if (this.currentSipSession) {
9685
- this.holdSipSession(this.currentSipSession, this.currentCallSession, true).catch(e => {
9732
+ this.holdSipSession(
9733
+ this.currentSipSession,
9734
+ this.currentCallSession,
9735
+ true,
9736
+ ).catch(e => {
9686
9737
  logger$8.warn('Unable to hold current session when making another call', e);
9687
9738
  });
9688
9739
  }
@@ -9697,6 +9748,7 @@ class WebRTCPhone extends Emitter {
9697
9748
  return Promise.resolve(null);
9698
9749
  }
9699
9750
  const callSession = this._createOutgoingCallSession(sipSession, cameraEnabled || false);
9751
+ callSession.setIsConference(conference);
9700
9752
  callSession.creationTime = new Date();
9701
9753
  this._updateCallSession(callSession);
9702
9754
 
@@ -10275,6 +10327,7 @@ class WebRTCPhone extends Emitter {
10275
10327
  recording: fromSession ? fromSession.isRecording() : false,
10276
10328
  recordingPaused: false, // @TODO
10277
10329
  sipSession,
10330
+ conference: !!fromSession && fromSession.isConference(),
10278
10331
  ...extra,
10279
10332
  });
10280
10333
 
@@ -10531,16 +10584,16 @@ class Phone extends Emitter {
10531
10584
  }
10532
10585
  }
10533
10586
 
10534
- hold(callSession , isConference = false) {
10535
- return this.phone && this.phone.hold(callSession, true, isConference);
10587
+ hold(callSession ) {
10588
+ return this.phone && this.phone.hold(callSession, true);
10536
10589
  }
10537
10590
 
10538
- unhold(callSession , isConference = false) {
10539
- return this.phone && this.phone.unhold(callSession, true, isConference);
10591
+ unhold(callSession ) {
10592
+ return this.phone && this.phone.unhold(callSession, true);
10540
10593
  }
10541
10594
 
10542
- resume(callSession , isConference = false) {
10543
- return this.phone && this.phone.resume(callSession, isConference);
10595
+ resume(callSession ) {
10596
+ return this.phone && this.phone.resume(callSession);
10544
10597
  }
10545
10598
 
10546
10599
  reject(callSession ) {
@@ -13639,6 +13692,7 @@ const Wazo = {
13639
13692
  InvalidAuthorization,
13640
13693
  CanceledCallError,
13641
13694
  SFUNotAvailableError,
13695
+ NoTenantIdError,
13642
13696
  };
13643
13697
 
13644
13698
  if (window) {
@@ -13652,6 +13706,7 @@ if (global) {
13652
13706
 
13653
13707
  class InvalidSubscription extends Error {}
13654
13708
  class InvalidAuthorization extends Error {}
13709
+ class NoTenantIdError extends Error {}
13655
13710
 
13656
13711
  const logger = IssueReporter$1.loggerFor('simple-auth');
13657
13712
 
@@ -13665,11 +13720,15 @@ class Auth {
13665
13720
 
13666
13721
 
13667
13722
 
13723
+
13724
+
13668
13725
 
13669
13726
  constructor() {
13670
13727
  this.expiration = DETAULT_EXPIRATION;
13671
13728
  this.authenticated = false;
13672
13729
  this.minSubscriptionType = null;
13730
+ this.BACKEND_WAZO = DEFAULT_BACKEND_USER;
13731
+ this.BACKEND_LDAP = BACKEND_LDAP_USER;
13673
13732
  }
13674
13733
 
13675
13734
  init(clientId ,
@@ -13702,12 +13761,18 @@ class Auth {
13702
13761
  setFetchOptions(options);
13703
13762
  }
13704
13763
 
13705
- async logIn(username , password ) {
13764
+ async logIn(username , password , backend , tenantId ) {
13765
+ if (backend && backend !== this.BACKEND_WAZO && !tenantId) {
13766
+ throw new NoTenantIdError('No tenant id');
13767
+ }
13768
+
13706
13769
  this.authenticated = false;
13707
13770
  this.session = null;
13708
13771
  const rawSession = await getApiClient().auth.logIn({
13709
13772
  username,
13710
13773
  password,
13774
+ backend,
13775
+ tenantId,
13711
13776
  expiration: this.expiration,
13712
13777
  mobile: this.mobile,
13713
13778
  });
@@ -13914,4 +13979,5 @@ var Auth$1 = global.wazoAuthInstance;
13914
13979
 
13915
13980
  exports.InvalidAuthorization = InvalidAuthorization;
13916
13981
  exports.InvalidSubscription = InvalidSubscription;
13982
+ exports.NoTenantIdError = NoTenantIdError;
13917
13983
  exports.default = Auth$1;