@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
@@ -4192,10 +4192,13 @@ var chatdMethods = (client , baseUrl ) => ({
4192
4192
  createRoom: async (name , users ) =>
4193
4193
  client.post(`${baseUrl}/users/me/rooms`, { name, users }).then(ChatRoom.parse),
4194
4194
 
4195
- getRoomMessages: async (roomUuid ) =>
4196
- client
4197
- .get(`${baseUrl}/users/me/rooms/${roomUuid}/messages`)
4198
- .then((response ) => ChatMessage.parseMany(response)),
4195
+ getRoomMessages: async (roomUuid , params = {}) => {
4196
+ const qs = ApiRequester.getQueryString(params);
4197
+
4198
+ return client
4199
+ .get(`${baseUrl}/users/me/rooms/${roomUuid}/messages${qs.length ? `?${qs}` : ''}`)
4200
+ .then((response ) => ChatMessage.parseMany(response));
4201
+ },
4199
4202
 
4200
4203
  sendRoomMessage: async (roomUuid , message ) =>
4201
4204
  client.post(`${baseUrl}/users/me/rooms/${roomUuid}/messages`, message).then(ChatMessage.parse),
@@ -4194,10 +4194,13 @@ var chatdMethods = (client , baseUrl ) => ({
4194
4194
  createRoom: async (name , users ) =>
4195
4195
  client.post(`${baseUrl}/users/me/rooms`, { name, users }).then(ChatRoom.parse),
4196
4196
 
4197
- getRoomMessages: async (roomUuid ) =>
4198
- client
4199
- .get(`${baseUrl}/users/me/rooms/${roomUuid}/messages`)
4200
- .then((response ) => ChatMessage.parseMany(response)),
4197
+ getRoomMessages: async (roomUuid , params = {}) => {
4198
+ const qs = ApiRequester.getQueryString(params);
4199
+
4200
+ return client
4201
+ .get(`${baseUrl}/users/me/rooms/${roomUuid}/messages${qs.length ? `?${qs}` : ''}`)
4202
+ .then((response ) => ChatMessage.parseMany(response));
4203
+ },
4201
4204
 
4202
4205
  sendRoomMessage: async (roomUuid , message ) =>
4203
4206
  client.post(`${baseUrl}/users/me/rooms/${roomUuid}/messages`, message).then(ChatMessage.parse),
@@ -4540,10 +4540,13 @@ var chatdMethods = (client , baseUrl ) => ({
4540
4540
  createRoom: async (name , users ) =>
4541
4541
  client.post(`${baseUrl}/users/me/rooms`, { name, users }).then(ChatRoom.parse),
4542
4542
 
4543
- getRoomMessages: async (roomUuid ) =>
4544
- client
4545
- .get(`${baseUrl}/users/me/rooms/${roomUuid}/messages`)
4546
- .then((response ) => ChatMessage.parseMany(response)),
4543
+ getRoomMessages: async (roomUuid , params = {}) => {
4544
+ const qs = ApiRequester.getQueryString(params);
4545
+
4546
+ return client
4547
+ .get(`${baseUrl}/users/me/rooms/${roomUuid}/messages${qs.length ? `?${qs}` : ''}`)
4548
+ .then((response ) => ChatMessage.parseMany(response));
4549
+ },
4547
4550
 
4548
4551
  sendRoomMessage: async (roomUuid , message ) =>
4549
4552
  client.post(`${baseUrl}/users/me/rooms/${roomUuid}/messages`, message).then(ChatMessage.parse),
@@ -968,6 +968,7 @@ const ON_NETWORK_STATS = 'onNetworkStats';
968
968
  const ON_CHAT = 'phone/ON_CHAT';
969
969
  const ON_SIGNAL = 'phone/ON_SIGNAL';
970
970
  const ON_DISCONNECTED = 'onDisconnected';
971
+ const ON_EARLY_MEDIA = 'onEarlyMedia';
971
972
 
972
973
  const MESSAGE_TYPE_CHAT = 'message/TYPE_CHAT';
973
974
  const MESSAGE_TYPE_SIGNAL = 'message/TYPE_SIGNAL';
@@ -1009,6 +1010,7 @@ const events = [
1009
1010
  ON_SIGNAL,
1010
1011
  ON_NETWORK_STATS,
1011
1012
  ON_DISCONNECTED,
1013
+ ON_EARLY_MEDIA,
1012
1014
  ];
1013
1015
 
1014
1016
  const logger = IssueReporter$1.loggerFor('webrtc-phone');
@@ -2438,6 +2440,10 @@ class WebRTCPhone extends Emitter {
2438
2440
  logger.info('WebRTC disconnected');
2439
2441
  this.eventEmitter.emit(ON_DISCONNECTED);
2440
2442
  });
2443
+ this.client.on(this.client.ON_EARLY_MEDIA, () => {
2444
+ logger.info('WebRTC early media');
2445
+ this.eventEmitter.emit(ON_EARLY_MEDIA);
2446
+ });
2441
2447
 
2442
2448
  this.client.on(this.client.REGISTERED, () => {
2443
2449
  logger.info('WebRTC registered', {
@@ -2700,6 +2706,7 @@ exports.ON_CAMERA_DISABLED = ON_CAMERA_DISABLED;
2700
2706
  exports.ON_CAMERA_RESUMED = ON_CAMERA_RESUMED;
2701
2707
  exports.ON_CHAT = ON_CHAT;
2702
2708
  exports.ON_DISCONNECTED = ON_DISCONNECTED;
2709
+ exports.ON_EARLY_MEDIA = ON_EARLY_MEDIA;
2703
2710
  exports.ON_MESSAGE = ON_MESSAGE;
2704
2711
  exports.ON_MESSAGE_TRACK_UPDATED = ON_MESSAGE_TRACK_UPDATED;
2705
2712
  exports.ON_NETWORK_STATS = ON_NETWORK_STATS;
package/lib/index.js CHANGED
@@ -5161,10 +5161,13 @@ var chatdMethods = (client , baseUrl ) => ({
5161
5161
  createRoom: async (name , users ) =>
5162
5162
  client.post(`${baseUrl}/users/me/rooms`, { name, users }).then(ChatRoom.parse),
5163
5163
 
5164
- getRoomMessages: async (roomUuid ) =>
5165
- client
5166
- .get(`${baseUrl}/users/me/rooms/${roomUuid}/messages`)
5167
- .then((response ) => ChatMessage.parseMany(response)),
5164
+ getRoomMessages: async (roomUuid , params = {}) => {
5165
+ const qs = ApiRequester.getQueryString(params);
5166
+
5167
+ return client
5168
+ .get(`${baseUrl}/users/me/rooms/${roomUuid}/messages${qs.length ? `?${qs}` : ''}`)
5169
+ .then((response ) => ChatMessage.parseMany(response));
5170
+ },
5168
5171
 
5169
5172
  sendRoomMessage: async (roomUuid , message ) =>
5170
5173
  client.post(`${baseUrl}/users/me/rooms/${roomUuid}/messages`, message).then(ChatMessage.parse),
@@ -6519,6 +6522,7 @@ const MESSAGE = 'message';
6519
6522
  const ACCEPTED = 'accepted';
6520
6523
  const REJECTED = 'rejected';
6521
6524
  const ON_TRACK$1 = 'onTrack';
6525
+ const ON_EARLY_MEDIA$1 = 'onEarlyMedia';
6522
6526
  const ON_REINVITE$1 = 'reinvite';
6523
6527
  const ON_ERROR = 'onError';
6524
6528
  const ON_SCREEN_SHARING_REINVITE = 'onScreenSharingReinvite';
@@ -6602,6 +6606,7 @@ class WebRTCClient extends Emitter {
6602
6606
 
6603
6607
 
6604
6608
 
6609
+
6605
6610
 
6606
6611
 
6607
6612
  static isAPrivateIp(ip ) {
@@ -6670,6 +6675,7 @@ class WebRTCClient extends Emitter {
6670
6675
  this.ON_SCREEN_SHARING_REINVITE = ON_SCREEN_SHARING_REINVITE;
6671
6676
  this.ON_NETWORK_STATS = ON_NETWORK_STATS$1;
6672
6677
  this.ON_DISCONNECTED = ON_DISCONNECTED$1;
6678
+ this.ON_EARLY_MEDIA = ON_EARLY_MEDIA$1;
6673
6679
  }
6674
6680
 
6675
6681
  configureMedia(media ) {
@@ -6957,6 +6963,11 @@ class WebRTCClient extends Emitter {
6957
6963
  }
6958
6964
  this._onAccepted(session, response.session, true);
6959
6965
  },
6966
+ onProgress: (payload) => {
6967
+ if (payload.message.statusCode === 183) {
6968
+ this._onEarlyProgress(payload.session);
6969
+ }
6970
+ },
6960
6971
  onReject: (response ) => {
6961
6972
  logger$9.info('on call rejected', { id: session.id, fromTag: session.fromTag });
6962
6973
  this._stopSendingStats(session);
@@ -8349,6 +8360,17 @@ class WebRTCClient extends Emitter {
8349
8360
  };
8350
8361
  }
8351
8362
 
8363
+ _onEarlyProgress(session ) {
8364
+ this._setupMedias(session);
8365
+
8366
+ const sessionId = this.getSipSessionId(session).substr(0, 20);
8367
+ this.updateRemoteStream(sessionId);
8368
+
8369
+ logger$9.info('Early media progress progress received', { sessionId });
8370
+
8371
+ this.eventEmitter.emit(ON_EARLY_MEDIA$1, session);
8372
+ }
8373
+
8352
8374
  _onAccepted(session , sessionDialog , withEvent = true) {
8353
8375
  logger$9.info('on call accepted', { id: session.id, remoteTag: session.remoteTag });
8354
8376
 
@@ -8400,15 +8422,22 @@ class WebRTCClient extends Emitter {
8400
8422
 
8401
8423
  _setupMedias(session , newStream ) {
8402
8424
  // Safari hack, because you cannot call .play() from a non user action
8403
- const sessionId = this.getSipSessionId(session);
8425
+ const sessionId = this.getSipSessionId(session).substr(0, 20);
8404
8426
  const isConference = this.isConference(sessionId);
8405
8427
 
8428
+ if (sessionId in this.audioElements) {
8429
+ logger$9.info('html element already exists for session', { sessionId });
8430
+ return;
8431
+ }
8432
+
8406
8433
  if (this._hasAudio() && this._isWeb() && !(sessionId in this.audioElements)) {
8407
8434
  this.createAudioElementFor(sessionId);
8408
8435
  }
8409
8436
 
8410
8437
  const audioElement = this.audioElements[sessionId];
8411
- const stream = newStream || this.getRemoteStream(sessionId);
8438
+ const sipSession = this.sipSessions[session.callId];
8439
+ const removeStream = this.getRemoteStream(sessionId);
8440
+ const stream = newStream || removeStream || sipSession.sessionDescriptionHandler.remoteMediaStream;
8412
8441
 
8413
8442
  if (!this._isWeb() || !stream) {
8414
8443
  return;
@@ -9648,6 +9677,7 @@ const ON_NETWORK_STATS = 'onNetworkStats';
9648
9677
  const ON_CHAT = 'phone/ON_CHAT';
9649
9678
  const ON_SIGNAL = 'phone/ON_SIGNAL';
9650
9679
  const ON_DISCONNECTED = 'onDisconnected';
9680
+ const ON_EARLY_MEDIA = 'onEarlyMedia';
9651
9681
 
9652
9682
  const MESSAGE_TYPE_CHAT = 'message/TYPE_CHAT';
9653
9683
  const MESSAGE_TYPE_SIGNAL = 'message/TYPE_SIGNAL';
@@ -9689,6 +9719,7 @@ const events = [
9689
9719
  ON_SIGNAL,
9690
9720
  ON_NETWORK_STATS,
9691
9721
  ON_DISCONNECTED,
9722
+ ON_EARLY_MEDIA,
9692
9723
  ];
9693
9724
 
9694
9725
  const logger$7 = IssueReporter$1.loggerFor('webrtc-phone');
@@ -11118,6 +11149,10 @@ class WebRTCPhone extends Emitter {
11118
11149
  logger$7.info('WebRTC disconnected');
11119
11150
  this.eventEmitter.emit(ON_DISCONNECTED);
11120
11151
  });
11152
+ this.client.on(this.client.ON_EARLY_MEDIA, () => {
11153
+ logger$7.info('WebRTC early media');
11154
+ this.eventEmitter.emit(ON_EARLY_MEDIA);
11155
+ });
11121
11156
 
11122
11157
  this.client.on(this.client.REGISTERED, () => {
11123
11158
  logger$7.info('WebRTC registered', {
@@ -11401,6 +11436,7 @@ var PHONE_EVENTS = /*#__PURE__*/Object.freeze({
11401
11436
  ON_CHAT: ON_CHAT,
11402
11437
  ON_SIGNAL: ON_SIGNAL,
11403
11438
  ON_DISCONNECTED: ON_DISCONNECTED,
11439
+ ON_EARLY_MEDIA: ON_EARLY_MEDIA,
11404
11440
  MESSAGE_TYPE_CHAT: MESSAGE_TYPE_CHAT,
11405
11441
  MESSAGE_TYPE_SIGNAL: MESSAGE_TYPE_SIGNAL,
11406
11442
  events: events,
@@ -4124,10 +4124,13 @@ var chatdMethods = (client , baseUrl ) => ({
4124
4124
  createRoom: async (name , users ) =>
4125
4125
  client.post(`${baseUrl}/users/me/rooms`, { name, users }).then(ChatRoom.parse),
4126
4126
 
4127
- getRoomMessages: async (roomUuid ) =>
4128
- client
4129
- .get(`${baseUrl}/users/me/rooms/${roomUuid}/messages`)
4130
- .then((response ) => ChatMessage.parseMany(response)),
4127
+ getRoomMessages: async (roomUuid , params = {}) => {
4128
+ const qs = ApiRequester.getQueryString(params);
4129
+
4130
+ return client
4131
+ .get(`${baseUrl}/users/me/rooms/${roomUuid}/messages${qs.length ? `?${qs}` : ''}`)
4132
+ .then((response ) => ChatMessage.parseMany(response));
4133
+ },
4131
4134
 
4132
4135
  sendRoomMessage: async (roomUuid , message ) =>
4133
4136
  client.post(`${baseUrl}/users/me/rooms/${roomUuid}/messages`, message).then(ChatMessage.parse),
@@ -4194,10 +4194,13 @@ var chatdMethods = (client , baseUrl ) => ({
4194
4194
  createRoom: async (name , users ) =>
4195
4195
  client.post(`${baseUrl}/users/me/rooms`, { name, users }).then(ChatRoom.parse),
4196
4196
 
4197
- getRoomMessages: async (roomUuid ) =>
4198
- client
4199
- .get(`${baseUrl}/users/me/rooms/${roomUuid}/messages`)
4200
- .then((response ) => ChatMessage.parseMany(response)),
4197
+ getRoomMessages: async (roomUuid , params = {}) => {
4198
+ const qs = ApiRequester.getQueryString(params);
4199
+
4200
+ return client
4201
+ .get(`${baseUrl}/users/me/rooms/${roomUuid}/messages${qs.length ? `?${qs}` : ''}`)
4202
+ .then((response ) => ChatMessage.parseMany(response));
4203
+ },
4201
4204
 
4202
4205
  sendRoomMessage: async (roomUuid , message ) =>
4203
4206
  client.post(`${baseUrl}/users/me/rooms/${roomUuid}/messages`, message).then(ChatMessage.parse),
@@ -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),
@@ -6698,6 +6701,7 @@ const MESSAGE = 'message';
6698
6701
  const ACCEPTED = 'accepted';
6699
6702
  const REJECTED = 'rejected';
6700
6703
  const ON_TRACK$1 = 'onTrack';
6704
+ const ON_EARLY_MEDIA$1 = 'onEarlyMedia';
6701
6705
  const ON_REINVITE$1 = 'reinvite';
6702
6706
  const ON_ERROR = 'onError';
6703
6707
  const ON_SCREEN_SHARING_REINVITE = 'onScreenSharingReinvite';
@@ -6781,6 +6785,7 @@ class WebRTCClient extends Emitter {
6781
6785
 
6782
6786
 
6783
6787
 
6788
+
6784
6789
 
6785
6790
 
6786
6791
  static isAPrivateIp(ip ) {
@@ -6849,6 +6854,7 @@ class WebRTCClient extends Emitter {
6849
6854
  this.ON_SCREEN_SHARING_REINVITE = ON_SCREEN_SHARING_REINVITE;
6850
6855
  this.ON_NETWORK_STATS = ON_NETWORK_STATS$1;
6851
6856
  this.ON_DISCONNECTED = ON_DISCONNECTED$1;
6857
+ this.ON_EARLY_MEDIA = ON_EARLY_MEDIA$1;
6852
6858
  }
6853
6859
 
6854
6860
  configureMedia(media ) {
@@ -7136,6 +7142,11 @@ class WebRTCClient extends Emitter {
7136
7142
  }
7137
7143
  this._onAccepted(session, response.session, true);
7138
7144
  },
7145
+ onProgress: (payload) => {
7146
+ if (payload.message.statusCode === 183) {
7147
+ this._onEarlyProgress(payload.session);
7148
+ }
7149
+ },
7139
7150
  onReject: (response ) => {
7140
7151
  logger$9.info('on call rejected', { id: session.id, fromTag: session.fromTag });
7141
7152
  this._stopSendingStats(session);
@@ -8528,6 +8539,17 @@ class WebRTCClient extends Emitter {
8528
8539
  };
8529
8540
  }
8530
8541
 
8542
+ _onEarlyProgress(session ) {
8543
+ this._setupMedias(session);
8544
+
8545
+ const sessionId = this.getSipSessionId(session).substr(0, 20);
8546
+ this.updateRemoteStream(sessionId);
8547
+
8548
+ logger$9.info('Early media progress progress received', { sessionId });
8549
+
8550
+ this.eventEmitter.emit(ON_EARLY_MEDIA$1, session);
8551
+ }
8552
+
8531
8553
  _onAccepted(session , sessionDialog , withEvent = true) {
8532
8554
  logger$9.info('on call accepted', { id: session.id, remoteTag: session.remoteTag });
8533
8555
 
@@ -8579,15 +8601,22 @@ class WebRTCClient extends Emitter {
8579
8601
 
8580
8602
  _setupMedias(session , newStream ) {
8581
8603
  // Safari hack, because you cannot call .play() from a non user action
8582
- const sessionId = this.getSipSessionId(session);
8604
+ const sessionId = this.getSipSessionId(session).substr(0, 20);
8583
8605
  const isConference = this.isConference(sessionId);
8584
8606
 
8607
+ if (sessionId in this.audioElements) {
8608
+ logger$9.info('html element already exists for session', { sessionId });
8609
+ return;
8610
+ }
8611
+
8585
8612
  if (this._hasAudio() && this._isWeb() && !(sessionId in this.audioElements)) {
8586
8613
  this.createAudioElementFor(sessionId);
8587
8614
  }
8588
8615
 
8589
8616
  const audioElement = this.audioElements[sessionId];
8590
- const stream = newStream || this.getRemoteStream(sessionId);
8617
+ const sipSession = this.sipSessions[session.callId];
8618
+ const removeStream = this.getRemoteStream(sessionId);
8619
+ const stream = newStream || removeStream || sipSession.sessionDescriptionHandler.remoteMediaStream;
8591
8620
 
8592
8621
  if (!this._isWeb() || !stream) {
8593
8622
  return;
@@ -8919,6 +8948,7 @@ const ON_NETWORK_STATS = 'onNetworkStats';
8919
8948
  const ON_CHAT = 'phone/ON_CHAT';
8920
8949
  const ON_SIGNAL = 'phone/ON_SIGNAL';
8921
8950
  const ON_DISCONNECTED = 'onDisconnected';
8951
+ const ON_EARLY_MEDIA = 'onEarlyMedia';
8922
8952
 
8923
8953
  const MESSAGE_TYPE_CHAT = 'message/TYPE_CHAT';
8924
8954
  const MESSAGE_TYPE_SIGNAL = 'message/TYPE_SIGNAL';
@@ -8960,6 +8990,7 @@ const events = [
8960
8990
  ON_SIGNAL,
8961
8991
  ON_NETWORK_STATS,
8962
8992
  ON_DISCONNECTED,
8993
+ ON_EARLY_MEDIA,
8963
8994
  ];
8964
8995
 
8965
8996
  const logger$8 = IssueReporter$1.loggerFor('webrtc-phone');
@@ -10389,6 +10420,10 @@ class WebRTCPhone extends Emitter {
10389
10420
  logger$8.info('WebRTC disconnected');
10390
10421
  this.eventEmitter.emit(ON_DISCONNECTED);
10391
10422
  });
10423
+ this.client.on(this.client.ON_EARLY_MEDIA, () => {
10424
+ logger$8.info('WebRTC early media');
10425
+ this.eventEmitter.emit(ON_EARLY_MEDIA);
10426
+ });
10392
10427
 
10393
10428
  this.client.on(this.client.REGISTERED, () => {
10394
10429
  logger$8.info('WebRTC registered', {
@@ -10672,6 +10707,7 @@ var PHONE_EVENTS = /*#__PURE__*/Object.freeze({
10672
10707
  ON_CHAT: ON_CHAT,
10673
10708
  ON_SIGNAL: ON_SIGNAL,
10674
10709
  ON_DISCONNECTED: ON_DISCONNECTED,
10710
+ ON_EARLY_MEDIA: ON_EARLY_MEDIA,
10675
10711
  MESSAGE_TYPE_CHAT: MESSAGE_TYPE_CHAT,
10676
10712
  MESSAGE_TYPE_SIGNAL: MESSAGE_TYPE_SIGNAL,
10677
10713
  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,
@@ -4192,10 +4192,13 @@ var chatdMethods = (client , baseUrl ) => ({
4192
4192
  createRoom: async (name , users ) =>
4193
4193
  client.post(`${baseUrl}/users/me/rooms`, { name, users }).then(ChatRoom.parse),
4194
4194
 
4195
- getRoomMessages: async (roomUuid ) =>
4196
- client
4197
- .get(`${baseUrl}/users/me/rooms/${roomUuid}/messages`)
4198
- .then((response ) => ChatMessage.parseMany(response)),
4195
+ getRoomMessages: async (roomUuid , params = {}) => {
4196
+ const qs = ApiRequester.getQueryString(params);
4197
+
4198
+ return client
4199
+ .get(`${baseUrl}/users/me/rooms/${roomUuid}/messages${qs.length ? `?${qs}` : ''}`)
4200
+ .then((response ) => ChatMessage.parseMany(response));
4201
+ },
4199
4202
 
4200
4203
  sendRoomMessage: async (roomUuid , message ) =>
4201
4204
  client.post(`${baseUrl}/users/me/rooms/${roomUuid}/messages`, message).then(ChatMessage.parse),
@@ -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,