@wazo/sdk 0.38.16 → 0.38.18

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 (69) hide show
  1. package/dist/wazo-sdk.js +2 -2
  2. package/esm/__tests__/api-client.test.js +7 -4
  3. package/esm/__tests__/web-rtc-client.test.js +35 -6
  4. package/esm/api/chatd.js +7 -4
  5. package/esm/api-client.js +7 -4
  6. package/esm/checker/Checker.js +35 -6
  7. package/esm/checker/checks/aor.js +7 -4
  8. package/esm/checker/checks/api.js +7 -4
  9. package/esm/checker/checks/index.js +35 -6
  10. package/esm/checker/checks/webrtc-transport.js +35 -6
  11. package/esm/checker/checks/webrtc.js +35 -6
  12. package/esm/domain/AdHocAPIConference.js +7 -4
  13. package/esm/domain/Features.js +7 -4
  14. package/esm/domain/Phone/CTIPhone.js +7 -4
  15. package/esm/domain/Phone/WebRTCPhone.js +7 -1
  16. package/esm/index.js +42 -6
  17. package/esm/service/CallApi.js +7 -4
  18. package/esm/service/getApiClient.js +7 -4
  19. package/esm/simple/Auth.js +42 -6
  20. package/esm/simple/Configuration.js +42 -6
  21. package/esm/simple/Directory.js +7 -4
  22. package/esm/simple/Phone.js +42 -6
  23. package/esm/simple/index.js +42 -6
  24. package/esm/simple/room/LocalParticipant.js +42 -6
  25. package/esm/simple/room/Participant.js +42 -6
  26. package/esm/simple/room/RemoteParticipant.js +42 -6
  27. package/esm/simple/room/Room.js +42 -6
  28. package/esm/simple/room/SipRoom.js +42 -6
  29. package/esm/simple/room/Stream.js +42 -6
  30. package/esm/simple/room/__tests__/Participant.test.js +42 -6
  31. package/esm/simple/room/__tests__/RemoteParticipant.test.js +42 -6
  32. package/esm/simple/utils.js +42 -6
  33. package/esm/web-rtc-client.js +35 -6
  34. package/lib/__tests__/api-client.test.js +7 -4
  35. package/lib/__tests__/web-rtc-client.test.js +35 -6
  36. package/lib/api/chatd.js +7 -4
  37. package/lib/api-client.js +7 -4
  38. package/lib/checker/Checker.js +35 -6
  39. package/lib/checker/checks/aor.js +7 -4
  40. package/lib/checker/checks/api.js +7 -4
  41. package/lib/checker/checks/index.js +35 -6
  42. package/lib/checker/checks/webrtc-transport.js +35 -6
  43. package/lib/checker/checks/webrtc.js +35 -6
  44. package/lib/domain/AdHocAPIConference.js +7 -4
  45. package/lib/domain/Features.js +7 -4
  46. package/lib/domain/Phone/CTIPhone.js +7 -4
  47. package/lib/domain/Phone/WebRTCPhone.js +7 -0
  48. package/lib/index.js +42 -6
  49. package/lib/service/CallApi.js +7 -4
  50. package/lib/service/getApiClient.js +7 -4
  51. package/lib/simple/Auth.js +42 -6
  52. package/lib/simple/Configuration.js +42 -6
  53. package/lib/simple/Directory.js +7 -4
  54. package/lib/simple/Phone.js +42 -6
  55. package/lib/simple/index.js +42 -6
  56. package/lib/simple/room/LocalParticipant.js +42 -6
  57. package/lib/simple/room/Participant.js +42 -6
  58. package/lib/simple/room/RemoteParticipant.js +42 -6
  59. package/lib/simple/room/Room.js +42 -6
  60. package/lib/simple/room/SipRoom.js +42 -6
  61. package/lib/simple/room/Stream.js +42 -6
  62. package/lib/simple/room/__tests__/Participant.test.js +42 -6
  63. package/lib/simple/room/__tests__/RemoteParticipant.test.js +42 -6
  64. package/lib/simple/utils.js +42 -6
  65. package/lib/web-rtc-client.js +35 -6
  66. package/package.json +1 -1
  67. package/src/api/chatd.js +7 -4
  68. package/src/domain/Phone/WebRTCPhone.js +6 -0
  69. package/src/web-rtc-client.js +28 -2
@@ -5047,10 +5047,13 @@ var chatdMethods = (client , baseUrl ) => ({
5047
5047
  createRoom: async (name , users ) =>
5048
5048
  client.post(`${baseUrl}/users/me/rooms`, { name, users }).then(ChatRoom.parse),
5049
5049
 
5050
- getRoomMessages: async (roomUuid ) =>
5051
- client
5052
- .get(`${baseUrl}/users/me/rooms/${roomUuid}/messages`)
5053
- .then((response ) => ChatMessage.parseMany(response)),
5050
+ getRoomMessages: async (roomUuid , params = {}) => {
5051
+ const qs = ApiRequester.getQueryString(params);
5052
+
5053
+ return client
5054
+ .get(`${baseUrl}/users/me/rooms/${roomUuid}/messages${qs.length ? `?${qs}` : ''}`)
5055
+ .then((response ) => ChatMessage.parseMany(response));
5056
+ },
5054
5057
 
5055
5058
  sendRoomMessage: async (roomUuid , message ) =>
5056
5059
  client.post(`${baseUrl}/users/me/rooms/${roomUuid}/messages`, message).then(ChatMessage.parse),
@@ -7027,6 +7030,7 @@ const MESSAGE = 'message';
7027
7030
  const ACCEPTED = 'accepted';
7028
7031
  const REJECTED = 'rejected';
7029
7032
  const ON_TRACK$1 = 'onTrack';
7033
+ const ON_EARLY_MEDIA$1 = 'onEarlyMedia';
7030
7034
  const ON_REINVITE$1 = 'reinvite';
7031
7035
  const ON_ERROR = 'onError';
7032
7036
  const ON_SCREEN_SHARING_REINVITE = 'onScreenSharingReinvite';
@@ -7110,6 +7114,7 @@ class WebRTCClient extends Emitter {
7110
7114
 
7111
7115
 
7112
7116
 
7117
+
7113
7118
 
7114
7119
 
7115
7120
  static isAPrivateIp(ip ) {
@@ -7178,6 +7183,7 @@ class WebRTCClient extends Emitter {
7178
7183
  this.ON_SCREEN_SHARING_REINVITE = ON_SCREEN_SHARING_REINVITE;
7179
7184
  this.ON_NETWORK_STATS = ON_NETWORK_STATS$1;
7180
7185
  this.ON_DISCONNECTED = ON_DISCONNECTED$1;
7186
+ this.ON_EARLY_MEDIA = ON_EARLY_MEDIA$1;
7181
7187
  }
7182
7188
 
7183
7189
  configureMedia(media ) {
@@ -7465,6 +7471,11 @@ class WebRTCClient extends Emitter {
7465
7471
  }
7466
7472
  this._onAccepted(session, response.session, true);
7467
7473
  },
7474
+ onProgress: (payload) => {
7475
+ if (payload.message.statusCode === 183) {
7476
+ this._onEarlyProgress(payload.session);
7477
+ }
7478
+ },
7468
7479
  onReject: (response ) => {
7469
7480
  logger$8.info('on call rejected', { id: session.id, fromTag: session.fromTag });
7470
7481
  this._stopSendingStats(session);
@@ -8857,6 +8868,17 @@ class WebRTCClient extends Emitter {
8857
8868
  };
8858
8869
  }
8859
8870
 
8871
+ _onEarlyProgress(session ) {
8872
+ this._setupMedias(session);
8873
+
8874
+ const sessionId = this.getSipSessionId(session).substr(0, 20);
8875
+ this.updateRemoteStream(sessionId);
8876
+
8877
+ logger$8.info('Early media progress progress received', { sessionId });
8878
+
8879
+ this.eventEmitter.emit(ON_EARLY_MEDIA$1, session);
8880
+ }
8881
+
8860
8882
  _onAccepted(session , sessionDialog , withEvent = true) {
8861
8883
  logger$8.info('on call accepted', { id: session.id, remoteTag: session.remoteTag });
8862
8884
 
@@ -8908,15 +8930,22 @@ class WebRTCClient extends Emitter {
8908
8930
 
8909
8931
  _setupMedias(session , newStream ) {
8910
8932
  // Safari hack, because you cannot call .play() from a non user action
8911
- const sessionId = this.getSipSessionId(session);
8933
+ const sessionId = this.getSipSessionId(session).substr(0, 20);
8912
8934
  const isConference = this.isConference(sessionId);
8913
8935
 
8936
+ if (sessionId in this.audioElements) {
8937
+ logger$8.info('html element already exists for session', { sessionId });
8938
+ return;
8939
+ }
8940
+
8914
8941
  if (this._hasAudio() && this._isWeb() && !(sessionId in this.audioElements)) {
8915
8942
  this.createAudioElementFor(sessionId);
8916
8943
  }
8917
8944
 
8918
8945
  const audioElement = this.audioElements[sessionId];
8919
- const stream = newStream || this.getRemoteStream(sessionId);
8946
+ const sipSession = this.sipSessions[session.callId];
8947
+ const removeStream = this.getRemoteStream(sessionId);
8948
+ const stream = newStream || removeStream || sipSession.sessionDescriptionHandler.remoteMediaStream;
8920
8949
 
8921
8950
  if (!this._isWeb() || !stream) {
8922
8951
  return;
@@ -9248,6 +9277,7 @@ const ON_NETWORK_STATS = 'onNetworkStats';
9248
9277
  const ON_CHAT = 'phone/ON_CHAT';
9249
9278
  const ON_SIGNAL = 'phone/ON_SIGNAL';
9250
9279
  const ON_DISCONNECTED = 'onDisconnected';
9280
+ const ON_EARLY_MEDIA = 'onEarlyMedia';
9251
9281
 
9252
9282
  const MESSAGE_TYPE_CHAT = 'message/TYPE_CHAT';
9253
9283
  const MESSAGE_TYPE_SIGNAL = 'message/TYPE_SIGNAL';
@@ -9289,6 +9319,7 @@ const events = [
9289
9319
  ON_SIGNAL,
9290
9320
  ON_NETWORK_STATS,
9291
9321
  ON_DISCONNECTED,
9322
+ ON_EARLY_MEDIA,
9292
9323
  ];
9293
9324
 
9294
9325
  const logger$7 = IssueReporter$1.loggerFor('webrtc-phone');
@@ -10718,6 +10749,10 @@ class WebRTCPhone extends Emitter {
10718
10749
  logger$7.info('WebRTC disconnected');
10719
10750
  this.eventEmitter.emit(ON_DISCONNECTED);
10720
10751
  });
10752
+ this.client.on(this.client.ON_EARLY_MEDIA, () => {
10753
+ logger$7.info('WebRTC early media');
10754
+ this.eventEmitter.emit(ON_EARLY_MEDIA);
10755
+ });
10721
10756
 
10722
10757
  this.client.on(this.client.REGISTERED, () => {
10723
10758
  logger$7.info('WebRTC registered', {
@@ -11001,6 +11036,7 @@ var PHONE_EVENTS = /*#__PURE__*/Object.freeze({
11001
11036
  ON_CHAT: ON_CHAT,
11002
11037
  ON_SIGNAL: ON_SIGNAL,
11003
11038
  ON_DISCONNECTED: ON_DISCONNECTED,
11039
+ ON_EARLY_MEDIA: ON_EARLY_MEDIA,
11004
11040
  MESSAGE_TYPE_CHAT: MESSAGE_TYPE_CHAT,
11005
11041
  MESSAGE_TYPE_SIGNAL: MESSAGE_TYPE_SIGNAL,
11006
11042
  events: events,
@@ -5047,10 +5047,13 @@ var chatdMethods = (client , baseUrl ) => ({
5047
5047
  createRoom: async (name , users ) =>
5048
5048
  client.post(`${baseUrl}/users/me/rooms`, { name, users }).then(ChatRoom.parse),
5049
5049
 
5050
- getRoomMessages: async (roomUuid ) =>
5051
- client
5052
- .get(`${baseUrl}/users/me/rooms/${roomUuid}/messages`)
5053
- .then((response ) => ChatMessage.parseMany(response)),
5050
+ getRoomMessages: async (roomUuid , params = {}) => {
5051
+ const qs = ApiRequester.getQueryString(params);
5052
+
5053
+ return client
5054
+ .get(`${baseUrl}/users/me/rooms/${roomUuid}/messages${qs.length ? `?${qs}` : ''}`)
5055
+ .then((response ) => ChatMessage.parseMany(response));
5056
+ },
5054
5057
 
5055
5058
  sendRoomMessage: async (roomUuid , message ) =>
5056
5059
  client.post(`${baseUrl}/users/me/rooms/${roomUuid}/messages`, message).then(ChatMessage.parse),
@@ -6696,6 +6699,7 @@ const MESSAGE = 'message';
6696
6699
  const ACCEPTED = 'accepted';
6697
6700
  const REJECTED = 'rejected';
6698
6701
  const ON_TRACK$1 = 'onTrack';
6702
+ const ON_EARLY_MEDIA$1 = 'onEarlyMedia';
6699
6703
  const ON_REINVITE$1 = 'reinvite';
6700
6704
  const ON_ERROR = 'onError';
6701
6705
  const ON_SCREEN_SHARING_REINVITE = 'onScreenSharingReinvite';
@@ -6779,6 +6783,7 @@ class WebRTCClient extends Emitter {
6779
6783
 
6780
6784
 
6781
6785
 
6786
+
6782
6787
 
6783
6788
 
6784
6789
  static isAPrivateIp(ip ) {
@@ -6847,6 +6852,7 @@ class WebRTCClient extends Emitter {
6847
6852
  this.ON_SCREEN_SHARING_REINVITE = ON_SCREEN_SHARING_REINVITE;
6848
6853
  this.ON_NETWORK_STATS = ON_NETWORK_STATS$1;
6849
6854
  this.ON_DISCONNECTED = ON_DISCONNECTED$1;
6855
+ this.ON_EARLY_MEDIA = ON_EARLY_MEDIA$1;
6850
6856
  }
6851
6857
 
6852
6858
  configureMedia(media ) {
@@ -7134,6 +7140,11 @@ class WebRTCClient extends Emitter {
7134
7140
  }
7135
7141
  this._onAccepted(session, response.session, true);
7136
7142
  },
7143
+ onProgress: (payload) => {
7144
+ if (payload.message.statusCode === 183) {
7145
+ this._onEarlyProgress(payload.session);
7146
+ }
7147
+ },
7137
7148
  onReject: (response ) => {
7138
7149
  logger$9.info('on call rejected', { id: session.id, fromTag: session.fromTag });
7139
7150
  this._stopSendingStats(session);
@@ -8526,6 +8537,17 @@ class WebRTCClient extends Emitter {
8526
8537
  };
8527
8538
  }
8528
8539
 
8540
+ _onEarlyProgress(session ) {
8541
+ this._setupMedias(session);
8542
+
8543
+ const sessionId = this.getSipSessionId(session).substr(0, 20);
8544
+ this.updateRemoteStream(sessionId);
8545
+
8546
+ logger$9.info('Early media progress progress received', { sessionId });
8547
+
8548
+ this.eventEmitter.emit(ON_EARLY_MEDIA$1, session);
8549
+ }
8550
+
8529
8551
  _onAccepted(session , sessionDialog , withEvent = true) {
8530
8552
  logger$9.info('on call accepted', { id: session.id, remoteTag: session.remoteTag });
8531
8553
 
@@ -8577,15 +8599,22 @@ class WebRTCClient extends Emitter {
8577
8599
 
8578
8600
  _setupMedias(session , newStream ) {
8579
8601
  // Safari hack, because you cannot call .play() from a non user action
8580
- const sessionId = this.getSipSessionId(session);
8602
+ const sessionId = this.getSipSessionId(session).substr(0, 20);
8581
8603
  const isConference = this.isConference(sessionId);
8582
8604
 
8605
+ if (sessionId in this.audioElements) {
8606
+ logger$9.info('html element already exists for session', { sessionId });
8607
+ return;
8608
+ }
8609
+
8583
8610
  if (this._hasAudio() && this._isWeb() && !(sessionId in this.audioElements)) {
8584
8611
  this.createAudioElementFor(sessionId);
8585
8612
  }
8586
8613
 
8587
8614
  const audioElement = this.audioElements[sessionId];
8588
- const stream = newStream || this.getRemoteStream(sessionId);
8615
+ const sipSession = this.sipSessions[session.callId];
8616
+ const removeStream = this.getRemoteStream(sessionId);
8617
+ const stream = newStream || removeStream || sipSession.sessionDescriptionHandler.remoteMediaStream;
8589
8618
 
8590
8619
  if (!this._isWeb() || !stream) {
8591
8620
  return;
@@ -8917,6 +8946,7 @@ const ON_NETWORK_STATS = 'onNetworkStats';
8917
8946
  const ON_CHAT = 'phone/ON_CHAT';
8918
8947
  const ON_SIGNAL = 'phone/ON_SIGNAL';
8919
8948
  const ON_DISCONNECTED = 'onDisconnected';
8949
+ const ON_EARLY_MEDIA = 'onEarlyMedia';
8920
8950
 
8921
8951
  const MESSAGE_TYPE_CHAT = 'message/TYPE_CHAT';
8922
8952
  const MESSAGE_TYPE_SIGNAL = 'message/TYPE_SIGNAL';
@@ -8958,6 +8988,7 @@ const events = [
8958
8988
  ON_SIGNAL,
8959
8989
  ON_NETWORK_STATS,
8960
8990
  ON_DISCONNECTED,
8991
+ ON_EARLY_MEDIA,
8961
8992
  ];
8962
8993
 
8963
8994
  const logger$8 = IssueReporter$1.loggerFor('webrtc-phone');
@@ -10387,6 +10418,10 @@ class WebRTCPhone extends Emitter {
10387
10418
  logger$8.info('WebRTC disconnected');
10388
10419
  this.eventEmitter.emit(ON_DISCONNECTED);
10389
10420
  });
10421
+ this.client.on(this.client.ON_EARLY_MEDIA, () => {
10422
+ logger$8.info('WebRTC early media');
10423
+ this.eventEmitter.emit(ON_EARLY_MEDIA);
10424
+ });
10390
10425
 
10391
10426
  this.client.on(this.client.REGISTERED, () => {
10392
10427
  logger$8.info('WebRTC registered', {
@@ -10670,6 +10705,7 @@ var PHONE_EVENTS = /*#__PURE__*/Object.freeze({
10670
10705
  ON_CHAT: ON_CHAT,
10671
10706
  ON_SIGNAL: ON_SIGNAL,
10672
10707
  ON_DISCONNECTED: ON_DISCONNECTED,
10708
+ ON_EARLY_MEDIA: ON_EARLY_MEDIA,
10673
10709
  MESSAGE_TYPE_CHAT: MESSAGE_TYPE_CHAT,
10674
10710
  MESSAGE_TYPE_SIGNAL: MESSAGE_TYPE_SIGNAL,
10675
10711
  events: events,
@@ -5047,10 +5047,13 @@ var chatdMethods = (client , baseUrl ) => ({
5047
5047
  createRoom: async (name , users ) =>
5048
5048
  client.post(`${baseUrl}/users/me/rooms`, { name, users }).then(ChatRoom.parse),
5049
5049
 
5050
- getRoomMessages: async (roomUuid ) =>
5051
- client
5052
- .get(`${baseUrl}/users/me/rooms/${roomUuid}/messages`)
5053
- .then((response ) => ChatMessage.parseMany(response)),
5050
+ getRoomMessages: async (roomUuid , params = {}) => {
5051
+ const qs = ApiRequester.getQueryString(params);
5052
+
5053
+ return client
5054
+ .get(`${baseUrl}/users/me/rooms/${roomUuid}/messages${qs.length ? `?${qs}` : ''}`)
5055
+ .then((response ) => ChatMessage.parseMany(response));
5056
+ },
5054
5057
 
5055
5058
  sendRoomMessage: async (roomUuid , message ) =>
5056
5059
  client.post(`${baseUrl}/users/me/rooms/${roomUuid}/messages`, message).then(ChatMessage.parse),
@@ -6696,6 +6699,7 @@ const MESSAGE = 'message';
6696
6699
  const ACCEPTED = 'accepted';
6697
6700
  const REJECTED = 'rejected';
6698
6701
  const ON_TRACK$1 = 'onTrack';
6702
+ const ON_EARLY_MEDIA$1 = 'onEarlyMedia';
6699
6703
  const ON_REINVITE$1 = 'reinvite';
6700
6704
  const ON_ERROR = 'onError';
6701
6705
  const ON_SCREEN_SHARING_REINVITE = 'onScreenSharingReinvite';
@@ -6779,6 +6783,7 @@ class WebRTCClient extends Emitter {
6779
6783
 
6780
6784
 
6781
6785
 
6786
+
6782
6787
 
6783
6788
 
6784
6789
  static isAPrivateIp(ip ) {
@@ -6847,6 +6852,7 @@ class WebRTCClient extends Emitter {
6847
6852
  this.ON_SCREEN_SHARING_REINVITE = ON_SCREEN_SHARING_REINVITE;
6848
6853
  this.ON_NETWORK_STATS = ON_NETWORK_STATS$1;
6849
6854
  this.ON_DISCONNECTED = ON_DISCONNECTED$1;
6855
+ this.ON_EARLY_MEDIA = ON_EARLY_MEDIA$1;
6850
6856
  }
6851
6857
 
6852
6858
  configureMedia(media ) {
@@ -7134,6 +7140,11 @@ class WebRTCClient extends Emitter {
7134
7140
  }
7135
7141
  this._onAccepted(session, response.session, true);
7136
7142
  },
7143
+ onProgress: (payload) => {
7144
+ if (payload.message.statusCode === 183) {
7145
+ this._onEarlyProgress(payload.session);
7146
+ }
7147
+ },
7137
7148
  onReject: (response ) => {
7138
7149
  logger$9.info('on call rejected', { id: session.id, fromTag: session.fromTag });
7139
7150
  this._stopSendingStats(session);
@@ -8526,6 +8537,17 @@ class WebRTCClient extends Emitter {
8526
8537
  };
8527
8538
  }
8528
8539
 
8540
+ _onEarlyProgress(session ) {
8541
+ this._setupMedias(session);
8542
+
8543
+ const sessionId = this.getSipSessionId(session).substr(0, 20);
8544
+ this.updateRemoteStream(sessionId);
8545
+
8546
+ logger$9.info('Early media progress progress received', { sessionId });
8547
+
8548
+ this.eventEmitter.emit(ON_EARLY_MEDIA$1, session);
8549
+ }
8550
+
8529
8551
  _onAccepted(session , sessionDialog , withEvent = true) {
8530
8552
  logger$9.info('on call accepted', { id: session.id, remoteTag: session.remoteTag });
8531
8553
 
@@ -8577,15 +8599,22 @@ class WebRTCClient extends Emitter {
8577
8599
 
8578
8600
  _setupMedias(session , newStream ) {
8579
8601
  // Safari hack, because you cannot call .play() from a non user action
8580
- const sessionId = this.getSipSessionId(session);
8602
+ const sessionId = this.getSipSessionId(session).substr(0, 20);
8581
8603
  const isConference = this.isConference(sessionId);
8582
8604
 
8605
+ if (sessionId in this.audioElements) {
8606
+ logger$9.info('html element already exists for session', { sessionId });
8607
+ return;
8608
+ }
8609
+
8583
8610
  if (this._hasAudio() && this._isWeb() && !(sessionId in this.audioElements)) {
8584
8611
  this.createAudioElementFor(sessionId);
8585
8612
  }
8586
8613
 
8587
8614
  const audioElement = this.audioElements[sessionId];
8588
- const stream = newStream || this.getRemoteStream(sessionId);
8615
+ const sipSession = this.sipSessions[session.callId];
8616
+ const removeStream = this.getRemoteStream(sessionId);
8617
+ const stream = newStream || removeStream || sipSession.sessionDescriptionHandler.remoteMediaStream;
8589
8618
 
8590
8619
  if (!this._isWeb() || !stream) {
8591
8620
  return;
@@ -8917,6 +8946,7 @@ const ON_NETWORK_STATS = 'onNetworkStats';
8917
8946
  const ON_CHAT = 'phone/ON_CHAT';
8918
8947
  const ON_SIGNAL = 'phone/ON_SIGNAL';
8919
8948
  const ON_DISCONNECTED = 'onDisconnected';
8949
+ const ON_EARLY_MEDIA = 'onEarlyMedia';
8920
8950
 
8921
8951
  const MESSAGE_TYPE_CHAT = 'message/TYPE_CHAT';
8922
8952
  const MESSAGE_TYPE_SIGNAL = 'message/TYPE_SIGNAL';
@@ -8958,6 +8988,7 @@ const events = [
8958
8988
  ON_SIGNAL,
8959
8989
  ON_NETWORK_STATS,
8960
8990
  ON_DISCONNECTED,
8991
+ ON_EARLY_MEDIA,
8961
8992
  ];
8962
8993
 
8963
8994
  const logger$8 = IssueReporter$1.loggerFor('webrtc-phone');
@@ -10387,6 +10418,10 @@ class WebRTCPhone extends Emitter {
10387
10418
  logger$8.info('WebRTC disconnected');
10388
10419
  this.eventEmitter.emit(ON_DISCONNECTED);
10389
10420
  });
10421
+ this.client.on(this.client.ON_EARLY_MEDIA, () => {
10422
+ logger$8.info('WebRTC early media');
10423
+ this.eventEmitter.emit(ON_EARLY_MEDIA);
10424
+ });
10390
10425
 
10391
10426
  this.client.on(this.client.REGISTERED, () => {
10392
10427
  logger$8.info('WebRTC registered', {
@@ -10670,6 +10705,7 @@ var PHONE_EVENTS = /*#__PURE__*/Object.freeze({
10670
10705
  ON_CHAT: ON_CHAT,
10671
10706
  ON_SIGNAL: ON_SIGNAL,
10672
10707
  ON_DISCONNECTED: ON_DISCONNECTED,
10708
+ ON_EARLY_MEDIA: ON_EARLY_MEDIA,
10673
10709
  MESSAGE_TYPE_CHAT: MESSAGE_TYPE_CHAT,
10674
10710
  MESSAGE_TYPE_SIGNAL: MESSAGE_TYPE_SIGNAL,
10675
10711
  events: events,
@@ -5047,10 +5047,13 @@ var chatdMethods = (client , baseUrl ) => ({
5047
5047
  createRoom: async (name , users ) =>
5048
5048
  client.post(`${baseUrl}/users/me/rooms`, { name, users }).then(ChatRoom.parse),
5049
5049
 
5050
- getRoomMessages: async (roomUuid ) =>
5051
- client
5052
- .get(`${baseUrl}/users/me/rooms/${roomUuid}/messages`)
5053
- .then((response ) => ChatMessage.parseMany(response)),
5050
+ getRoomMessages: async (roomUuid , params = {}) => {
5051
+ const qs = ApiRequester.getQueryString(params);
5052
+
5053
+ return client
5054
+ .get(`${baseUrl}/users/me/rooms/${roomUuid}/messages${qs.length ? `?${qs}` : ''}`)
5055
+ .then((response ) => ChatMessage.parseMany(response));
5056
+ },
5054
5057
 
5055
5058
  sendRoomMessage: async (roomUuid , message ) =>
5056
5059
  client.post(`${baseUrl}/users/me/rooms/${roomUuid}/messages`, message).then(ChatMessage.parse),
@@ -7027,6 +7030,7 @@ const MESSAGE = 'message';
7027
7030
  const ACCEPTED = 'accepted';
7028
7031
  const REJECTED = 'rejected';
7029
7032
  const ON_TRACK$1 = 'onTrack';
7033
+ const ON_EARLY_MEDIA$1 = 'onEarlyMedia';
7030
7034
  const ON_REINVITE$1 = 'reinvite';
7031
7035
  const ON_ERROR = 'onError';
7032
7036
  const ON_SCREEN_SHARING_REINVITE = 'onScreenSharingReinvite';
@@ -7110,6 +7114,7 @@ class WebRTCClient extends Emitter {
7110
7114
 
7111
7115
 
7112
7116
 
7117
+
7113
7118
 
7114
7119
 
7115
7120
  static isAPrivateIp(ip ) {
@@ -7178,6 +7183,7 @@ class WebRTCClient extends Emitter {
7178
7183
  this.ON_SCREEN_SHARING_REINVITE = ON_SCREEN_SHARING_REINVITE;
7179
7184
  this.ON_NETWORK_STATS = ON_NETWORK_STATS$1;
7180
7185
  this.ON_DISCONNECTED = ON_DISCONNECTED$1;
7186
+ this.ON_EARLY_MEDIA = ON_EARLY_MEDIA$1;
7181
7187
  }
7182
7188
 
7183
7189
  configureMedia(media ) {
@@ -7465,6 +7471,11 @@ class WebRTCClient extends Emitter {
7465
7471
  }
7466
7472
  this._onAccepted(session, response.session, true);
7467
7473
  },
7474
+ onProgress: (payload) => {
7475
+ if (payload.message.statusCode === 183) {
7476
+ this._onEarlyProgress(payload.session);
7477
+ }
7478
+ },
7468
7479
  onReject: (response ) => {
7469
7480
  logger$8.info('on call rejected', { id: session.id, fromTag: session.fromTag });
7470
7481
  this._stopSendingStats(session);
@@ -8857,6 +8868,17 @@ class WebRTCClient extends Emitter {
8857
8868
  };
8858
8869
  }
8859
8870
 
8871
+ _onEarlyProgress(session ) {
8872
+ this._setupMedias(session);
8873
+
8874
+ const sessionId = this.getSipSessionId(session).substr(0, 20);
8875
+ this.updateRemoteStream(sessionId);
8876
+
8877
+ logger$8.info('Early media progress progress received', { sessionId });
8878
+
8879
+ this.eventEmitter.emit(ON_EARLY_MEDIA$1, session);
8880
+ }
8881
+
8860
8882
  _onAccepted(session , sessionDialog , withEvent = true) {
8861
8883
  logger$8.info('on call accepted', { id: session.id, remoteTag: session.remoteTag });
8862
8884
 
@@ -8908,15 +8930,22 @@ class WebRTCClient extends Emitter {
8908
8930
 
8909
8931
  _setupMedias(session , newStream ) {
8910
8932
  // Safari hack, because you cannot call .play() from a non user action
8911
- const sessionId = this.getSipSessionId(session);
8933
+ const sessionId = this.getSipSessionId(session).substr(0, 20);
8912
8934
  const isConference = this.isConference(sessionId);
8913
8935
 
8936
+ if (sessionId in this.audioElements) {
8937
+ logger$8.info('html element already exists for session', { sessionId });
8938
+ return;
8939
+ }
8940
+
8914
8941
  if (this._hasAudio() && this._isWeb() && !(sessionId in this.audioElements)) {
8915
8942
  this.createAudioElementFor(sessionId);
8916
8943
  }
8917
8944
 
8918
8945
  const audioElement = this.audioElements[sessionId];
8919
- const stream = newStream || this.getRemoteStream(sessionId);
8946
+ const sipSession = this.sipSessions[session.callId];
8947
+ const removeStream = this.getRemoteStream(sessionId);
8948
+ const stream = newStream || removeStream || sipSession.sessionDescriptionHandler.remoteMediaStream;
8920
8949
 
8921
8950
  if (!this._isWeb() || !stream) {
8922
8951
  return;
@@ -9248,6 +9277,7 @@ const ON_NETWORK_STATS = 'onNetworkStats';
9248
9277
  const ON_CHAT = 'phone/ON_CHAT';
9249
9278
  const ON_SIGNAL = 'phone/ON_SIGNAL';
9250
9279
  const ON_DISCONNECTED = 'onDisconnected';
9280
+ const ON_EARLY_MEDIA = 'onEarlyMedia';
9251
9281
 
9252
9282
  const MESSAGE_TYPE_CHAT = 'message/TYPE_CHAT';
9253
9283
  const MESSAGE_TYPE_SIGNAL = 'message/TYPE_SIGNAL';
@@ -9289,6 +9319,7 @@ const events = [
9289
9319
  ON_SIGNAL,
9290
9320
  ON_NETWORK_STATS,
9291
9321
  ON_DISCONNECTED,
9322
+ ON_EARLY_MEDIA,
9292
9323
  ];
9293
9324
 
9294
9325
  const logger$7 = IssueReporter$1.loggerFor('webrtc-phone');
@@ -10718,6 +10749,10 @@ class WebRTCPhone extends Emitter {
10718
10749
  logger$7.info('WebRTC disconnected');
10719
10750
  this.eventEmitter.emit(ON_DISCONNECTED);
10720
10751
  });
10752
+ this.client.on(this.client.ON_EARLY_MEDIA, () => {
10753
+ logger$7.info('WebRTC early media');
10754
+ this.eventEmitter.emit(ON_EARLY_MEDIA);
10755
+ });
10721
10756
 
10722
10757
  this.client.on(this.client.REGISTERED, () => {
10723
10758
  logger$7.info('WebRTC registered', {
@@ -11001,6 +11036,7 @@ var PHONE_EVENTS = /*#__PURE__*/Object.freeze({
11001
11036
  ON_CHAT: ON_CHAT,
11002
11037
  ON_SIGNAL: ON_SIGNAL,
11003
11038
  ON_DISCONNECTED: ON_DISCONNECTED,
11039
+ ON_EARLY_MEDIA: ON_EARLY_MEDIA,
11004
11040
  MESSAGE_TYPE_CHAT: MESSAGE_TYPE_CHAT,
11005
11041
  MESSAGE_TYPE_SIGNAL: MESSAGE_TYPE_SIGNAL,
11006
11042
  events: events,
@@ -5049,10 +5049,13 @@ var chatdMethods = (client , baseUrl ) => ({
5049
5049
  createRoom: async (name , users ) =>
5050
5050
  client.post(`${baseUrl}/users/me/rooms`, { name, users }).then(ChatRoom.parse),
5051
5051
 
5052
- getRoomMessages: async (roomUuid ) =>
5053
- client
5054
- .get(`${baseUrl}/users/me/rooms/${roomUuid}/messages`)
5055
- .then((response ) => ChatMessage.parseMany(response)),
5052
+ getRoomMessages: async (roomUuid , params = {}) => {
5053
+ const qs = ApiRequester.getQueryString(params);
5054
+
5055
+ return client
5056
+ .get(`${baseUrl}/users/me/rooms/${roomUuid}/messages${qs.length ? `?${qs}` : ''}`)
5057
+ .then((response ) => ChatMessage.parseMany(response));
5058
+ },
5056
5059
 
5057
5060
  sendRoomMessage: async (roomUuid , message ) =>
5058
5061
  client.post(`${baseUrl}/users/me/rooms/${roomUuid}/messages`, message).then(ChatMessage.parse),
@@ -7029,6 +7032,7 @@ const MESSAGE = 'message';
7029
7032
  const ACCEPTED = 'accepted';
7030
7033
  const REJECTED = 'rejected';
7031
7034
  const ON_TRACK$1 = 'onTrack';
7035
+ const ON_EARLY_MEDIA$1 = 'onEarlyMedia';
7032
7036
  const ON_REINVITE$1 = 'reinvite';
7033
7037
  const ON_ERROR = 'onError';
7034
7038
  const ON_SCREEN_SHARING_REINVITE = 'onScreenSharingReinvite';
@@ -7112,6 +7116,7 @@ class WebRTCClient extends Emitter {
7112
7116
 
7113
7117
 
7114
7118
 
7119
+
7115
7120
 
7116
7121
 
7117
7122
  static isAPrivateIp(ip ) {
@@ -7180,6 +7185,7 @@ class WebRTCClient extends Emitter {
7180
7185
  this.ON_SCREEN_SHARING_REINVITE = ON_SCREEN_SHARING_REINVITE;
7181
7186
  this.ON_NETWORK_STATS = ON_NETWORK_STATS$1;
7182
7187
  this.ON_DISCONNECTED = ON_DISCONNECTED$1;
7188
+ this.ON_EARLY_MEDIA = ON_EARLY_MEDIA$1;
7183
7189
  }
7184
7190
 
7185
7191
  configureMedia(media ) {
@@ -7467,6 +7473,11 @@ class WebRTCClient extends Emitter {
7467
7473
  }
7468
7474
  this._onAccepted(session, response.session, true);
7469
7475
  },
7476
+ onProgress: (payload) => {
7477
+ if (payload.message.statusCode === 183) {
7478
+ this._onEarlyProgress(payload.session);
7479
+ }
7480
+ },
7470
7481
  onReject: (response ) => {
7471
7482
  logger$8.info('on call rejected', { id: session.id, fromTag: session.fromTag });
7472
7483
  this._stopSendingStats(session);
@@ -8859,6 +8870,17 @@ class WebRTCClient extends Emitter {
8859
8870
  };
8860
8871
  }
8861
8872
 
8873
+ _onEarlyProgress(session ) {
8874
+ this._setupMedias(session);
8875
+
8876
+ const sessionId = this.getSipSessionId(session).substr(0, 20);
8877
+ this.updateRemoteStream(sessionId);
8878
+
8879
+ logger$8.info('Early media progress progress received', { sessionId });
8880
+
8881
+ this.eventEmitter.emit(ON_EARLY_MEDIA$1, session);
8882
+ }
8883
+
8862
8884
  _onAccepted(session , sessionDialog , withEvent = true) {
8863
8885
  logger$8.info('on call accepted', { id: session.id, remoteTag: session.remoteTag });
8864
8886
 
@@ -8910,15 +8932,22 @@ class WebRTCClient extends Emitter {
8910
8932
 
8911
8933
  _setupMedias(session , newStream ) {
8912
8934
  // Safari hack, because you cannot call .play() from a non user action
8913
- const sessionId = this.getSipSessionId(session);
8935
+ const sessionId = this.getSipSessionId(session).substr(0, 20);
8914
8936
  const isConference = this.isConference(sessionId);
8915
8937
 
8938
+ if (sessionId in this.audioElements) {
8939
+ logger$8.info('html element already exists for session', { sessionId });
8940
+ return;
8941
+ }
8942
+
8916
8943
  if (this._hasAudio() && this._isWeb() && !(sessionId in this.audioElements)) {
8917
8944
  this.createAudioElementFor(sessionId);
8918
8945
  }
8919
8946
 
8920
8947
  const audioElement = this.audioElements[sessionId];
8921
- const stream = newStream || this.getRemoteStream(sessionId);
8948
+ const sipSession = this.sipSessions[session.callId];
8949
+ const removeStream = this.getRemoteStream(sessionId);
8950
+ const stream = newStream || removeStream || sipSession.sessionDescriptionHandler.remoteMediaStream;
8922
8951
 
8923
8952
  if (!this._isWeb() || !stream) {
8924
8953
  return;
@@ -9250,6 +9279,7 @@ const ON_NETWORK_STATS = 'onNetworkStats';
9250
9279
  const ON_CHAT = 'phone/ON_CHAT';
9251
9280
  const ON_SIGNAL = 'phone/ON_SIGNAL';
9252
9281
  const ON_DISCONNECTED = 'onDisconnected';
9282
+ const ON_EARLY_MEDIA = 'onEarlyMedia';
9253
9283
 
9254
9284
  const MESSAGE_TYPE_CHAT = 'message/TYPE_CHAT';
9255
9285
  const MESSAGE_TYPE_SIGNAL = 'message/TYPE_SIGNAL';
@@ -9291,6 +9321,7 @@ const events = [
9291
9321
  ON_SIGNAL,
9292
9322
  ON_NETWORK_STATS,
9293
9323
  ON_DISCONNECTED,
9324
+ ON_EARLY_MEDIA,
9294
9325
  ];
9295
9326
 
9296
9327
  const logger$7 = IssueReporter$1.loggerFor('webrtc-phone');
@@ -10720,6 +10751,10 @@ class WebRTCPhone extends Emitter {
10720
10751
  logger$7.info('WebRTC disconnected');
10721
10752
  this.eventEmitter.emit(ON_DISCONNECTED);
10722
10753
  });
10754
+ this.client.on(this.client.ON_EARLY_MEDIA, () => {
10755
+ logger$7.info('WebRTC early media');
10756
+ this.eventEmitter.emit(ON_EARLY_MEDIA);
10757
+ });
10723
10758
 
10724
10759
  this.client.on(this.client.REGISTERED, () => {
10725
10760
  logger$7.info('WebRTC registered', {
@@ -11003,6 +11038,7 @@ var PHONE_EVENTS = /*#__PURE__*/Object.freeze({
11003
11038
  ON_CHAT: ON_CHAT,
11004
11039
  ON_SIGNAL: ON_SIGNAL,
11005
11040
  ON_DISCONNECTED: ON_DISCONNECTED,
11041
+ ON_EARLY_MEDIA: ON_EARLY_MEDIA,
11006
11042
  MESSAGE_TYPE_CHAT: MESSAGE_TYPE_CHAT,
11007
11043
  MESSAGE_TYPE_SIGNAL: MESSAGE_TYPE_SIGNAL,
11008
11044
  events: events,