@wazo/sdk 0.37.2 → 0.37.6

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/dist/wazo-sdk.js +5 -5
  2. package/esm/__tests__/api-client.test.js +84 -22
  3. package/esm/__tests__/web-rtc-client.test.js +156 -55
  4. package/esm/api/call-logd.js +10 -22
  5. package/esm/api/calld.js +3 -0
  6. package/esm/api/confd.js +71 -0
  7. package/esm/api-client.js +84 -22
  8. package/esm/checker/Checker.js +160 -55
  9. package/esm/checker/checks/aor.js +84 -22
  10. package/esm/checker/checks/api.js +84 -22
  11. package/esm/checker/checks/index.js +160 -55
  12. package/esm/checker/checks/wazo-websocket.js +4 -0
  13. package/esm/checker/checks/webrtc-transport.js +156 -55
  14. package/esm/checker/checks/webrtc.js +156 -55
  15. package/esm/domain/AdHocAPIConference.js +84 -22
  16. package/esm/domain/CallLog.js +10 -22
  17. package/esm/domain/Features.js +84 -22
  18. package/esm/domain/Meeting.js +71 -0
  19. package/esm/domain/Phone/CTIPhone.js +84 -22
  20. package/esm/domain/Phone/WebRTCPhone.js +22 -8
  21. package/esm/domain/__tests__/CallLog.test.js +10 -22
  22. package/esm/index.js +726 -371
  23. package/esm/lib/WazoSessionDescriptionHandler.js +17 -9
  24. package/esm/service/CallApi.js +84 -22
  25. package/esm/service/getApiClient.js +84 -22
  26. package/esm/simple/Auth.js +717 -363
  27. package/esm/simple/Configuration.js +717 -363
  28. package/esm/simple/Directory.js +84 -22
  29. package/esm/simple/Phone.js +709 -355
  30. package/esm/simple/Websocket.js +6 -0
  31. package/esm/simple/index.js +719 -365
  32. package/esm/simple/room/LocalParticipant.js +689 -335
  33. package/esm/simple/room/Participant.js +689 -335
  34. package/esm/simple/room/RemoteParticipant.js +689 -335
  35. package/esm/simple/room/Room.js +689 -335
  36. package/esm/simple/room/SipRoom.js +13001 -0
  37. package/esm/simple/room/Stream.js +719 -365
  38. package/esm/simple/room/__tests__/RemoteParticipant.test.js +4130 -3774
  39. package/esm/simple/utils.js +719 -365
  40. package/esm/web-rtc-client.js +156 -55
  41. package/esm/websocket-client.js +5 -1
  42. package/lib/__tests__/api-client.test.js +84 -22
  43. package/lib/__tests__/web-rtc-client.test.js +156 -55
  44. package/lib/api/call-logd.js +10 -22
  45. package/lib/api/calld.js +3 -0
  46. package/lib/api/confd.js +71 -0
  47. package/lib/api-client.js +84 -22
  48. package/lib/checker/Checker.js +160 -55
  49. package/lib/checker/checks/aor.js +84 -22
  50. package/lib/checker/checks/api.js +84 -22
  51. package/lib/checker/checks/index.js +160 -55
  52. package/lib/checker/checks/wazo-websocket.js +4 -0
  53. package/lib/checker/checks/webrtc-transport.js +156 -55
  54. package/lib/checker/checks/webrtc.js +156 -55
  55. package/lib/domain/AdHocAPIConference.js +84 -22
  56. package/lib/domain/CallLog.js +10 -22
  57. package/lib/domain/Features.js +84 -22
  58. package/lib/domain/Meeting.js +73 -0
  59. package/lib/domain/Phone/CTIPhone.js +84 -22
  60. package/lib/domain/Phone/WebRTCPhone.js +22 -8
  61. package/lib/domain/__tests__/CallLog.test.js +10 -22
  62. package/lib/index.js +726 -371
  63. package/lib/lib/WazoSessionDescriptionHandler.js +17 -9
  64. package/lib/service/CallApi.js +84 -22
  65. package/lib/service/getApiClient.js +84 -22
  66. package/lib/simple/Auth.js +717 -363
  67. package/lib/simple/Configuration.js +717 -363
  68. package/lib/simple/Directory.js +84 -22
  69. package/lib/simple/Phone.js +709 -355
  70. package/lib/simple/Websocket.js +6 -0
  71. package/lib/simple/index.js +719 -365
  72. package/lib/simple/room/LocalParticipant.js +689 -335
  73. package/lib/simple/room/Participant.js +689 -335
  74. package/lib/simple/room/RemoteParticipant.js +689 -335
  75. package/lib/simple/room/Room.js +689 -335
  76. package/lib/simple/room/SipRoom.js +13011 -0
  77. package/lib/simple/room/Stream.js +719 -365
  78. package/lib/simple/room/__tests__/RemoteParticipant.test.js +4131 -3775
  79. package/lib/simple/utils.js +719 -365
  80. package/lib/web-rtc-client.js +156 -55
  81. package/lib/websocket-client.js +6 -0
  82. package/package.json +1 -1
  83. package/src/api/calld.js +3 -0
  84. package/src/api/confd.js +13 -0
  85. package/src/domain/CallLog.js +10 -22
  86. package/src/domain/Meeting.js +59 -0
  87. package/src/domain/Phone/WebRTCPhone.js +22 -8
  88. package/src/index.js +2 -0
  89. package/src/lib/WazoSessionDescriptionHandler.js +17 -9
  90. package/src/simple/Phone.js +13 -4
  91. package/src/simple/index.js +4 -0
  92. package/src/simple/room/Participant.js +7 -0
  93. package/src/simple/room/Room.js +158 -79
  94. package/src/simple/room/SipRoom.js +147 -0
  95. package/src/simple/room/Stream.js +1 -3
  96. package/src/simple/room/__tests__/RemoteParticipant.test.js +3 -2
  97. package/src/types/WebSocketMessage.js +21 -0
  98. package/src/web-rtc-client.js +55 -24
  99. package/src/websocket-client.js +4 -0
@@ -769,7 +769,9 @@ class WazoSessionDescriptionHandler extends SessionDescriptionHandler {
769
769
  .then(() => {
770
770
  if (isConference && (options.constraints && !options.constraints.video) && !('hold' in options) && !audioOnly) {
771
771
  // Add a video an empty bundle to be able to replaceTrack when joining a conference without video
772
- this.peerConnection.addTransceiver('video', { streams: [this._localMediaStream], direction: 'sendrecv' });
772
+ if (this.peerConnection.addTransceiver) {
773
+ this.peerConnection.addTransceiver('video', { streams: [this._localMediaStream], direction: 'sendrecv' });
774
+ }
773
775
  }
774
776
  })
775
777
  .then(() => this.createLocalOfferOrAnswer(options))
@@ -796,12 +798,6 @@ class WazoSessionDescriptionHandler extends SessionDescriptionHandler {
796
798
  };
797
799
  })
798
800
  .then((sessionDescription) => this.applyModifiers(sessionDescription, modifiers))
799
- .then((sessionDescription) => {
800
- // Set new constraints to avoid the constraints check issue in `sdh.getLocalMediaStream` later.
801
- this.localMediaStreamConstraints = options.constraints;
802
-
803
- return sessionDescription;
804
- })
805
801
  .then((sessionDescription) => ({ body: sessionDescription.sdp, contentType: 'application/sdp' }))
806
802
  .catch((error) => {
807
803
  wazoLogger.error('error when creating media', error);
@@ -996,6 +992,9 @@ class WazoSessionDescriptionHandler extends SessionDescriptionHandler {
996
992
 
997
993
  // set the transceiver direction to the answer direction
998
994
  this._peerConnection.getTransceivers().forEach((transceiver) => {
995
+ if (transceiver.stopped) {
996
+ return;
997
+ }
999
998
  if (transceiver.direction /* guarding, but should always be true */) {
1000
999
  const { receiver } = transceiver;
1001
1000
  if (isConference && audioOnly && receiver.track && receiver.track.kind === 'video') {
@@ -1040,10 +1039,15 @@ class WazoSessionDescriptionHandler extends SessionDescriptionHandler {
1040
1039
  if (kind !== 'audio' && kind !== 'video') {
1041
1040
  throw new Error(`Unknown new track kind ${kind}.`);
1042
1041
  }
1043
- const sender = pc.getSenders().find((otherSender) => otherSender.track && otherSender.track.kind === kind);
1042
+ const sender = pc.getSenders && pc.getSenders().find((otherSender) =>
1043
+ otherSender.track && otherSender.track.kind === kind);
1044
1044
 
1045
1045
  // Do not reuse sender video tracks in SFU
1046
1046
  if (sender && (!sfu || newTrack.kind === 'audio')) {
1047
+ if (sender.track) {
1048
+ // eslint-disable-next-line no-param-reassign
1049
+ newTrack.enabled = sender.track.enabled;
1050
+ }
1047
1051
  trackUpdates.push(
1048
1052
  new Promise((resolve) => {
1049
1053
  this.logger.debug(`SessionDescriptionHandler.setLocalMediaStream - replacing sender ${kind} track`);
@@ -1077,7 +1081,11 @@ class WazoSessionDescriptionHandler extends SessionDescriptionHandler {
1077
1081
  // Review: could make streamless tracks a configurable option?
1078
1082
  // https://developer.mozilla.org/en-US/docs/Web/API/RTCPeerConnection/addTrack#Usage_notes
1079
1083
  try {
1080
- pc.addTrack(newTrack, localStream);
1084
+ if (pc.addTrack) {
1085
+ pc.addTrack(newTrack, localStream);
1086
+ } else {
1087
+ pc.addStream(localStream);
1088
+ }
1081
1089
  } catch (error) {
1082
1090
  this.logger.error(`SessionDescriptionHandler.setLocalMediaStream - failed to add sender ${kind} track`);
1083
1091
  throw error;
@@ -3034,6 +3042,65 @@ class ExternalApp {
3034
3042
  }
3035
3043
  }
3036
3044
 
3045
+ //
3046
+
3047
+
3048
+
3049
+
3050
+
3051
+
3052
+
3053
+
3054
+
3055
+
3056
+
3057
+ class Meeting {
3058
+
3059
+
3060
+
3061
+
3062
+
3063
+
3064
+
3065
+
3066
+
3067
+
3068
+ static parse(plain ) {
3069
+ return new Meeting({
3070
+ guestSipAuthorization: plain.guest_sip_authorization,
3071
+ hostname: plain.hostname,
3072
+ name: plain.name,
3073
+ ownerUuids: plain.owner_uuids,
3074
+ port: plain.port,
3075
+ uuid: plain.uuid,
3076
+ number: plain.number,
3077
+ });
3078
+ }
3079
+
3080
+ static newFrom(meeting ) {
3081
+ return newFrom(meeting, Meeting);
3082
+ }
3083
+
3084
+ constructor({ uuid, name, guestSipAuthorization, ownerUuids, port, hostname, number } = {}) {
3085
+ this.guestSipAuthorization = guestSipAuthorization;
3086
+ this.hostname = hostname;
3087
+ this.name = name;
3088
+ this.ownerUuids = ownerUuids;
3089
+ this.port = port;
3090
+ this.uuid = uuid;
3091
+ this.number = number;
3092
+
3093
+ // Useful to compare instead of instanceof with minified code
3094
+ this.type = 'Meeting';
3095
+ }
3096
+
3097
+ getGuestSipCredentials() {
3098
+ // eslint-disable-next-line no-undef
3099
+ const [username, secret] = atob(this.guestSipAuthorization).split(':');
3100
+ return { username, secret };
3101
+ }
3102
+ }
3103
+
3037
3104
  /* */
3038
3105
 
3039
3106
  var confdMethods = (client , baseUrl ) => ({
@@ -3098,6 +3165,18 @@ var confdMethods = (client , baseUrl ) => ({
3098
3165
  return null;
3099
3166
  }
3100
3167
  },
3168
+
3169
+ createMyMeeting: (name ) =>
3170
+ client.post(`${baseUrl}/users/me/meetings`, { name }).then(Meeting.parse),
3171
+
3172
+ deleteMyMeeting: (meetingUuid ) =>
3173
+ client.delete(`${baseUrl}/users/me/meetings/${meetingUuid}`, null),
3174
+
3175
+ getMeeting: (meetingUuid ) =>
3176
+ client.get(`${baseUrl}/meetings/${meetingUuid}`, null).then(Meeting.parse),
3177
+
3178
+ guestGetMeeting: (meetingUuid ) =>
3179
+ client.get(`${baseUrl}/guests/me/meetings/${meetingUuid}`, null).then(Meeting.parse),
3101
3180
  });
3102
3181
 
3103
3182
  //
@@ -3682,7 +3761,11 @@ class CallLog {
3682
3761
  answered: plain.answered,
3683
3762
  callDirection: plain.call_direction,
3684
3763
  destination: {
3685
- extension: plain.requested_extension || plain.destination_extension,
3764
+ // @TEMP: Temporarily assuming empty numbers are meetings
3765
+ // which is admittedly a very dangerous assumption. Did i mention it was temporary?
3766
+ extension: plain.requested_extension
3767
+ || plain.destination_extension
3768
+ || `meeting-${plain.requested_name || plain.destination_name || ''}`,
3686
3769
  name: plain.requested_name || plain.destination_name || '',
3687
3770
  },
3688
3771
  source: {
@@ -3698,27 +3781,11 @@ class CallLog {
3698
3781
  }
3699
3782
 
3700
3783
  static parseNew(plain , session ) {
3701
- return new CallLog({
3702
- answer: plain.answer ? moment(plain.answer).toDate() : null,
3703
- answered: plain.answered,
3704
- callDirection: plain.call_direction,
3705
- destination: {
3706
- extension: plain.requested_extension || plain.destination_extension,
3707
- name: plain.requested_name || plain.destination_name || '',
3708
- },
3709
- source: {
3710
- extension: plain.source_extension,
3711
- name: plain.source_name,
3712
- },
3713
- id: plain.id,
3714
- duration: (plain.duration || 0) * 1000, // duration is in seconds
3715
- start: moment(plain.start).toDate(),
3716
- end: plain.end ? moment(plain.end).toDate() : null,
3717
- recordings: Recording.parseMany(plain.recordings),
3718
- // @TODO: FIXME add verification declined vs missed call
3719
- newMissedCall: session
3720
- && session.hasExtension(plain.requested_extension || plain.destination_extension) && !plain.answered,
3721
- });
3784
+ const callLog = CallLog.parse(plain);
3785
+ // @TODO: FIXME add verification declined vs missed call
3786
+ callLog.newMissedCall = session
3787
+ && session.hasExtension(plain.requested_extension || plain.destination_extension) && !plain.answered;
3788
+ return callLog;
3722
3789
  }
3723
3790
 
3724
3791
  static newFrom(profile ) {
@@ -4475,6 +4542,9 @@ var calldMethods = (client , baseUrl ) => ({
4475
4542
  getConferenceParticipantsAsUser: async (conferenceId ) =>
4476
4543
  client.get(`${baseUrl}/users/me/conferences/${conferenceId}/participants`),
4477
4544
 
4545
+ getMeetingParticipantsAsUser: async (meetingUuid ) =>
4546
+ client.get(`${baseUrl}/users/me/meetings/${meetingUuid}/participants`),
4547
+
4478
4548
  listTrunks: () => client.get(`${baseUrl}/trunks`),
4479
4549
 
4480
4550
  mute: (callId ) =>
@@ -5110,6 +5180,7 @@ const MAX_REGISTER_TRIES = 10;
5110
5180
 
5111
5181
 
5112
5182
 
5183
+
5113
5184
 
5114
5185
 
5115
5186
 
@@ -5136,6 +5207,7 @@ class WebRTCClient extends Emitter {
5136
5207
 
5137
5208
 
5138
5209
 
5210
+
5139
5211
 
5140
5212
  // sugar
5141
5213
 
@@ -5174,6 +5246,8 @@ class WebRTCClient extends Emitter {
5174
5246
  super();
5175
5247
  this.uaConfigOverrides = uaConfigOverrides;
5176
5248
  this.config = config;
5249
+ this.skipRegister = config.skipRegister;
5250
+
5177
5251
  this._buildConfig(config, session).then((newConfig ) => {
5178
5252
  this.config = newConfig;
5179
5253
  this.userAgent = this.createUserAgent(uaConfigOverrides);
@@ -5301,14 +5375,22 @@ class WebRTCClient extends Emitter {
5301
5375
  }
5302
5376
 
5303
5377
  register(tries = 0) {
5304
- logger.info('sdk webrtc registering...', {
5378
+ const logInfo = {
5305
5379
  userAgent: !!this.userAgent,
5306
5380
  registered: this.isRegistered(),
5307
5381
  connectionPromise: !!this.connectionPromise,
5308
5382
  registerer: !!this.registerer,
5309
5383
  waiting: this.registerer && this.registerer.waiting,
5310
5384
  tries,
5311
- });
5385
+ skipRegister: this.skipRegister,
5386
+ };
5387
+
5388
+ if (this.skipRegister) {
5389
+ logger.info('sdk webrtc skip register...', logInfo);
5390
+ return Promise.resolve();
5391
+ }
5392
+
5393
+ logger.info('sdk webrtc registering...', logInfo);
5312
5394
 
5313
5395
  if (!this.userAgent) {
5314
5396
  logger.info('sdk webrtc recreating User Agent');
@@ -5639,12 +5721,18 @@ class WebRTCClient extends Emitter {
5639
5721
  }
5640
5722
 
5641
5723
  if (pc.getSenders) {
5724
+ if (!pc.getSenders().length) {
5725
+ return false;
5726
+ }
5642
5727
  pc.getSenders().forEach(sender => {
5643
5728
  if (sender && sender.track && sender.track.kind === 'audio') {
5644
5729
  muted = muted && !sender.track.enabled;
5645
5730
  }
5646
5731
  });
5647
5732
  } else {
5733
+ if (!pc.getLocalStreams().length) {
5734
+ return false;
5735
+ }
5648
5736
  pc.getLocalStreams().forEach(stream => {
5649
5737
  stream.getAudioTracks().forEach(track => {
5650
5738
  muted = muted && !track.enabled;
@@ -5703,6 +5791,8 @@ class WebRTCClient extends Emitter {
5703
5791
  }
5704
5792
  options.sessionDescriptionHandlerOptions = {
5705
5793
  constraints: options.constraints,
5794
+ hold: true,
5795
+ conference: isConference,
5706
5796
  };
5707
5797
 
5708
5798
  // Send re-INVITE
@@ -5745,6 +5835,8 @@ class WebRTCClient extends Emitter {
5745
5835
  }
5746
5836
  options.sessionDescriptionHandlerOptions = {
5747
5837
  constraints: options.constraints,
5838
+ hold: false,
5839
+ conference: isConference,
5748
5840
  };
5749
5841
 
5750
5842
  // Send re-INVITE
@@ -5928,7 +6020,8 @@ class WebRTCClient extends Emitter {
5928
6020
  }
5929
6021
  const sdh = session.sessionDescriptionHandler;
5930
6022
  const pc = sdh.peerConnection;
5931
- const localStream = this.getLocalStream(this.getSipSessionId(session));
6023
+ const sessionId = this.getSipSessionId(session);
6024
+ const localStream = this.getLocalStream(sessionId);
5932
6025
 
5933
6026
  // Release old video stream
5934
6027
  if (localStream) {
@@ -5954,11 +6047,8 @@ class WebRTCClient extends Emitter {
5954
6047
 
5955
6048
  // let's update the local stream
5956
6049
  this.eventEmitter.emit('onVideoInputChange', stream);
5957
- try {
5958
- await sdh.setLocalMediaStream(stream);
5959
- } catch (_) {
5960
- // Nothing to do
5961
- }
6050
+ this.setLocalMediaStream(sessionId, stream);
6051
+
5962
6052
  return stream;
5963
6053
  });
5964
6054
  }
@@ -6260,9 +6350,11 @@ class WebRTCClient extends Emitter {
6260
6350
  remoteStream.removeTrack(track);
6261
6351
  });
6262
6352
 
6263
- pc.getReceivers().forEach(receiver => {
6264
- remoteStream.addTrack(receiver.track);
6265
- });
6353
+ if (pc.getReceivers) {
6354
+ pc.getReceivers().forEach(receiver => {
6355
+ remoteStream.addTrack(receiver.track);
6356
+ });
6357
+ }
6266
6358
  }
6267
6359
 
6268
6360
  getMediaConfiguration(enableVideo , conference = false, constraints = null) {
@@ -6297,6 +6389,25 @@ class WebRTCClient extends Emitter {
6297
6389
  return sessionId in this.conferences;
6298
6390
  }
6299
6391
 
6392
+ createAudioElementFor(sessionId ) {
6393
+ const audio = document.createElement('audio');
6394
+ audio.setAttribute('id', `audio-${sessionId}`);
6395
+
6396
+ if (audio.setSinkId && this.audioOutputDeviceId) {
6397
+ audio.setSinkId(this.audioOutputDeviceId);
6398
+ }
6399
+
6400
+ if (document.body) {
6401
+ document.body.appendChild(audio);
6402
+ }
6403
+ this.audioElements[sessionId] = audio;
6404
+
6405
+ audio.volume = this.audioOutputVolume;
6406
+ audio.autoplay = true;
6407
+
6408
+ return audio;
6409
+ }
6410
+
6300
6411
  _onTransportError() {
6301
6412
  this.eventEmitter.emit(TRANSPORT_ERROR);
6302
6413
  this.attemptReconnection();
@@ -6526,7 +6637,7 @@ class WebRTCClient extends Emitter {
6526
6637
  let hadRemoteVideo = false;
6527
6638
 
6528
6639
  // Monkey patch `onInviteRequest` to be able to know if there was a remote video stream before `onInvite` is called
6529
- // Becase when `onInvite` is called we already got the video track
6640
+ // Because when `onInvite` is called we already got the video track
6530
6641
  session.onInviteRequest = (request) => {
6531
6642
  hadRemoteVideo = this.hasARemoteVideoTrack(sipSessionId);
6532
6643
 
@@ -6601,20 +6712,10 @@ class WebRTCClient extends Emitter {
6601
6712
  const isConference = this.isConference(sessionId);
6602
6713
 
6603
6714
  if (this._hasAudio() && this._isWeb() && !(sessionId in this.audioElements)) {
6604
- const audio = document.createElement('audio');
6605
- audio.setAttribute('id', `audio-${sessionId}`);
6606
-
6607
- if (audio.setSinkId && this.audioOutputDeviceId) {
6608
- audio.setSinkId(this.audioOutputDeviceId);
6609
- }
6610
-
6611
- if (document.body) {
6612
- document.body.appendChild(audio);
6613
- }
6614
- this.audioElements[sessionId] = audio;
6715
+ this.createAudioElementFor(sessionId);
6615
6716
  }
6616
6717
 
6617
- const audioElement = this.audioElements[this.getSipSessionId(session)];
6718
+ const audioElement = this.audioElements[sessionId];
6618
6719
  const stream = newStream || this.getRemoteStream(sessionId);
6619
6720
 
6620
6721
  if (!this._isWeb() || !stream) {
@@ -465,6 +465,8 @@ const CONFERENCE_USER_PARTICIPANT_JOINED = 'conference_user_participant_joined';
465
465
  const CONFERENCE_USER_PARTICIPANT_LEFT = 'conference_user_participant_left';
466
466
  const CONFERENCE_USER_PARTICIPANT_TALK_STARTED = 'conference_user_participant_talk_started';
467
467
  const CONFERENCE_USER_PARTICIPANT_TALK_STOPPED = 'conference_user_participant_talk_stopped';
468
+ const MEETING_USER_PARTICIPANT_JOINED = 'meeting_user_participant_joined';
469
+ const MEETING_USER_PARTICIPANT_LEFT = 'meeting_user_participant_left';
468
470
  const SWITCHBOARD_QUEUED_CALLS_UPDATED = 'switchboard_queued_calls_updated';
469
471
  const SWITCHBOARD_QUEUED_CALL_ANSWERED = 'switchboard_queued_call_answered';
470
472
  const SWITCHBOARD_HELD_CALLS_UPDATED = 'switchboard_held_calls_updated';
@@ -811,6 +813,8 @@ WebSocketClient.eventLists = [
811
813
  CHATD_USER_ROOM_CREATED,
812
814
  CONFERENCE_USER_PARTICIPANT_JOINED,
813
815
  CONFERENCE_USER_PARTICIPANT_LEFT,
816
+ MEETING_USER_PARTICIPANT_JOINED,
817
+ MEETING_USER_PARTICIPANT_LEFT,
814
818
  CONFERENCE_USER_PARTICIPANT_TALK_STARTED,
815
819
  CONFERENCE_USER_PARTICIPANT_TALK_STOPPED,
816
820
  SWITCHBOARD_QUEUED_CALLS_UPDATED,
@@ -848,4 +852,4 @@ WebSocketClient.eventLists = [
848
852
  ];
849
853
 
850
854
  export default WebSocketClient;
851
- export { AGENT_PAUSED, AGENT_STATUS_UPDATE, AGENT_UNPAUSED, APPLICATION_CALL_ANSWERED, APPLICATION_CALL_DELETED, APPLICATION_CALL_DTMF_RECEIVED, APPLICATION_CALL_ENTERED, APPLICATION_CALL_INITIATED, APPLICATION_CALL_UPDATED, APPLICATION_DESTINATION_NODE_CREATED, APPLICATION_NODE_CREATED, APPLICATION_NODE_DELETED, APPLICATION_NODE_UPDATED, APPLICATION_PLAYBACK_CREATED, APPLICATION_PLAYBACK_DELETED, APPLICATION_PROGRESS_STARTED, APPLICATION_PROGRESS_STOPPED, APPLICATION_SNOOP_CREATED, APPLICATION_SNOOP_DELETED, APPLICATION_SNOOP_UPDATED, APPLICATION_USER_OUTGOING_CALL_CREATED, AUTH_SESSION_EXPIRE_SOON, AUTH_USER_EXTERNAL_AUTH_ADDED, AUTH_USER_EXTERNAL_AUTH_DELETED, CALL_ANSWERED, CALL_CREATED, CALL_DTMF_CREATED, CALL_ENDED, CALL_HELD, CALL_LOG_USER_CREATED, CALL_RESUMED, CALL_UPDATED, CHATD_PRESENCE_UPDATED, CHATD_USER_ROOM_CREATED, CHATD_USER_ROOM_MESSAGE_CREATED, CHAT_MESSAGE_RECEIVED, CHAT_MESSAGE_SENT, CONFERENCE_ADHOC_DELETED, CONFERENCE_ADHOC_PARTICIPANT_LEFT, CONFERENCE_USER_PARTICIPANT_JOINED, CONFERENCE_USER_PARTICIPANT_LEFT, CONFERENCE_USER_PARTICIPANT_TALK_STARTED, CONFERENCE_USER_PARTICIPANT_TALK_STOPPED, ENDPOINT_STATUS_UPDATE, FAVORITE_ADDED, FAVORITE_DELETED, FAX_OUTBOUND_USER_CREATED, FAX_OUTBOUND_USER_FAILED, FAX_OUTBOUND_USER_SUCCEEDED, HEARTBEAT_ENGINE_VERSION, LINE_STATUS_UPDATED, SOCKET_EVENTS, SWITCHBOARD_HELD_CALLS_UPDATED, SWITCHBOARD_HELD_CALL_ANSWERED, SWITCHBOARD_QUEUED_CALLS_UPDATED, SWITCHBOARD_QUEUED_CALL_ANSWERED, TRUNK_STATUS_UPDATED, USERS_FORWARDS_BUSY_UPDATED, USERS_FORWARDS_NOANSWER_UPDATED, USERS_FORWARDS_UNCONDITIONAL_UPDATED, USERS_SERVICES_DND_UPDATED, USER_STATUS_UPDATE, USER_VOICEMAIL_MESSAGE_CREATED, USER_VOICEMAIL_MESSAGE_DELETED, USER_VOICEMAIL_MESSAGE_UPDATED };
855
+ export { AGENT_PAUSED, AGENT_STATUS_UPDATE, AGENT_UNPAUSED, APPLICATION_CALL_ANSWERED, APPLICATION_CALL_DELETED, APPLICATION_CALL_DTMF_RECEIVED, APPLICATION_CALL_ENTERED, APPLICATION_CALL_INITIATED, APPLICATION_CALL_UPDATED, APPLICATION_DESTINATION_NODE_CREATED, APPLICATION_NODE_CREATED, APPLICATION_NODE_DELETED, APPLICATION_NODE_UPDATED, APPLICATION_PLAYBACK_CREATED, APPLICATION_PLAYBACK_DELETED, APPLICATION_PROGRESS_STARTED, APPLICATION_PROGRESS_STOPPED, APPLICATION_SNOOP_CREATED, APPLICATION_SNOOP_DELETED, APPLICATION_SNOOP_UPDATED, APPLICATION_USER_OUTGOING_CALL_CREATED, AUTH_SESSION_EXPIRE_SOON, AUTH_USER_EXTERNAL_AUTH_ADDED, AUTH_USER_EXTERNAL_AUTH_DELETED, CALL_ANSWERED, CALL_CREATED, CALL_DTMF_CREATED, CALL_ENDED, CALL_HELD, CALL_LOG_USER_CREATED, CALL_RESUMED, CALL_UPDATED, CHATD_PRESENCE_UPDATED, CHATD_USER_ROOM_CREATED, CHATD_USER_ROOM_MESSAGE_CREATED, CHAT_MESSAGE_RECEIVED, CHAT_MESSAGE_SENT, CONFERENCE_ADHOC_DELETED, CONFERENCE_ADHOC_PARTICIPANT_LEFT, CONFERENCE_USER_PARTICIPANT_JOINED, CONFERENCE_USER_PARTICIPANT_LEFT, CONFERENCE_USER_PARTICIPANT_TALK_STARTED, CONFERENCE_USER_PARTICIPANT_TALK_STOPPED, ENDPOINT_STATUS_UPDATE, FAVORITE_ADDED, FAVORITE_DELETED, FAX_OUTBOUND_USER_CREATED, FAX_OUTBOUND_USER_FAILED, FAX_OUTBOUND_USER_SUCCEEDED, HEARTBEAT_ENGINE_VERSION, LINE_STATUS_UPDATED, MEETING_USER_PARTICIPANT_JOINED, MEETING_USER_PARTICIPANT_LEFT, SOCKET_EVENTS, SWITCHBOARD_HELD_CALLS_UPDATED, SWITCHBOARD_HELD_CALL_ANSWERED, SWITCHBOARD_QUEUED_CALLS_UPDATED, SWITCHBOARD_QUEUED_CALL_ANSWERED, TRUNK_STATUS_UPDATED, USERS_FORWARDS_BUSY_UPDATED, USERS_FORWARDS_NOANSWER_UPDATED, USERS_FORWARDS_UNCONDITIONAL_UPDATED, USERS_SERVICES_DND_UPDATED, USER_STATUS_UPDATE, USER_VOICEMAIL_MESSAGE_CREATED, USER_VOICEMAIL_MESSAGE_DELETED, USER_VOICEMAIL_MESSAGE_UPDATED };
@@ -2499,6 +2499,65 @@ class ExternalApp {
2499
2499
  }
2500
2500
  }
2501
2501
 
2502
+ //
2503
+
2504
+
2505
+
2506
+
2507
+
2508
+
2509
+
2510
+
2511
+
2512
+
2513
+
2514
+ class Meeting {
2515
+
2516
+
2517
+
2518
+
2519
+
2520
+
2521
+
2522
+
2523
+
2524
+
2525
+ static parse(plain ) {
2526
+ return new Meeting({
2527
+ guestSipAuthorization: plain.guest_sip_authorization,
2528
+ hostname: plain.hostname,
2529
+ name: plain.name,
2530
+ ownerUuids: plain.owner_uuids,
2531
+ port: plain.port,
2532
+ uuid: plain.uuid,
2533
+ number: plain.number,
2534
+ });
2535
+ }
2536
+
2537
+ static newFrom(meeting ) {
2538
+ return newFrom(meeting, Meeting);
2539
+ }
2540
+
2541
+ constructor({ uuid, name, guestSipAuthorization, ownerUuids, port, hostname, number } = {}) {
2542
+ this.guestSipAuthorization = guestSipAuthorization;
2543
+ this.hostname = hostname;
2544
+ this.name = name;
2545
+ this.ownerUuids = ownerUuids;
2546
+ this.port = port;
2547
+ this.uuid = uuid;
2548
+ this.number = number;
2549
+
2550
+ // Useful to compare instead of instanceof with minified code
2551
+ this.type = 'Meeting';
2552
+ }
2553
+
2554
+ getGuestSipCredentials() {
2555
+ // eslint-disable-next-line no-undef
2556
+ const [username, secret] = atob(this.guestSipAuthorization).split(':');
2557
+ return { username, secret };
2558
+ }
2559
+ }
2560
+
2502
2561
  /* */
2503
2562
 
2504
2563
  var confdMethods = (client , baseUrl ) => ({
@@ -2563,6 +2622,18 @@ var confdMethods = (client , baseUrl ) => ({
2563
2622
  return null;
2564
2623
  }
2565
2624
  },
2625
+
2626
+ createMyMeeting: (name ) =>
2627
+ client.post(`${baseUrl}/users/me/meetings`, { name }).then(Meeting.parse),
2628
+
2629
+ deleteMyMeeting: (meetingUuid ) =>
2630
+ client.delete(`${baseUrl}/users/me/meetings/${meetingUuid}`, null),
2631
+
2632
+ getMeeting: (meetingUuid ) =>
2633
+ client.get(`${baseUrl}/meetings/${meetingUuid}`, null).then(Meeting.parse),
2634
+
2635
+ guestGetMeeting: (meetingUuid ) =>
2636
+ client.get(`${baseUrl}/guests/me/meetings/${meetingUuid}`, null).then(Meeting.parse),
2566
2637
  });
2567
2638
 
2568
2639
  //
@@ -3147,7 +3218,11 @@ class CallLog {
3147
3218
  answered: plain.answered,
3148
3219
  callDirection: plain.call_direction,
3149
3220
  destination: {
3150
- extension: plain.requested_extension || plain.destination_extension,
3221
+ // @TEMP: Temporarily assuming empty numbers are meetings
3222
+ // which is admittedly a very dangerous assumption. Did i mention it was temporary?
3223
+ extension: plain.requested_extension
3224
+ || plain.destination_extension
3225
+ || `meeting-${plain.requested_name || plain.destination_name || ''}`,
3151
3226
  name: plain.requested_name || plain.destination_name || '',
3152
3227
  },
3153
3228
  source: {
@@ -3163,27 +3238,11 @@ class CallLog {
3163
3238
  }
3164
3239
 
3165
3240
  static parseNew(plain , session ) {
3166
- return new CallLog({
3167
- answer: plain.answer ? moment__default['default'](plain.answer).toDate() : null,
3168
- answered: plain.answered,
3169
- callDirection: plain.call_direction,
3170
- destination: {
3171
- extension: plain.requested_extension || plain.destination_extension,
3172
- name: plain.requested_name || plain.destination_name || '',
3173
- },
3174
- source: {
3175
- extension: plain.source_extension,
3176
- name: plain.source_name,
3177
- },
3178
- id: plain.id,
3179
- duration: (plain.duration || 0) * 1000, // duration is in seconds
3180
- start: moment__default['default'](plain.start).toDate(),
3181
- end: plain.end ? moment__default['default'](plain.end).toDate() : null,
3182
- recordings: Recording.parseMany(plain.recordings),
3183
- // @TODO: FIXME add verification declined vs missed call
3184
- newMissedCall: session
3185
- && session.hasExtension(plain.requested_extension || plain.destination_extension) && !plain.answered,
3186
- });
3241
+ const callLog = CallLog.parse(plain);
3242
+ // @TODO: FIXME add verification declined vs missed call
3243
+ callLog.newMissedCall = session
3244
+ && session.hasExtension(plain.requested_extension || plain.destination_extension) && !plain.answered;
3245
+ return callLog;
3187
3246
  }
3188
3247
 
3189
3248
  static newFrom(profile ) {
@@ -3940,6 +3999,9 @@ var calldMethods = (client , baseUrl ) => ({
3940
3999
  getConferenceParticipantsAsUser: async (conferenceId ) =>
3941
4000
  client.get(`${baseUrl}/users/me/conferences/${conferenceId}/participants`),
3942
4001
 
4002
+ getMeetingParticipantsAsUser: async (meetingUuid ) =>
4003
+ client.get(`${baseUrl}/users/me/meetings/${meetingUuid}/participants`),
4004
+
3943
4005
  listTrunks: () => client.get(`${baseUrl}/trunks`),
3944
4006
 
3945
4007
  mute: (callId ) =>