@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
@@ -4792,10 +4792,13 @@ var chatdMethods = (client , baseUrl ) => ({
4792
4792
  createRoom: async (name , users ) =>
4793
4793
  client.post(`${baseUrl}/users/me/rooms`, { name, users }).then(ChatRoom.parse),
4794
4794
 
4795
- getRoomMessages: async (roomUuid ) =>
4796
- client
4797
- .get(`${baseUrl}/users/me/rooms/${roomUuid}/messages`)
4798
- .then((response ) => ChatMessage.parseMany(response)),
4795
+ getRoomMessages: async (roomUuid , params = {}) => {
4796
+ const qs = ApiRequester.getQueryString(params);
4797
+
4798
+ return client
4799
+ .get(`${baseUrl}/users/me/rooms/${roomUuid}/messages${qs.length ? `?${qs}` : ''}`)
4800
+ .then((response ) => ChatMessage.parseMany(response));
4801
+ },
4799
4802
 
4800
4803
  sendRoomMessage: async (roomUuid , message ) =>
4801
4804
  client.post(`${baseUrl}/users/me/rooms/${roomUuid}/messages`, message).then(ChatMessage.parse),
@@ -5616,6 +5619,7 @@ const MESSAGE = 'message';
5616
5619
  const ACCEPTED = 'accepted';
5617
5620
  const REJECTED = 'rejected';
5618
5621
  const ON_TRACK = 'onTrack';
5622
+ const ON_EARLY_MEDIA = 'onEarlyMedia';
5619
5623
  const ON_REINVITE = 'reinvite';
5620
5624
  const ON_ERROR = 'onError';
5621
5625
  const ON_SCREEN_SHARING_REINVITE = 'onScreenSharingReinvite';
@@ -5699,6 +5703,7 @@ class WebRTCClient extends Emitter {
5699
5703
 
5700
5704
 
5701
5705
 
5706
+
5702
5707
 
5703
5708
 
5704
5709
  static isAPrivateIp(ip ) {
@@ -5767,6 +5772,7 @@ class WebRTCClient extends Emitter {
5767
5772
  this.ON_SCREEN_SHARING_REINVITE = ON_SCREEN_SHARING_REINVITE;
5768
5773
  this.ON_NETWORK_STATS = ON_NETWORK_STATS;
5769
5774
  this.ON_DISCONNECTED = ON_DISCONNECTED;
5775
+ this.ON_EARLY_MEDIA = ON_EARLY_MEDIA;
5770
5776
  }
5771
5777
 
5772
5778
  configureMedia(media ) {
@@ -6054,6 +6060,11 @@ class WebRTCClient extends Emitter {
6054
6060
  }
6055
6061
  this._onAccepted(session, response.session, true);
6056
6062
  },
6063
+ onProgress: (payload) => {
6064
+ if (payload.message.statusCode === 183) {
6065
+ this._onEarlyProgress(payload.session);
6066
+ }
6067
+ },
6057
6068
  onReject: (response ) => {
6058
6069
  logger.info('on call rejected', { id: session.id, fromTag: session.fromTag });
6059
6070
  this._stopSendingStats(session);
@@ -7446,6 +7457,17 @@ class WebRTCClient extends Emitter {
7446
7457
  };
7447
7458
  }
7448
7459
 
7460
+ _onEarlyProgress(session ) {
7461
+ this._setupMedias(session);
7462
+
7463
+ const sessionId = this.getSipSessionId(session).substr(0, 20);
7464
+ this.updateRemoteStream(sessionId);
7465
+
7466
+ logger.info('Early media progress progress received', { sessionId });
7467
+
7468
+ this.eventEmitter.emit(ON_EARLY_MEDIA, session);
7469
+ }
7470
+
7449
7471
  _onAccepted(session , sessionDialog , withEvent = true) {
7450
7472
  logger.info('on call accepted', { id: session.id, remoteTag: session.remoteTag });
7451
7473
 
@@ -7497,15 +7519,22 @@ class WebRTCClient extends Emitter {
7497
7519
 
7498
7520
  _setupMedias(session , newStream ) {
7499
7521
  // Safari hack, because you cannot call .play() from a non user action
7500
- const sessionId = this.getSipSessionId(session);
7522
+ const sessionId = this.getSipSessionId(session).substr(0, 20);
7501
7523
  const isConference = this.isConference(sessionId);
7502
7524
 
7525
+ if (sessionId in this.audioElements) {
7526
+ logger.info('html element already exists for session', { sessionId });
7527
+ return;
7528
+ }
7529
+
7503
7530
  if (this._hasAudio() && this._isWeb() && !(sessionId in this.audioElements)) {
7504
7531
  this.createAudioElementFor(sessionId);
7505
7532
  }
7506
7533
 
7507
7534
  const audioElement = this.audioElements[sessionId];
7508
- const stream = newStream || this.getRemoteStream(sessionId);
7535
+ const sipSession = this.sipSessions[session.callId];
7536
+ const removeStream = this.getRemoteStream(sessionId);
7537
+ const stream = newStream || removeStream || sipSession.sessionDescriptionHandler.remoteMediaStream;
7509
7538
 
7510
7539
  if (!this._isWeb() || !stream) {
7511
7540
  return;
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@wazo/sdk",
3
- "version": "0.38.16",
3
+ "version": "0.38.18",
4
4
  "description": "Wazo's JavaScript Software Development Kit.",
5
5
  "main": "dist/wazo-sdk.js",
6
6
  "author": "Wazo (http://wazo.io)",
package/src/api/chatd.js CHANGED
@@ -64,10 +64,13 @@ export default (client: ApiRequester, baseUrl: string) => ({
64
64
  createRoom: async (name: string, users: Array<ChatUser>): Promise<ChatRoom> =>
65
65
  client.post(`${baseUrl}/users/me/rooms`, { name, users }).then(ChatRoom.parse),
66
66
 
67
- getRoomMessages: async (roomUuid: string): Promise<Array<ChatMessage>> =>
68
- client
69
- .get(`${baseUrl}/users/me/rooms/${roomUuid}/messages`)
70
- .then((response: ChatMessageListResponse) => ChatMessage.parseMany(response)),
67
+ getRoomMessages: async (roomUuid: string, params: GetMessagesOptions = {}): Promise<Array<ChatMessage>> => {
68
+ const qs = ApiRequester.getQueryString(params);
69
+
70
+ return client
71
+ .get(`${baseUrl}/users/me/rooms/${roomUuid}/messages${qs.length ? `?${qs}` : ''}`)
72
+ .then((response: ChatMessageListResponse) => ChatMessage.parseMany(response));
73
+ },
71
74
 
72
75
  sendRoomMessage: async (roomUuid: string, message: ChatMessage): Promise<ChatMessage> =>
73
76
  client.post(`${baseUrl}/users/me/rooms/${roomUuid}/messages`, message).then(ChatMessage.parse),
@@ -54,6 +54,7 @@ export const ON_NETWORK_STATS = 'onNetworkStats';
54
54
  export const ON_CHAT = 'phone/ON_CHAT';
55
55
  export const ON_SIGNAL = 'phone/ON_SIGNAL';
56
56
  export const ON_DISCONNECTED = 'onDisconnected';
57
+ export const ON_EARLY_MEDIA = 'onEarlyMedia';
57
58
 
58
59
  export const MESSAGE_TYPE_CHAT = 'message/TYPE_CHAT';
59
60
  export const MESSAGE_TYPE_SIGNAL = 'message/TYPE_SIGNAL';
@@ -95,6 +96,7 @@ export const events = [
95
96
  ON_SIGNAL,
96
97
  ON_NETWORK_STATS,
97
98
  ON_DISCONNECTED,
99
+ ON_EARLY_MEDIA,
98
100
  ];
99
101
 
100
102
  const logger = IssueReporter.loggerFor('webrtc-phone');
@@ -1526,6 +1528,10 @@ export default class WebRTCPhone extends Emitter implements Phone {
1526
1528
  logger.info('WebRTC disconnected');
1527
1529
  this.eventEmitter.emit(ON_DISCONNECTED);
1528
1530
  });
1531
+ this.client.on(this.client.ON_EARLY_MEDIA, () => {
1532
+ logger.info('WebRTC early media');
1533
+ this.eventEmitter.emit(ON_EARLY_MEDIA);
1534
+ });
1529
1535
 
1530
1536
  this.client.on(this.client.REGISTERED, () => {
1531
1537
  logger.info('WebRTC registered', {
@@ -65,6 +65,7 @@ const MESSAGE = 'message';
65
65
  const ACCEPTED = 'accepted';
66
66
  const REJECTED = 'rejected';
67
67
  const ON_TRACK = 'onTrack';
68
+ const ON_EARLY_MEDIA = 'onEarlyMedia';
68
69
  const ON_REINVITE = 'reinvite';
69
70
  const ON_ERROR = 'onError';
70
71
  const ON_SCREEN_SHARING_REINVITE = 'onScreenSharingReinvite';
@@ -148,6 +149,7 @@ export default class WebRTCClient extends Emitter {
148
149
  ON_ERROR: string;
149
150
  ON_SCREEN_SHARING_REINVITE: string;
150
151
  ON_NETWORK_STATS: string;
152
+ ON_EARLY_MEDIA: string;
151
153
  ON_DISCONNECTED: string;
152
154
 
153
155
  static isAPrivateIp(ip: string): boolean {
@@ -216,6 +218,7 @@ export default class WebRTCClient extends Emitter {
216
218
  this.ON_SCREEN_SHARING_REINVITE = ON_SCREEN_SHARING_REINVITE;
217
219
  this.ON_NETWORK_STATS = ON_NETWORK_STATS;
218
220
  this.ON_DISCONNECTED = ON_DISCONNECTED;
221
+ this.ON_EARLY_MEDIA = ON_EARLY_MEDIA;
219
222
  }
220
223
 
221
224
  configureMedia(media: MediaConfig) {
@@ -503,6 +506,11 @@ export default class WebRTCClient extends Emitter {
503
506
  }
504
507
  this._onAccepted(session, response.session, true);
505
508
  },
509
+ onProgress: (payload) => {
510
+ if (payload.message.statusCode === 183) {
511
+ this._onEarlyProgress(payload.session);
512
+ }
513
+ },
506
514
  onReject: (response: IncomingResponse) => {
507
515
  logger.info('on call rejected', { id: session.id, fromTag: session.fromTag });
508
516
  this._stopSendingStats(session);
@@ -1895,6 +1903,17 @@ export default class WebRTCClient extends Emitter {
1895
1903
  };
1896
1904
  }
1897
1905
 
1906
+ _onEarlyProgress(session: SessionDialog) {
1907
+ this._setupMedias(session);
1908
+
1909
+ const sessionId = this.getSipSessionId(session).substr(0, 20);
1910
+ this.updateRemoteStream(sessionId);
1911
+
1912
+ logger.info('Early media progress progress received', { sessionId });
1913
+
1914
+ this.eventEmitter.emit(ON_EARLY_MEDIA, session);
1915
+ }
1916
+
1898
1917
  _onAccepted(session: Session, sessionDialog?: SessionDialog, withEvent: boolean = true) {
1899
1918
  logger.info('on call accepted', { id: session.id, remoteTag: session.remoteTag });
1900
1919
 
@@ -1946,15 +1965,22 @@ export default class WebRTCClient extends Emitter {
1946
1965
 
1947
1966
  _setupMedias(session: Session, newStream: ?MediaStream) {
1948
1967
  // Safari hack, because you cannot call .play() from a non user action
1949
- const sessionId = this.getSipSessionId(session);
1968
+ const sessionId = this.getSipSessionId(session).substr(0, 20);
1950
1969
  const isConference = this.isConference(sessionId);
1951
1970
 
1971
+ if (sessionId in this.audioElements) {
1972
+ logger.info('html element already exists for session', { sessionId });
1973
+ return;
1974
+ }
1975
+
1952
1976
  if (this._hasAudio() && this._isWeb() && !(sessionId in this.audioElements)) {
1953
1977
  this.createAudioElementFor(sessionId);
1954
1978
  }
1955
1979
 
1956
1980
  const audioElement = this.audioElements[sessionId];
1957
- const stream = newStream || this.getRemoteStream(sessionId);
1981
+ const sipSession = this.sipSessions[session.callId];
1982
+ const removeStream = this.getRemoteStream(sessionId);
1983
+ const stream = newStream || removeStream || sipSession.sessionDescriptionHandler.remoteMediaStream;
1958
1984
 
1959
1985
  if (!this._isWeb() || !stream) {
1960
1986
  return;