@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
@@ -959,6 +959,7 @@ const ON_NETWORK_STATS = 'onNetworkStats';
959
959
  const ON_CHAT = 'phone/ON_CHAT';
960
960
  const ON_SIGNAL = 'phone/ON_SIGNAL';
961
961
  const ON_DISCONNECTED = 'onDisconnected';
962
+ const ON_EARLY_MEDIA = 'onEarlyMedia';
962
963
 
963
964
  const MESSAGE_TYPE_CHAT = 'message/TYPE_CHAT';
964
965
  const MESSAGE_TYPE_SIGNAL = 'message/TYPE_SIGNAL';
@@ -1000,6 +1001,7 @@ const events = [
1000
1001
  ON_SIGNAL,
1001
1002
  ON_NETWORK_STATS,
1002
1003
  ON_DISCONNECTED,
1004
+ ON_EARLY_MEDIA,
1003
1005
  ];
1004
1006
 
1005
1007
  const logger = IssueReporter$1.loggerFor('webrtc-phone');
@@ -2429,6 +2431,10 @@ class WebRTCPhone extends Emitter {
2429
2431
  logger.info('WebRTC disconnected');
2430
2432
  this.eventEmitter.emit(ON_DISCONNECTED);
2431
2433
  });
2434
+ this.client.on(this.client.ON_EARLY_MEDIA, () => {
2435
+ logger.info('WebRTC early media');
2436
+ this.eventEmitter.emit(ON_EARLY_MEDIA);
2437
+ });
2432
2438
 
2433
2439
  this.client.on(this.client.REGISTERED, () => {
2434
2440
  logger.info('WebRTC registered', {
@@ -2670,4 +2676,4 @@ class WebRTCPhone extends Emitter {
2670
2676
  }
2671
2677
 
2672
2678
  export default WebRTCPhone;
2673
- export { MESSAGE_TYPE_CHAT, MESSAGE_TYPE_SIGNAL, ON_AUDIO_STREAM, ON_CALL_ACCEPTED, ON_CALL_ANSWERED, ON_CALL_CANCELED, ON_CALL_ENDED, ON_CALL_ENDING, ON_CALL_ERROR, ON_CALL_FAILED, ON_CALL_HELD, ON_CALL_INCOMING, ON_CALL_MUTED, ON_CALL_OUTGOING, ON_CALL_REJECTED, ON_CALL_RESUMED, ON_CALL_UNHELD, ON_CALL_UNMUTED, ON_CAMERA_DISABLED, ON_CAMERA_RESUMED, ON_CHAT, ON_DISCONNECTED, ON_MESSAGE, ON_MESSAGE_TRACK_UPDATED, ON_NETWORK_STATS, ON_PLAY_HANGUP_SOUND, ON_PLAY_INBOUND_CALL_SIGNAL_SOUND, ON_PLAY_PROGRESS_SOUND, ON_PLAY_RING_SOUND, ON_PROGRESS, ON_REGISTERED, ON_REINVITE, ON_REMOVE_STREAM, ON_SHARE_SCREEN_ENDED, ON_SHARE_SCREEN_ENDING, ON_SHARE_SCREEN_STARTED, ON_SIGNAL, ON_TERMINATE_SOUND, ON_TRACK, ON_UNREGISTERED, ON_USER_AGENT, ON_VIDEO_INPUT_CHANGE, ON_VIDEO_STREAM, events };
2679
+ export { MESSAGE_TYPE_CHAT, MESSAGE_TYPE_SIGNAL, ON_AUDIO_STREAM, ON_CALL_ACCEPTED, ON_CALL_ANSWERED, ON_CALL_CANCELED, ON_CALL_ENDED, ON_CALL_ENDING, ON_CALL_ERROR, ON_CALL_FAILED, ON_CALL_HELD, ON_CALL_INCOMING, ON_CALL_MUTED, ON_CALL_OUTGOING, ON_CALL_REJECTED, ON_CALL_RESUMED, ON_CALL_UNHELD, ON_CALL_UNMUTED, ON_CAMERA_DISABLED, ON_CAMERA_RESUMED, ON_CHAT, ON_DISCONNECTED, ON_EARLY_MEDIA, ON_MESSAGE, ON_MESSAGE_TRACK_UPDATED, ON_NETWORK_STATS, ON_PLAY_HANGUP_SOUND, ON_PLAY_INBOUND_CALL_SIGNAL_SOUND, ON_PLAY_PROGRESS_SOUND, ON_PLAY_RING_SOUND, ON_PROGRESS, ON_REGISTERED, ON_REINVITE, ON_REMOVE_STREAM, ON_SHARE_SCREEN_ENDED, ON_SHARE_SCREEN_ENDING, ON_SHARE_SCREEN_STARTED, ON_SIGNAL, ON_TERMINATE_SOUND, ON_TRACK, ON_UNREGISTERED, ON_USER_AGENT, ON_VIDEO_INPUT_CHANGE, ON_VIDEO_STREAM, events };
package/esm/index.js CHANGED
@@ -5150,10 +5150,13 @@ var chatdMethods = (client , baseUrl ) => ({
5150
5150
  createRoom: async (name , users ) =>
5151
5151
  client.post(`${baseUrl}/users/me/rooms`, { name, users }).then(ChatRoom.parse),
5152
5152
 
5153
- getRoomMessages: async (roomUuid ) =>
5154
- client
5155
- .get(`${baseUrl}/users/me/rooms/${roomUuid}/messages`)
5156
- .then((response ) => ChatMessage.parseMany(response)),
5153
+ getRoomMessages: async (roomUuid , params = {}) => {
5154
+ const qs = ApiRequester.getQueryString(params);
5155
+
5156
+ return client
5157
+ .get(`${baseUrl}/users/me/rooms/${roomUuid}/messages${qs.length ? `?${qs}` : ''}`)
5158
+ .then((response ) => ChatMessage.parseMany(response));
5159
+ },
5157
5160
 
5158
5161
  sendRoomMessage: async (roomUuid , message ) =>
5159
5162
  client.post(`${baseUrl}/users/me/rooms/${roomUuid}/messages`, message).then(ChatMessage.parse),
@@ -6508,6 +6511,7 @@ const MESSAGE = 'message';
6508
6511
  const ACCEPTED = 'accepted';
6509
6512
  const REJECTED = 'rejected';
6510
6513
  const ON_TRACK$1 = 'onTrack';
6514
+ const ON_EARLY_MEDIA$1 = 'onEarlyMedia';
6511
6515
  const ON_REINVITE$1 = 'reinvite';
6512
6516
  const ON_ERROR = 'onError';
6513
6517
  const ON_SCREEN_SHARING_REINVITE = 'onScreenSharingReinvite';
@@ -6591,6 +6595,7 @@ class WebRTCClient extends Emitter {
6591
6595
 
6592
6596
 
6593
6597
 
6598
+
6594
6599
 
6595
6600
 
6596
6601
  static isAPrivateIp(ip ) {
@@ -6659,6 +6664,7 @@ class WebRTCClient extends Emitter {
6659
6664
  this.ON_SCREEN_SHARING_REINVITE = ON_SCREEN_SHARING_REINVITE;
6660
6665
  this.ON_NETWORK_STATS = ON_NETWORK_STATS$1;
6661
6666
  this.ON_DISCONNECTED = ON_DISCONNECTED$1;
6667
+ this.ON_EARLY_MEDIA = ON_EARLY_MEDIA$1;
6662
6668
  }
6663
6669
 
6664
6670
  configureMedia(media ) {
@@ -6946,6 +6952,11 @@ class WebRTCClient extends Emitter {
6946
6952
  }
6947
6953
  this._onAccepted(session, response.session, true);
6948
6954
  },
6955
+ onProgress: (payload) => {
6956
+ if (payload.message.statusCode === 183) {
6957
+ this._onEarlyProgress(payload.session);
6958
+ }
6959
+ },
6949
6960
  onReject: (response ) => {
6950
6961
  logger$9.info('on call rejected', { id: session.id, fromTag: session.fromTag });
6951
6962
  this._stopSendingStats(session);
@@ -8338,6 +8349,17 @@ class WebRTCClient extends Emitter {
8338
8349
  };
8339
8350
  }
8340
8351
 
8352
+ _onEarlyProgress(session ) {
8353
+ this._setupMedias(session);
8354
+
8355
+ const sessionId = this.getSipSessionId(session).substr(0, 20);
8356
+ this.updateRemoteStream(sessionId);
8357
+
8358
+ logger$9.info('Early media progress progress received', { sessionId });
8359
+
8360
+ this.eventEmitter.emit(ON_EARLY_MEDIA$1, session);
8361
+ }
8362
+
8341
8363
  _onAccepted(session , sessionDialog , withEvent = true) {
8342
8364
  logger$9.info('on call accepted', { id: session.id, remoteTag: session.remoteTag });
8343
8365
 
@@ -8389,15 +8411,22 @@ class WebRTCClient extends Emitter {
8389
8411
 
8390
8412
  _setupMedias(session , newStream ) {
8391
8413
  // Safari hack, because you cannot call .play() from a non user action
8392
- const sessionId = this.getSipSessionId(session);
8414
+ const sessionId = this.getSipSessionId(session).substr(0, 20);
8393
8415
  const isConference = this.isConference(sessionId);
8394
8416
 
8417
+ if (sessionId in this.audioElements) {
8418
+ logger$9.info('html element already exists for session', { sessionId });
8419
+ return;
8420
+ }
8421
+
8395
8422
  if (this._hasAudio() && this._isWeb() && !(sessionId in this.audioElements)) {
8396
8423
  this.createAudioElementFor(sessionId);
8397
8424
  }
8398
8425
 
8399
8426
  const audioElement = this.audioElements[sessionId];
8400
- const stream = newStream || this.getRemoteStream(sessionId);
8427
+ const sipSession = this.sipSessions[session.callId];
8428
+ const removeStream = this.getRemoteStream(sessionId);
8429
+ const stream = newStream || removeStream || sipSession.sessionDescriptionHandler.remoteMediaStream;
8401
8430
 
8402
8431
  if (!this._isWeb() || !stream) {
8403
8432
  return;
@@ -9637,6 +9666,7 @@ const ON_NETWORK_STATS = 'onNetworkStats';
9637
9666
  const ON_CHAT = 'phone/ON_CHAT';
9638
9667
  const ON_SIGNAL = 'phone/ON_SIGNAL';
9639
9668
  const ON_DISCONNECTED = 'onDisconnected';
9669
+ const ON_EARLY_MEDIA = 'onEarlyMedia';
9640
9670
 
9641
9671
  const MESSAGE_TYPE_CHAT = 'message/TYPE_CHAT';
9642
9672
  const MESSAGE_TYPE_SIGNAL = 'message/TYPE_SIGNAL';
@@ -9678,6 +9708,7 @@ const events = [
9678
9708
  ON_SIGNAL,
9679
9709
  ON_NETWORK_STATS,
9680
9710
  ON_DISCONNECTED,
9711
+ ON_EARLY_MEDIA,
9681
9712
  ];
9682
9713
 
9683
9714
  const logger$7 = IssueReporter$1.loggerFor('webrtc-phone');
@@ -11107,6 +11138,10 @@ class WebRTCPhone extends Emitter {
11107
11138
  logger$7.info('WebRTC disconnected');
11108
11139
  this.eventEmitter.emit(ON_DISCONNECTED);
11109
11140
  });
11141
+ this.client.on(this.client.ON_EARLY_MEDIA, () => {
11142
+ logger$7.info('WebRTC early media');
11143
+ this.eventEmitter.emit(ON_EARLY_MEDIA);
11144
+ });
11110
11145
 
11111
11146
  this.client.on(this.client.REGISTERED, () => {
11112
11147
  logger$7.info('WebRTC registered', {
@@ -11390,6 +11425,7 @@ var PHONE_EVENTS = /*#__PURE__*/Object.freeze({
11390
11425
  ON_CHAT: ON_CHAT,
11391
11426
  ON_SIGNAL: ON_SIGNAL,
11392
11427
  ON_DISCONNECTED: ON_DISCONNECTED,
11428
+ ON_EARLY_MEDIA: ON_EARLY_MEDIA,
11393
11429
  MESSAGE_TYPE_CHAT: MESSAGE_TYPE_CHAT,
11394
11430
  MESSAGE_TYPE_SIGNAL: MESSAGE_TYPE_SIGNAL,
11395
11431
  events: events,
@@ -4118,10 +4118,13 @@ var chatdMethods = (client , baseUrl ) => ({
4118
4118
  createRoom: async (name , users ) =>
4119
4119
  client.post(`${baseUrl}/users/me/rooms`, { name, users }).then(ChatRoom.parse),
4120
4120
 
4121
- getRoomMessages: async (roomUuid ) =>
4122
- client
4123
- .get(`${baseUrl}/users/me/rooms/${roomUuid}/messages`)
4124
- .then((response ) => ChatMessage.parseMany(response)),
4121
+ getRoomMessages: async (roomUuid , params = {}) => {
4122
+ const qs = ApiRequester.getQueryString(params);
4123
+
4124
+ return client
4125
+ .get(`${baseUrl}/users/me/rooms/${roomUuid}/messages${qs.length ? `?${qs}` : ''}`)
4126
+ .then((response ) => ChatMessage.parseMany(response));
4127
+ },
4125
4128
 
4126
4129
  sendRoomMessage: async (roomUuid , message ) =>
4127
4130
  client.post(`${baseUrl}/users/me/rooms/${roomUuid}/messages`, message).then(ChatMessage.parse),
@@ -4186,10 +4186,13 @@ var chatdMethods = (client , baseUrl ) => ({
4186
4186
  createRoom: async (name , users ) =>
4187
4187
  client.post(`${baseUrl}/users/me/rooms`, { name, users }).then(ChatRoom.parse),
4188
4188
 
4189
- getRoomMessages: async (roomUuid ) =>
4190
- client
4191
- .get(`${baseUrl}/users/me/rooms/${roomUuid}/messages`)
4192
- .then((response ) => ChatMessage.parseMany(response)),
4189
+ getRoomMessages: async (roomUuid , params = {}) => {
4190
+ const qs = ApiRequester.getQueryString(params);
4191
+
4192
+ return client
4193
+ .get(`${baseUrl}/users/me/rooms/${roomUuid}/messages${qs.length ? `?${qs}` : ''}`)
4194
+ .then((response ) => ChatMessage.parseMany(response));
4195
+ },
4193
4196
 
4194
4197
  sendRoomMessage: async (roomUuid , message ) =>
4195
4198
  client.post(`${baseUrl}/users/me/rooms/${roomUuid}/messages`, message).then(ChatMessage.parse),
@@ -5037,10 +5037,13 @@ var chatdMethods = (client , baseUrl ) => ({
5037
5037
  createRoom: async (name , users ) =>
5038
5038
  client.post(`${baseUrl}/users/me/rooms`, { name, users }).then(ChatRoom.parse),
5039
5039
 
5040
- getRoomMessages: async (roomUuid ) =>
5041
- client
5042
- .get(`${baseUrl}/users/me/rooms/${roomUuid}/messages`)
5043
- .then((response ) => ChatMessage.parseMany(response)),
5040
+ getRoomMessages: async (roomUuid , params = {}) => {
5041
+ const qs = ApiRequester.getQueryString(params);
5042
+
5043
+ return client
5044
+ .get(`${baseUrl}/users/me/rooms/${roomUuid}/messages${qs.length ? `?${qs}` : ''}`)
5045
+ .then((response ) => ChatMessage.parseMany(response));
5046
+ },
5044
5047
 
5045
5048
  sendRoomMessage: async (roomUuid , message ) =>
5046
5049
  client.post(`${baseUrl}/users/me/rooms/${roomUuid}/messages`, message).then(ChatMessage.parse),
@@ -6686,6 +6689,7 @@ const MESSAGE = 'message';
6686
6689
  const ACCEPTED = 'accepted';
6687
6690
  const REJECTED = 'rejected';
6688
6691
  const ON_TRACK$1 = 'onTrack';
6692
+ const ON_EARLY_MEDIA$1 = 'onEarlyMedia';
6689
6693
  const ON_REINVITE$1 = 'reinvite';
6690
6694
  const ON_ERROR = 'onError';
6691
6695
  const ON_SCREEN_SHARING_REINVITE = 'onScreenSharingReinvite';
@@ -6769,6 +6773,7 @@ class WebRTCClient extends Emitter {
6769
6773
 
6770
6774
 
6771
6775
 
6776
+
6772
6777
 
6773
6778
 
6774
6779
  static isAPrivateIp(ip ) {
@@ -6837,6 +6842,7 @@ class WebRTCClient extends Emitter {
6837
6842
  this.ON_SCREEN_SHARING_REINVITE = ON_SCREEN_SHARING_REINVITE;
6838
6843
  this.ON_NETWORK_STATS = ON_NETWORK_STATS$1;
6839
6844
  this.ON_DISCONNECTED = ON_DISCONNECTED$1;
6845
+ this.ON_EARLY_MEDIA = ON_EARLY_MEDIA$1;
6840
6846
  }
6841
6847
 
6842
6848
  configureMedia(media ) {
@@ -7124,6 +7130,11 @@ class WebRTCClient extends Emitter {
7124
7130
  }
7125
7131
  this._onAccepted(session, response.session, true);
7126
7132
  },
7133
+ onProgress: (payload) => {
7134
+ if (payload.message.statusCode === 183) {
7135
+ this._onEarlyProgress(payload.session);
7136
+ }
7137
+ },
7127
7138
  onReject: (response ) => {
7128
7139
  logger$9.info('on call rejected', { id: session.id, fromTag: session.fromTag });
7129
7140
  this._stopSendingStats(session);
@@ -8516,6 +8527,17 @@ class WebRTCClient extends Emitter {
8516
8527
  };
8517
8528
  }
8518
8529
 
8530
+ _onEarlyProgress(session ) {
8531
+ this._setupMedias(session);
8532
+
8533
+ const sessionId = this.getSipSessionId(session).substr(0, 20);
8534
+ this.updateRemoteStream(sessionId);
8535
+
8536
+ logger$9.info('Early media progress progress received', { sessionId });
8537
+
8538
+ this.eventEmitter.emit(ON_EARLY_MEDIA$1, session);
8539
+ }
8540
+
8519
8541
  _onAccepted(session , sessionDialog , withEvent = true) {
8520
8542
  logger$9.info('on call accepted', { id: session.id, remoteTag: session.remoteTag });
8521
8543
 
@@ -8567,15 +8589,22 @@ class WebRTCClient extends Emitter {
8567
8589
 
8568
8590
  _setupMedias(session , newStream ) {
8569
8591
  // Safari hack, because you cannot call .play() from a non user action
8570
- const sessionId = this.getSipSessionId(session);
8592
+ const sessionId = this.getSipSessionId(session).substr(0, 20);
8571
8593
  const isConference = this.isConference(sessionId);
8572
8594
 
8595
+ if (sessionId in this.audioElements) {
8596
+ logger$9.info('html element already exists for session', { sessionId });
8597
+ return;
8598
+ }
8599
+
8573
8600
  if (this._hasAudio() && this._isWeb() && !(sessionId in this.audioElements)) {
8574
8601
  this.createAudioElementFor(sessionId);
8575
8602
  }
8576
8603
 
8577
8604
  const audioElement = this.audioElements[sessionId];
8578
- const stream = newStream || this.getRemoteStream(sessionId);
8605
+ const sipSession = this.sipSessions[session.callId];
8606
+ const removeStream = this.getRemoteStream(sessionId);
8607
+ const stream = newStream || removeStream || sipSession.sessionDescriptionHandler.remoteMediaStream;
8579
8608
 
8580
8609
  if (!this._isWeb() || !stream) {
8581
8610
  return;
@@ -8907,6 +8936,7 @@ const ON_NETWORK_STATS = 'onNetworkStats';
8907
8936
  const ON_CHAT = 'phone/ON_CHAT';
8908
8937
  const ON_SIGNAL = 'phone/ON_SIGNAL';
8909
8938
  const ON_DISCONNECTED = 'onDisconnected';
8939
+ const ON_EARLY_MEDIA = 'onEarlyMedia';
8910
8940
 
8911
8941
  const MESSAGE_TYPE_CHAT = 'message/TYPE_CHAT';
8912
8942
  const MESSAGE_TYPE_SIGNAL = 'message/TYPE_SIGNAL';
@@ -8948,6 +8978,7 @@ const events = [
8948
8978
  ON_SIGNAL,
8949
8979
  ON_NETWORK_STATS,
8950
8980
  ON_DISCONNECTED,
8981
+ ON_EARLY_MEDIA,
8951
8982
  ];
8952
8983
 
8953
8984
  const logger$8 = IssueReporter$1.loggerFor('webrtc-phone');
@@ -10377,6 +10408,10 @@ class WebRTCPhone extends Emitter {
10377
10408
  logger$8.info('WebRTC disconnected');
10378
10409
  this.eventEmitter.emit(ON_DISCONNECTED);
10379
10410
  });
10411
+ this.client.on(this.client.ON_EARLY_MEDIA, () => {
10412
+ logger$8.info('WebRTC early media');
10413
+ this.eventEmitter.emit(ON_EARLY_MEDIA);
10414
+ });
10380
10415
 
10381
10416
  this.client.on(this.client.REGISTERED, () => {
10382
10417
  logger$8.info('WebRTC registered', {
@@ -10660,6 +10695,7 @@ var PHONE_EVENTS = /*#__PURE__*/Object.freeze({
10660
10695
  ON_CHAT: ON_CHAT,
10661
10696
  ON_SIGNAL: ON_SIGNAL,
10662
10697
  ON_DISCONNECTED: ON_DISCONNECTED,
10698
+ ON_EARLY_MEDIA: ON_EARLY_MEDIA,
10663
10699
  MESSAGE_TYPE_CHAT: MESSAGE_TYPE_CHAT,
10664
10700
  MESSAGE_TYPE_SIGNAL: MESSAGE_TYPE_SIGNAL,
10665
10701
  events: events,
@@ -5037,10 +5037,13 @@ var chatdMethods = (client , baseUrl ) => ({
5037
5037
  createRoom: async (name , users ) =>
5038
5038
  client.post(`${baseUrl}/users/me/rooms`, { name, users }).then(ChatRoom.parse),
5039
5039
 
5040
- getRoomMessages: async (roomUuid ) =>
5041
- client
5042
- .get(`${baseUrl}/users/me/rooms/${roomUuid}/messages`)
5043
- .then((response ) => ChatMessage.parseMany(response)),
5040
+ getRoomMessages: async (roomUuid , params = {}) => {
5041
+ const qs = ApiRequester.getQueryString(params);
5042
+
5043
+ return client
5044
+ .get(`${baseUrl}/users/me/rooms/${roomUuid}/messages${qs.length ? `?${qs}` : ''}`)
5045
+ .then((response ) => ChatMessage.parseMany(response));
5046
+ },
5044
5047
 
5045
5048
  sendRoomMessage: async (roomUuid , message ) =>
5046
5049
  client.post(`${baseUrl}/users/me/rooms/${roomUuid}/messages`, message).then(ChatMessage.parse),
@@ -6686,6 +6689,7 @@ const MESSAGE = 'message';
6686
6689
  const ACCEPTED = 'accepted';
6687
6690
  const REJECTED = 'rejected';
6688
6691
  const ON_TRACK$1 = 'onTrack';
6692
+ const ON_EARLY_MEDIA$1 = 'onEarlyMedia';
6689
6693
  const ON_REINVITE$1 = 'reinvite';
6690
6694
  const ON_ERROR = 'onError';
6691
6695
  const ON_SCREEN_SHARING_REINVITE = 'onScreenSharingReinvite';
@@ -6769,6 +6773,7 @@ class WebRTCClient extends Emitter {
6769
6773
 
6770
6774
 
6771
6775
 
6776
+
6772
6777
 
6773
6778
 
6774
6779
  static isAPrivateIp(ip ) {
@@ -6837,6 +6842,7 @@ class WebRTCClient extends Emitter {
6837
6842
  this.ON_SCREEN_SHARING_REINVITE = ON_SCREEN_SHARING_REINVITE;
6838
6843
  this.ON_NETWORK_STATS = ON_NETWORK_STATS$1;
6839
6844
  this.ON_DISCONNECTED = ON_DISCONNECTED$1;
6845
+ this.ON_EARLY_MEDIA = ON_EARLY_MEDIA$1;
6840
6846
  }
6841
6847
 
6842
6848
  configureMedia(media ) {
@@ -7124,6 +7130,11 @@ class WebRTCClient extends Emitter {
7124
7130
  }
7125
7131
  this._onAccepted(session, response.session, true);
7126
7132
  },
7133
+ onProgress: (payload) => {
7134
+ if (payload.message.statusCode === 183) {
7135
+ this._onEarlyProgress(payload.session);
7136
+ }
7137
+ },
7127
7138
  onReject: (response ) => {
7128
7139
  logger$9.info('on call rejected', { id: session.id, fromTag: session.fromTag });
7129
7140
  this._stopSendingStats(session);
@@ -8516,6 +8527,17 @@ class WebRTCClient extends Emitter {
8516
8527
  };
8517
8528
  }
8518
8529
 
8530
+ _onEarlyProgress(session ) {
8531
+ this._setupMedias(session);
8532
+
8533
+ const sessionId = this.getSipSessionId(session).substr(0, 20);
8534
+ this.updateRemoteStream(sessionId);
8535
+
8536
+ logger$9.info('Early media progress progress received', { sessionId });
8537
+
8538
+ this.eventEmitter.emit(ON_EARLY_MEDIA$1, session);
8539
+ }
8540
+
8519
8541
  _onAccepted(session , sessionDialog , withEvent = true) {
8520
8542
  logger$9.info('on call accepted', { id: session.id, remoteTag: session.remoteTag });
8521
8543
 
@@ -8567,15 +8589,22 @@ class WebRTCClient extends Emitter {
8567
8589
 
8568
8590
  _setupMedias(session , newStream ) {
8569
8591
  // Safari hack, because you cannot call .play() from a non user action
8570
- const sessionId = this.getSipSessionId(session);
8592
+ const sessionId = this.getSipSessionId(session).substr(0, 20);
8571
8593
  const isConference = this.isConference(sessionId);
8572
8594
 
8595
+ if (sessionId in this.audioElements) {
8596
+ logger$9.info('html element already exists for session', { sessionId });
8597
+ return;
8598
+ }
8599
+
8573
8600
  if (this._hasAudio() && this._isWeb() && !(sessionId in this.audioElements)) {
8574
8601
  this.createAudioElementFor(sessionId);
8575
8602
  }
8576
8603
 
8577
8604
  const audioElement = this.audioElements[sessionId];
8578
- const stream = newStream || this.getRemoteStream(sessionId);
8605
+ const sipSession = this.sipSessions[session.callId];
8606
+ const removeStream = this.getRemoteStream(sessionId);
8607
+ const stream = newStream || removeStream || sipSession.sessionDescriptionHandler.remoteMediaStream;
8579
8608
 
8580
8609
  if (!this._isWeb() || !stream) {
8581
8610
  return;
@@ -8907,6 +8936,7 @@ const ON_NETWORK_STATS = 'onNetworkStats';
8907
8936
  const ON_CHAT = 'phone/ON_CHAT';
8908
8937
  const ON_SIGNAL = 'phone/ON_SIGNAL';
8909
8938
  const ON_DISCONNECTED = 'onDisconnected';
8939
+ const ON_EARLY_MEDIA = 'onEarlyMedia';
8910
8940
 
8911
8941
  const MESSAGE_TYPE_CHAT = 'message/TYPE_CHAT';
8912
8942
  const MESSAGE_TYPE_SIGNAL = 'message/TYPE_SIGNAL';
@@ -8948,6 +8978,7 @@ const events = [
8948
8978
  ON_SIGNAL,
8949
8979
  ON_NETWORK_STATS,
8950
8980
  ON_DISCONNECTED,
8981
+ ON_EARLY_MEDIA,
8951
8982
  ];
8952
8983
 
8953
8984
  const logger$8 = IssueReporter$1.loggerFor('webrtc-phone');
@@ -10377,6 +10408,10 @@ class WebRTCPhone extends Emitter {
10377
10408
  logger$8.info('WebRTC disconnected');
10378
10409
  this.eventEmitter.emit(ON_DISCONNECTED);
10379
10410
  });
10411
+ this.client.on(this.client.ON_EARLY_MEDIA, () => {
10412
+ logger$8.info('WebRTC early media');
10413
+ this.eventEmitter.emit(ON_EARLY_MEDIA);
10414
+ });
10380
10415
 
10381
10416
  this.client.on(this.client.REGISTERED, () => {
10382
10417
  logger$8.info('WebRTC registered', {
@@ -10660,6 +10695,7 @@ var PHONE_EVENTS = /*#__PURE__*/Object.freeze({
10660
10695
  ON_CHAT: ON_CHAT,
10661
10696
  ON_SIGNAL: ON_SIGNAL,
10662
10697
  ON_DISCONNECTED: ON_DISCONNECTED,
10698
+ ON_EARLY_MEDIA: ON_EARLY_MEDIA,
10663
10699
  MESSAGE_TYPE_CHAT: MESSAGE_TYPE_CHAT,
10664
10700
  MESSAGE_TYPE_SIGNAL: MESSAGE_TYPE_SIGNAL,
10665
10701
  events: events,
@@ -4186,10 +4186,13 @@ var chatdMethods = (client , baseUrl ) => ({
4186
4186
  createRoom: async (name , users ) =>
4187
4187
  client.post(`${baseUrl}/users/me/rooms`, { name, users }).then(ChatRoom.parse),
4188
4188
 
4189
- getRoomMessages: async (roomUuid ) =>
4190
- client
4191
- .get(`${baseUrl}/users/me/rooms/${roomUuid}/messages`)
4192
- .then((response ) => ChatMessage.parseMany(response)),
4189
+ getRoomMessages: async (roomUuid , params = {}) => {
4190
+ const qs = ApiRequester.getQueryString(params);
4191
+
4192
+ return client
4193
+ .get(`${baseUrl}/users/me/rooms/${roomUuid}/messages${qs.length ? `?${qs}` : ''}`)
4194
+ .then((response ) => ChatMessage.parseMany(response));
4195
+ },
4193
4196
 
4194
4197
  sendRoomMessage: async (roomUuid , message ) =>
4195
4198
  client.post(`${baseUrl}/users/me/rooms/${roomUuid}/messages`, message).then(ChatMessage.parse),
@@ -5037,10 +5037,13 @@ var chatdMethods = (client , baseUrl ) => ({
5037
5037
  createRoom: async (name , users ) =>
5038
5038
  client.post(`${baseUrl}/users/me/rooms`, { name, users }).then(ChatRoom.parse),
5039
5039
 
5040
- getRoomMessages: async (roomUuid ) =>
5041
- client
5042
- .get(`${baseUrl}/users/me/rooms/${roomUuid}/messages`)
5043
- .then((response ) => ChatMessage.parseMany(response)),
5040
+ getRoomMessages: async (roomUuid , params = {}) => {
5041
+ const qs = ApiRequester.getQueryString(params);
5042
+
5043
+ return client
5044
+ .get(`${baseUrl}/users/me/rooms/${roomUuid}/messages${qs.length ? `?${qs}` : ''}`)
5045
+ .then((response ) => ChatMessage.parseMany(response));
5046
+ },
5044
5047
 
5045
5048
  sendRoomMessage: async (roomUuid , message ) =>
5046
5049
  client.post(`${baseUrl}/users/me/rooms/${roomUuid}/messages`, message).then(ChatMessage.parse),
@@ -6686,6 +6689,7 @@ const MESSAGE = 'message';
6686
6689
  const ACCEPTED = 'accepted';
6687
6690
  const REJECTED = 'rejected';
6688
6691
  const ON_TRACK$1 = 'onTrack';
6692
+ const ON_EARLY_MEDIA$1 = 'onEarlyMedia';
6689
6693
  const ON_REINVITE$1 = 'reinvite';
6690
6694
  const ON_ERROR = 'onError';
6691
6695
  const ON_SCREEN_SHARING_REINVITE = 'onScreenSharingReinvite';
@@ -6769,6 +6773,7 @@ class WebRTCClient extends Emitter {
6769
6773
 
6770
6774
 
6771
6775
 
6776
+
6772
6777
 
6773
6778
 
6774
6779
  static isAPrivateIp(ip ) {
@@ -6837,6 +6842,7 @@ class WebRTCClient extends Emitter {
6837
6842
  this.ON_SCREEN_SHARING_REINVITE = ON_SCREEN_SHARING_REINVITE;
6838
6843
  this.ON_NETWORK_STATS = ON_NETWORK_STATS$1;
6839
6844
  this.ON_DISCONNECTED = ON_DISCONNECTED$1;
6845
+ this.ON_EARLY_MEDIA = ON_EARLY_MEDIA$1;
6840
6846
  }
6841
6847
 
6842
6848
  configureMedia(media ) {
@@ -7124,6 +7130,11 @@ class WebRTCClient extends Emitter {
7124
7130
  }
7125
7131
  this._onAccepted(session, response.session, true);
7126
7132
  },
7133
+ onProgress: (payload) => {
7134
+ if (payload.message.statusCode === 183) {
7135
+ this._onEarlyProgress(payload.session);
7136
+ }
7137
+ },
7127
7138
  onReject: (response ) => {
7128
7139
  logger$9.info('on call rejected', { id: session.id, fromTag: session.fromTag });
7129
7140
  this._stopSendingStats(session);
@@ -8516,6 +8527,17 @@ class WebRTCClient extends Emitter {
8516
8527
  };
8517
8528
  }
8518
8529
 
8530
+ _onEarlyProgress(session ) {
8531
+ this._setupMedias(session);
8532
+
8533
+ const sessionId = this.getSipSessionId(session).substr(0, 20);
8534
+ this.updateRemoteStream(sessionId);
8535
+
8536
+ logger$9.info('Early media progress progress received', { sessionId });
8537
+
8538
+ this.eventEmitter.emit(ON_EARLY_MEDIA$1, session);
8539
+ }
8540
+
8519
8541
  _onAccepted(session , sessionDialog , withEvent = true) {
8520
8542
  logger$9.info('on call accepted', { id: session.id, remoteTag: session.remoteTag });
8521
8543
 
@@ -8567,15 +8589,22 @@ class WebRTCClient extends Emitter {
8567
8589
 
8568
8590
  _setupMedias(session , newStream ) {
8569
8591
  // Safari hack, because you cannot call .play() from a non user action
8570
- const sessionId = this.getSipSessionId(session);
8592
+ const sessionId = this.getSipSessionId(session).substr(0, 20);
8571
8593
  const isConference = this.isConference(sessionId);
8572
8594
 
8595
+ if (sessionId in this.audioElements) {
8596
+ logger$9.info('html element already exists for session', { sessionId });
8597
+ return;
8598
+ }
8599
+
8573
8600
  if (this._hasAudio() && this._isWeb() && !(sessionId in this.audioElements)) {
8574
8601
  this.createAudioElementFor(sessionId);
8575
8602
  }
8576
8603
 
8577
8604
  const audioElement = this.audioElements[sessionId];
8578
- const stream = newStream || this.getRemoteStream(sessionId);
8605
+ const sipSession = this.sipSessions[session.callId];
8606
+ const removeStream = this.getRemoteStream(sessionId);
8607
+ const stream = newStream || removeStream || sipSession.sessionDescriptionHandler.remoteMediaStream;
8579
8608
 
8580
8609
  if (!this._isWeb() || !stream) {
8581
8610
  return;
@@ -8907,6 +8936,7 @@ const ON_NETWORK_STATS = 'onNetworkStats';
8907
8936
  const ON_CHAT = 'phone/ON_CHAT';
8908
8937
  const ON_SIGNAL = 'phone/ON_SIGNAL';
8909
8938
  const ON_DISCONNECTED = 'onDisconnected';
8939
+ const ON_EARLY_MEDIA = 'onEarlyMedia';
8910
8940
 
8911
8941
  const MESSAGE_TYPE_CHAT = 'message/TYPE_CHAT';
8912
8942
  const MESSAGE_TYPE_SIGNAL = 'message/TYPE_SIGNAL';
@@ -8948,6 +8978,7 @@ const events = [
8948
8978
  ON_SIGNAL,
8949
8979
  ON_NETWORK_STATS,
8950
8980
  ON_DISCONNECTED,
8981
+ ON_EARLY_MEDIA,
8951
8982
  ];
8952
8983
 
8953
8984
  const logger$8 = IssueReporter$1.loggerFor('webrtc-phone');
@@ -10377,6 +10408,10 @@ class WebRTCPhone extends Emitter {
10377
10408
  logger$8.info('WebRTC disconnected');
10378
10409
  this.eventEmitter.emit(ON_DISCONNECTED);
10379
10410
  });
10411
+ this.client.on(this.client.ON_EARLY_MEDIA, () => {
10412
+ logger$8.info('WebRTC early media');
10413
+ this.eventEmitter.emit(ON_EARLY_MEDIA);
10414
+ });
10380
10415
 
10381
10416
  this.client.on(this.client.REGISTERED, () => {
10382
10417
  logger$8.info('WebRTC registered', {
@@ -10660,6 +10695,7 @@ var PHONE_EVENTS = /*#__PURE__*/Object.freeze({
10660
10695
  ON_CHAT: ON_CHAT,
10661
10696
  ON_SIGNAL: ON_SIGNAL,
10662
10697
  ON_DISCONNECTED: ON_DISCONNECTED,
10698
+ ON_EARLY_MEDIA: ON_EARLY_MEDIA,
10663
10699
  MESSAGE_TYPE_CHAT: MESSAGE_TYPE_CHAT,
10664
10700
  MESSAGE_TYPE_SIGNAL: MESSAGE_TYPE_SIGNAL,
10665
10701
  events: events,