@wazo/sdk 0.37.26 → 0.37.30

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 (121) hide show
  1. package/README.md +98 -59
  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 +18 -5
  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 +18 -5
  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 +18 -5
  21. package/esm/checker/checks/wazo-websocket.js +1 -1
  22. package/esm/checker/checks/webrtc-transport.js +18 -5
  23. package/esm/checker/checks/webrtc.js +18 -5
  24. package/esm/domain/AdHocAPIConference.js +1 -1
  25. package/esm/domain/CallSession.js +29 -2
  26. package/esm/domain/Features.js +1 -1
  27. package/esm/domain/Phone/CTIPhone.js +30 -3
  28. package/esm/domain/Phone/WebRTCPhone.js +55 -6
  29. package/esm/domain/SFUNotAvailableError.js +9 -0
  30. package/esm/domain/__tests__/CallSession.test.js +46 -2
  31. package/esm/domain/__tests__/IndirectTransfer.test.js +29 -2
  32. package/esm/domain/__tests__/Room.test.js +29 -2
  33. package/esm/index.js +83 -10
  34. package/esm/lib/WazoSessionDescriptionHandler.js +9 -4
  35. package/esm/service/CallApi.js +1 -1
  36. package/esm/service/IssueReporter.js +1 -1
  37. package/esm/service/__tests__/IssueReporter.test.js +1 -1
  38. package/esm/service/getApiClient.js +1 -1
  39. package/esm/simple/Auth.js +82 -10
  40. package/esm/simple/Configuration.js +82 -10
  41. package/esm/simple/Directory.js +1 -1
  42. package/esm/simple/Phone.js +82 -10
  43. package/esm/simple/Websocket.js +1 -1
  44. package/esm/simple/index.js +82 -10
  45. package/esm/simple/room/LocalParticipant.js +82 -10
  46. package/esm/simple/room/Participant.js +82 -10
  47. package/esm/simple/room/RemoteParticipant.js +82 -10
  48. package/esm/simple/room/Room.js +82 -10
  49. package/esm/simple/room/SipRoom.js +82 -10
  50. package/esm/simple/room/Stream.js +82 -10
  51. package/esm/simple/room/__tests__/RemoteParticipant.test.js +82 -10
  52. package/esm/simple/utils.js +82 -10
  53. package/esm/utils/__tests__/api-requester.test.js +1 -1
  54. package/esm/utils/api-requester.js +1 -1
  55. package/esm/web-rtc-client.js +18 -5
  56. package/esm/websocket-client.js +1 -1
  57. package/lib/__tests__/api-client.test.js +1 -1
  58. package/lib/__tests__/web-rtc-client.test.js +18 -5
  59. package/lib/api/agentd.js +1 -1
  60. package/lib/api/amid.js +1 -1
  61. package/lib/api/application.js +1 -1
  62. package/lib/api/auth.js +1 -1
  63. package/lib/api/call-logd.js +1 -1
  64. package/lib/api/calld.js +1 -1
  65. package/lib/api/chatd.js +1 -1
  66. package/lib/api/confd.js +1 -1
  67. package/lib/api/ctid-ng.js +1 -1
  68. package/lib/api/dird.js +1 -1
  69. package/lib/api/webhookd.js +1 -1
  70. package/lib/api-client.js +1 -1
  71. package/lib/checker/Checker.js +18 -5
  72. package/lib/checker/checks/aor.js +1 -1
  73. package/lib/checker/checks/api.js +1 -1
  74. package/lib/checker/checks/index.js +18 -5
  75. package/lib/checker/checks/wazo-websocket.js +1 -1
  76. package/lib/checker/checks/webrtc-transport.js +18 -5
  77. package/lib/checker/checks/webrtc.js +18 -5
  78. package/lib/domain/AdHocAPIConference.js +1 -1
  79. package/lib/domain/CallSession.js +29 -2
  80. package/lib/domain/Features.js +1 -1
  81. package/lib/domain/Phone/CTIPhone.js +30 -3
  82. package/lib/domain/Phone/WebRTCPhone.js +55 -5
  83. package/lib/domain/SFUNotAvailableError.js +11 -0
  84. package/lib/domain/__tests__/CallSession.test.js +46 -2
  85. package/lib/domain/__tests__/IndirectTransfer.test.js +29 -2
  86. package/lib/domain/__tests__/Room.test.js +29 -2
  87. package/lib/index.js +83 -10
  88. package/lib/lib/WazoSessionDescriptionHandler.js +9 -4
  89. package/lib/service/CallApi.js +1 -1
  90. package/lib/service/IssueReporter.js +1 -1
  91. package/lib/service/__tests__/IssueReporter.test.js +1 -1
  92. package/lib/service/getApiClient.js +1 -1
  93. package/lib/simple/Auth.js +82 -10
  94. package/lib/simple/Configuration.js +82 -10
  95. package/lib/simple/Directory.js +1 -1
  96. package/lib/simple/Phone.js +82 -10
  97. package/lib/simple/Websocket.js +1 -1
  98. package/lib/simple/index.js +82 -10
  99. package/lib/simple/room/LocalParticipant.js +82 -10
  100. package/lib/simple/room/Participant.js +82 -10
  101. package/lib/simple/room/RemoteParticipant.js +82 -10
  102. package/lib/simple/room/Room.js +82 -10
  103. package/lib/simple/room/SipRoom.js +82 -10
  104. package/lib/simple/room/Stream.js +82 -10
  105. package/lib/simple/room/__tests__/RemoteParticipant.test.js +82 -10
  106. package/lib/simple/utils.js +82 -10
  107. package/lib/utils/__tests__/api-requester.test.js +1 -1
  108. package/lib/utils/api-requester.js +1 -1
  109. package/lib/web-rtc-client.js +18 -5
  110. package/lib/websocket-client.js +1 -1
  111. package/package.json +1 -1
  112. package/src/domain/CallSession.js +32 -4
  113. package/src/domain/Phone/WebRTCPhone.js +24 -2
  114. package/src/domain/SFUNotAvailableError.js +7 -0
  115. package/src/domain/__tests__/CallSession.test.js +17 -0
  116. package/src/index.js +2 -0
  117. package/src/lib/WazoSessionDescriptionHandler.js +8 -3
  118. package/src/simple/Phone.js +2 -1
  119. package/src/simple/index.js +2 -0
  120. package/src/utils/api-requester.js +1 -1
  121. package/src/web-rtc-client.js +9 -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.
@@ -5339,6 +5344,7 @@ const MAX_REGISTER_TRIES = 10;
5339
5344
 
5340
5345
 
5341
5346
 
5347
+
5342
5348
 
5343
5349
 
5344
5350
 
@@ -6955,6 +6961,13 @@ class WebRTCClient extends Emitter {
6955
6961
  }
6956
6962
 
6957
6963
  _createWebRTCConfiguration(configOverrides = {}) {
6964
+ let { host } = this.config;
6965
+ let port = this.config.port || 443;
6966
+
6967
+ if (this.config.websocketSip) {
6968
+ [host, port = 443] = this.config.websocketSip.split(':');
6969
+ }
6970
+
6958
6971
  const config = {
6959
6972
  authorizationUsername: this.config.authorizationUser,
6960
6973
  authorizationPassword: this.config.password,
@@ -6990,7 +7003,7 @@ class WebRTCClient extends Emitter {
6990
7003
  },
6991
7004
  transportOptions: {
6992
7005
  traceSip: configOverrides.traceSip || false,
6993
- wsServers: `wss://${this.config.host}:${this.config.port || 443}/api/asterisk/ws`,
7006
+ wsServers: `wss://${host}:${port}/api/asterisk/ws`,
6994
7007
  },
6995
7008
  sessionDescriptionHandlerFactoryOptions: {
6996
7009
  modifiers: [replaceLocalIpModifier],
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.
@@ -5924,6 +5929,7 @@ const MAX_REGISTER_TRIES = 10;
5924
5929
 
5925
5930
 
5926
5931
 
5932
+
5927
5933
 
5928
5934
 
5929
5935
 
@@ -7540,6 +7546,13 @@ class WebRTCClient extends Emitter {
7540
7546
  }
7541
7547
 
7542
7548
  _createWebRTCConfiguration(configOverrides = {}) {
7549
+ let { host } = this.config;
7550
+ let port = this.config.port || 443;
7551
+
7552
+ if (this.config.websocketSip) {
7553
+ [host, port = 443] = this.config.websocketSip.split(':');
7554
+ }
7555
+
7543
7556
  const config = {
7544
7557
  authorizationUsername: this.config.authorizationUser,
7545
7558
  authorizationPassword: this.config.password,
@@ -7575,7 +7588,7 @@ class WebRTCClient extends Emitter {
7575
7588
  },
7576
7589
  transportOptions: {
7577
7590
  traceSip: configOverrides.traceSip || false,
7578
- wsServers: `wss://${this.config.host}:${this.config.port || 443}/api/asterisk/ws`,
7591
+ wsServers: `wss://${host}:${port}/api/asterisk/ws`,
7579
7592
  },
7580
7593
  sessionDescriptionHandlerFactoryOptions: {
7581
7594
  modifiers: [replaceLocalIpModifier],
@@ -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.
@@ -5924,6 +5929,7 @@ const MAX_REGISTER_TRIES = 10;
5924
5929
 
5925
5930
 
5926
5931
 
5932
+
5927
5933
 
5928
5934
 
5929
5935
 
@@ -7540,6 +7546,13 @@ class WebRTCClient extends Emitter {
7540
7546
  }
7541
7547
 
7542
7548
  _createWebRTCConfiguration(configOverrides = {}) {
7549
+ let { host } = this.config;
7550
+ let port = this.config.port || 443;
7551
+
7552
+ if (this.config.websocketSip) {
7553
+ [host, port = 443] = this.config.websocketSip.split(':');
7554
+ }
7555
+
7543
7556
  const config = {
7544
7557
  authorizationUsername: this.config.authorizationUser,
7545
7558
  authorizationPassword: this.config.password,
@@ -7575,7 +7588,7 @@ class WebRTCClient extends Emitter {
7575
7588
  },
7576
7589
  transportOptions: {
7577
7590
  traceSip: configOverrides.traceSip || false,
7578
- wsServers: `wss://${this.config.host}:${this.config.port || 443}/api/asterisk/ws`,
7591
+ wsServers: `wss://${host}:${port}/api/asterisk/ws`,
7579
7592
  },
7580
7593
  sessionDescriptionHandlerFactoryOptions: {
7581
7594
  modifiers: [replaceLocalIpModifier],
@@ -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.
@@ -5339,6 +5344,7 @@ const MAX_REGISTER_TRIES = 10;
5339
5344
 
5340
5345
 
5341
5346
 
5347
+
5342
5348
 
5343
5349
 
5344
5350
 
@@ -6955,6 +6961,13 @@ class WebRTCClient extends Emitter {
6955
6961
  }
6956
6962
 
6957
6963
  _createWebRTCConfiguration(configOverrides = {}) {
6964
+ let { host } = this.config;
6965
+ let port = this.config.port || 443;
6966
+
6967
+ if (this.config.websocketSip) {
6968
+ [host, port = 443] = this.config.websocketSip.split(':');
6969
+ }
6970
+
6958
6971
  const config = {
6959
6972
  authorizationUsername: this.config.authorizationUser,
6960
6973
  authorizationPassword: this.config.password,
@@ -6990,7 +7003,7 @@ class WebRTCClient extends Emitter {
6990
7003
  },
6991
7004
  transportOptions: {
6992
7005
  traceSip: configOverrides.traceSip || false,
6993
- wsServers: `wss://${this.config.host}:${this.config.port || 443}/api/asterisk/ws`,
7006
+ wsServers: `wss://${host}:${port}/api/asterisk/ws`,
6994
7007
  },
6995
7008
  sessionDescriptionHandlerFactoryOptions: {
6996
7009
  modifiers: [replaceLocalIpModifier],
@@ -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.
@@ -5339,6 +5344,7 @@ const MAX_REGISTER_TRIES = 10;
5339
5344
 
5340
5345
 
5341
5346
 
5347
+
5342
5348
 
5343
5349
 
5344
5350
 
@@ -6955,6 +6961,13 @@ class WebRTCClient extends Emitter {
6955
6961
  }
6956
6962
 
6957
6963
  _createWebRTCConfiguration(configOverrides = {}) {
6964
+ let { host } = this.config;
6965
+ let port = this.config.port || 443;
6966
+
6967
+ if (this.config.websocketSip) {
6968
+ [host, port = 443] = this.config.websocketSip.split(':');
6969
+ }
6970
+
6958
6971
  const config = {
6959
6972
  authorizationUsername: this.config.authorizationUser,
6960
6973
  authorizationPassword: this.config.password,
@@ -6990,7 +7003,7 @@ class WebRTCClient extends Emitter {
6990
7003
  },
6991
7004
  transportOptions: {
6992
7005
  traceSip: configOverrides.traceSip || false,
6993
- wsServers: `wss://${this.config.host}:${this.config.port || 443}/api/asterisk/ws`,
7006
+ wsServers: `wss://${host}:${port}/api/asterisk/ws`,
6994
7007
  },
6995
7008
  sessionDescriptionHandlerFactoryOptions: {
6996
7009
  modifiers: [replaceLocalIpModifier],
@@ -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
  }
@@ -32,13 +32,16 @@ var updateFrom = (instance , from ) => {
32
32
 
33
33
 
34
34
 
35
+
35
36
 
36
37
 
37
38
 
38
39
 
39
40
 
41
+
40
42
 
41
43
 
44
+
42
45
 
43
46
 
44
47
 
@@ -55,6 +58,7 @@ var updateFrom = (instance , from ) => {
55
58
 
56
59
 
57
60
 
61
+
58
62
 
59
63
 
60
64
  class CallSession {
@@ -74,10 +78,14 @@ class CallSession {
74
78
 
75
79
 
76
80
 
77
-
81
+
82
+
83
+ // = creationTime
78
84
 
79
85
 
80
86
 
87
+
88
+
81
89
 
82
90
 
83
91
 
@@ -113,6 +121,8 @@ class CallSession {
113
121
 
114
122
 
115
123
 
124
+
125
+
116
126
 
117
127
  constructor({
118
128
  answered,
@@ -126,6 +136,8 @@ class CallSession {
126
136
  paused,
127
137
  ringing,
128
138
  startTime,
139
+ creationTime,
140
+ endTime,
129
141
  cameraEnabled,
130
142
  dialedExtension,
131
143
  sipCallId,
@@ -138,12 +150,16 @@ class CallSession {
138
150
  recording,
139
151
  recordingPaused,
140
152
  videoRemotelyDowngraded,
153
+ sipSession,
154
+ answerTime,
141
155
  } ) {
142
156
  this.callId = callId;
143
157
  this.sipCallId = sipCallId;
144
158
  this.displayName = displayName;
145
159
  this.number = number;
160
+ this.creationTime = creationTime;
146
161
  this.startTime = startTime;
162
+ this.endTime = endTime;
147
163
  this.isCaller = isCaller;
148
164
  this.answered = answered;
149
165
  this.answeredBySystem = answeredBySystem;
@@ -162,6 +178,8 @@ class CallSession {
162
178
  this.recording = recording || false;
163
179
  this.recordingPaused = recordingPaused || false;
164
180
  this.videoRemotelyDowngraded = videoRemotelyDowngraded;
181
+ this.sipSession = sipSession;
182
+ this.answerTime = answerTime || this.answerTime;
165
183
 
166
184
  // Useful to compare instead of instanceof with minified code
167
185
  this.type = 'CallSession';
@@ -192,7 +210,7 @@ class CallSession {
192
210
  }
193
211
 
194
212
  answer() {
195
- this.answered = true;
213
+ this.answerTime = new Date();
196
214
  }
197
215
 
198
216
  systemAnswer() {
@@ -348,6 +366,15 @@ class CallSession {
348
366
  return newFrom(callSession, CallSession);
349
367
  }
350
368
 
369
+ // Retro-compatibility: `answered` was a boolean before. We can reproduce the behaviour with a getter/setter
370
+ set answered(value ) {
371
+ this.answerTime = value ? new Date() : null;
372
+ }
373
+
374
+ get answered() {
375
+ return !!this.answerTime;
376
+ }
377
+
351
378
  static parseCall(call ) {
352
379
  return new CallSession({
353
380
  callId: call.id,
@@ -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
  }