@wazo/sdk 0.37.28 → 0.37.32

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 (81) hide show
  1. package/README.md +2 -1
  2. package/dist/wazo-sdk.js +4 -4
  3. package/esm/__tests__/api-client.test.js +30 -0
  4. package/esm/__tests__/web-rtc-client.test.js +65 -6
  5. package/esm/api/calld.js +30 -0
  6. package/esm/api-client.js +30 -0
  7. package/esm/checker/Checker.js +65 -6
  8. package/esm/checker/checks/aor.js +30 -0
  9. package/esm/checker/checks/api.js +30 -0
  10. package/esm/checker/checks/index.js +65 -6
  11. package/esm/checker/checks/webrtc-transport.js +65 -6
  12. package/esm/checker/checks/webrtc.js +65 -6
  13. package/esm/domain/AdHocAPIConference.js +30 -0
  14. package/esm/domain/CallSession.js +15 -3
  15. package/esm/domain/Features.js +30 -0
  16. package/esm/domain/MeetingStatus.js +29 -0
  17. package/esm/domain/Phone/CTIPhone.js +45 -3
  18. package/esm/domain/Phone/WebRTCPhone.js +28 -6
  19. package/esm/domain/__tests__/CallSession.test.js +32 -3
  20. package/esm/domain/__tests__/IndirectTransfer.test.js +15 -3
  21. package/esm/domain/__tests__/Room.test.js +15 -3
  22. package/esm/index.js +93 -12
  23. package/esm/service/CallApi.js +30 -0
  24. package/esm/service/getApiClient.js +30 -0
  25. package/esm/simple/Auth.js +93 -12
  26. package/esm/simple/Configuration.js +93 -12
  27. package/esm/simple/Directory.js +30 -0
  28. package/esm/simple/Phone.js +93 -12
  29. package/esm/simple/index.js +93 -12
  30. package/esm/simple/room/LocalParticipant.js +93 -12
  31. package/esm/simple/room/Participant.js +93 -12
  32. package/esm/simple/room/RemoteParticipant.js +93 -12
  33. package/esm/simple/room/Room.js +93 -12
  34. package/esm/simple/room/SipRoom.js +93 -12
  35. package/esm/simple/room/Stream.js +93 -12
  36. package/esm/simple/room/__tests__/RemoteParticipant.test.js +93 -12
  37. package/esm/simple/utils.js +93 -12
  38. package/esm/web-rtc-client.js +65 -6
  39. package/lib/__tests__/api-client.test.js +30 -0
  40. package/lib/__tests__/web-rtc-client.test.js +65 -6
  41. package/lib/api/calld.js +30 -0
  42. package/lib/api-client.js +30 -0
  43. package/lib/checker/Checker.js +65 -6
  44. package/lib/checker/checks/aor.js +30 -0
  45. package/lib/checker/checks/api.js +30 -0
  46. package/lib/checker/checks/index.js +65 -6
  47. package/lib/checker/checks/webrtc-transport.js +65 -6
  48. package/lib/checker/checks/webrtc.js +65 -6
  49. package/lib/domain/AdHocAPIConference.js +30 -0
  50. package/lib/domain/CallSession.js +15 -3
  51. package/lib/domain/Features.js +30 -0
  52. package/lib/domain/MeetingStatus.js +31 -0
  53. package/lib/domain/Phone/CTIPhone.js +45 -3
  54. package/lib/domain/Phone/WebRTCPhone.js +28 -6
  55. package/lib/domain/__tests__/CallSession.test.js +32 -3
  56. package/lib/domain/__tests__/IndirectTransfer.test.js +15 -3
  57. package/lib/domain/__tests__/Room.test.js +15 -3
  58. package/lib/index.js +93 -12
  59. package/lib/service/CallApi.js +30 -0
  60. package/lib/service/getApiClient.js +30 -0
  61. package/lib/simple/Auth.js +93 -12
  62. package/lib/simple/Configuration.js +93 -12
  63. package/lib/simple/Directory.js +30 -0
  64. package/lib/simple/Phone.js +93 -12
  65. package/lib/simple/index.js +93 -12
  66. package/lib/simple/room/LocalParticipant.js +93 -12
  67. package/lib/simple/room/Participant.js +93 -12
  68. package/lib/simple/room/RemoteParticipant.js +93 -12
  69. package/lib/simple/room/Room.js +93 -12
  70. package/lib/simple/room/SipRoom.js +93 -12
  71. package/lib/simple/room/Stream.js +93 -12
  72. package/lib/simple/room/__tests__/RemoteParticipant.test.js +93 -12
  73. package/lib/simple/utils.js +93 -12
  74. package/lib/web-rtc-client.js +65 -6
  75. package/package.json +1 -1
  76. package/src/api/calld.js +3 -0
  77. package/src/domain/CallSession.js +16 -4
  78. package/src/domain/MeetingStatus.js +27 -0
  79. package/src/domain/Phone/WebRTCPhone.js +13 -3
  80. package/src/domain/__tests__/CallSession.test.js +17 -0
  81. package/src/web-rtc-client.js +35 -6
@@ -87,6 +87,7 @@ type WebRtcConfig = {
87
87
  displayName: string,
88
88
  host: string,
89
89
  port?: number,
90
+ websocketSip?: ?string,
90
91
  authorizationUser: ?string,
91
92
  password: ?string,
92
93
  uri: string,
@@ -128,6 +129,7 @@ export default class WebRTCClient extends Emitter {
128
129
  skipRegister: boolean;
129
130
  networkMonitoringInterval: { [string]: IntervalID };
130
131
  sessionNetworkStats: { [string]: Object };
132
+ forceClosed: boolean;
131
133
 
132
134
  // sugar
133
135
  ON_USER_AGENT: string;
@@ -190,6 +192,7 @@ export default class WebRTCClient extends Emitter {
190
192
  this.conferences = {};
191
193
  this.networkMonitoringInterval = {};
192
194
  this.sessionNetworkStats = {};
195
+ this.forceClosed = false;
193
196
 
194
197
  this._boundOnHeartbeat = this._onHeartbeat.bind(this);
195
198
  this.heartbeat = new Heartbeat(config.heartbeatDelay, config.heartbeatTimeout, config.maxHeartbeats);
@@ -311,6 +314,8 @@ export default class WebRTCClient extends Emitter {
311
314
  skipRegister: this.skipRegister,
312
315
  };
313
316
 
317
+ this.forceClosed = false;
318
+
314
319
  if (this.skipRegister) {
315
320
  logger.info('sdk webrtc skip register...', logInfo);
316
321
  return Promise.resolve();
@@ -335,7 +340,15 @@ export default class WebRTCClient extends Emitter {
335
340
  const registerOptions = this._isWeb() ? {} : { extraContactHeaderParams: ['mobility=mobile'] };
336
341
 
337
342
  const onRegisterFailed = () => {
338
- logger.info('sdk webrtc registering failed', { tries, registerer: !!this.registerer });
343
+ logger.info('sdk webrtc registering failed', {
344
+ tries,
345
+ registerer: !!this.registerer,
346
+ forceClosed: this.forceClosed,
347
+ });
348
+ if (this.forceClosed) {
349
+ return;
350
+ }
351
+
339
352
  this.connectionPromise = null;
340
353
  if (this.registerer && this.registerer.waiting) {
341
354
  this.registerer.waitingToggle(false);
@@ -613,8 +626,9 @@ export default class WebRTCClient extends Emitter {
613
626
  }
614
627
  }
615
628
 
616
- async close() {
617
- logger.info('sdk webrtc closing client', { userAgent: !!this.userAgent });
629
+ async close(force: boolean = false) {
630
+ logger.info('sdk webrtc closing client', { userAgent: !!this.userAgent, force });
631
+ this.forceClosed = force;
618
632
  this._cleanupMedia();
619
633
  this.connectionPromise = null;
620
634
 
@@ -633,7 +647,7 @@ export default class WebRTCClient extends Emitter {
633
647
  this.userAgent.delegate = null;
634
648
  this.userAgent.stateChange.removeAllListeners();
635
649
 
636
- await this._disconnectTransport();
650
+ await this._disconnectTransport(force);
637
651
 
638
652
  this._cleanupRegister();
639
653
 
@@ -1703,6 +1717,13 @@ export default class WebRTCClient extends Emitter {
1703
1717
  }
1704
1718
 
1705
1719
  _createWebRTCConfiguration(configOverrides: Object = {}) {
1720
+ let { host } = this.config;
1721
+ let port = this.config.port || 443;
1722
+
1723
+ if (this.config.websocketSip) {
1724
+ [host, port = 443] = this.config.websocketSip.split(':');
1725
+ }
1726
+
1706
1727
  const config: Object = {
1707
1728
  authorizationUsername: this.config.authorizationUser,
1708
1729
  authorizationPassword: this.config.password,
@@ -1738,7 +1759,7 @@ export default class WebRTCClient extends Emitter {
1738
1759
  },
1739
1760
  transportOptions: {
1740
1761
  traceSip: configOverrides.traceSip || false,
1741
- wsServers: `wss://${this.config.host}:${this.config.port || 443}/api/asterisk/ws`,
1762
+ wsServers: `wss://${host}:${port}/api/asterisk/ws`,
1742
1763
  },
1743
1764
  sessionDescriptionHandlerFactoryOptions: {
1744
1765
  modifiers: [replaceLocalIpModifier],
@@ -2062,7 +2083,15 @@ export default class WebRTCClient extends Emitter {
2062
2083
  return UserAgent.makeURI(`sip:${target}@${this.config.host}`);
2063
2084
  }
2064
2085
 
2065
- async _disconnectTransport() {
2086
+ async _disconnectTransport(force: boolean = false) {
2087
+ if (force) {
2088
+ // Bypass sip.js state machine that prevent to close WS with the state `Connecting`
2089
+ this.userAgent.transport.disconnectResolve = () => {};
2090
+ // eslint-disable-next-line
2091
+ this.userAgent.transport._ws.close(1000);
2092
+ return;
2093
+ }
2094
+
2066
2095
  // Check if `disconnectPromise` is not present to avoid `Disconnect promise must not be defined` errors.
2067
2096
  if (this.userAgent && this.userAgent.transport && !this.userAgent.transport.disconnectPromise) {
2068
2097
  try {