@wazo/sdk 0.37.25 → 0.37.29

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 (125) hide show
  1. package/README.md +96 -58
  2. package/dist/wazo-sdk.js +3 -3
  3. package/esm/__tests__/api-client.test.js +2 -2
  4. package/esm/__tests__/web-rtc-client.test.js +10 -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 +2 -2
  15. package/esm/api/webhookd.js +1 -1
  16. package/esm/api-client.js +2 -2
  17. package/esm/checker/Checker.js +10 -5
  18. package/esm/checker/checks/aor.js +2 -2
  19. package/esm/checker/checks/api.js +2 -2
  20. package/esm/checker/checks/index.js +10 -5
  21. package/esm/checker/checks/wazo-websocket.js +1 -1
  22. package/esm/checker/checks/webrtc-transport.js +10 -5
  23. package/esm/checker/checks/webrtc.js +10 -5
  24. package/esm/domain/AdHocAPIConference.js +2 -2
  25. package/esm/domain/CallSession.js +29 -2
  26. package/esm/domain/Contact.js +1 -1
  27. package/esm/domain/Features.js +2 -2
  28. package/esm/domain/Phone/CTIPhone.js +31 -4
  29. package/esm/domain/Phone/WebRTCPhone.js +55 -6
  30. package/esm/domain/SFUNotAvailableError.js +9 -0
  31. package/esm/domain/__tests__/CallSession.test.js +46 -2
  32. package/esm/domain/__tests__/Contact.test.js +1 -1
  33. package/esm/domain/__tests__/IndirectTransfer.test.js +29 -2
  34. package/esm/domain/__tests__/Room.test.js +29 -2
  35. package/esm/index.js +75 -10
  36. package/esm/lib/WazoSessionDescriptionHandler.js +9 -4
  37. package/esm/service/CallApi.js +2 -2
  38. package/esm/service/IssueReporter.js +1 -1
  39. package/esm/service/__tests__/IssueReporter.test.js +1 -1
  40. package/esm/service/getApiClient.js +2 -2
  41. package/esm/simple/Auth.js +74 -10
  42. package/esm/simple/Configuration.js +74 -10
  43. package/esm/simple/Directory.js +2 -2
  44. package/esm/simple/Phone.js +74 -10
  45. package/esm/simple/Websocket.js +1 -1
  46. package/esm/simple/index.js +74 -10
  47. package/esm/simple/room/LocalParticipant.js +74 -10
  48. package/esm/simple/room/Participant.js +74 -10
  49. package/esm/simple/room/RemoteParticipant.js +74 -10
  50. package/esm/simple/room/Room.js +74 -10
  51. package/esm/simple/room/SipRoom.js +74 -10
  52. package/esm/simple/room/Stream.js +74 -10
  53. package/esm/simple/room/__tests__/RemoteParticipant.test.js +74 -10
  54. package/esm/simple/utils.js +74 -10
  55. package/esm/utils/__tests__/api-requester.test.js +1 -1
  56. package/esm/utils/api-requester.js +1 -1
  57. package/esm/web-rtc-client.js +10 -5
  58. package/esm/websocket-client.js +1 -1
  59. package/lib/__tests__/api-client.test.js +2 -2
  60. package/lib/__tests__/web-rtc-client.test.js +10 -5
  61. package/lib/api/agentd.js +1 -1
  62. package/lib/api/amid.js +1 -1
  63. package/lib/api/application.js +1 -1
  64. package/lib/api/auth.js +1 -1
  65. package/lib/api/call-logd.js +1 -1
  66. package/lib/api/calld.js +1 -1
  67. package/lib/api/chatd.js +1 -1
  68. package/lib/api/confd.js +1 -1
  69. package/lib/api/ctid-ng.js +1 -1
  70. package/lib/api/dird.js +2 -2
  71. package/lib/api/webhookd.js +1 -1
  72. package/lib/api-client.js +2 -2
  73. package/lib/checker/Checker.js +10 -5
  74. package/lib/checker/checks/aor.js +2 -2
  75. package/lib/checker/checks/api.js +2 -2
  76. package/lib/checker/checks/index.js +10 -5
  77. package/lib/checker/checks/wazo-websocket.js +1 -1
  78. package/lib/checker/checks/webrtc-transport.js +10 -5
  79. package/lib/checker/checks/webrtc.js +10 -5
  80. package/lib/domain/AdHocAPIConference.js +2 -2
  81. package/lib/domain/CallSession.js +29 -2
  82. package/lib/domain/Contact.js +1 -1
  83. package/lib/domain/Features.js +2 -2
  84. package/lib/domain/Phone/CTIPhone.js +31 -4
  85. package/lib/domain/Phone/WebRTCPhone.js +55 -5
  86. package/lib/domain/SFUNotAvailableError.js +11 -0
  87. package/lib/domain/__tests__/CallSession.test.js +46 -2
  88. package/lib/domain/__tests__/Contact.test.js +1 -1
  89. package/lib/domain/__tests__/IndirectTransfer.test.js +29 -2
  90. package/lib/domain/__tests__/Room.test.js +29 -2
  91. package/lib/index.js +75 -10
  92. package/lib/lib/WazoSessionDescriptionHandler.js +9 -4
  93. package/lib/service/CallApi.js +2 -2
  94. package/lib/service/IssueReporter.js +1 -1
  95. package/lib/service/__tests__/IssueReporter.test.js +1 -1
  96. package/lib/service/getApiClient.js +2 -2
  97. package/lib/simple/Auth.js +74 -10
  98. package/lib/simple/Configuration.js +74 -10
  99. package/lib/simple/Directory.js +2 -2
  100. package/lib/simple/Phone.js +74 -10
  101. package/lib/simple/Websocket.js +1 -1
  102. package/lib/simple/index.js +74 -10
  103. package/lib/simple/room/LocalParticipant.js +74 -10
  104. package/lib/simple/room/Participant.js +74 -10
  105. package/lib/simple/room/RemoteParticipant.js +74 -10
  106. package/lib/simple/room/Room.js +74 -10
  107. package/lib/simple/room/SipRoom.js +74 -10
  108. package/lib/simple/room/Stream.js +74 -10
  109. package/lib/simple/room/__tests__/RemoteParticipant.test.js +74 -10
  110. package/lib/simple/utils.js +74 -10
  111. package/lib/utils/__tests__/api-requester.test.js +1 -1
  112. package/lib/utils/api-requester.js +1 -1
  113. package/lib/web-rtc-client.js +10 -5
  114. package/lib/websocket-client.js +1 -1
  115. package/package.json +1 -1
  116. package/src/domain/CallSession.js +32 -4
  117. package/src/domain/Contact.js +1 -1
  118. package/src/domain/Phone/WebRTCPhone.js +24 -2
  119. package/src/domain/SFUNotAvailableError.js +7 -0
  120. package/src/domain/__tests__/CallSession.test.js +17 -0
  121. package/src/index.js +2 -0
  122. package/src/lib/WazoSessionDescriptionHandler.js +8 -3
  123. package/src/simple/Phone.js +2 -1
  124. package/src/simple/index.js +2 -0
  125. 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
  }
@@ -1904,7 +1904,7 @@ class Contact {
1904
1904
  this[key] = old[key] || this[key];
1905
1905
  });
1906
1906
 
1907
- if (old.lineState && !this.lineState) {
1907
+ if (old.lineState) {
1908
1908
  this.lineState = old.lineState;
1909
1909
  }
1910
1910
 
@@ -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.
@@ -2447,7 +2452,7 @@ class Contact {
2447
2452
  this[key] = old[key] || this[key];
2448
2453
  });
2449
2454
 
2450
- if (old.lineState && !this.lineState) {
2455
+ if (old.lineState) {
2451
2456
  this.lineState = old.lineState;
2452
2457
  }
2453
2458
 
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
  }
@@ -1388,7 +1388,7 @@ class Contact {
1388
1388
  this[key] = old[key] || this[key];
1389
1389
  });
1390
1390
 
1391
- if (old.lineState && !this.lineState) {
1391
+ if (old.lineState) {
1392
1392
  this.lineState = old.lineState;
1393
1393
  }
1394
1394
 
@@ -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
  }
@@ -1904,7 +1904,7 @@ class Contact {
1904
1904
  this[key] = old[key] || this[key];
1905
1905
  });
1906
1906
 
1907
- if (old.lineState && !this.lineState) {
1907
+ if (old.lineState) {
1908
1908
  this.lineState = old.lineState;
1909
1909
  }
1910
1910
 
@@ -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
  }
@@ -1922,7 +1922,7 @@ class Contact {
1922
1922
  this[key] = old[key] || this[key];
1923
1923
  });
1924
1924
 
1925
- if (old.lineState && !this.lineState) {
1925
+ if (old.lineState) {
1926
1926
  this.lineState = old.lineState;
1927
1927
  }
1928
1928
 
@@ -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
  }
@@ -1904,7 +1904,7 @@ class Contact {
1904
1904
  this[key] = old[key] || this[key];
1905
1905
  });
1906
1906
 
1907
- if (old.lineState && !this.lineState) {
1907
+ if (old.lineState) {
1908
1908
  this.lineState = old.lineState;
1909
1909
  }
1910
1910
 
@@ -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
  }
@@ -1904,7 +1904,7 @@ class Contact {
1904
1904
  this[key] = old[key] || this[key];
1905
1905
  });
1906
1906
 
1907
- if (old.lineState && !this.lineState) {
1907
+ if (old.lineState) {
1908
1908
  this.lineState = old.lineState;
1909
1909
  }
1910
1910
 
@@ -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
  }
@@ -1922,7 +1922,7 @@ class Contact {
1922
1922
  this[key] = old[key] || this[key];
1923
1923
  });
1924
1924
 
1925
- if (old.lineState && !this.lineState) {
1925
+ if (old.lineState) {
1926
1926
  this.lineState = old.lineState;
1927
1927
  }
1928
1928
 
@@ -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.
@@ -2447,7 +2452,7 @@ class Contact {
2447
2452
  this[key] = old[key] || this[key];
2448
2453
  });
2449
2454
 
2450
- if (old.lineState && !this.lineState) {
2455
+ if (old.lineState) {
2451
2456
  this.lineState = old.lineState;
2452
2457
  }
2453
2458
 
@@ -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.
@@ -2447,7 +2452,7 @@ class Contact {
2447
2452
  this[key] = old[key] || this[key];
2448
2453
  });
2449
2454
 
2450
- if (old.lineState && !this.lineState) {
2455
+ if (old.lineState) {
2451
2456
  this.lineState = old.lineState;
2452
2457
  }
2453
2458
 
@@ -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
  }
@@ -2113,7 +2113,7 @@ class Contact {
2113
2113
  this[key] = old[key] || this[key];
2114
2114
  });
2115
2115
 
2116
- if (old.lineState && !this.lineState) {
2116
+ if (old.lineState) {
2117
2117
  this.lineState = old.lineState;
2118
2118
  }
2119
2119
 
@@ -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,
@@ -698,7 +698,7 @@ class Contact {
698
698
  this[key] = old[key] || this[key];
699
699
  });
700
700
 
701
- if (old.lineState && !this.lineState) {
701
+ if (old.lineState) {
702
702
  this.lineState = old.lineState;
703
703
  }
704
704
 
@@ -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
  }
@@ -1904,7 +1904,7 @@ class Contact {
1904
1904
  this[key] = old[key] || this[key];
1905
1905
  });
1906
1906
 
1907
- if (old.lineState && !this.lineState) {
1907
+ if (old.lineState) {
1908
1908
  this.lineState = old.lineState;
1909
1909
  }
1910
1910
 
@@ -1217,7 +1217,7 @@ class Contact {
1217
1217
  this[key] = old[key] || this[key];
1218
1218
  });
1219
1219
 
1220
- if (old.lineState && !this.lineState) {
1220
+ if (old.lineState) {
1221
1221
  this.lineState = old.lineState;
1222
1222
  }
1223
1223
 
@@ -1706,13 +1706,16 @@ var updateFrom = (instance , from ) => {
1706
1706
 
1707
1707
 
1708
1708
 
1709
+
1709
1710
 
1710
1711
 
1711
1712
 
1712
1713
 
1713
1714
 
1715
+
1714
1716
 
1715
1717
 
1718
+
1716
1719
 
1717
1720
 
1718
1721
 
@@ -1729,6 +1732,7 @@ var updateFrom = (instance , from ) => {
1729
1732
 
1730
1733
 
1731
1734
 
1735
+
1732
1736
 
1733
1737
 
1734
1738
  class CallSession {
@@ -1748,10 +1752,14 @@ class CallSession {
1748
1752
 
1749
1753
 
1750
1754
 
1751
-
1755
+
1756
+
1757
+ // = creationTime
1752
1758
 
1753
1759
 
1754
1760
 
1761
+
1762
+
1755
1763
 
1756
1764
 
1757
1765
 
@@ -1787,6 +1795,8 @@ class CallSession {
1787
1795
 
1788
1796
 
1789
1797
 
1798
+
1799
+
1790
1800
 
1791
1801
  constructor({
1792
1802
  answered,
@@ -1800,6 +1810,8 @@ class CallSession {
1800
1810
  paused,
1801
1811
  ringing,
1802
1812
  startTime,
1813
+ creationTime,
1814
+ endTime,
1803
1815
  cameraEnabled,
1804
1816
  dialedExtension,
1805
1817
  sipCallId,
@@ -1812,12 +1824,16 @@ class CallSession {
1812
1824
  recording,
1813
1825
  recordingPaused,
1814
1826
  videoRemotelyDowngraded,
1827
+ sipSession,
1828
+ answerTime,
1815
1829
  } ) {
1816
1830
  this.callId = callId;
1817
1831
  this.sipCallId = sipCallId;
1818
1832
  this.displayName = displayName;
1819
1833
  this.number = number;
1834
+ this.creationTime = creationTime;
1820
1835
  this.startTime = startTime;
1836
+ this.endTime = endTime;
1821
1837
  this.isCaller = isCaller;
1822
1838
  this.answered = answered;
1823
1839
  this.answeredBySystem = answeredBySystem;
@@ -1836,6 +1852,8 @@ class CallSession {
1836
1852
  this.recording = recording || false;
1837
1853
  this.recordingPaused = recordingPaused || false;
1838
1854
  this.videoRemotelyDowngraded = videoRemotelyDowngraded;
1855
+ this.sipSession = sipSession;
1856
+ this.answerTime = answerTime || this.answerTime;
1839
1857
 
1840
1858
  // Useful to compare instead of instanceof with minified code
1841
1859
  this.type = 'CallSession';
@@ -1866,7 +1884,7 @@ class CallSession {
1866
1884
  }
1867
1885
 
1868
1886
  answer() {
1869
- this.answered = true;
1887
+ this.answerTime = new Date();
1870
1888
  }
1871
1889
 
1872
1890
  systemAnswer() {
@@ -2022,6 +2040,15 @@ class CallSession {
2022
2040
  return newFrom(callSession, CallSession);
2023
2041
  }
2024
2042
 
2043
+ // Retro-compatibility: `answered` was a boolean before. We can reproduce the behaviour with a getter/setter
2044
+ set answered(value ) {
2045
+ this.answerTime = value ? new Date() : null;
2046
+ }
2047
+
2048
+ get answered() {
2049
+ return !!this.answerTime;
2050
+ }
2051
+
2025
2052
  static parseCall(call ) {
2026
2053
  return new CallSession({
2027
2054
  callId: call.id,
@@ -2837,7 +2864,7 @@ const logger$2 = IssueReporter$1 ? IssueReporter$1.loggerFor('api') : console;
2837
2864
 
2838
2865
  // Use a function here to be able to mock it in tests
2839
2866
  const realFetch = () => {
2840
- if (typeof document !== 'undefined') {
2867
+ if (typeof document !== 'undefined' && window.fetch) {
2841
2868
  // Browser
2842
2869
  return window.fetch;
2843
2870
  }