@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
@@ -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.
@@ -5342,6 +5347,7 @@ const MAX_REGISTER_TRIES = 10;
5342
5347
 
5343
5348
 
5344
5349
 
5350
+
5345
5351
 
5346
5352
 
5347
5353
 
@@ -6958,6 +6964,13 @@ class WebRTCClient extends Emitter {
6958
6964
  }
6959
6965
 
6960
6966
  _createWebRTCConfiguration(configOverrides = {}) {
6967
+ let { host } = this.config;
6968
+ let port = this.config.port || 443;
6969
+
6970
+ if (this.config.websocketSip) {
6971
+ [host, port = 443] = this.config.websocketSip.split(':');
6972
+ }
6973
+
6961
6974
  const config = {
6962
6975
  authorizationUsername: this.config.authorizationUser,
6963
6976
  authorizationPassword: this.config.password,
@@ -6993,7 +7006,7 @@ class WebRTCClient extends Emitter {
6993
7006
  },
6994
7007
  transportOptions: {
6995
7008
  traceSip: configOverrides.traceSip || false,
6996
- wsServers: `wss://${this.config.host}:${this.config.port || 443}/api/asterisk/ws`,
7009
+ wsServers: `wss://${host}:${port}/api/asterisk/ws`,
6997
7010
  },
6998
7011
  sessionDescriptionHandlerFactoryOptions: {
6999
7012
  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
  }
@@ -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
  }
@@ -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.
@@ -5348,6 +5353,7 @@ const MAX_REGISTER_TRIES = 10;
5348
5353
 
5349
5354
 
5350
5355
 
5356
+
5351
5357
 
5352
5358
 
5353
5359
 
@@ -6964,6 +6970,13 @@ class WebRTCClient extends Emitter {
6964
6970
  }
6965
6971
 
6966
6972
  _createWebRTCConfiguration(configOverrides = {}) {
6973
+ let { host } = this.config;
6974
+ let port = this.config.port || 443;
6975
+
6976
+ if (this.config.websocketSip) {
6977
+ [host, port = 443] = this.config.websocketSip.split(':');
6978
+ }
6979
+
6967
6980
  const config = {
6968
6981
  authorizationUsername: this.config.authorizationUser,
6969
6982
  authorizationPassword: this.config.password,
@@ -6999,7 +7012,7 @@ class WebRTCClient extends Emitter {
6999
7012
  },
7000
7013
  transportOptions: {
7001
7014
  traceSip: configOverrides.traceSip || false,
7002
- wsServers: `wss://${this.config.host}:${this.config.port || 443}/api/asterisk/ws`,
7015
+ wsServers: `wss://${host}:${port}/api/asterisk/ws`,
7003
7016
  },
7004
7017
  sessionDescriptionHandlerFactoryOptions: {
7005
7018
  modifiers: [replaceLocalIpModifier],
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.
@@ -5934,6 +5939,7 @@ const MAX_REGISTER_TRIES = 10;
5934
5939
 
5935
5940
 
5936
5941
 
5942
+
5937
5943
 
5938
5944
 
5939
5945
 
@@ -7550,6 +7556,13 @@ class WebRTCClient extends Emitter {
7550
7556
  }
7551
7557
 
7552
7558
  _createWebRTCConfiguration(configOverrides = {}) {
7559
+ let { host } = this.config;
7560
+ let port = this.config.port || 443;
7561
+
7562
+ if (this.config.websocketSip) {
7563
+ [host, port = 443] = this.config.websocketSip.split(':');
7564
+ }
7565
+
7553
7566
  const config = {
7554
7567
  authorizationUsername: this.config.authorizationUser,
7555
7568
  authorizationPassword: this.config.password,
@@ -7585,7 +7598,7 @@ class WebRTCClient extends Emitter {
7585
7598
  },
7586
7599
  transportOptions: {
7587
7600
  traceSip: configOverrides.traceSip || false,
7588
- wsServers: `wss://${this.config.host}:${this.config.port || 443}/api/asterisk/ws`,
7601
+ wsServers: `wss://${host}:${port}/api/asterisk/ws`,
7589
7602
  },
7590
7603
  sessionDescriptionHandlerFactoryOptions: {
7591
7604
  modifiers: [replaceLocalIpModifier],
@@ -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.
@@ -5934,6 +5939,7 @@ const MAX_REGISTER_TRIES = 10;
5934
5939
 
5935
5940
 
5936
5941
 
5942
+
5937
5943
 
5938
5944
 
5939
5945
 
@@ -7550,6 +7556,13 @@ class WebRTCClient extends Emitter {
7550
7556
  }
7551
7557
 
7552
7558
  _createWebRTCConfiguration(configOverrides = {}) {
7559
+ let { host } = this.config;
7560
+ let port = this.config.port || 443;
7561
+
7562
+ if (this.config.websocketSip) {
7563
+ [host, port = 443] = this.config.websocketSip.split(':');
7564
+ }
7565
+
7553
7566
  const config = {
7554
7567
  authorizationUsername: this.config.authorizationUser,
7555
7568
  authorizationPassword: this.config.password,
@@ -7585,7 +7598,7 @@ class WebRTCClient extends Emitter {
7585
7598
  },
7586
7599
  transportOptions: {
7587
7600
  traceSip: configOverrides.traceSip || false,
7588
- wsServers: `wss://${this.config.host}:${this.config.port || 443}/api/asterisk/ws`,
7601
+ wsServers: `wss://${host}:${port}/api/asterisk/ws`,
7589
7602
  },
7590
7603
  sessionDescriptionHandlerFactoryOptions: {
7591
7604
  modifiers: [replaceLocalIpModifier],
@@ -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.
@@ -5348,6 +5353,7 @@ const MAX_REGISTER_TRIES = 10;
5348
5353
 
5349
5354
 
5350
5355
 
5356
+
5351
5357
 
5352
5358
 
5353
5359
 
@@ -6964,6 +6970,13 @@ class WebRTCClient extends Emitter {
6964
6970
  }
6965
6971
 
6966
6972
  _createWebRTCConfiguration(configOverrides = {}) {
6973
+ let { host } = this.config;
6974
+ let port = this.config.port || 443;
6975
+
6976
+ if (this.config.websocketSip) {
6977
+ [host, port = 443] = this.config.websocketSip.split(':');
6978
+ }
6979
+
6967
6980
  const config = {
6968
6981
  authorizationUsername: this.config.authorizationUser,
6969
6982
  authorizationPassword: this.config.password,
@@ -6999,7 +7012,7 @@ class WebRTCClient extends Emitter {
6999
7012
  },
7000
7013
  transportOptions: {
7001
7014
  traceSip: configOverrides.traceSip || false,
7002
- wsServers: `wss://${this.config.host}:${this.config.port || 443}/api/asterisk/ws`,
7015
+ wsServers: `wss://${host}:${port}/api/asterisk/ws`,
7003
7016
  },
7004
7017
  sessionDescriptionHandlerFactoryOptions: {
7005
7018
  modifiers: [replaceLocalIpModifier],
@@ -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.
@@ -5348,6 +5353,7 @@ const MAX_REGISTER_TRIES = 10;
5348
5353
 
5349
5354
 
5350
5355
 
5356
+
5351
5357
 
5352
5358
 
5353
5359
 
@@ -6964,6 +6970,13 @@ class WebRTCClient extends Emitter {
6964
6970
  }
6965
6971
 
6966
6972
  _createWebRTCConfiguration(configOverrides = {}) {
6973
+ let { host } = this.config;
6974
+ let port = this.config.port || 443;
6975
+
6976
+ if (this.config.websocketSip) {
6977
+ [host, port = 443] = this.config.websocketSip.split(':');
6978
+ }
6979
+
6967
6980
  const config = {
6968
6981
  authorizationUsername: this.config.authorizationUser,
6969
6982
  authorizationPassword: this.config.password,
@@ -6999,7 +7012,7 @@ class WebRTCClient extends Emitter {
6999
7012
  },
7000
7013
  transportOptions: {
7001
7014
  traceSip: configOverrides.traceSip || false,
7002
- wsServers: `wss://${this.config.host}:${this.config.port || 443}/api/asterisk/ws`,
7015
+ wsServers: `wss://${host}:${port}/api/asterisk/ws`,
7003
7016
  },
7004
7017
  sessionDescriptionHandlerFactoryOptions: {
7005
7018
  modifiers: [replaceLocalIpModifier],
@@ -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
  }
@@ -34,13 +34,16 @@ var updateFrom = (instance , from ) => {
34
34
 
35
35
 
36
36
 
37
+
37
38
 
38
39
 
39
40
 
40
41
 
41
42
 
43
+
42
44
 
43
45
 
46
+
44
47
 
45
48
 
46
49
 
@@ -57,6 +60,7 @@ var updateFrom = (instance , from ) => {
57
60
 
58
61
 
59
62
 
63
+
60
64
 
61
65
 
62
66
  class CallSession {
@@ -76,10 +80,14 @@ class CallSession {
76
80
 
77
81
 
78
82
 
79
-
83
+
84
+
85
+ // = creationTime
80
86
 
81
87
 
82
88
 
89
+
90
+
83
91
 
84
92
 
85
93
 
@@ -115,6 +123,8 @@ class CallSession {
115
123
 
116
124
 
117
125
 
126
+
127
+
118
128
 
119
129
  constructor({
120
130
  answered,
@@ -128,6 +138,8 @@ class CallSession {
128
138
  paused,
129
139
  ringing,
130
140
  startTime,
141
+ creationTime,
142
+ endTime,
131
143
  cameraEnabled,
132
144
  dialedExtension,
133
145
  sipCallId,
@@ -140,12 +152,16 @@ class CallSession {
140
152
  recording,
141
153
  recordingPaused,
142
154
  videoRemotelyDowngraded,
155
+ sipSession,
156
+ answerTime,
143
157
  } ) {
144
158
  this.callId = callId;
145
159
  this.sipCallId = sipCallId;
146
160
  this.displayName = displayName;
147
161
  this.number = number;
162
+ this.creationTime = creationTime;
148
163
  this.startTime = startTime;
164
+ this.endTime = endTime;
149
165
  this.isCaller = isCaller;
150
166
  this.answered = answered;
151
167
  this.answeredBySystem = answeredBySystem;
@@ -164,6 +180,8 @@ class CallSession {
164
180
  this.recording = recording || false;
165
181
  this.recordingPaused = recordingPaused || false;
166
182
  this.videoRemotelyDowngraded = videoRemotelyDowngraded;
183
+ this.sipSession = sipSession;
184
+ this.answerTime = answerTime || this.answerTime;
167
185
 
168
186
  // Useful to compare instead of instanceof with minified code
169
187
  this.type = 'CallSession';
@@ -194,7 +212,7 @@ class CallSession {
194
212
  }
195
213
 
196
214
  answer() {
197
- this.answered = true;
215
+ this.answerTime = new Date();
198
216
  }
199
217
 
200
218
  systemAnswer() {
@@ -350,6 +368,15 @@ class CallSession {
350
368
  return newFrom(callSession, CallSession);
351
369
  }
352
370
 
371
+ // Retro-compatibility: `answered` was a boolean before. We can reproduce the behaviour with a getter/setter
372
+ set answered(value ) {
373
+ this.answerTime = value ? new Date() : null;
374
+ }
375
+
376
+ get answered() {
377
+ return !!this.answerTime;
378
+ }
379
+
353
380
  static parseCall(call ) {
354
381
  return new CallSession({
355
382
  callId: call.id,
@@ -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
  }