@wazo/sdk 0.37.0 → 0.37.4

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 (144) hide show
  1. package/dist/wazo-sdk.js +5 -5
  2. package/esm/__tests__/api-client.test.js +91 -23
  3. package/esm/__tests__/web-rtc-client.test.js +165 -56
  4. package/esm/api/agentd.js +7 -1
  5. package/esm/api/amid.js +7 -1
  6. package/esm/api/application.js +7 -1
  7. package/esm/api/auth.js +7 -1
  8. package/esm/api/call-logd.js +17 -23
  9. package/esm/api/calld.js +10 -18
  10. package/esm/api/chatd.js +7 -1
  11. package/esm/api/confd.js +78 -1
  12. package/esm/api/ctid-ng.js +7 -1
  13. package/esm/api/dird.js +7 -1
  14. package/esm/api/webhookd.js +7 -1
  15. package/esm/api-client.js +91 -23
  16. package/esm/checker/Checker.js +169 -56
  17. package/esm/checker/checks/aor.js +91 -23
  18. package/esm/checker/checks/api.js +91 -23
  19. package/esm/checker/checks/index.js +169 -56
  20. package/esm/checker/checks/wazo-websocket.js +11 -1
  21. package/esm/checker/checks/webrtc-transport.js +165 -56
  22. package/esm/checker/checks/webrtc.js +165 -56
  23. package/esm/domain/AdHocAPIConference.js +1722 -1654
  24. package/esm/domain/CallLog.js +10 -22
  25. package/esm/domain/CallSession.js +1 -18
  26. package/esm/domain/Features.js +91 -23
  27. package/esm/domain/IndirectTransfer.js +0 -17
  28. package/esm/domain/Meeting.js +71 -0
  29. package/esm/domain/Phone/CTIPhone.js +98 -26
  30. package/esm/domain/Phone/Phone.js +0 -17
  31. package/esm/domain/Phone/WebRTCPhone.js +47 -27
  32. package/esm/domain/Room.js +0 -17
  33. package/esm/domain/SwitchboardCall.js +0 -17
  34. package/esm/domain/__tests__/CallLog.test.js +10 -22
  35. package/esm/domain/__tests__/CallSession.test.js +1 -18
  36. package/esm/domain/__tests__/IndirectTransfer.test.js +1 -18
  37. package/esm/domain/__tests__/Room.test.js +1 -18
  38. package/esm/index.js +3880 -3111
  39. package/esm/lib/WazoSessionDescriptionHandler.js +24 -10
  40. package/esm/service/CallApi.js +91 -23
  41. package/esm/service/IssueReporter.js +7 -1
  42. package/esm/service/__tests__/IssueReporter.test.js +9 -1
  43. package/esm/service/getApiClient.js +91 -23
  44. package/esm/simple/Auth.js +1126 -360
  45. package/esm/simple/Configuration.js +1126 -360
  46. package/esm/simple/Directory.js +91 -23
  47. package/esm/simple/Phone.js +3724 -2958
  48. package/esm/simple/Websocket.js +13 -1
  49. package/esm/simple/index.js +1128 -362
  50. package/esm/simple/room/LocalParticipant.js +1097 -331
  51. package/esm/simple/room/Participant.js +1097 -331
  52. package/esm/simple/room/RemoteParticipant.js +1097 -331
  53. package/esm/simple/room/Room.js +1097 -331
  54. package/esm/simple/room/SipRoom.js +12996 -0
  55. package/esm/simple/room/Stream.js +1128 -362
  56. package/esm/simple/room/__tests__/RemoteParticipant.test.js +5157 -4389
  57. package/esm/simple/utils.js +1128 -362
  58. package/esm/utils/__tests__/api-requester.test.js +7 -1
  59. package/esm/utils/api-requester.js +7 -1
  60. package/esm/web-rtc-client.js +165 -56
  61. package/esm/websocket-client.js +12 -2
  62. package/lib/__tests__/api-client.test.js +91 -23
  63. package/lib/__tests__/web-rtc-client.test.js +165 -56
  64. package/lib/api/agentd.js +7 -1
  65. package/lib/api/amid.js +7 -1
  66. package/lib/api/application.js +7 -1
  67. package/lib/api/auth.js +7 -1
  68. package/lib/api/call-logd.js +17 -23
  69. package/lib/api/calld.js +10 -18
  70. package/lib/api/chatd.js +7 -1
  71. package/lib/api/confd.js +78 -1
  72. package/lib/api/ctid-ng.js +7 -1
  73. package/lib/api/dird.js +7 -1
  74. package/lib/api/webhookd.js +7 -1
  75. package/lib/api-client.js +91 -23
  76. package/lib/checker/Checker.js +169 -56
  77. package/lib/checker/checks/aor.js +91 -23
  78. package/lib/checker/checks/api.js +91 -23
  79. package/lib/checker/checks/index.js +169 -56
  80. package/lib/checker/checks/wazo-websocket.js +11 -1
  81. package/lib/checker/checks/webrtc-transport.js +165 -56
  82. package/lib/checker/checks/webrtc.js +165 -56
  83. package/lib/domain/AdHocAPIConference.js +1722 -1654
  84. package/lib/domain/CallLog.js +10 -22
  85. package/lib/domain/CallSession.js +1 -18
  86. package/lib/domain/Features.js +91 -23
  87. package/lib/domain/IndirectTransfer.js +0 -17
  88. package/lib/domain/Meeting.js +73 -0
  89. package/lib/domain/Phone/CTIPhone.js +98 -26
  90. package/lib/domain/Phone/Phone.js +0 -16
  91. package/lib/domain/Phone/WebRTCPhone.js +47 -27
  92. package/lib/domain/Room.js +0 -17
  93. package/lib/domain/SwitchboardCall.js +0 -17
  94. package/lib/domain/__tests__/CallLog.test.js +10 -22
  95. package/lib/domain/__tests__/CallSession.test.js +1 -18
  96. package/lib/domain/__tests__/IndirectTransfer.test.js +1 -18
  97. package/lib/domain/__tests__/Room.test.js +1 -18
  98. package/lib/index.js +3880 -3111
  99. package/lib/lib/WazoSessionDescriptionHandler.js +24 -10
  100. package/lib/service/CallApi.js +91 -23
  101. package/lib/service/IssueReporter.js +7 -1
  102. package/lib/service/__tests__/IssueReporter.test.js +9 -1
  103. package/lib/service/getApiClient.js +91 -23
  104. package/lib/simple/Auth.js +1126 -360
  105. package/lib/simple/Configuration.js +1126 -360
  106. package/lib/simple/Directory.js +91 -23
  107. package/lib/simple/Phone.js +3724 -2958
  108. package/lib/simple/Websocket.js +13 -1
  109. package/lib/simple/index.js +1128 -362
  110. package/lib/simple/room/LocalParticipant.js +1097 -331
  111. package/lib/simple/room/Participant.js +1097 -331
  112. package/lib/simple/room/RemoteParticipant.js +1097 -331
  113. package/lib/simple/room/Room.js +1097 -331
  114. package/lib/simple/room/SipRoom.js +13006 -0
  115. package/lib/simple/room/Stream.js +1128 -362
  116. package/lib/simple/room/__tests__/RemoteParticipant.test.js +5157 -4389
  117. package/lib/simple/utils.js +1128 -362
  118. package/lib/utils/__tests__/api-requester.test.js +7 -1
  119. package/lib/utils/api-requester.js +7 -1
  120. package/lib/web-rtc-client.js +165 -56
  121. package/lib/websocket-client.js +13 -1
  122. package/package.json +1 -1
  123. package/src/api/calld.js +3 -0
  124. package/src/api/confd.js +13 -0
  125. package/src/domain/CallLog.js +10 -22
  126. package/src/domain/CallSession.js +1 -2
  127. package/src/domain/Meeting.js +59 -0
  128. package/src/domain/Phone/CTIPhone.js +6 -2
  129. package/src/domain/Phone/Phone.js +2 -0
  130. package/src/domain/Phone/WebRTCPhone.js +22 -8
  131. package/src/index.js +6 -0
  132. package/src/lib/WazoSessionDescriptionHandler.js +17 -9
  133. package/src/service/IssueReporter.js +7 -1
  134. package/src/service/__tests__/IssueReporter.test.js +2 -0
  135. package/src/simple/Phone.js +13 -4
  136. package/src/simple/index.js +8 -0
  137. package/src/simple/room/Participant.js +7 -0
  138. package/src/simple/room/Room.js +157 -79
  139. package/src/simple/room/SipRoom.js +147 -0
  140. package/src/simple/room/Stream.js +1 -3
  141. package/src/simple/room/__tests__/RemoteParticipant.test.js +3 -2
  142. package/src/types/WebSocketMessage.js +21 -0
  143. package/src/web-rtc-client.js +57 -24
  144. package/src/websocket-client.js +4 -0
@@ -600,7 +600,13 @@ class IssueReporter {
600
600
  }
601
601
 
602
602
  _isLevelAbove(level1 , level2 ) {
603
- return LOG_LEVELS.indexOf(level1) > LOG_LEVELS.indexOf(level2);
603
+ const index1 = LOG_LEVELS.indexOf(level1);
604
+ const index2 = LOG_LEVELS.indexOf(level2);
605
+ if (index1 === -1 || index2 === -1) {
606
+ return false;
607
+ }
608
+
609
+ return index1 > index2;
604
610
  }
605
611
 
606
612
  _makeCategory(category ) {
@@ -772,7 +778,9 @@ class WazoSessionDescriptionHandler extends sessionDescriptionHandler.SessionDes
772
778
  .then(() => {
773
779
  if (isConference && (options.constraints && !options.constraints.video) && !('hold' in options) && !audioOnly) {
774
780
  // Add a video an empty bundle to be able to replaceTrack when joining a conference without video
775
- this.peerConnection.addTransceiver('video', { streams: [this._localMediaStream], direction: 'sendrecv' });
781
+ if (this.peerConnection.addTransceiver) {
782
+ this.peerConnection.addTransceiver('video', { streams: [this._localMediaStream], direction: 'sendrecv' });
783
+ }
776
784
  }
777
785
  })
778
786
  .then(() => this.createLocalOfferOrAnswer(options))
@@ -799,12 +807,6 @@ class WazoSessionDescriptionHandler extends sessionDescriptionHandler.SessionDes
799
807
  };
800
808
  })
801
809
  .then((sessionDescription) => this.applyModifiers(sessionDescription, modifiers))
802
- .then((sessionDescription) => {
803
- // Set new constraints to avoid the constraints check issue in `sdh.getLocalMediaStream` later.
804
- this.localMediaStreamConstraints = options.constraints;
805
-
806
- return sessionDescription;
807
- })
808
810
  .then((sessionDescription) => ({ body: sessionDescription.sdp, contentType: 'application/sdp' }))
809
811
  .catch((error) => {
810
812
  wazoLogger.error('error when creating media', error);
@@ -999,6 +1001,9 @@ class WazoSessionDescriptionHandler extends sessionDescriptionHandler.SessionDes
999
1001
 
1000
1002
  // set the transceiver direction to the answer direction
1001
1003
  this._peerConnection.getTransceivers().forEach((transceiver) => {
1004
+ if (transceiver.stopped) {
1005
+ return;
1006
+ }
1002
1007
  if (transceiver.direction /* guarding, but should always be true */) {
1003
1008
  const { receiver } = transceiver;
1004
1009
  if (isConference && audioOnly && receiver.track && receiver.track.kind === 'video') {
@@ -1043,10 +1048,15 @@ class WazoSessionDescriptionHandler extends sessionDescriptionHandler.SessionDes
1043
1048
  if (kind !== 'audio' && kind !== 'video') {
1044
1049
  throw new Error(`Unknown new track kind ${kind}.`);
1045
1050
  }
1046
- const sender = pc.getSenders().find((otherSender) => otherSender.track && otherSender.track.kind === kind);
1051
+ const sender = pc.getSenders && pc.getSenders().find((otherSender) =>
1052
+ otherSender.track && otherSender.track.kind === kind);
1047
1053
 
1048
1054
  // Do not reuse sender video tracks in SFU
1049
1055
  if (sender && (!sfu || newTrack.kind === 'audio')) {
1056
+ if (sender.track) {
1057
+ // eslint-disable-next-line no-param-reassign
1058
+ newTrack.enabled = sender.track.enabled;
1059
+ }
1050
1060
  trackUpdates.push(
1051
1061
  new Promise((resolve) => {
1052
1062
  this.logger.debug(`SessionDescriptionHandler.setLocalMediaStream - replacing sender ${kind} track`);
@@ -1080,7 +1090,11 @@ class WazoSessionDescriptionHandler extends sessionDescriptionHandler.SessionDes
1080
1090
  // Review: could make streamless tracks a configurable option?
1081
1091
  // https://developer.mozilla.org/en-US/docs/Web/API/RTCPeerConnection/addTrack#Usage_notes
1082
1092
  try {
1083
- pc.addTrack(newTrack, localStream);
1093
+ if (pc.addTrack) {
1094
+ pc.addTrack(newTrack, localStream);
1095
+ } else {
1096
+ pc.addStream(localStream);
1097
+ }
1084
1098
  } catch (error) {
1085
1099
  this.logger.error(`SessionDescriptionHandler.setLocalMediaStream - failed to add sender ${kind} track`);
1086
1100
  throw error;
@@ -3037,6 +3051,65 @@ class ExternalApp {
3037
3051
  }
3038
3052
  }
3039
3053
 
3054
+ //
3055
+
3056
+
3057
+
3058
+
3059
+
3060
+
3061
+
3062
+
3063
+
3064
+
3065
+
3066
+ class Meeting {
3067
+
3068
+
3069
+
3070
+
3071
+
3072
+
3073
+
3074
+
3075
+
3076
+
3077
+ static parse(plain ) {
3078
+ return new Meeting({
3079
+ guestSipAuthorization: plain.guest_sip_authorization,
3080
+ hostname: plain.hostname,
3081
+ name: plain.name,
3082
+ ownerUuids: plain.owner_uuids,
3083
+ port: plain.port,
3084
+ uuid: plain.uuid,
3085
+ number: plain.number,
3086
+ });
3087
+ }
3088
+
3089
+ static newFrom(meeting ) {
3090
+ return newFrom(meeting, Meeting);
3091
+ }
3092
+
3093
+ constructor({ uuid, name, guestSipAuthorization, ownerUuids, port, hostname, number } = {}) {
3094
+ this.guestSipAuthorization = guestSipAuthorization;
3095
+ this.hostname = hostname;
3096
+ this.name = name;
3097
+ this.ownerUuids = ownerUuids;
3098
+ this.port = port;
3099
+ this.uuid = uuid;
3100
+ this.number = number;
3101
+
3102
+ // Useful to compare instead of instanceof with minified code
3103
+ this.type = 'Meeting';
3104
+ }
3105
+
3106
+ getGuestSipCredentials() {
3107
+ // eslint-disable-next-line no-undef
3108
+ const [username, secret] = atob(this.guestSipAuthorization).split(':');
3109
+ return { username, secret };
3110
+ }
3111
+ }
3112
+
3040
3113
  /* */
3041
3114
 
3042
3115
  var confdMethods = (client , baseUrl ) => ({
@@ -3101,6 +3174,18 @@ var confdMethods = (client , baseUrl ) => ({
3101
3174
  return null;
3102
3175
  }
3103
3176
  },
3177
+
3178
+ createMyMeeting: (name ) =>
3179
+ client.post(`${baseUrl}/users/me/meetings`, { name }).then(Meeting.parse),
3180
+
3181
+ deleteMyMeeting: (meetingUuid ) =>
3182
+ client.delete(`${baseUrl}/users/me/meetings/${meetingUuid}`, null),
3183
+
3184
+ getMeeting: (meetingUuid ) =>
3185
+ client.get(`${baseUrl}/meetings/${meetingUuid}`, null).then(Meeting.parse),
3186
+
3187
+ guestGetMeeting: (meetingUuid ) =>
3188
+ client.get(`${baseUrl}/guests/me/meetings/${meetingUuid}`, null).then(Meeting.parse),
3104
3189
  });
3105
3190
 
3106
3191
  //
@@ -3685,7 +3770,11 @@ class CallLog {
3685
3770
  answered: plain.answered,
3686
3771
  callDirection: plain.call_direction,
3687
3772
  destination: {
3688
- extension: plain.requested_extension || plain.destination_extension,
3773
+ // @TEMP: Temporarily assuming empty numbers are meetings
3774
+ // which is admittedly a very dangerous assumption. Did i mention it was temporary?
3775
+ extension: plain.requested_extension
3776
+ || plain.destination_extension
3777
+ || `meeting-${plain.requested_name || plain.destination_name || ''}`,
3689
3778
  name: plain.requested_name || plain.destination_name || '',
3690
3779
  },
3691
3780
  source: {
@@ -3701,27 +3790,11 @@ class CallLog {
3701
3790
  }
3702
3791
 
3703
3792
  static parseNew(plain , session ) {
3704
- return new CallLog({
3705
- answer: plain.answer ? moment__default['default'](plain.answer).toDate() : null,
3706
- answered: plain.answered,
3707
- callDirection: plain.call_direction,
3708
- destination: {
3709
- extension: plain.requested_extension || plain.destination_extension,
3710
- name: plain.requested_name || plain.destination_name || '',
3711
- },
3712
- source: {
3713
- extension: plain.source_extension,
3714
- name: plain.source_name,
3715
- },
3716
- id: plain.id,
3717
- duration: (plain.duration || 0) * 1000, // duration is in seconds
3718
- start: moment__default['default'](plain.start).toDate(),
3719
- end: plain.end ? moment__default['default'](plain.end).toDate() : null,
3720
- recordings: Recording.parseMany(plain.recordings),
3721
- // @TODO: FIXME add verification declined vs missed call
3722
- newMissedCall: session
3723
- && session.hasExtension(plain.requested_extension || plain.destination_extension) && !plain.answered,
3724
- });
3793
+ const callLog = CallLog.parse(plain);
3794
+ // @TODO: FIXME add verification declined vs missed call
3795
+ callLog.newMissedCall = session
3796
+ && session.hasExtension(plain.requested_extension || plain.destination_extension) && !plain.answered;
3797
+ return callLog;
3725
3798
  }
3726
3799
 
3727
3800
  static newFrom(profile ) {
@@ -4478,6 +4551,9 @@ var calldMethods = (client , baseUrl ) => ({
4478
4551
  getConferenceParticipantsAsUser: async (conferenceId ) =>
4479
4552
  client.get(`${baseUrl}/users/me/conferences/${conferenceId}/participants`),
4480
4553
 
4554
+ getMeetingParticipantsAsUser: async (meetingUuid ) =>
4555
+ client.get(`${baseUrl}/users/me/meetings/${meetingUuid}/participants`),
4556
+
4481
4557
  listTrunks: () => client.get(`${baseUrl}/trunks`),
4482
4558
 
4483
4559
  mute: (callId ) =>
@@ -5110,6 +5186,7 @@ const MAX_REGISTER_TRIES = 10;
5110
5186
 
5111
5187
 
5112
5188
 
5189
+
5113
5190
 
5114
5191
 
5115
5192
 
@@ -5136,6 +5213,7 @@ class WebRTCClient extends Emitter {
5136
5213
 
5137
5214
 
5138
5215
 
5216
+
5139
5217
 
5140
5218
  // sugar
5141
5219
 
@@ -5174,6 +5252,8 @@ class WebRTCClient extends Emitter {
5174
5252
  super();
5175
5253
  this.uaConfigOverrides = uaConfigOverrides;
5176
5254
  this.config = config;
5255
+ this.skipRegister = config.skipRegister;
5256
+
5177
5257
  this._buildConfig(config, session).then((newConfig ) => {
5178
5258
  this.config = newConfig;
5179
5259
  this.userAgent = this.createUserAgent(uaConfigOverrides);
@@ -5301,14 +5381,22 @@ class WebRTCClient extends Emitter {
5301
5381
  }
5302
5382
 
5303
5383
  register(tries = 0) {
5304
- logger.info('sdk webrtc registering...', {
5384
+ const logInfo = {
5305
5385
  userAgent: !!this.userAgent,
5306
5386
  registered: this.isRegistered(),
5307
5387
  connectionPromise: !!this.connectionPromise,
5308
5388
  registerer: !!this.registerer,
5309
5389
  waiting: this.registerer && this.registerer.waiting,
5310
5390
  tries,
5311
- });
5391
+ skipRegister: this.skipRegister,
5392
+ };
5393
+
5394
+ if (this.skipRegister) {
5395
+ logger.info('sdk webrtc skip register...', logInfo);
5396
+ return Promise.resolve();
5397
+ }
5398
+
5399
+ logger.info('sdk webrtc registering...', logInfo);
5312
5400
 
5313
5401
  if (!this.userAgent) {
5314
5402
  logger.info('sdk webrtc recreating User Agent');
@@ -5639,12 +5727,18 @@ class WebRTCClient extends Emitter {
5639
5727
  }
5640
5728
 
5641
5729
  if (pc.getSenders) {
5730
+ if (!pc.getSenders().length) {
5731
+ return false;
5732
+ }
5642
5733
  pc.getSenders().forEach(sender => {
5643
5734
  if (sender && sender.track && sender.track.kind === 'audio') {
5644
5735
  muted = muted && !sender.track.enabled;
5645
5736
  }
5646
5737
  });
5647
5738
  } else {
5739
+ if (!pc.getLocalStreams().length) {
5740
+ return false;
5741
+ }
5648
5742
  pc.getLocalStreams().forEach(stream => {
5649
5743
  stream.getAudioTracks().forEach(track => {
5650
5744
  muted = muted && !track.enabled;
@@ -5701,6 +5795,9 @@ class WebRTCClient extends Emitter {
5701
5795
  if (!this._isWeb()) {
5702
5796
  options.sessionDescriptionHandlerModifiers = [modifiers.holdModifier];
5703
5797
  }
5798
+ options.sessionDescriptionHandlerOptions = {
5799
+ constraints: options.constraints,
5800
+ };
5704
5801
 
5705
5802
  // Send re-INVITE
5706
5803
  return session.invite(options);
@@ -5740,6 +5837,9 @@ class WebRTCClient extends Emitter {
5740
5837
  // (eg: holdModifier)
5741
5838
  options.sessionDescriptionHandlerModifiers = [];
5742
5839
  }
5840
+ options.sessionDescriptionHandlerOptions = {
5841
+ constraints: options.constraints,
5842
+ };
5743
5843
 
5744
5844
  // Send re-INVITE
5745
5845
  return session.invite(options);
@@ -5922,7 +6022,8 @@ class WebRTCClient extends Emitter {
5922
6022
  }
5923
6023
  const sdh = session.sessionDescriptionHandler;
5924
6024
  const pc = sdh.peerConnection;
5925
- const localStream = this.getLocalStream(this.getSipSessionId(session));
6025
+ const sessionId = this.getSipSessionId(session);
6026
+ const localStream = this.getLocalStream(sessionId);
5926
6027
 
5927
6028
  // Release old video stream
5928
6029
  if (localStream) {
@@ -5948,11 +6049,8 @@ class WebRTCClient extends Emitter {
5948
6049
 
5949
6050
  // let's update the local stream
5950
6051
  this.eventEmitter.emit('onVideoInputChange', stream);
5951
- try {
5952
- await sdh.setLocalMediaStream(stream);
5953
- } catch (_) {
5954
- // Nothing to do
5955
- }
6052
+ this.setLocalMediaStream(sessionId, stream);
6053
+
5956
6054
  return stream;
5957
6055
  });
5958
6056
  }
@@ -6254,9 +6352,11 @@ class WebRTCClient extends Emitter {
6254
6352
  remoteStream.removeTrack(track);
6255
6353
  });
6256
6354
 
6257
- pc.getReceivers().forEach(receiver => {
6258
- remoteStream.addTrack(receiver.track);
6259
- });
6355
+ if (pc.getReceivers) {
6356
+ pc.getReceivers().forEach(receiver => {
6357
+ remoteStream.addTrack(receiver.track);
6358
+ });
6359
+ }
6260
6360
  }
6261
6361
 
6262
6362
  getMediaConfiguration(enableVideo , conference = false, constraints = null) {
@@ -6291,6 +6391,25 @@ class WebRTCClient extends Emitter {
6291
6391
  return sessionId in this.conferences;
6292
6392
  }
6293
6393
 
6394
+ createAudioElementFor(sessionId ) {
6395
+ const audio = document.createElement('audio');
6396
+ audio.setAttribute('id', `audio-${sessionId}`);
6397
+
6398
+ if (audio.setSinkId && this.audioOutputDeviceId) {
6399
+ audio.setSinkId(this.audioOutputDeviceId);
6400
+ }
6401
+
6402
+ if (document.body) {
6403
+ document.body.appendChild(audio);
6404
+ }
6405
+ this.audioElements[sessionId] = audio;
6406
+
6407
+ audio.volume = this.audioOutputVolume;
6408
+ audio.autoplay = true;
6409
+
6410
+ return audio;
6411
+ }
6412
+
6294
6413
  _onTransportError() {
6295
6414
  this.eventEmitter.emit(TRANSPORT_ERROR);
6296
6415
  this.attemptReconnection();
@@ -6520,7 +6639,7 @@ class WebRTCClient extends Emitter {
6520
6639
  let hadRemoteVideo = false;
6521
6640
 
6522
6641
  // Monkey patch `onInviteRequest` to be able to know if there was a remote video stream before `onInvite` is called
6523
- // Becase when `onInvite` is called we already got the video track
6642
+ // Because when `onInvite` is called we already got the video track
6524
6643
  session.onInviteRequest = (request) => {
6525
6644
  hadRemoteVideo = this.hasARemoteVideoTrack(sipSessionId);
6526
6645
 
@@ -6595,20 +6714,10 @@ class WebRTCClient extends Emitter {
6595
6714
  const isConference = this.isConference(sessionId);
6596
6715
 
6597
6716
  if (this._hasAudio() && this._isWeb() && !(sessionId in this.audioElements)) {
6598
- const audio = document.createElement('audio');
6599
- audio.setAttribute('id', `audio-${sessionId}`);
6600
-
6601
- if (audio.setSinkId && this.audioOutputDeviceId) {
6602
- audio.setSinkId(this.audioOutputDeviceId);
6603
- }
6604
-
6605
- if (document.body) {
6606
- document.body.appendChild(audio);
6607
- }
6608
- this.audioElements[sessionId] = audio;
6717
+ this.createAudioElementFor(sessionId);
6609
6718
  }
6610
6719
 
6611
- const audioElement = this.audioElements[this.getSipSessionId(session)];
6720
+ const audioElement = this.audioElements[sessionId];
6612
6721
  const stream = newStream || this.getRemoteStream(sessionId);
6613
6722
 
6614
6723
  if (!this._isWeb() || !stream) {
package/lib/api/agentd.js CHANGED
@@ -311,7 +311,13 @@ class IssueReporter {
311
311
  }
312
312
 
313
313
  _isLevelAbove(level1 , level2 ) {
314
- return LOG_LEVELS.indexOf(level1) > LOG_LEVELS.indexOf(level2);
314
+ const index1 = LOG_LEVELS.indexOf(level1);
315
+ const index2 = LOG_LEVELS.indexOf(level2);
316
+ if (index1 === -1 || index2 === -1) {
317
+ return false;
318
+ }
319
+
320
+ return index1 > index2;
315
321
  }
316
322
 
317
323
  _makeCategory(category ) {
package/lib/api/amid.js CHANGED
@@ -250,7 +250,13 @@ class IssueReporter {
250
250
  }
251
251
 
252
252
  _isLevelAbove(level1 , level2 ) {
253
- return LOG_LEVELS.indexOf(level1) > LOG_LEVELS.indexOf(level2);
253
+ const index1 = LOG_LEVELS.indexOf(level1);
254
+ const index2 = LOG_LEVELS.indexOf(level2);
255
+ if (index1 === -1 || index2 === -1) {
256
+ return false;
257
+ }
258
+
259
+ return index1 > index2;
254
260
  }
255
261
 
256
262
  _makeCategory(category ) {
@@ -311,7 +311,13 @@ class IssueReporter {
311
311
  }
312
312
 
313
313
  _isLevelAbove(level1 , level2 ) {
314
- return LOG_LEVELS.indexOf(level1) > LOG_LEVELS.indexOf(level2);
314
+ const index1 = LOG_LEVELS.indexOf(level1);
315
+ const index2 = LOG_LEVELS.indexOf(level2);
316
+ if (index1 === -1 || index2 === -1) {
317
+ return false;
318
+ }
319
+
320
+ return index1 > index2;
315
321
  }
316
322
 
317
323
  _makeCategory(category ) {
package/lib/api/auth.js CHANGED
@@ -314,7 +314,13 @@ class IssueReporter {
314
314
  }
315
315
 
316
316
  _isLevelAbove(level1 , level2 ) {
317
- return LOG_LEVELS.indexOf(level1) > LOG_LEVELS.indexOf(level2);
317
+ const index1 = LOG_LEVELS.indexOf(level1);
318
+ const index2 = LOG_LEVELS.indexOf(level2);
319
+ if (index1 === -1 || index2 === -1) {
320
+ return false;
321
+ }
322
+
323
+ return index1 > index2;
318
324
  }
319
325
 
320
326
  _makeCategory(category ) {
@@ -251,7 +251,13 @@ class IssueReporter {
251
251
  }
252
252
 
253
253
  _isLevelAbove(level1 , level2 ) {
254
- return LOG_LEVELS.indexOf(level1) > LOG_LEVELS.indexOf(level2);
254
+ const index1 = LOG_LEVELS.indexOf(level1);
255
+ const index2 = LOG_LEVELS.indexOf(level2);
256
+ if (index1 === -1 || index2 === -1) {
257
+ return false;
258
+ }
259
+
260
+ return index1 > index2;
255
261
  }
256
262
 
257
263
  _makeCategory(category ) {
@@ -450,7 +456,11 @@ class CallLog {
450
456
  answered: plain.answered,
451
457
  callDirection: plain.call_direction,
452
458
  destination: {
453
- extension: plain.requested_extension || plain.destination_extension,
459
+ // @TEMP: Temporarily assuming empty numbers are meetings
460
+ // which is admittedly a very dangerous assumption. Did i mention it was temporary?
461
+ extension: plain.requested_extension
462
+ || plain.destination_extension
463
+ || `meeting-${plain.requested_name || plain.destination_name || ''}`,
454
464
  name: plain.requested_name || plain.destination_name || '',
455
465
  },
456
466
  source: {
@@ -466,27 +476,11 @@ class CallLog {
466
476
  }
467
477
 
468
478
  static parseNew(plain , session ) {
469
- return new CallLog({
470
- answer: plain.answer ? moment__default['default'](plain.answer).toDate() : null,
471
- answered: plain.answered,
472
- callDirection: plain.call_direction,
473
- destination: {
474
- extension: plain.requested_extension || plain.destination_extension,
475
- name: plain.requested_name || plain.destination_name || '',
476
- },
477
- source: {
478
- extension: plain.source_extension,
479
- name: plain.source_name,
480
- },
481
- id: plain.id,
482
- duration: (plain.duration || 0) * 1000, // duration is in seconds
483
- start: moment__default['default'](plain.start).toDate(),
484
- end: plain.end ? moment__default['default'](plain.end).toDate() : null,
485
- recordings: Recording.parseMany(plain.recordings),
486
- // @TODO: FIXME add verification declined vs missed call
487
- newMissedCall: session
488
- && session.hasExtension(plain.requested_extension || plain.destination_extension) && !plain.answered,
489
- });
479
+ const callLog = CallLog.parse(plain);
480
+ // @TODO: FIXME add verification declined vs missed call
481
+ callLog.newMissedCall = session
482
+ && session.hasExtension(plain.requested_extension || plain.destination_extension) && !plain.answered;
483
+ return callLog;
490
484
  }
491
485
 
492
486
  static newFrom(profile ) {
package/lib/api/calld.js CHANGED
@@ -3,7 +3,6 @@
3
3
  var jsBase64 = require('js-base64');
4
4
  var moment = require('moment');
5
5
  require('sip.js/lib/api/session-state');
6
- var jsrsasign = require('jsrsasign');
7
6
 
8
7
  function _interopDefaultLegacy (e) { return e && typeof e === 'object' && 'default' in e ? e : { 'default': e }; }
9
8
 
@@ -313,7 +312,13 @@ class IssueReporter {
313
312
  }
314
313
 
315
314
  _isLevelAbove(level1 , level2 ) {
316
- return LOG_LEVELS.indexOf(level1) > LOG_LEVELS.indexOf(level2);
315
+ const index1 = LOG_LEVELS.indexOf(level1);
316
+ const index2 = LOG_LEVELS.indexOf(level2);
317
+ if (index1 === -1 || index2 === -1) {
318
+ return false;
319
+ }
320
+
321
+ return index1 > index2;
317
322
  }
318
323
 
319
324
  _makeCategory(category ) {
@@ -1031,22 +1036,6 @@ class Call {
1031
1036
  }
1032
1037
  }
1033
1038
 
1034
- //
1035
-
1036
- const swarmPublicKey = `-----BEGIN PUBLIC KEY-----
1037
- MIIBIjANBgkqhkiG9w0BAQEFAAOCAQ8AMIIBCgKCAQEAmkXOuNfY8u5xoTiIhkb8
1038
- djnbIwG/Wrz3vpo8BZir8L5e1a1nSy740qBjP7ZINBQoALDhFfmdOfJnCyEGiHuz
1039
- ZW6jbG6C3PryE3Bu6GKwqSmD6k3q4Zk27fpwYAnNl+rWhYYM563rJZBda/INyHNN
1040
- pK7M1mixWi7gNdjjXwoEXSSBx+VpYMkY6LiAB2mvHXTY9M1qI14dvgGoQISZQoKi
1041
- NMTRCg5UP2ic0Dd9nSz/XpcOxGfa+0fwIl1F7RC1tJXOqvkGGPTOV4LLfg/Yta3h
1042
- nUPX9EZZDIX6vO/0IBV1LzjSl2A1bYFYAjJfowv3i1CpvONBOClHjSY5t9Y8MH6p
1043
- BwIDAQAB
1044
- -----END PUBLIC KEY-----`;
1045
-
1046
- //
1047
-
1048
- jsrsasign.KEYUTIL.getKey(swarmPublicKey);
1049
-
1050
1039
  //
1051
1040
  /* eslint-disable no-param-reassign */
1052
1041
 
@@ -1258,6 +1247,9 @@ var calld = (client , baseUrl ) => ({
1258
1247
  getConferenceParticipantsAsUser: async (conferenceId ) =>
1259
1248
  client.get(`${baseUrl}/users/me/conferences/${conferenceId}/participants`),
1260
1249
 
1250
+ getMeetingParticipantsAsUser: async (meetingUuid ) =>
1251
+ client.get(`${baseUrl}/users/me/meetings/${meetingUuid}/participants`),
1252
+
1261
1253
  listTrunks: () => client.get(`${baseUrl}/trunks`),
1262
1254
 
1263
1255
  mute: (callId ) =>
package/lib/api/chatd.js CHANGED
@@ -311,7 +311,13 @@ class IssueReporter {
311
311
  }
312
312
 
313
313
  _isLevelAbove(level1 , level2 ) {
314
- return LOG_LEVELS.indexOf(level1) > LOG_LEVELS.indexOf(level2);
314
+ const index1 = LOG_LEVELS.indexOf(level1);
315
+ const index2 = LOG_LEVELS.indexOf(level2);
316
+ if (index1 === -1 || index2 === -1) {
317
+ return false;
318
+ }
319
+
320
+ return index1 > index2;
315
321
  }
316
322
 
317
323
  _makeCategory(category ) {