@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
@@ -113,7 +113,7 @@ const logger$2 = IssueReporter$1 ? IssueReporter$1.loggerFor('api') : console;
113
113
 
114
114
  // Use a function here to be able to mock it in tests
115
115
  const realFetch = () => {
116
- if (typeof document !== 'undefined') {
116
+ if (typeof document !== 'undefined' && window.fetch) {
117
117
  // Browser
118
118
  return window.fetch;
119
119
  }
@@ -832,11 +832,16 @@ class WazoSessionDescriptionHandler extends sessionDescriptionHandler.SessionDes
832
832
 
833
833
  // $FlowFixMe
834
834
  setRemoteSessionDescription(sessionDescription ) {
835
- const result = super.setRemoteSessionDescription(sessionDescription);
835
+ try {
836
+ const result = super.setRemoteSessionDescription(sessionDescription);
836
837
 
837
- this.eventEmitter.emit('setDescription', sessionDescription);
838
+ this.eventEmitter.emit('setDescription', sessionDescription);
838
839
 
839
- return result;
840
+ return result;
841
+ } catch (error) {
842
+ this.logger.error('SessionDescriptionHandler.setRemoteSessionDescription error', error);
843
+ throw error;
844
+ }
840
845
  }
841
846
 
842
847
  // Overridden to avoid to fix ice-candidates missing in the SDP in react-native and chrome canary.
package/lib/api/agentd.js CHANGED
@@ -446,7 +446,7 @@ const logger = IssueReporter$1 ? IssueReporter$1.loggerFor('api') : console;
446
446
 
447
447
  // Use a function here to be able to mock it in tests
448
448
  const realFetch = () => {
449
- if (typeof document !== 'undefined') {
449
+ if (typeof document !== 'undefined' && window.fetch) {
450
450
  // Browser
451
451
  return window.fetch;
452
452
  }
package/lib/api/amid.js CHANGED
@@ -374,7 +374,7 @@ IssueReporter$1 ? IssueReporter$1.loggerFor('api') : console;
374
374
 
375
375
  // Use a function here to be able to mock it in tests
376
376
  const realFetch = () => {
377
- if (typeof document !== 'undefined') {
377
+ if (typeof document !== 'undefined' && window.fetch) {
378
378
  // Browser
379
379
  return window.fetch;
380
380
  }
@@ -446,7 +446,7 @@ const logger = IssueReporter$1 ? IssueReporter$1.loggerFor('api') : console;
446
446
 
447
447
  // Use a function here to be able to mock it in tests
448
448
  const realFetch = () => {
449
- if (typeof document !== 'undefined') {
449
+ if (typeof document !== 'undefined' && window.fetch) {
450
450
  // Browser
451
451
  return window.fetch;
452
452
  }
package/lib/api/auth.js CHANGED
@@ -449,7 +449,7 @@ const logger = IssueReporter$1 ? IssueReporter$1.loggerFor('api') : console;
449
449
 
450
450
  // Use a function here to be able to mock it in tests
451
451
  const realFetch = () => {
452
- if (typeof document !== 'undefined') {
452
+ if (typeof document !== 'undefined' && window.fetch) {
453
453
  // Browser
454
454
  return window.fetch;
455
455
  }
@@ -375,7 +375,7 @@ IssueReporter$1 ? IssueReporter$1.loggerFor('api') : console;
375
375
 
376
376
  // Use a function here to be able to mock it in tests
377
377
  const realFetch = () => {
378
- if (typeof document !== 'undefined') {
378
+ if (typeof document !== 'undefined' && window.fetch) {
379
379
  // Browser
380
380
  return window.fetch;
381
381
  }
package/lib/api/calld.js CHANGED
@@ -447,7 +447,7 @@ const logger = IssueReporter$1 ? IssueReporter$1.loggerFor('api') : console;
447
447
 
448
448
  // Use a function here to be able to mock it in tests
449
449
  const realFetch = () => {
450
- if (typeof document !== 'undefined') {
450
+ if (typeof document !== 'undefined' && window.fetch) {
451
451
  // Browser
452
452
  return window.fetch;
453
453
  }
package/lib/api/chatd.js CHANGED
@@ -446,7 +446,7 @@ const logger = IssueReporter$1 ? IssueReporter$1.loggerFor('api') : console;
446
446
 
447
447
  // Use a function here to be able to mock it in tests
448
448
  const realFetch = () => {
449
- if (typeof document !== 'undefined') {
449
+ if (typeof document !== 'undefined' && window.fetch) {
450
450
  // Browser
451
451
  return window.fetch;
452
452
  }
package/lib/api/confd.js CHANGED
@@ -446,7 +446,7 @@ const logger = IssueReporter$1 ? IssueReporter$1.loggerFor('api') : console;
446
446
 
447
447
  // Use a function here to be able to mock it in tests
448
448
  const realFetch = () => {
449
- if (typeof document !== 'undefined') {
449
+ if (typeof document !== 'undefined' && window.fetch) {
450
450
  // Browser
451
451
  return window.fetch;
452
452
  }
@@ -450,7 +450,7 @@ const logger = IssueReporter$1 ? IssueReporter$1.loggerFor('api') : console;
450
450
 
451
451
  // Use a function here to be able to mock it in tests
452
452
  const realFetch = () => {
453
- if (typeof document !== 'undefined') {
453
+ if (typeof document !== 'undefined' && window.fetch) {
454
454
  // Browser
455
455
  return window.fetch;
456
456
  }
package/lib/api/dird.js CHANGED
@@ -448,7 +448,7 @@ const logger = IssueReporter$1 ? IssueReporter$1.loggerFor('api') : console;
448
448
 
449
449
  // Use a function here to be able to mock it in tests
450
450
  const realFetch = () => {
451
- if (typeof document !== 'undefined') {
451
+ if (typeof document !== 'undefined' && window.fetch) {
452
452
  // Browser
453
453
  return window.fetch;
454
454
  }
@@ -374,7 +374,7 @@ IssueReporter$1 ? IssueReporter$1.loggerFor('api') : console;
374
374
 
375
375
  // Use a function here to be able to mock it in tests
376
376
  const realFetch = () => {
377
- if (typeof document !== 'undefined') {
377
+ if (typeof document !== 'undefined' && window.fetch) {
378
378
  // Browser
379
379
  return window.fetch;
380
380
  }
package/lib/api-client.js CHANGED
@@ -450,7 +450,7 @@ const logger$1 = IssueReporter$1 ? IssueReporter$1.loggerFor('api') : console;
450
450
 
451
451
  // Use a function here to be able to mock it in tests
452
452
  const realFetch = () => {
453
- if (typeof document !== 'undefined') {
453
+ if (typeof document !== 'undefined' && window.fetch) {
454
454
  // Browser
455
455
  return window.fetch;
456
456
  }
@@ -472,7 +472,7 @@ const logger$4 = IssueReporter$1 ? IssueReporter$1.loggerFor('api') : console;
472
472
 
473
473
  // Use a function here to be able to mock it in tests
474
474
  const realFetch = () => {
475
- if (typeof document !== 'undefined') {
475
+ if (typeof document !== 'undefined' && window.fetch) {
476
476
  // Browser
477
477
  return window.fetch;
478
478
  }
@@ -5489,11 +5489,16 @@ class WazoSessionDescriptionHandler extends sessionDescriptionHandler.SessionDes
5489
5489
 
5490
5490
  // $FlowFixMe
5491
5491
  setRemoteSessionDescription(sessionDescription ) {
5492
- const result = super.setRemoteSessionDescription(sessionDescription);
5492
+ try {
5493
+ const result = super.setRemoteSessionDescription(sessionDescription);
5493
5494
 
5494
- this.eventEmitter.emit('setDescription', sessionDescription);
5495
+ this.eventEmitter.emit('setDescription', sessionDescription);
5495
5496
 
5496
- return result;
5497
+ return result;
5498
+ } catch (error) {
5499
+ this.logger.error('SessionDescriptionHandler.setRemoteSessionDescription error', error);
5500
+ throw error;
5501
+ }
5497
5502
  }
5498
5503
 
5499
5504
  // Overridden to avoid to fix ice-candidates missing in the SDP in react-native and chrome canary.
@@ -450,7 +450,7 @@ const logger$1 = IssueReporter$1 ? IssueReporter$1.loggerFor('api') : console;
450
450
 
451
451
  // Use a function here to be able to mock it in tests
452
452
  const realFetch = () => {
453
- if (typeof document !== 'undefined') {
453
+ if (typeof document !== 'undefined' && window.fetch) {
454
454
  // Browser
455
455
  return window.fetch;
456
456
  }
@@ -450,7 +450,7 @@ const logger$1 = IssueReporter$1 ? IssueReporter$1.loggerFor('api') : console;
450
450
 
451
451
  // Use a function here to be able to mock it in tests
452
452
  const realFetch = () => {
453
- if (typeof document !== 'undefined') {
453
+ if (typeof document !== 'undefined' && window.fetch) {
454
454
  // Browser
455
455
  return window.fetch;
456
456
  }
@@ -472,7 +472,7 @@ const logger$3 = IssueReporter$1 ? IssueReporter$1.loggerFor('api') : console;
472
472
 
473
473
  // Use a function here to be able to mock it in tests
474
474
  const realFetch = () => {
475
- if (typeof document !== 'undefined') {
475
+ if (typeof document !== 'undefined' && window.fetch) {
476
476
  // Browser
477
477
  return window.fetch;
478
478
  }
@@ -5489,11 +5489,16 @@ class WazoSessionDescriptionHandler extends sessionDescriptionHandler.SessionDes
5489
5489
 
5490
5490
  // $FlowFixMe
5491
5491
  setRemoteSessionDescription(sessionDescription ) {
5492
- const result = super.setRemoteSessionDescription(sessionDescription);
5492
+ try {
5493
+ const result = super.setRemoteSessionDescription(sessionDescription);
5493
5494
 
5494
- this.eventEmitter.emit('setDescription', sessionDescription);
5495
+ this.eventEmitter.emit('setDescription', sessionDescription);
5495
5496
 
5496
- return result;
5497
+ return result;
5498
+ } catch (error) {
5499
+ this.logger.error('SessionDescriptionHandler.setRemoteSessionDescription error', error);
5500
+ throw error;
5501
+ }
5497
5502
  }
5498
5503
 
5499
5504
  // Overridden to avoid to fix ice-candidates missing in the SDP in react-native and chrome canary.
@@ -47,7 +47,7 @@ IssueReporter$1 ? IssueReporter$1.loggerFor('api') : console;
47
47
 
48
48
  // Use a function here to be able to mock it in tests
49
49
  const realFetch = () => {
50
- if (typeof document !== 'undefined') {
50
+ if (typeof document !== 'undefined' && window.fetch) {
51
51
  // Browser
52
52
  return window.fetch;
53
53
  }
@@ -113,7 +113,7 @@ const logger$2 = IssueReporter$1 ? IssueReporter$1.loggerFor('api') : console;
113
113
 
114
114
  // Use a function here to be able to mock it in tests
115
115
  const realFetch = () => {
116
- if (typeof document !== 'undefined') {
116
+ if (typeof document !== 'undefined' && window.fetch) {
117
117
  // Browser
118
118
  return window.fetch;
119
119
  }
@@ -832,11 +832,16 @@ class WazoSessionDescriptionHandler extends sessionDescriptionHandler.SessionDes
832
832
 
833
833
  // $FlowFixMe
834
834
  setRemoteSessionDescription(sessionDescription ) {
835
- const result = super.setRemoteSessionDescription(sessionDescription);
835
+ try {
836
+ const result = super.setRemoteSessionDescription(sessionDescription);
836
837
 
837
- this.eventEmitter.emit('setDescription', sessionDescription);
838
+ this.eventEmitter.emit('setDescription', sessionDescription);
838
839
 
839
- return result;
840
+ return result;
841
+ } catch (error) {
842
+ this.logger.error('SessionDescriptionHandler.setRemoteSessionDescription error', error);
843
+ throw error;
844
+ }
840
845
  }
841
846
 
842
847
  // Overridden to avoid to fix ice-candidates missing in the SDP in react-native and chrome canary.
@@ -113,7 +113,7 @@ const logger$2 = IssueReporter$1 ? IssueReporter$1.loggerFor('api') : console;
113
113
 
114
114
  // Use a function here to be able to mock it in tests
115
115
  const realFetch = () => {
116
- if (typeof document !== 'undefined') {
116
+ if (typeof document !== 'undefined' && window.fetch) {
117
117
  // Browser
118
118
  return window.fetch;
119
119
  }
@@ -832,11 +832,16 @@ class WazoSessionDescriptionHandler extends sessionDescriptionHandler.SessionDes
832
832
 
833
833
  // $FlowFixMe
834
834
  setRemoteSessionDescription(sessionDescription ) {
835
- const result = super.setRemoteSessionDescription(sessionDescription);
835
+ try {
836
+ const result = super.setRemoteSessionDescription(sessionDescription);
836
837
 
837
- this.eventEmitter.emit('setDescription', sessionDescription);
838
+ this.eventEmitter.emit('setDescription', sessionDescription);
838
839
 
839
- return result;
840
+ return result;
841
+ } catch (error) {
842
+ this.logger.error('SessionDescriptionHandler.setRemoteSessionDescription error', error);
843
+ throw error;
844
+ }
840
845
  }
841
846
 
842
847
  // Overridden to avoid to fix ice-candidates missing in the SDP in react-native and chrome canary.
@@ -670,7 +670,7 @@ const logger$1 = IssueReporter$1 ? IssueReporter$1.loggerFor('api') : console;
670
670
 
671
671
  // Use a function here to be able to mock it in tests
672
672
  const realFetch = () => {
673
- if (typeof document !== 'undefined') {
673
+ if (typeof document !== 'undefined' && window.fetch) {
674
674
  // Browser
675
675
  return window.fetch;
676
676
  }
@@ -452,7 +452,7 @@ const logger$1 = IssueReporter$1 ? IssueReporter$1.loggerFor('api') : console;
452
452
 
453
453
  // Use a function here to be able to mock it in tests
454
454
  const realFetch = () => {
455
- if (typeof document !== 'undefined') {
455
+ if (typeof document !== 'undefined' && window.fetch) {
456
456
  // Browser
457
457
  return window.fetch;
458
458
  }
@@ -2846,7 +2846,7 @@ const logger$2 = IssueReporter$1 ? IssueReporter$1.loggerFor('api') : console;
2846
2846
 
2847
2847
  // Use a function here to be able to mock it in tests
2848
2848
  const realFetch = () => {
2849
- if (typeof document !== 'undefined') {
2849
+ if (typeof document !== 'undefined' && window.fetch) {
2850
2850
  // Browser
2851
2851
  return window.fetch;
2852
2852
  }
@@ -414,7 +414,7 @@ IssueReporter$1 ? IssueReporter$1.loggerFor('api') : console;
414
414
 
415
415
  // Use a function here to be able to mock it in tests
416
416
  const realFetch = () => {
417
- if (typeof document !== 'undefined') {
417
+ if (typeof document !== 'undefined' && window.fetch) {
418
418
  // Browser
419
419
  return window.fetch;
420
420
  }
@@ -1539,6 +1539,7 @@ class WebRTCPhone extends Emitter {
1539
1539
  _onCallTerminated(sipSession ) {
1540
1540
  logger.info('WebRTC phone - on call terminated', { sipId: sipSession.id });
1541
1541
 
1542
+ const sipSessionId = this.getSipSessionId(sipSession);
1542
1543
  const callSession = this._createCallSession(sipSession);
1543
1544
  const isCurrentSession = this.isCurrentCallSipSession(callSession);
1544
1545
  const isCurrentIncomingCall = callSession.is(this.getIncomingCallSession());
@@ -1556,7 +1557,6 @@ class WebRTCPhone extends Emitter {
1556
1557
  }, 5);
1557
1558
  }
1558
1559
 
1559
- const sipSessionId = this.getSipSessionId(sipSession);
1560
1560
  if (sipSessionId) {
1561
1561
  this.removeIncomingSessions(sipSessionId);
1562
1562
  }
@@ -2201,8 +2201,12 @@ class WebRTCPhone extends Emitter {
2201
2201
  }
2202
2202
 
2203
2203
  const sessionId = this.incomingSessions[0];
2204
+ const sipSession = this.client.getSipSession(sessionId);
2205
+ if (!sipSession) {
2206
+ return null;
2207
+ }
2204
2208
 
2205
- return this._createCallSession(this.client.getSipSession(sessionId));
2209
+ return this._createCallSession(sipSession);
2206
2210
  }
2207
2211
 
2208
2212
  sendMessage(sipSession = null, body , contentType = 'text/plain') {
package/lib/index.js CHANGED
@@ -475,7 +475,7 @@ const logger$c = IssueReporter$1 ? IssueReporter$1.loggerFor('api') : console;
475
475
 
476
476
  // Use a function here to be able to mock it in tests
477
477
  const realFetch = () => {
478
- if (typeof document !== 'undefined') {
478
+ if (typeof document !== 'undefined' && window.fetch) {
479
479
  // Browser
480
480
  return window.fetch;
481
481
  }
@@ -5635,11 +5635,16 @@ class WazoSessionDescriptionHandler extends sessionDescriptionHandler.SessionDes
5635
5635
 
5636
5636
  // $FlowFixMe
5637
5637
  setRemoteSessionDescription(sessionDescription ) {
5638
- const result = super.setRemoteSessionDescription(sessionDescription);
5638
+ try {
5639
+ const result = super.setRemoteSessionDescription(sessionDescription);
5639
5640
 
5640
- this.eventEmitter.emit('setDescription', sessionDescription);
5641
+ this.eventEmitter.emit('setDescription', sessionDescription);
5641
5642
 
5642
- return result;
5643
+ return result;
5644
+ } catch (error) {
5645
+ this.logger.error('SessionDescriptionHandler.setRemoteSessionDescription error', error);
5646
+ throw error;
5647
+ }
5643
5648
  }
5644
5649
 
5645
5650
  // Overridden to avoid to fix ice-candidates missing in the SDP in react-native and chrome canary.
@@ -9836,6 +9841,7 @@ class WebRTCPhone extends Emitter {
9836
9841
  _onCallTerminated(sipSession ) {
9837
9842
  logger$7.info('WebRTC phone - on call terminated', { sipId: sipSession.id });
9838
9843
 
9844
+ const sipSessionId = this.getSipSessionId(sipSession);
9839
9845
  const callSession = this._createCallSession(sipSession);
9840
9846
  const isCurrentSession = this.isCurrentCallSipSession(callSession);
9841
9847
  const isCurrentIncomingCall = callSession.is(this.getIncomingCallSession());
@@ -9853,7 +9859,6 @@ class WebRTCPhone extends Emitter {
9853
9859
  }, 5);
9854
9860
  }
9855
9861
 
9856
- const sipSessionId = this.getSipSessionId(sipSession);
9857
9862
  if (sipSessionId) {
9858
9863
  this.removeIncomingSessions(sipSessionId);
9859
9864
  }
@@ -10498,8 +10503,12 @@ class WebRTCPhone extends Emitter {
10498
10503
  }
10499
10504
 
10500
10505
  const sessionId = this.incomingSessions[0];
10506
+ const sipSession = this.client.getSipSession(sessionId);
10507
+ if (!sipSession) {
10508
+ return null;
10509
+ }
10501
10510
 
10502
- return this._createCallSession(this.client.getSipSession(sessionId));
10511
+ return this._createCallSession(sipSession);
10503
10512
  }
10504
10513
 
10505
10514
  sendMessage(sipSession = null, body , contentType = 'text/plain') {
@@ -25,7 +25,7 @@ IssueReporter$1 ? IssueReporter$1.loggerFor('api') : console;
25
25
 
26
26
  // Use a function here to be able to mock it in tests
27
27
  const realFetch = () => {
28
- if (typeof document !== 'undefined') {
28
+ if (typeof document !== 'undefined' && window.fetch) {
29
29
  // Browser
30
30
  return window.fetch;
31
31
  }
@@ -497,11 +497,16 @@ class WazoSessionDescriptionHandler extends sessionDescriptionHandler.SessionDes
497
497
 
498
498
  // $FlowFixMe
499
499
  setRemoteSessionDescription(sessionDescription ) {
500
- const result = super.setRemoteSessionDescription(sessionDescription);
500
+ try {
501
+ const result = super.setRemoteSessionDescription(sessionDescription);
501
502
 
502
- this.eventEmitter.emit('setDescription', sessionDescription);
503
+ this.eventEmitter.emit('setDescription', sessionDescription);
503
504
 
504
- return result;
505
+ return result;
506
+ } catch (error) {
507
+ this.logger.error('SessionDescriptionHandler.setRemoteSessionDescription error', error);
508
+ throw error;
509
+ }
505
510
  }
506
511
 
507
512
  // Overridden to avoid to fix ice-candidates missing in the SDP in react-native and chrome canary.
@@ -2472,7 +2472,7 @@ const logger$1 = IssueReporter$1 ? IssueReporter$1.loggerFor('api') : console;
2472
2472
 
2473
2473
  // Use a function here to be able to mock it in tests
2474
2474
  const realFetch = () => {
2475
- if (typeof document !== 'undefined') {
2475
+ if (typeof document !== 'undefined' && window.fetch) {
2476
2476
  // Browser
2477
2477
  return window.fetch;
2478
2478
  }
@@ -17,7 +17,7 @@ IssueReporter$1 ? IssueReporter$1.loggerFor('api') : console;
17
17
 
18
18
  // Use a function here to be able to mock it in tests
19
19
  const realFetch = () => {
20
- if (typeof document !== 'undefined') {
20
+ if (typeof document !== 'undefined' && window.fetch) {
21
21
  // Browser
22
22
  return window.fetch;
23
23
  }
@@ -17,7 +17,7 @@ IssueReporter$1 ? IssueReporter$1.loggerFor('api') : console;
17
17
 
18
18
  // Use a function here to be able to mock it in tests
19
19
  const realFetch = () => {
20
- if (typeof document !== 'undefined') {
20
+ if (typeof document !== 'undefined' && window.fetch) {
21
21
  // Browser
22
22
  return window.fetch;
23
23
  }
@@ -452,7 +452,7 @@ const logger$1 = IssueReporter$1 ? IssueReporter$1.loggerFor('api') : console;
452
452
 
453
453
  // Use a function here to be able to mock it in tests
454
454
  const realFetch = () => {
455
- if (typeof document !== 'undefined') {
455
+ if (typeof document !== 'undefined' && window.fetch) {
456
456
  // Browser
457
457
  return window.fetch;
458
458
  }
@@ -1963,7 +1963,7 @@ const logger$c = IssueReporter$1 ? IssueReporter$1.loggerFor('api') : console;
1963
1963
 
1964
1964
  // Use a function here to be able to mock it in tests
1965
1965
  const realFetch = () => {
1966
- if (typeof document !== 'undefined') {
1966
+ if (typeof document !== 'undefined' && window.fetch) {
1967
1967
  // Browser
1968
1968
  return window.fetch;
1969
1969
  }
@@ -5810,11 +5810,16 @@ class WazoSessionDescriptionHandler extends sessionDescriptionHandler.SessionDes
5810
5810
 
5811
5811
  // $FlowFixMe
5812
5812
  setRemoteSessionDescription(sessionDescription ) {
5813
- const result = super.setRemoteSessionDescription(sessionDescription);
5813
+ try {
5814
+ const result = super.setRemoteSessionDescription(sessionDescription);
5814
5815
 
5815
- this.eventEmitter.emit('setDescription', sessionDescription);
5816
+ this.eventEmitter.emit('setDescription', sessionDescription);
5816
5817
 
5817
- return result;
5818
+ return result;
5819
+ } catch (error) {
5820
+ this.logger.error('SessionDescriptionHandler.setRemoteSessionDescription error', error);
5821
+ throw error;
5822
+ }
5818
5823
  }
5819
5824
 
5820
5825
  // Overridden to avoid to fix ice-candidates missing in the SDP in react-native and chrome canary.
@@ -9118,6 +9123,7 @@ class WebRTCPhone extends Emitter {
9118
9123
  _onCallTerminated(sipSession ) {
9119
9124
  logger$8.info('WebRTC phone - on call terminated', { sipId: sipSession.id });
9120
9125
 
9126
+ const sipSessionId = this.getSipSessionId(sipSession);
9121
9127
  const callSession = this._createCallSession(sipSession);
9122
9128
  const isCurrentSession = this.isCurrentCallSipSession(callSession);
9123
9129
  const isCurrentIncomingCall = callSession.is(this.getIncomingCallSession());
@@ -9135,7 +9141,6 @@ class WebRTCPhone extends Emitter {
9135
9141
  }, 5);
9136
9142
  }
9137
9143
 
9138
- const sipSessionId = this.getSipSessionId(sipSession);
9139
9144
  if (sipSessionId) {
9140
9145
  this.removeIncomingSessions(sipSessionId);
9141
9146
  }
@@ -9780,8 +9785,12 @@ class WebRTCPhone extends Emitter {
9780
9785
  }
9781
9786
 
9782
9787
  const sessionId = this.incomingSessions[0];
9788
+ const sipSession = this.client.getSipSession(sessionId);
9789
+ if (!sipSession) {
9790
+ return null;
9791
+ }
9783
9792
 
9784
- return this._createCallSession(this.client.getSipSession(sessionId));
9793
+ return this._createCallSession(sipSession);
9785
9794
  }
9786
9795
 
9787
9796
  sendMessage(sipSession = null, body , contentType = 'text/plain') {
@@ -1961,7 +1961,7 @@ const logger$c = IssueReporter$1 ? IssueReporter$1.loggerFor('api') : console;
1961
1961
 
1962
1962
  // Use a function here to be able to mock it in tests
1963
1963
  const realFetch = () => {
1964
- if (typeof document !== 'undefined') {
1964
+ if (typeof document !== 'undefined' && window.fetch) {
1965
1965
  // Browser
1966
1966
  return window.fetch;
1967
1967
  }
@@ -5808,11 +5808,16 @@ class WazoSessionDescriptionHandler extends sessionDescriptionHandler.SessionDes
5808
5808
 
5809
5809
  // $FlowFixMe
5810
5810
  setRemoteSessionDescription(sessionDescription ) {
5811
- const result = super.setRemoteSessionDescription(sessionDescription);
5811
+ try {
5812
+ const result = super.setRemoteSessionDescription(sessionDescription);
5812
5813
 
5813
- this.eventEmitter.emit('setDescription', sessionDescription);
5814
+ this.eventEmitter.emit('setDescription', sessionDescription);
5814
5815
 
5815
- return result;
5816
+ return result;
5817
+ } catch (error) {
5818
+ this.logger.error('SessionDescriptionHandler.setRemoteSessionDescription error', error);
5819
+ throw error;
5820
+ }
5816
5821
  }
5817
5822
 
5818
5823
  // Overridden to avoid to fix ice-candidates missing in the SDP in react-native and chrome canary.
@@ -9116,6 +9121,7 @@ class WebRTCPhone extends Emitter {
9116
9121
  _onCallTerminated(sipSession ) {
9117
9122
  logger$8.info('WebRTC phone - on call terminated', { sipId: sipSession.id });
9118
9123
 
9124
+ const sipSessionId = this.getSipSessionId(sipSession);
9119
9125
  const callSession = this._createCallSession(sipSession);
9120
9126
  const isCurrentSession = this.isCurrentCallSipSession(callSession);
9121
9127
  const isCurrentIncomingCall = callSession.is(this.getIncomingCallSession());
@@ -9133,7 +9139,6 @@ class WebRTCPhone extends Emitter {
9133
9139
  }, 5);
9134
9140
  }
9135
9141
 
9136
- const sipSessionId = this.getSipSessionId(sipSession);
9137
9142
  if (sipSessionId) {
9138
9143
  this.removeIncomingSessions(sipSessionId);
9139
9144
  }
@@ -9778,8 +9783,12 @@ class WebRTCPhone extends Emitter {
9778
9783
  }
9779
9784
 
9780
9785
  const sessionId = this.incomingSessions[0];
9786
+ const sipSession = this.client.getSipSession(sessionId);
9787
+ if (!sipSession) {
9788
+ return null;
9789
+ }
9781
9790
 
9782
- return this._createCallSession(this.client.getSipSession(sessionId));
9791
+ return this._createCallSession(sipSession);
9783
9792
  }
9784
9793
 
9785
9794
  sendMessage(sipSession = null, body , contentType = 'text/plain') {
@@ -450,7 +450,7 @@ const logger$1 = IssueReporter$1 ? IssueReporter$1.loggerFor('api') : console;
450
450
 
451
451
  // Use a function here to be able to mock it in tests
452
452
  const realFetch = () => {
453
- if (typeof document !== 'undefined') {
453
+ if (typeof document !== 'undefined' && window.fetch) {
454
454
  // Browser
455
455
  return window.fetch;
456
456
  }