@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
@@ -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),
@@ -7017,6 +7020,7 @@ const MESSAGE = 'message';
7017
7020
  const ACCEPTED = 'accepted';
7018
7021
  const REJECTED = 'rejected';
7019
7022
  const ON_TRACK$1 = 'onTrack';
7023
+ const ON_EARLY_MEDIA$1 = 'onEarlyMedia';
7020
7024
  const ON_REINVITE$1 = 'reinvite';
7021
7025
  const ON_ERROR = 'onError';
7022
7026
  const ON_SCREEN_SHARING_REINVITE = 'onScreenSharingReinvite';
@@ -7100,6 +7104,7 @@ class WebRTCClient extends Emitter {
7100
7104
 
7101
7105
 
7102
7106
 
7107
+
7103
7108
 
7104
7109
 
7105
7110
  static isAPrivateIp(ip ) {
@@ -7168,6 +7173,7 @@ class WebRTCClient extends Emitter {
7168
7173
  this.ON_SCREEN_SHARING_REINVITE = ON_SCREEN_SHARING_REINVITE;
7169
7174
  this.ON_NETWORK_STATS = ON_NETWORK_STATS$1;
7170
7175
  this.ON_DISCONNECTED = ON_DISCONNECTED$1;
7176
+ this.ON_EARLY_MEDIA = ON_EARLY_MEDIA$1;
7171
7177
  }
7172
7178
 
7173
7179
  configureMedia(media ) {
@@ -7455,6 +7461,11 @@ class WebRTCClient extends Emitter {
7455
7461
  }
7456
7462
  this._onAccepted(session, response.session, true);
7457
7463
  },
7464
+ onProgress: (payload) => {
7465
+ if (payload.message.statusCode === 183) {
7466
+ this._onEarlyProgress(payload.session);
7467
+ }
7468
+ },
7458
7469
  onReject: (response ) => {
7459
7470
  logger$8.info('on call rejected', { id: session.id, fromTag: session.fromTag });
7460
7471
  this._stopSendingStats(session);
@@ -8847,6 +8858,17 @@ class WebRTCClient extends Emitter {
8847
8858
  };
8848
8859
  }
8849
8860
 
8861
+ _onEarlyProgress(session ) {
8862
+ this._setupMedias(session);
8863
+
8864
+ const sessionId = this.getSipSessionId(session).substr(0, 20);
8865
+ this.updateRemoteStream(sessionId);
8866
+
8867
+ logger$8.info('Early media progress progress received', { sessionId });
8868
+
8869
+ this.eventEmitter.emit(ON_EARLY_MEDIA$1, session);
8870
+ }
8871
+
8850
8872
  _onAccepted(session , sessionDialog , withEvent = true) {
8851
8873
  logger$8.info('on call accepted', { id: session.id, remoteTag: session.remoteTag });
8852
8874
 
@@ -8898,15 +8920,22 @@ class WebRTCClient extends Emitter {
8898
8920
 
8899
8921
  _setupMedias(session , newStream ) {
8900
8922
  // Safari hack, because you cannot call .play() from a non user action
8901
- const sessionId = this.getSipSessionId(session);
8923
+ const sessionId = this.getSipSessionId(session).substr(0, 20);
8902
8924
  const isConference = this.isConference(sessionId);
8903
8925
 
8926
+ if (sessionId in this.audioElements) {
8927
+ logger$8.info('html element already exists for session', { sessionId });
8928
+ return;
8929
+ }
8930
+
8904
8931
  if (this._hasAudio() && this._isWeb() && !(sessionId in this.audioElements)) {
8905
8932
  this.createAudioElementFor(sessionId);
8906
8933
  }
8907
8934
 
8908
8935
  const audioElement = this.audioElements[sessionId];
8909
- const stream = newStream || this.getRemoteStream(sessionId);
8936
+ const sipSession = this.sipSessions[session.callId];
8937
+ const removeStream = this.getRemoteStream(sessionId);
8938
+ const stream = newStream || removeStream || sipSession.sessionDescriptionHandler.remoteMediaStream;
8910
8939
 
8911
8940
  if (!this._isWeb() || !stream) {
8912
8941
  return;
@@ -9238,6 +9267,7 @@ const ON_NETWORK_STATS = 'onNetworkStats';
9238
9267
  const ON_CHAT = 'phone/ON_CHAT';
9239
9268
  const ON_SIGNAL = 'phone/ON_SIGNAL';
9240
9269
  const ON_DISCONNECTED = 'onDisconnected';
9270
+ const ON_EARLY_MEDIA = 'onEarlyMedia';
9241
9271
 
9242
9272
  const MESSAGE_TYPE_CHAT = 'message/TYPE_CHAT';
9243
9273
  const MESSAGE_TYPE_SIGNAL = 'message/TYPE_SIGNAL';
@@ -9279,6 +9309,7 @@ const events = [
9279
9309
  ON_SIGNAL,
9280
9310
  ON_NETWORK_STATS,
9281
9311
  ON_DISCONNECTED,
9312
+ ON_EARLY_MEDIA,
9282
9313
  ];
9283
9314
 
9284
9315
  const logger$7 = IssueReporter$1.loggerFor('webrtc-phone');
@@ -10708,6 +10739,10 @@ class WebRTCPhone extends Emitter {
10708
10739
  logger$7.info('WebRTC disconnected');
10709
10740
  this.eventEmitter.emit(ON_DISCONNECTED);
10710
10741
  });
10742
+ this.client.on(this.client.ON_EARLY_MEDIA, () => {
10743
+ logger$7.info('WebRTC early media');
10744
+ this.eventEmitter.emit(ON_EARLY_MEDIA);
10745
+ });
10711
10746
 
10712
10747
  this.client.on(this.client.REGISTERED, () => {
10713
10748
  logger$7.info('WebRTC registered', {
@@ -10991,6 +11026,7 @@ var PHONE_EVENTS = /*#__PURE__*/Object.freeze({
10991
11026
  ON_CHAT: ON_CHAT,
10992
11027
  ON_SIGNAL: ON_SIGNAL,
10993
11028
  ON_DISCONNECTED: ON_DISCONNECTED,
11029
+ ON_EARLY_MEDIA: ON_EARLY_MEDIA,
10994
11030
  MESSAGE_TYPE_CHAT: MESSAGE_TYPE_CHAT,
10995
11031
  MESSAGE_TYPE_SIGNAL: MESSAGE_TYPE_SIGNAL,
10996
11032
  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),
@@ -7017,6 +7020,7 @@ const MESSAGE = 'message';
7017
7020
  const ACCEPTED = 'accepted';
7018
7021
  const REJECTED = 'rejected';
7019
7022
  const ON_TRACK$1 = 'onTrack';
7023
+ const ON_EARLY_MEDIA$1 = 'onEarlyMedia';
7020
7024
  const ON_REINVITE$1 = 'reinvite';
7021
7025
  const ON_ERROR = 'onError';
7022
7026
  const ON_SCREEN_SHARING_REINVITE = 'onScreenSharingReinvite';
@@ -7100,6 +7104,7 @@ class WebRTCClient extends Emitter {
7100
7104
 
7101
7105
 
7102
7106
 
7107
+
7103
7108
 
7104
7109
 
7105
7110
  static isAPrivateIp(ip ) {
@@ -7168,6 +7173,7 @@ class WebRTCClient extends Emitter {
7168
7173
  this.ON_SCREEN_SHARING_REINVITE = ON_SCREEN_SHARING_REINVITE;
7169
7174
  this.ON_NETWORK_STATS = ON_NETWORK_STATS$1;
7170
7175
  this.ON_DISCONNECTED = ON_DISCONNECTED$1;
7176
+ this.ON_EARLY_MEDIA = ON_EARLY_MEDIA$1;
7171
7177
  }
7172
7178
 
7173
7179
  configureMedia(media ) {
@@ -7455,6 +7461,11 @@ class WebRTCClient extends Emitter {
7455
7461
  }
7456
7462
  this._onAccepted(session, response.session, true);
7457
7463
  },
7464
+ onProgress: (payload) => {
7465
+ if (payload.message.statusCode === 183) {
7466
+ this._onEarlyProgress(payload.session);
7467
+ }
7468
+ },
7458
7469
  onReject: (response ) => {
7459
7470
  logger$8.info('on call rejected', { id: session.id, fromTag: session.fromTag });
7460
7471
  this._stopSendingStats(session);
@@ -8847,6 +8858,17 @@ class WebRTCClient extends Emitter {
8847
8858
  };
8848
8859
  }
8849
8860
 
8861
+ _onEarlyProgress(session ) {
8862
+ this._setupMedias(session);
8863
+
8864
+ const sessionId = this.getSipSessionId(session).substr(0, 20);
8865
+ this.updateRemoteStream(sessionId);
8866
+
8867
+ logger$8.info('Early media progress progress received', { sessionId });
8868
+
8869
+ this.eventEmitter.emit(ON_EARLY_MEDIA$1, session);
8870
+ }
8871
+
8850
8872
  _onAccepted(session , sessionDialog , withEvent = true) {
8851
8873
  logger$8.info('on call accepted', { id: session.id, remoteTag: session.remoteTag });
8852
8874
 
@@ -8898,15 +8920,22 @@ class WebRTCClient extends Emitter {
8898
8920
 
8899
8921
  _setupMedias(session , newStream ) {
8900
8922
  // Safari hack, because you cannot call .play() from a non user action
8901
- const sessionId = this.getSipSessionId(session);
8923
+ const sessionId = this.getSipSessionId(session).substr(0, 20);
8902
8924
  const isConference = this.isConference(sessionId);
8903
8925
 
8926
+ if (sessionId in this.audioElements) {
8927
+ logger$8.info('html element already exists for session', { sessionId });
8928
+ return;
8929
+ }
8930
+
8904
8931
  if (this._hasAudio() && this._isWeb() && !(sessionId in this.audioElements)) {
8905
8932
  this.createAudioElementFor(sessionId);
8906
8933
  }
8907
8934
 
8908
8935
  const audioElement = this.audioElements[sessionId];
8909
- const stream = newStream || this.getRemoteStream(sessionId);
8936
+ const sipSession = this.sipSessions[session.callId];
8937
+ const removeStream = this.getRemoteStream(sessionId);
8938
+ const stream = newStream || removeStream || sipSession.sessionDescriptionHandler.remoteMediaStream;
8910
8939
 
8911
8940
  if (!this._isWeb() || !stream) {
8912
8941
  return;
@@ -9238,6 +9267,7 @@ const ON_NETWORK_STATS = 'onNetworkStats';
9238
9267
  const ON_CHAT = 'phone/ON_CHAT';
9239
9268
  const ON_SIGNAL = 'phone/ON_SIGNAL';
9240
9269
  const ON_DISCONNECTED = 'onDisconnected';
9270
+ const ON_EARLY_MEDIA = 'onEarlyMedia';
9241
9271
 
9242
9272
  const MESSAGE_TYPE_CHAT = 'message/TYPE_CHAT';
9243
9273
  const MESSAGE_TYPE_SIGNAL = 'message/TYPE_SIGNAL';
@@ -9279,6 +9309,7 @@ const events = [
9279
9309
  ON_SIGNAL,
9280
9310
  ON_NETWORK_STATS,
9281
9311
  ON_DISCONNECTED,
9312
+ ON_EARLY_MEDIA,
9282
9313
  ];
9283
9314
 
9284
9315
  const logger$7 = IssueReporter$1.loggerFor('webrtc-phone');
@@ -10708,6 +10739,10 @@ class WebRTCPhone extends Emitter {
10708
10739
  logger$7.info('WebRTC disconnected');
10709
10740
  this.eventEmitter.emit(ON_DISCONNECTED);
10710
10741
  });
10742
+ this.client.on(this.client.ON_EARLY_MEDIA, () => {
10743
+ logger$7.info('WebRTC early media');
10744
+ this.eventEmitter.emit(ON_EARLY_MEDIA);
10745
+ });
10711
10746
 
10712
10747
  this.client.on(this.client.REGISTERED, () => {
10713
10748
  logger$7.info('WebRTC registered', {
@@ -10991,6 +11026,7 @@ var PHONE_EVENTS = /*#__PURE__*/Object.freeze({
10991
11026
  ON_CHAT: ON_CHAT,
10992
11027
  ON_SIGNAL: ON_SIGNAL,
10993
11028
  ON_DISCONNECTED: ON_DISCONNECTED,
11029
+ ON_EARLY_MEDIA: ON_EARLY_MEDIA,
10994
11030
  MESSAGE_TYPE_CHAT: MESSAGE_TYPE_CHAT,
10995
11031
  MESSAGE_TYPE_SIGNAL: MESSAGE_TYPE_SIGNAL,
10996
11032
  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),
@@ -7017,6 +7020,7 @@ const MESSAGE = 'message';
7017
7020
  const ACCEPTED = 'accepted';
7018
7021
  const REJECTED = 'rejected';
7019
7022
  const ON_TRACK$1 = 'onTrack';
7023
+ const ON_EARLY_MEDIA$1 = 'onEarlyMedia';
7020
7024
  const ON_REINVITE$1 = 'reinvite';
7021
7025
  const ON_ERROR = 'onError';
7022
7026
  const ON_SCREEN_SHARING_REINVITE = 'onScreenSharingReinvite';
@@ -7100,6 +7104,7 @@ class WebRTCClient extends Emitter {
7100
7104
 
7101
7105
 
7102
7106
 
7107
+
7103
7108
 
7104
7109
 
7105
7110
  static isAPrivateIp(ip ) {
@@ -7168,6 +7173,7 @@ class WebRTCClient extends Emitter {
7168
7173
  this.ON_SCREEN_SHARING_REINVITE = ON_SCREEN_SHARING_REINVITE;
7169
7174
  this.ON_NETWORK_STATS = ON_NETWORK_STATS$1;
7170
7175
  this.ON_DISCONNECTED = ON_DISCONNECTED$1;
7176
+ this.ON_EARLY_MEDIA = ON_EARLY_MEDIA$1;
7171
7177
  }
7172
7178
 
7173
7179
  configureMedia(media ) {
@@ -7455,6 +7461,11 @@ class WebRTCClient extends Emitter {
7455
7461
  }
7456
7462
  this._onAccepted(session, response.session, true);
7457
7463
  },
7464
+ onProgress: (payload) => {
7465
+ if (payload.message.statusCode === 183) {
7466
+ this._onEarlyProgress(payload.session);
7467
+ }
7468
+ },
7458
7469
  onReject: (response ) => {
7459
7470
  logger$8.info('on call rejected', { id: session.id, fromTag: session.fromTag });
7460
7471
  this._stopSendingStats(session);
@@ -8847,6 +8858,17 @@ class WebRTCClient extends Emitter {
8847
8858
  };
8848
8859
  }
8849
8860
 
8861
+ _onEarlyProgress(session ) {
8862
+ this._setupMedias(session);
8863
+
8864
+ const sessionId = this.getSipSessionId(session).substr(0, 20);
8865
+ this.updateRemoteStream(sessionId);
8866
+
8867
+ logger$8.info('Early media progress progress received', { sessionId });
8868
+
8869
+ this.eventEmitter.emit(ON_EARLY_MEDIA$1, session);
8870
+ }
8871
+
8850
8872
  _onAccepted(session , sessionDialog , withEvent = true) {
8851
8873
  logger$8.info('on call accepted', { id: session.id, remoteTag: session.remoteTag });
8852
8874
 
@@ -8898,15 +8920,22 @@ class WebRTCClient extends Emitter {
8898
8920
 
8899
8921
  _setupMedias(session , newStream ) {
8900
8922
  // Safari hack, because you cannot call .play() from a non user action
8901
- const sessionId = this.getSipSessionId(session);
8923
+ const sessionId = this.getSipSessionId(session).substr(0, 20);
8902
8924
  const isConference = this.isConference(sessionId);
8903
8925
 
8926
+ if (sessionId in this.audioElements) {
8927
+ logger$8.info('html element already exists for session', { sessionId });
8928
+ return;
8929
+ }
8930
+
8904
8931
  if (this._hasAudio() && this._isWeb() && !(sessionId in this.audioElements)) {
8905
8932
  this.createAudioElementFor(sessionId);
8906
8933
  }
8907
8934
 
8908
8935
  const audioElement = this.audioElements[sessionId];
8909
- const stream = newStream || this.getRemoteStream(sessionId);
8936
+ const sipSession = this.sipSessions[session.callId];
8937
+ const removeStream = this.getRemoteStream(sessionId);
8938
+ const stream = newStream || removeStream || sipSession.sessionDescriptionHandler.remoteMediaStream;
8910
8939
 
8911
8940
  if (!this._isWeb() || !stream) {
8912
8941
  return;
@@ -9238,6 +9267,7 @@ const ON_NETWORK_STATS = 'onNetworkStats';
9238
9267
  const ON_CHAT = 'phone/ON_CHAT';
9239
9268
  const ON_SIGNAL = 'phone/ON_SIGNAL';
9240
9269
  const ON_DISCONNECTED = 'onDisconnected';
9270
+ const ON_EARLY_MEDIA = 'onEarlyMedia';
9241
9271
 
9242
9272
  const MESSAGE_TYPE_CHAT = 'message/TYPE_CHAT';
9243
9273
  const MESSAGE_TYPE_SIGNAL = 'message/TYPE_SIGNAL';
@@ -9279,6 +9309,7 @@ const events = [
9279
9309
  ON_SIGNAL,
9280
9310
  ON_NETWORK_STATS,
9281
9311
  ON_DISCONNECTED,
9312
+ ON_EARLY_MEDIA,
9282
9313
  ];
9283
9314
 
9284
9315
  const logger$7 = IssueReporter$1.loggerFor('webrtc-phone');
@@ -10708,6 +10739,10 @@ class WebRTCPhone extends Emitter {
10708
10739
  logger$7.info('WebRTC disconnected');
10709
10740
  this.eventEmitter.emit(ON_DISCONNECTED);
10710
10741
  });
10742
+ this.client.on(this.client.ON_EARLY_MEDIA, () => {
10743
+ logger$7.info('WebRTC early media');
10744
+ this.eventEmitter.emit(ON_EARLY_MEDIA);
10745
+ });
10711
10746
 
10712
10747
  this.client.on(this.client.REGISTERED, () => {
10713
10748
  logger$7.info('WebRTC registered', {
@@ -10991,6 +11026,7 @@ var PHONE_EVENTS = /*#__PURE__*/Object.freeze({
10991
11026
  ON_CHAT: ON_CHAT,
10992
11027
  ON_SIGNAL: ON_SIGNAL,
10993
11028
  ON_DISCONNECTED: ON_DISCONNECTED,
11029
+ ON_EARLY_MEDIA: ON_EARLY_MEDIA,
10994
11030
  MESSAGE_TYPE_CHAT: MESSAGE_TYPE_CHAT,
10995
11031
  MESSAGE_TYPE_SIGNAL: MESSAGE_TYPE_SIGNAL,
10996
11032
  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),
@@ -7017,6 +7020,7 @@ const MESSAGE = 'message';
7017
7020
  const ACCEPTED = 'accepted';
7018
7021
  const REJECTED = 'rejected';
7019
7022
  const ON_TRACK$1 = 'onTrack';
7023
+ const ON_EARLY_MEDIA$1 = 'onEarlyMedia';
7020
7024
  const ON_REINVITE$1 = 'reinvite';
7021
7025
  const ON_ERROR = 'onError';
7022
7026
  const ON_SCREEN_SHARING_REINVITE = 'onScreenSharingReinvite';
@@ -7100,6 +7104,7 @@ class WebRTCClient extends Emitter {
7100
7104
 
7101
7105
 
7102
7106
 
7107
+
7103
7108
 
7104
7109
 
7105
7110
  static isAPrivateIp(ip ) {
@@ -7168,6 +7173,7 @@ class WebRTCClient extends Emitter {
7168
7173
  this.ON_SCREEN_SHARING_REINVITE = ON_SCREEN_SHARING_REINVITE;
7169
7174
  this.ON_NETWORK_STATS = ON_NETWORK_STATS$1;
7170
7175
  this.ON_DISCONNECTED = ON_DISCONNECTED$1;
7176
+ this.ON_EARLY_MEDIA = ON_EARLY_MEDIA$1;
7171
7177
  }
7172
7178
 
7173
7179
  configureMedia(media ) {
@@ -7455,6 +7461,11 @@ class WebRTCClient extends Emitter {
7455
7461
  }
7456
7462
  this._onAccepted(session, response.session, true);
7457
7463
  },
7464
+ onProgress: (payload) => {
7465
+ if (payload.message.statusCode === 183) {
7466
+ this._onEarlyProgress(payload.session);
7467
+ }
7468
+ },
7458
7469
  onReject: (response ) => {
7459
7470
  logger$8.info('on call rejected', { id: session.id, fromTag: session.fromTag });
7460
7471
  this._stopSendingStats(session);
@@ -8847,6 +8858,17 @@ class WebRTCClient extends Emitter {
8847
8858
  };
8848
8859
  }
8849
8860
 
8861
+ _onEarlyProgress(session ) {
8862
+ this._setupMedias(session);
8863
+
8864
+ const sessionId = this.getSipSessionId(session).substr(0, 20);
8865
+ this.updateRemoteStream(sessionId);
8866
+
8867
+ logger$8.info('Early media progress progress received', { sessionId });
8868
+
8869
+ this.eventEmitter.emit(ON_EARLY_MEDIA$1, session);
8870
+ }
8871
+
8850
8872
  _onAccepted(session , sessionDialog , withEvent = true) {
8851
8873
  logger$8.info('on call accepted', { id: session.id, remoteTag: session.remoteTag });
8852
8874
 
@@ -8898,15 +8920,22 @@ class WebRTCClient extends Emitter {
8898
8920
 
8899
8921
  _setupMedias(session , newStream ) {
8900
8922
  // Safari hack, because you cannot call .play() from a non user action
8901
- const sessionId = this.getSipSessionId(session);
8923
+ const sessionId = this.getSipSessionId(session).substr(0, 20);
8902
8924
  const isConference = this.isConference(sessionId);
8903
8925
 
8926
+ if (sessionId in this.audioElements) {
8927
+ logger$8.info('html element already exists for session', { sessionId });
8928
+ return;
8929
+ }
8930
+
8904
8931
  if (this._hasAudio() && this._isWeb() && !(sessionId in this.audioElements)) {
8905
8932
  this.createAudioElementFor(sessionId);
8906
8933
  }
8907
8934
 
8908
8935
  const audioElement = this.audioElements[sessionId];
8909
- const stream = newStream || this.getRemoteStream(sessionId);
8936
+ const sipSession = this.sipSessions[session.callId];
8937
+ const removeStream = this.getRemoteStream(sessionId);
8938
+ const stream = newStream || removeStream || sipSession.sessionDescriptionHandler.remoteMediaStream;
8910
8939
 
8911
8940
  if (!this._isWeb() || !stream) {
8912
8941
  return;
@@ -9238,6 +9267,7 @@ const ON_NETWORK_STATS = 'onNetworkStats';
9238
9267
  const ON_CHAT = 'phone/ON_CHAT';
9239
9268
  const ON_SIGNAL = 'phone/ON_SIGNAL';
9240
9269
  const ON_DISCONNECTED = 'onDisconnected';
9270
+ const ON_EARLY_MEDIA = 'onEarlyMedia';
9241
9271
 
9242
9272
  const MESSAGE_TYPE_CHAT = 'message/TYPE_CHAT';
9243
9273
  const MESSAGE_TYPE_SIGNAL = 'message/TYPE_SIGNAL';
@@ -9279,6 +9309,7 @@ const events = [
9279
9309
  ON_SIGNAL,
9280
9310
  ON_NETWORK_STATS,
9281
9311
  ON_DISCONNECTED,
9312
+ ON_EARLY_MEDIA,
9282
9313
  ];
9283
9314
 
9284
9315
  const logger$7 = IssueReporter$1.loggerFor('webrtc-phone');
@@ -10708,6 +10739,10 @@ class WebRTCPhone extends Emitter {
10708
10739
  logger$7.info('WebRTC disconnected');
10709
10740
  this.eventEmitter.emit(ON_DISCONNECTED);
10710
10741
  });
10742
+ this.client.on(this.client.ON_EARLY_MEDIA, () => {
10743
+ logger$7.info('WebRTC early media');
10744
+ this.eventEmitter.emit(ON_EARLY_MEDIA);
10745
+ });
10711
10746
 
10712
10747
  this.client.on(this.client.REGISTERED, () => {
10713
10748
  logger$7.info('WebRTC registered', {
@@ -10991,6 +11026,7 @@ var PHONE_EVENTS = /*#__PURE__*/Object.freeze({
10991
11026
  ON_CHAT: ON_CHAT,
10992
11027
  ON_SIGNAL: ON_SIGNAL,
10993
11028
  ON_DISCONNECTED: ON_DISCONNECTED,
11029
+ ON_EARLY_MEDIA: ON_EARLY_MEDIA,
10994
11030
  MESSAGE_TYPE_CHAT: MESSAGE_TYPE_CHAT,
10995
11031
  MESSAGE_TYPE_SIGNAL: MESSAGE_TYPE_SIGNAL,
10996
11032
  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),
@@ -7017,6 +7020,7 @@ const MESSAGE = 'message';
7017
7020
  const ACCEPTED = 'accepted';
7018
7021
  const REJECTED = 'rejected';
7019
7022
  const ON_TRACK$1 = 'onTrack';
7023
+ const ON_EARLY_MEDIA$1 = 'onEarlyMedia';
7020
7024
  const ON_REINVITE$1 = 'reinvite';
7021
7025
  const ON_ERROR = 'onError';
7022
7026
  const ON_SCREEN_SHARING_REINVITE = 'onScreenSharingReinvite';
@@ -7100,6 +7104,7 @@ class WebRTCClient extends Emitter {
7100
7104
 
7101
7105
 
7102
7106
 
7107
+
7103
7108
 
7104
7109
 
7105
7110
  static isAPrivateIp(ip ) {
@@ -7168,6 +7173,7 @@ class WebRTCClient extends Emitter {
7168
7173
  this.ON_SCREEN_SHARING_REINVITE = ON_SCREEN_SHARING_REINVITE;
7169
7174
  this.ON_NETWORK_STATS = ON_NETWORK_STATS$1;
7170
7175
  this.ON_DISCONNECTED = ON_DISCONNECTED$1;
7176
+ this.ON_EARLY_MEDIA = ON_EARLY_MEDIA$1;
7171
7177
  }
7172
7178
 
7173
7179
  configureMedia(media ) {
@@ -7455,6 +7461,11 @@ class WebRTCClient extends Emitter {
7455
7461
  }
7456
7462
  this._onAccepted(session, response.session, true);
7457
7463
  },
7464
+ onProgress: (payload) => {
7465
+ if (payload.message.statusCode === 183) {
7466
+ this._onEarlyProgress(payload.session);
7467
+ }
7468
+ },
7458
7469
  onReject: (response ) => {
7459
7470
  logger$8.info('on call rejected', { id: session.id, fromTag: session.fromTag });
7460
7471
  this._stopSendingStats(session);
@@ -8847,6 +8858,17 @@ class WebRTCClient extends Emitter {
8847
8858
  };
8848
8859
  }
8849
8860
 
8861
+ _onEarlyProgress(session ) {
8862
+ this._setupMedias(session);
8863
+
8864
+ const sessionId = this.getSipSessionId(session).substr(0, 20);
8865
+ this.updateRemoteStream(sessionId);
8866
+
8867
+ logger$8.info('Early media progress progress received', { sessionId });
8868
+
8869
+ this.eventEmitter.emit(ON_EARLY_MEDIA$1, session);
8870
+ }
8871
+
8850
8872
  _onAccepted(session , sessionDialog , withEvent = true) {
8851
8873
  logger$8.info('on call accepted', { id: session.id, remoteTag: session.remoteTag });
8852
8874
 
@@ -8898,15 +8920,22 @@ class WebRTCClient extends Emitter {
8898
8920
 
8899
8921
  _setupMedias(session , newStream ) {
8900
8922
  // Safari hack, because you cannot call .play() from a non user action
8901
- const sessionId = this.getSipSessionId(session);
8923
+ const sessionId = this.getSipSessionId(session).substr(0, 20);
8902
8924
  const isConference = this.isConference(sessionId);
8903
8925
 
8926
+ if (sessionId in this.audioElements) {
8927
+ logger$8.info('html element already exists for session', { sessionId });
8928
+ return;
8929
+ }
8930
+
8904
8931
  if (this._hasAudio() && this._isWeb() && !(sessionId in this.audioElements)) {
8905
8932
  this.createAudioElementFor(sessionId);
8906
8933
  }
8907
8934
 
8908
8935
  const audioElement = this.audioElements[sessionId];
8909
- const stream = newStream || this.getRemoteStream(sessionId);
8936
+ const sipSession = this.sipSessions[session.callId];
8937
+ const removeStream = this.getRemoteStream(sessionId);
8938
+ const stream = newStream || removeStream || sipSession.sessionDescriptionHandler.remoteMediaStream;
8910
8939
 
8911
8940
  if (!this._isWeb() || !stream) {
8912
8941
  return;
@@ -9238,6 +9267,7 @@ const ON_NETWORK_STATS = 'onNetworkStats';
9238
9267
  const ON_CHAT = 'phone/ON_CHAT';
9239
9268
  const ON_SIGNAL = 'phone/ON_SIGNAL';
9240
9269
  const ON_DISCONNECTED = 'onDisconnected';
9270
+ const ON_EARLY_MEDIA = 'onEarlyMedia';
9241
9271
 
9242
9272
  const MESSAGE_TYPE_CHAT = 'message/TYPE_CHAT';
9243
9273
  const MESSAGE_TYPE_SIGNAL = 'message/TYPE_SIGNAL';
@@ -9279,6 +9309,7 @@ const events = [
9279
9309
  ON_SIGNAL,
9280
9310
  ON_NETWORK_STATS,
9281
9311
  ON_DISCONNECTED,
9312
+ ON_EARLY_MEDIA,
9282
9313
  ];
9283
9314
 
9284
9315
  const logger$7 = IssueReporter$1.loggerFor('webrtc-phone');
@@ -10708,6 +10739,10 @@ class WebRTCPhone extends Emitter {
10708
10739
  logger$7.info('WebRTC disconnected');
10709
10740
  this.eventEmitter.emit(ON_DISCONNECTED);
10710
10741
  });
10742
+ this.client.on(this.client.ON_EARLY_MEDIA, () => {
10743
+ logger$7.info('WebRTC early media');
10744
+ this.eventEmitter.emit(ON_EARLY_MEDIA);
10745
+ });
10711
10746
 
10712
10747
  this.client.on(this.client.REGISTERED, () => {
10713
10748
  logger$7.info('WebRTC registered', {
@@ -10991,6 +11026,7 @@ var PHONE_EVENTS = /*#__PURE__*/Object.freeze({
10991
11026
  ON_CHAT: ON_CHAT,
10992
11027
  ON_SIGNAL: ON_SIGNAL,
10993
11028
  ON_DISCONNECTED: ON_DISCONNECTED,
11029
+ ON_EARLY_MEDIA: ON_EARLY_MEDIA,
10994
11030
  MESSAGE_TYPE_CHAT: MESSAGE_TYPE_CHAT,
10995
11031
  MESSAGE_TYPE_SIGNAL: MESSAGE_TYPE_SIGNAL,
10996
11032
  events: events,