@wazo/sdk 0.37.26 → 0.37.27

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 (104) hide show
  1. package/README.md +95 -57
  2. package/dist/wazo-sdk.js +3 -3
  3. package/esm/__tests__/api-client.test.js +1 -1
  4. package/esm/__tests__/web-rtc-client.test.js +9 -4
  5. package/esm/api/agentd.js +1 -1
  6. package/esm/api/amid.js +1 -1
  7. package/esm/api/application.js +1 -1
  8. package/esm/api/auth.js +1 -1
  9. package/esm/api/call-logd.js +1 -1
  10. package/esm/api/calld.js +1 -1
  11. package/esm/api/chatd.js +1 -1
  12. package/esm/api/confd.js +1 -1
  13. package/esm/api/ctid-ng.js +1 -1
  14. package/esm/api/dird.js +1 -1
  15. package/esm/api/webhookd.js +1 -1
  16. package/esm/api-client.js +1 -1
  17. package/esm/checker/Checker.js +9 -4
  18. package/esm/checker/checks/aor.js +1 -1
  19. package/esm/checker/checks/api.js +1 -1
  20. package/esm/checker/checks/index.js +9 -4
  21. package/esm/checker/checks/wazo-websocket.js +1 -1
  22. package/esm/checker/checks/webrtc-transport.js +9 -4
  23. package/esm/checker/checks/webrtc.js +9 -4
  24. package/esm/domain/AdHocAPIConference.js +1 -1
  25. package/esm/domain/Features.js +1 -1
  26. package/esm/domain/Phone/CTIPhone.js +1 -1
  27. package/esm/domain/Phone/WebRTCPhone.js +7 -3
  28. package/esm/index.js +15 -6
  29. package/esm/lib/WazoSessionDescriptionHandler.js +9 -4
  30. package/esm/service/CallApi.js +1 -1
  31. package/esm/service/IssueReporter.js +1 -1
  32. package/esm/service/__tests__/IssueReporter.test.js +1 -1
  33. package/esm/service/getApiClient.js +1 -1
  34. package/esm/simple/Auth.js +15 -6
  35. package/esm/simple/Configuration.js +15 -6
  36. package/esm/simple/Directory.js +1 -1
  37. package/esm/simple/Phone.js +15 -6
  38. package/esm/simple/Websocket.js +1 -1
  39. package/esm/simple/index.js +15 -6
  40. package/esm/simple/room/LocalParticipant.js +15 -6
  41. package/esm/simple/room/Participant.js +15 -6
  42. package/esm/simple/room/RemoteParticipant.js +15 -6
  43. package/esm/simple/room/Room.js +15 -6
  44. package/esm/simple/room/SipRoom.js +15 -6
  45. package/esm/simple/room/Stream.js +15 -6
  46. package/esm/simple/room/__tests__/RemoteParticipant.test.js +15 -6
  47. package/esm/simple/utils.js +15 -6
  48. package/esm/utils/__tests__/api-requester.test.js +1 -1
  49. package/esm/utils/api-requester.js +1 -1
  50. package/esm/web-rtc-client.js +9 -4
  51. package/esm/websocket-client.js +1 -1
  52. package/lib/__tests__/api-client.test.js +1 -1
  53. package/lib/__tests__/web-rtc-client.test.js +9 -4
  54. package/lib/api/agentd.js +1 -1
  55. package/lib/api/amid.js +1 -1
  56. package/lib/api/application.js +1 -1
  57. package/lib/api/auth.js +1 -1
  58. package/lib/api/call-logd.js +1 -1
  59. package/lib/api/calld.js +1 -1
  60. package/lib/api/chatd.js +1 -1
  61. package/lib/api/confd.js +1 -1
  62. package/lib/api/ctid-ng.js +1 -1
  63. package/lib/api/dird.js +1 -1
  64. package/lib/api/webhookd.js +1 -1
  65. package/lib/api-client.js +1 -1
  66. package/lib/checker/Checker.js +9 -4
  67. package/lib/checker/checks/aor.js +1 -1
  68. package/lib/checker/checks/api.js +1 -1
  69. package/lib/checker/checks/index.js +9 -4
  70. package/lib/checker/checks/wazo-websocket.js +1 -1
  71. package/lib/checker/checks/webrtc-transport.js +9 -4
  72. package/lib/checker/checks/webrtc.js +9 -4
  73. package/lib/domain/AdHocAPIConference.js +1 -1
  74. package/lib/domain/Features.js +1 -1
  75. package/lib/domain/Phone/CTIPhone.js +1 -1
  76. package/lib/domain/Phone/WebRTCPhone.js +7 -3
  77. package/lib/index.js +15 -6
  78. package/lib/lib/WazoSessionDescriptionHandler.js +9 -4
  79. package/lib/service/CallApi.js +1 -1
  80. package/lib/service/IssueReporter.js +1 -1
  81. package/lib/service/__tests__/IssueReporter.test.js +1 -1
  82. package/lib/service/getApiClient.js +1 -1
  83. package/lib/simple/Auth.js +15 -6
  84. package/lib/simple/Configuration.js +15 -6
  85. package/lib/simple/Directory.js +1 -1
  86. package/lib/simple/Phone.js +15 -6
  87. package/lib/simple/Websocket.js +1 -1
  88. package/lib/simple/index.js +15 -6
  89. package/lib/simple/room/LocalParticipant.js +15 -6
  90. package/lib/simple/room/Participant.js +15 -6
  91. package/lib/simple/room/RemoteParticipant.js +15 -6
  92. package/lib/simple/room/Room.js +15 -6
  93. package/lib/simple/room/SipRoom.js +15 -6
  94. package/lib/simple/room/Stream.js +15 -6
  95. package/lib/simple/room/__tests__/RemoteParticipant.test.js +15 -6
  96. package/lib/simple/utils.js +15 -6
  97. package/lib/utils/__tests__/api-requester.test.js +1 -1
  98. package/lib/utils/api-requester.js +1 -1
  99. package/lib/web-rtc-client.js +9 -4
  100. package/lib/websocket-client.js +1 -1
  101. package/package.json +1 -1
  102. package/src/domain/Phone/WebRTCPhone.js +6 -2
  103. package/src/lib/WazoSessionDescriptionHandler.js +8 -3
  104. package/src/utils/api-requester.js +1 -1
@@ -444,7 +444,7 @@ const logger$1 = IssueReporter$1 ? IssueReporter$1.loggerFor('api') : console;
444
444
 
445
445
  // Use a function here to be able to mock it in tests
446
446
  const realFetch = () => {
447
- if (typeof document !== 'undefined') {
447
+ if (typeof document !== 'undefined' && window.fetch) {
448
448
  // Browser
449
449
  return window.fetch;
450
450
  }
@@ -104,7 +104,7 @@ const logger$2 = IssueReporter$1 ? IssueReporter$1.loggerFor('api') : console;
104
104
 
105
105
  // Use a function here to be able to mock it in tests
106
106
  const realFetch = () => {
107
- if (typeof document !== 'undefined') {
107
+ if (typeof document !== 'undefined' && window.fetch) {
108
108
  // Browser
109
109
  return window.fetch;
110
110
  }
@@ -823,11 +823,16 @@ class WazoSessionDescriptionHandler extends SessionDescriptionHandler {
823
823
 
824
824
  // $FlowFixMe
825
825
  setRemoteSessionDescription(sessionDescription ) {
826
- const result = super.setRemoteSessionDescription(sessionDescription);
826
+ try {
827
+ const result = super.setRemoteSessionDescription(sessionDescription);
827
828
 
828
- this.eventEmitter.emit('setDescription', sessionDescription);
829
+ this.eventEmitter.emit('setDescription', sessionDescription);
829
830
 
830
- return result;
831
+ return result;
832
+ } catch (error) {
833
+ this.logger.error('SessionDescriptionHandler.setRemoteSessionDescription error', error);
834
+ throw error;
835
+ }
831
836
  }
832
837
 
833
838
  // Overridden to avoid to fix ice-candidates missing in the SDP in react-native and chrome canary.
package/esm/api/agentd.js CHANGED
@@ -440,7 +440,7 @@ const logger = IssueReporter$1 ? IssueReporter$1.loggerFor('api') : console;
440
440
 
441
441
  // Use a function here to be able to mock it in tests
442
442
  const realFetch = () => {
443
- if (typeof document !== 'undefined') {
443
+ if (typeof document !== 'undefined' && window.fetch) {
444
444
  // Browser
445
445
  return window.fetch;
446
446
  }
package/esm/api/amid.js CHANGED
@@ -368,7 +368,7 @@ IssueReporter$1 ? IssueReporter$1.loggerFor('api') : console;
368
368
 
369
369
  // Use a function here to be able to mock it in tests
370
370
  const realFetch = () => {
371
- if (typeof document !== 'undefined') {
371
+ if (typeof document !== 'undefined' && window.fetch) {
372
372
  // Browser
373
373
  return window.fetch;
374
374
  }
@@ -440,7 +440,7 @@ const logger = IssueReporter$1 ? IssueReporter$1.loggerFor('api') : console;
440
440
 
441
441
  // Use a function here to be able to mock it in tests
442
442
  const realFetch = () => {
443
- if (typeof document !== 'undefined') {
443
+ if (typeof document !== 'undefined' && window.fetch) {
444
444
  // Browser
445
445
  return window.fetch;
446
446
  }
package/esm/api/auth.js CHANGED
@@ -441,7 +441,7 @@ const logger = IssueReporter$1 ? IssueReporter$1.loggerFor('api') : console;
441
441
 
442
442
  // Use a function here to be able to mock it in tests
443
443
  const realFetch = () => {
444
- if (typeof document !== 'undefined') {
444
+ if (typeof document !== 'undefined' && window.fetch) {
445
445
  // Browser
446
446
  return window.fetch;
447
447
  }
@@ -369,7 +369,7 @@ IssueReporter$1 ? IssueReporter$1.loggerFor('api') : console;
369
369
 
370
370
  // Use a function here to be able to mock it in tests
371
371
  const realFetch = () => {
372
- if (typeof document !== 'undefined') {
372
+ if (typeof document !== 'undefined' && window.fetch) {
373
373
  // Browser
374
374
  return window.fetch;
375
375
  }
package/esm/api/calld.js CHANGED
@@ -441,7 +441,7 @@ const logger = IssueReporter$1 ? IssueReporter$1.loggerFor('api') : console;
441
441
 
442
442
  // Use a function here to be able to mock it in tests
443
443
  const realFetch = () => {
444
- if (typeof document !== 'undefined') {
444
+ if (typeof document !== 'undefined' && window.fetch) {
445
445
  // Browser
446
446
  return window.fetch;
447
447
  }
package/esm/api/chatd.js CHANGED
@@ -440,7 +440,7 @@ const logger = IssueReporter$1 ? IssueReporter$1.loggerFor('api') : console;
440
440
 
441
441
  // Use a function here to be able to mock it in tests
442
442
  const realFetch = () => {
443
- if (typeof document !== 'undefined') {
443
+ if (typeof document !== 'undefined' && window.fetch) {
444
444
  // Browser
445
445
  return window.fetch;
446
446
  }
package/esm/api/confd.js CHANGED
@@ -440,7 +440,7 @@ const logger = IssueReporter$1 ? IssueReporter$1.loggerFor('api') : console;
440
440
 
441
441
  // Use a function here to be able to mock it in tests
442
442
  const realFetch = () => {
443
- if (typeof document !== 'undefined') {
443
+ if (typeof document !== 'undefined' && window.fetch) {
444
444
  // Browser
445
445
  return window.fetch;
446
446
  }
@@ -444,7 +444,7 @@ const logger = IssueReporter$1 ? IssueReporter$1.loggerFor('api') : console;
444
444
 
445
445
  // Use a function here to be able to mock it in tests
446
446
  const realFetch = () => {
447
- if (typeof document !== 'undefined') {
447
+ if (typeof document !== 'undefined' && window.fetch) {
448
448
  // Browser
449
449
  return window.fetch;
450
450
  }
package/esm/api/dird.js CHANGED
@@ -442,7 +442,7 @@ const logger = IssueReporter$1 ? IssueReporter$1.loggerFor('api') : console;
442
442
 
443
443
  // Use a function here to be able to mock it in tests
444
444
  const realFetch = () => {
445
- if (typeof document !== 'undefined') {
445
+ if (typeof document !== 'undefined' && window.fetch) {
446
446
  // Browser
447
447
  return window.fetch;
448
448
  }
@@ -368,7 +368,7 @@ IssueReporter$1 ? IssueReporter$1.loggerFor('api') : console;
368
368
 
369
369
  // Use a function here to be able to mock it in tests
370
370
  const realFetch = () => {
371
- if (typeof document !== 'undefined') {
371
+ if (typeof document !== 'undefined' && window.fetch) {
372
372
  // Browser
373
373
  return window.fetch;
374
374
  }
package/esm/api-client.js CHANGED
@@ -444,7 +444,7 @@ const logger$1 = IssueReporter$1 ? IssueReporter$1.loggerFor('api') : console;
444
444
 
445
445
  // Use a function here to be able to mock it in tests
446
446
  const realFetch = () => {
447
- if (typeof document !== 'undefined') {
447
+ if (typeof document !== 'undefined' && window.fetch) {
448
448
  // Browser
449
449
  return window.fetch;
450
450
  }
@@ -462,7 +462,7 @@ const logger$4 = IssueReporter$1 ? IssueReporter$1.loggerFor('api') : console;
462
462
 
463
463
  // Use a function here to be able to mock it in tests
464
464
  const realFetch = () => {
465
- if (typeof document !== 'undefined') {
465
+ if (typeof document !== 'undefined' && window.fetch) {
466
466
  // Browser
467
467
  return window.fetch;
468
468
  }
@@ -5479,11 +5479,16 @@ class WazoSessionDescriptionHandler extends SessionDescriptionHandler {
5479
5479
 
5480
5480
  // $FlowFixMe
5481
5481
  setRemoteSessionDescription(sessionDescription ) {
5482
- const result = super.setRemoteSessionDescription(sessionDescription);
5482
+ try {
5483
+ const result = super.setRemoteSessionDescription(sessionDescription);
5483
5484
 
5484
- this.eventEmitter.emit('setDescription', sessionDescription);
5485
+ this.eventEmitter.emit('setDescription', sessionDescription);
5485
5486
 
5486
- return result;
5487
+ return result;
5488
+ } catch (error) {
5489
+ this.logger.error('SessionDescriptionHandler.setRemoteSessionDescription error', error);
5490
+ throw error;
5491
+ }
5487
5492
  }
5488
5493
 
5489
5494
  // Overridden to avoid to fix ice-candidates missing in the SDP in react-native and chrome canary.
@@ -444,7 +444,7 @@ const logger$1 = IssueReporter$1 ? IssueReporter$1.loggerFor('api') : console;
444
444
 
445
445
  // Use a function here to be able to mock it in tests
446
446
  const realFetch = () => {
447
- if (typeof document !== 'undefined') {
447
+ if (typeof document !== 'undefined' && window.fetch) {
448
448
  // Browser
449
449
  return window.fetch;
450
450
  }
@@ -444,7 +444,7 @@ const logger$1 = IssueReporter$1 ? IssueReporter$1.loggerFor('api') : console;
444
444
 
445
445
  // Use a function here to be able to mock it in tests
446
446
  const realFetch = () => {
447
- if (typeof document !== 'undefined') {
447
+ if (typeof document !== 'undefined' && window.fetch) {
448
448
  // Browser
449
449
  return window.fetch;
450
450
  }
@@ -462,7 +462,7 @@ const logger$3 = IssueReporter$1 ? IssueReporter$1.loggerFor('api') : console;
462
462
 
463
463
  // Use a function here to be able to mock it in tests
464
464
  const realFetch = () => {
465
- if (typeof document !== 'undefined') {
465
+ if (typeof document !== 'undefined' && window.fetch) {
466
466
  // Browser
467
467
  return window.fetch;
468
468
  }
@@ -5479,11 +5479,16 @@ class WazoSessionDescriptionHandler extends SessionDescriptionHandler {
5479
5479
 
5480
5480
  // $FlowFixMe
5481
5481
  setRemoteSessionDescription(sessionDescription ) {
5482
- const result = super.setRemoteSessionDescription(sessionDescription);
5482
+ try {
5483
+ const result = super.setRemoteSessionDescription(sessionDescription);
5483
5484
 
5484
- this.eventEmitter.emit('setDescription', sessionDescription);
5485
+ this.eventEmitter.emit('setDescription', sessionDescription);
5485
5486
 
5486
- return result;
5487
+ return result;
5488
+ } catch (error) {
5489
+ this.logger.error('SessionDescriptionHandler.setRemoteSessionDescription error', error);
5490
+ throw error;
5491
+ }
5487
5492
  }
5488
5493
 
5489
5494
  // Overridden to avoid to fix ice-candidates missing in the SDP in react-native and chrome canary.
@@ -39,7 +39,7 @@ IssueReporter$1 ? IssueReporter$1.loggerFor('api') : console;
39
39
 
40
40
  // Use a function here to be able to mock it in tests
41
41
  const realFetch = () => {
42
- if (typeof document !== 'undefined') {
42
+ if (typeof document !== 'undefined' && window.fetch) {
43
43
  // Browser
44
44
  return window.fetch;
45
45
  }
@@ -104,7 +104,7 @@ const logger$2 = IssueReporter$1 ? IssueReporter$1.loggerFor('api') : console;
104
104
 
105
105
  // Use a function here to be able to mock it in tests
106
106
  const realFetch = () => {
107
- if (typeof document !== 'undefined') {
107
+ if (typeof document !== 'undefined' && window.fetch) {
108
108
  // Browser
109
109
  return window.fetch;
110
110
  }
@@ -823,11 +823,16 @@ class WazoSessionDescriptionHandler extends SessionDescriptionHandler {
823
823
 
824
824
  // $FlowFixMe
825
825
  setRemoteSessionDescription(sessionDescription ) {
826
- const result = super.setRemoteSessionDescription(sessionDescription);
826
+ try {
827
+ const result = super.setRemoteSessionDescription(sessionDescription);
827
828
 
828
- this.eventEmitter.emit('setDescription', sessionDescription);
829
+ this.eventEmitter.emit('setDescription', sessionDescription);
829
830
 
830
- return result;
831
+ return result;
832
+ } catch (error) {
833
+ this.logger.error('SessionDescriptionHandler.setRemoteSessionDescription error', error);
834
+ throw error;
835
+ }
831
836
  }
832
837
 
833
838
  // Overridden to avoid to fix ice-candidates missing in the SDP in react-native and chrome canary.
@@ -104,7 +104,7 @@ const logger$2 = IssueReporter$1 ? IssueReporter$1.loggerFor('api') : console;
104
104
 
105
105
  // Use a function here to be able to mock it in tests
106
106
  const realFetch = () => {
107
- if (typeof document !== 'undefined') {
107
+ if (typeof document !== 'undefined' && window.fetch) {
108
108
  // Browser
109
109
  return window.fetch;
110
110
  }
@@ -823,11 +823,16 @@ class WazoSessionDescriptionHandler extends SessionDescriptionHandler {
823
823
 
824
824
  // $FlowFixMe
825
825
  setRemoteSessionDescription(sessionDescription ) {
826
- const result = super.setRemoteSessionDescription(sessionDescription);
826
+ try {
827
+ const result = super.setRemoteSessionDescription(sessionDescription);
827
828
 
828
- this.eventEmitter.emit('setDescription', sessionDescription);
829
+ this.eventEmitter.emit('setDescription', sessionDescription);
829
830
 
830
- return result;
831
+ return result;
832
+ } catch (error) {
833
+ this.logger.error('SessionDescriptionHandler.setRemoteSessionDescription error', error);
834
+ throw error;
835
+ }
831
836
  }
832
837
 
833
838
  // Overridden to avoid to fix ice-candidates missing in the SDP in react-native and chrome canary.
@@ -664,7 +664,7 @@ const logger$1 = IssueReporter$1 ? IssueReporter$1.loggerFor('api') : console;
664
664
 
665
665
  // Use a function here to be able to mock it in tests
666
666
  const realFetch = () => {
667
- if (typeof document !== 'undefined') {
667
+ if (typeof document !== 'undefined' && window.fetch) {
668
668
  // Browser
669
669
  return window.fetch;
670
670
  }
@@ -444,7 +444,7 @@ const logger$1 = IssueReporter$1 ? IssueReporter$1.loggerFor('api') : console;
444
444
 
445
445
  // Use a function here to be able to mock it in tests
446
446
  const realFetch = () => {
447
- if (typeof document !== 'undefined') {
447
+ if (typeof document !== 'undefined' && window.fetch) {
448
448
  // Browser
449
449
  return window.fetch;
450
450
  }
@@ -2837,7 +2837,7 @@ const logger$2 = IssueReporter$1 ? IssueReporter$1.loggerFor('api') : console;
2837
2837
 
2838
2838
  // Use a function here to be able to mock it in tests
2839
2839
  const realFetch = () => {
2840
- if (typeof document !== 'undefined') {
2840
+ if (typeof document !== 'undefined' && window.fetch) {
2841
2841
  // Browser
2842
2842
  return window.fetch;
2843
2843
  }
@@ -405,7 +405,7 @@ IssueReporter$1 ? IssueReporter$1.loggerFor('api') : console;
405
405
 
406
406
  // Use a function here to be able to mock it in tests
407
407
  const realFetch = () => {
408
- if (typeof document !== 'undefined') {
408
+ if (typeof document !== 'undefined' && window.fetch) {
409
409
  // Browser
410
410
  return window.fetch;
411
411
  }
@@ -1530,6 +1530,7 @@ class WebRTCPhone extends Emitter {
1530
1530
  _onCallTerminated(sipSession ) {
1531
1531
  logger.info('WebRTC phone - on call terminated', { sipId: sipSession.id });
1532
1532
 
1533
+ const sipSessionId = this.getSipSessionId(sipSession);
1533
1534
  const callSession = this._createCallSession(sipSession);
1534
1535
  const isCurrentSession = this.isCurrentCallSipSession(callSession);
1535
1536
  const isCurrentIncomingCall = callSession.is(this.getIncomingCallSession());
@@ -1547,7 +1548,6 @@ class WebRTCPhone extends Emitter {
1547
1548
  }, 5);
1548
1549
  }
1549
1550
 
1550
- const sipSessionId = this.getSipSessionId(sipSession);
1551
1551
  if (sipSessionId) {
1552
1552
  this.removeIncomingSessions(sipSessionId);
1553
1553
  }
@@ -2192,8 +2192,12 @@ class WebRTCPhone extends Emitter {
2192
2192
  }
2193
2193
 
2194
2194
  const sessionId = this.incomingSessions[0];
2195
+ const sipSession = this.client.getSipSession(sessionId);
2196
+ if (!sipSession) {
2197
+ return null;
2198
+ }
2195
2199
 
2196
- return this._createCallSession(this.client.getSipSession(sessionId));
2200
+ return this._createCallSession(sipSession);
2197
2201
  }
2198
2202
 
2199
2203
  sendMessage(sipSession = null, body , contentType = 'text/plain') {
package/esm/index.js CHANGED
@@ -464,7 +464,7 @@ const logger$c = IssueReporter$1 ? IssueReporter$1.loggerFor('api') : console;
464
464
 
465
465
  // Use a function here to be able to mock it in tests
466
466
  const realFetch = () => {
467
- if (typeof document !== 'undefined') {
467
+ if (typeof document !== 'undefined' && window.fetch) {
468
468
  // Browser
469
469
  return window.fetch;
470
470
  }
@@ -5624,11 +5624,16 @@ class WazoSessionDescriptionHandler extends SessionDescriptionHandler {
5624
5624
 
5625
5625
  // $FlowFixMe
5626
5626
  setRemoteSessionDescription(sessionDescription ) {
5627
- const result = super.setRemoteSessionDescription(sessionDescription);
5627
+ try {
5628
+ const result = super.setRemoteSessionDescription(sessionDescription);
5628
5629
 
5629
- this.eventEmitter.emit('setDescription', sessionDescription);
5630
+ this.eventEmitter.emit('setDescription', sessionDescription);
5630
5631
 
5631
- return result;
5632
+ return result;
5633
+ } catch (error) {
5634
+ this.logger.error('SessionDescriptionHandler.setRemoteSessionDescription error', error);
5635
+ throw error;
5636
+ }
5632
5637
  }
5633
5638
 
5634
5639
  // Overridden to avoid to fix ice-candidates missing in the SDP in react-native and chrome canary.
@@ -9825,6 +9830,7 @@ class WebRTCPhone extends Emitter {
9825
9830
  _onCallTerminated(sipSession ) {
9826
9831
  logger$7.info('WebRTC phone - on call terminated', { sipId: sipSession.id });
9827
9832
 
9833
+ const sipSessionId = this.getSipSessionId(sipSession);
9828
9834
  const callSession = this._createCallSession(sipSession);
9829
9835
  const isCurrentSession = this.isCurrentCallSipSession(callSession);
9830
9836
  const isCurrentIncomingCall = callSession.is(this.getIncomingCallSession());
@@ -9842,7 +9848,6 @@ class WebRTCPhone extends Emitter {
9842
9848
  }, 5);
9843
9849
  }
9844
9850
 
9845
- const sipSessionId = this.getSipSessionId(sipSession);
9846
9851
  if (sipSessionId) {
9847
9852
  this.removeIncomingSessions(sipSessionId);
9848
9853
  }
@@ -10487,8 +10492,12 @@ class WebRTCPhone extends Emitter {
10487
10492
  }
10488
10493
 
10489
10494
  const sessionId = this.incomingSessions[0];
10495
+ const sipSession = this.client.getSipSession(sessionId);
10496
+ if (!sipSession) {
10497
+ return null;
10498
+ }
10490
10499
 
10491
- return this._createCallSession(this.client.getSipSession(sessionId));
10500
+ return this._createCallSession(sipSession);
10492
10501
  }
10493
10502
 
10494
10503
  sendMessage(sipSession = null, body , contentType = 'text/plain') {
@@ -15,7 +15,7 @@ IssueReporter$1 ? IssueReporter$1.loggerFor('api') : console;
15
15
 
16
16
  // Use a function here to be able to mock it in tests
17
17
  const realFetch = () => {
18
- if (typeof document !== 'undefined') {
18
+ if (typeof document !== 'undefined' && window.fetch) {
19
19
  // Browser
20
20
  return window.fetch;
21
21
  }
@@ -487,11 +487,16 @@ class WazoSessionDescriptionHandler extends SessionDescriptionHandler {
487
487
 
488
488
  // $FlowFixMe
489
489
  setRemoteSessionDescription(sessionDescription ) {
490
- const result = super.setRemoteSessionDescription(sessionDescription);
490
+ try {
491
+ const result = super.setRemoteSessionDescription(sessionDescription);
491
492
 
492
- this.eventEmitter.emit('setDescription', sessionDescription);
493
+ this.eventEmitter.emit('setDescription', sessionDescription);
493
494
 
494
- return result;
495
+ return result;
496
+ } catch (error) {
497
+ this.logger.error('SessionDescriptionHandler.setRemoteSessionDescription error', error);
498
+ throw error;
499
+ }
495
500
  }
496
501
 
497
502
  // Overridden to avoid to fix ice-candidates missing in the SDP in react-native and chrome canary.
@@ -2466,7 +2466,7 @@ const logger$1 = IssueReporter$1 ? IssueReporter$1.loggerFor('api') : console;
2466
2466
 
2467
2467
  // Use a function here to be able to mock it in tests
2468
2468
  const realFetch = () => {
2469
- if (typeof document !== 'undefined') {
2469
+ if (typeof document !== 'undefined' && window.fetch) {
2470
2470
  // Browser
2471
2471
  return window.fetch;
2472
2472
  }
@@ -11,7 +11,7 @@ IssueReporter$1 ? IssueReporter$1.loggerFor('api') : console;
11
11
 
12
12
  // Use a function here to be able to mock it in tests
13
13
  const realFetch = () => {
14
- if (typeof document !== 'undefined') {
14
+ if (typeof document !== 'undefined' && window.fetch) {
15
15
  // Browser
16
16
  return window.fetch;
17
17
  }
@@ -11,7 +11,7 @@ IssueReporter$1 ? IssueReporter$1.loggerFor('api') : console;
11
11
 
12
12
  // Use a function here to be able to mock it in tests
13
13
  const realFetch = () => {
14
- if (typeof document !== 'undefined') {
14
+ if (typeof document !== 'undefined' && window.fetch) {
15
15
  // Browser
16
16
  return window.fetch;
17
17
  }
@@ -444,7 +444,7 @@ const logger$1 = IssueReporter$1 ? IssueReporter$1.loggerFor('api') : console;
444
444
 
445
445
  // Use a function here to be able to mock it in tests
446
446
  const realFetch = () => {
447
- if (typeof document !== 'undefined') {
447
+ if (typeof document !== 'undefined' && window.fetch) {
448
448
  // Browser
449
449
  return window.fetch;
450
450
  }
@@ -1951,7 +1951,7 @@ const logger$c = IssueReporter$1 ? IssueReporter$1.loggerFor('api') : console;
1951
1951
 
1952
1952
  // Use a function here to be able to mock it in tests
1953
1953
  const realFetch = () => {
1954
- if (typeof document !== 'undefined') {
1954
+ if (typeof document !== 'undefined' && window.fetch) {
1955
1955
  // Browser
1956
1956
  return window.fetch;
1957
1957
  }
@@ -5798,11 +5798,16 @@ class WazoSessionDescriptionHandler extends SessionDescriptionHandler {
5798
5798
 
5799
5799
  // $FlowFixMe
5800
5800
  setRemoteSessionDescription(sessionDescription ) {
5801
- const result = super.setRemoteSessionDescription(sessionDescription);
5801
+ try {
5802
+ const result = super.setRemoteSessionDescription(sessionDescription);
5802
5803
 
5803
- this.eventEmitter.emit('setDescription', sessionDescription);
5804
+ this.eventEmitter.emit('setDescription', sessionDescription);
5804
5805
 
5805
- return result;
5806
+ return result;
5807
+ } catch (error) {
5808
+ this.logger.error('SessionDescriptionHandler.setRemoteSessionDescription error', error);
5809
+ throw error;
5810
+ }
5806
5811
  }
5807
5812
 
5808
5813
  // Overridden to avoid to fix ice-candidates missing in the SDP in react-native and chrome canary.
@@ -9106,6 +9111,7 @@ class WebRTCPhone extends Emitter {
9106
9111
  _onCallTerminated(sipSession ) {
9107
9112
  logger$8.info('WebRTC phone - on call terminated', { sipId: sipSession.id });
9108
9113
 
9114
+ const sipSessionId = this.getSipSessionId(sipSession);
9109
9115
  const callSession = this._createCallSession(sipSession);
9110
9116
  const isCurrentSession = this.isCurrentCallSipSession(callSession);
9111
9117
  const isCurrentIncomingCall = callSession.is(this.getIncomingCallSession());
@@ -9123,7 +9129,6 @@ class WebRTCPhone extends Emitter {
9123
9129
  }, 5);
9124
9130
  }
9125
9131
 
9126
- const sipSessionId = this.getSipSessionId(sipSession);
9127
9132
  if (sipSessionId) {
9128
9133
  this.removeIncomingSessions(sipSessionId);
9129
9134
  }
@@ -9768,8 +9773,12 @@ class WebRTCPhone extends Emitter {
9768
9773
  }
9769
9774
 
9770
9775
  const sessionId = this.incomingSessions[0];
9776
+ const sipSession = this.client.getSipSession(sessionId);
9777
+ if (!sipSession) {
9778
+ return null;
9779
+ }
9771
9780
 
9772
- return this._createCallSession(this.client.getSipSession(sessionId));
9781
+ return this._createCallSession(sipSession);
9773
9782
  }
9774
9783
 
9775
9784
  sendMessage(sipSession = null, body , contentType = 'text/plain') {
@@ -1951,7 +1951,7 @@ const logger$c = IssueReporter$1 ? IssueReporter$1.loggerFor('api') : console;
1951
1951
 
1952
1952
  // Use a function here to be able to mock it in tests
1953
1953
  const realFetch = () => {
1954
- if (typeof document !== 'undefined') {
1954
+ if (typeof document !== 'undefined' && window.fetch) {
1955
1955
  // Browser
1956
1956
  return window.fetch;
1957
1957
  }
@@ -5798,11 +5798,16 @@ class WazoSessionDescriptionHandler extends SessionDescriptionHandler {
5798
5798
 
5799
5799
  // $FlowFixMe
5800
5800
  setRemoteSessionDescription(sessionDescription ) {
5801
- const result = super.setRemoteSessionDescription(sessionDescription);
5801
+ try {
5802
+ const result = super.setRemoteSessionDescription(sessionDescription);
5802
5803
 
5803
- this.eventEmitter.emit('setDescription', sessionDescription);
5804
+ this.eventEmitter.emit('setDescription', sessionDescription);
5804
5805
 
5805
- return result;
5806
+ return result;
5807
+ } catch (error) {
5808
+ this.logger.error('SessionDescriptionHandler.setRemoteSessionDescription error', error);
5809
+ throw error;
5810
+ }
5806
5811
  }
5807
5812
 
5808
5813
  // Overridden to avoid to fix ice-candidates missing in the SDP in react-native and chrome canary.
@@ -9106,6 +9111,7 @@ class WebRTCPhone extends Emitter {
9106
9111
  _onCallTerminated(sipSession ) {
9107
9112
  logger$8.info('WebRTC phone - on call terminated', { sipId: sipSession.id });
9108
9113
 
9114
+ const sipSessionId = this.getSipSessionId(sipSession);
9109
9115
  const callSession = this._createCallSession(sipSession);
9110
9116
  const isCurrentSession = this.isCurrentCallSipSession(callSession);
9111
9117
  const isCurrentIncomingCall = callSession.is(this.getIncomingCallSession());
@@ -9123,7 +9129,6 @@ class WebRTCPhone extends Emitter {
9123
9129
  }, 5);
9124
9130
  }
9125
9131
 
9126
- const sipSessionId = this.getSipSessionId(sipSession);
9127
9132
  if (sipSessionId) {
9128
9133
  this.removeIncomingSessions(sipSessionId);
9129
9134
  }
@@ -9768,8 +9773,12 @@ class WebRTCPhone extends Emitter {
9768
9773
  }
9769
9774
 
9770
9775
  const sessionId = this.incomingSessions[0];
9776
+ const sipSession = this.client.getSipSession(sessionId);
9777
+ if (!sipSession) {
9778
+ return null;
9779
+ }
9771
9780
 
9772
- return this._createCallSession(this.client.getSipSession(sessionId));
9781
+ return this._createCallSession(sipSession);
9773
9782
  }
9774
9783
 
9775
9784
  sendMessage(sipSession = null, body , contentType = 'text/plain') {
@@ -444,7 +444,7 @@ const logger$1 = IssueReporter$1 ? IssueReporter$1.loggerFor('api') : console;
444
444
 
445
445
  // Use a function here to be able to mock it in tests
446
446
  const realFetch = () => {
447
- if (typeof document !== 'undefined') {
447
+ if (typeof document !== 'undefined' && window.fetch) {
448
448
  // Browser
449
449
  return window.fetch;
450
450
  }