@wazo/sdk 0.37.24 → 0.37.28

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 (129) hide show
  1. package/README.md +96 -58
  2. package/dist/wazo-sdk.js +6 -6
  3. package/esm/__tests__/api-client.test.js +14 -14
  4. package/esm/__tests__/web-rtc-client.test.js +130 -108
  5. package/esm/api/agentd.js +1 -1
  6. package/esm/api/amid.js +2 -2
  7. package/esm/api/application.js +1 -1
  8. package/esm/api/auth.js +1 -1
  9. package/esm/api/call-logd.js +3 -3
  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 +4 -4
  14. package/esm/api/dird.js +3 -3
  15. package/esm/api/webhookd.js +2 -2
  16. package/esm/api-client.js +14 -14
  17. package/esm/checker/Checker.js +155 -133
  18. package/esm/checker/checks/aor.js +14 -14
  19. package/esm/checker/checks/api.js +14 -14
  20. package/esm/checker/checks/index.js +145 -123
  21. package/esm/checker/checks/wazo-websocket.js +16 -16
  22. package/esm/checker/checks/webrtc-transport.js +130 -108
  23. package/esm/checker/checks/webrtc.js +130 -108
  24. package/esm/domain/AdHocAPIConference.js +14 -14
  25. package/esm/domain/CallLog.js +1 -1
  26. package/esm/domain/CallSession.js +15 -0
  27. package/esm/domain/Contact.js +2 -2
  28. package/esm/domain/Features.js +14 -14
  29. package/esm/domain/Phone/CTIPhone.js +43 -28
  30. package/esm/domain/Phone/WebRTCPhone.js +126 -90
  31. package/esm/domain/SFUNotAvailableError.js +9 -0
  32. package/esm/domain/__tests__/CallLog.test.js +1 -1
  33. package/esm/domain/__tests__/CallSession.test.js +15 -0
  34. package/esm/domain/__tests__/Contact.test.js +2 -2
  35. package/esm/domain/__tests__/IndirectTransfer.test.js +15 -0
  36. package/esm/domain/__tests__/Room.test.js +15 -0
  37. package/esm/index.js +415 -346
  38. package/esm/lib/WazoSessionDescriptionHandler.js +10 -5
  39. package/esm/service/CallApi.js +14 -14
  40. package/esm/service/IssueReporter.js +2 -2
  41. package/esm/service/__tests__/IssueReporter.test.js +2 -2
  42. package/esm/service/getApiClient.js +14 -14
  43. package/esm/simple/Auth.js +404 -336
  44. package/esm/simple/Configuration.js +404 -336
  45. package/esm/simple/Directory.js +14 -14
  46. package/esm/simple/Phone.js +404 -336
  47. package/esm/simple/Websocket.js +18 -18
  48. package/esm/simple/index.js +408 -340
  49. package/esm/simple/room/LocalParticipant.js +408 -340
  50. package/esm/simple/room/Participant.js +408 -340
  51. package/esm/simple/room/RemoteParticipant.js +408 -340
  52. package/esm/simple/room/Room.js +409 -341
  53. package/esm/simple/room/SipRoom.js +408 -340
  54. package/esm/simple/room/Stream.js +408 -340
  55. package/esm/simple/room/__tests__/RemoteParticipant.test.js +408 -340
  56. package/esm/simple/utils.js +408 -340
  57. package/esm/utils/__tests__/api-requester.test.js +1 -1
  58. package/esm/utils/api-requester.js +1 -1
  59. package/esm/web-rtc-client.js +130 -108
  60. package/esm/websocket-client.js +16 -16
  61. package/lib/__tests__/api-client.test.js +14 -14
  62. package/lib/__tests__/web-rtc-client.test.js +130 -108
  63. package/lib/api/agentd.js +1 -1
  64. package/lib/api/amid.js +2 -2
  65. package/lib/api/application.js +1 -1
  66. package/lib/api/auth.js +1 -1
  67. package/lib/api/call-logd.js +3 -3
  68. package/lib/api/calld.js +1 -1
  69. package/lib/api/chatd.js +1 -1
  70. package/lib/api/confd.js +1 -1
  71. package/lib/api/ctid-ng.js +4 -4
  72. package/lib/api/dird.js +3 -3
  73. package/lib/api/webhookd.js +2 -2
  74. package/lib/api-client.js +14 -14
  75. package/lib/checker/Checker.js +155 -133
  76. package/lib/checker/checks/aor.js +14 -14
  77. package/lib/checker/checks/api.js +14 -14
  78. package/lib/checker/checks/index.js +145 -123
  79. package/lib/checker/checks/wazo-websocket.js +16 -16
  80. package/lib/checker/checks/webrtc-transport.js +130 -108
  81. package/lib/checker/checks/webrtc.js +130 -108
  82. package/lib/domain/AdHocAPIConference.js +14 -14
  83. package/lib/domain/CallLog.js +1 -1
  84. package/lib/domain/CallSession.js +15 -0
  85. package/lib/domain/Contact.js +2 -2
  86. package/lib/domain/Features.js +14 -14
  87. package/lib/domain/Phone/CTIPhone.js +43 -28
  88. package/lib/domain/Phone/WebRTCPhone.js +126 -89
  89. package/lib/domain/SFUNotAvailableError.js +11 -0
  90. package/lib/domain/__tests__/CallLog.test.js +1 -1
  91. package/lib/domain/__tests__/CallSession.test.js +15 -0
  92. package/lib/domain/__tests__/Contact.test.js +2 -2
  93. package/lib/domain/__tests__/IndirectTransfer.test.js +15 -0
  94. package/lib/domain/__tests__/Room.test.js +15 -0
  95. package/lib/index.js +415 -346
  96. package/lib/lib/WazoSessionDescriptionHandler.js +10 -5
  97. package/lib/service/CallApi.js +14 -14
  98. package/lib/service/IssueReporter.js +2 -2
  99. package/lib/service/__tests__/IssueReporter.test.js +2 -2
  100. package/lib/service/getApiClient.js +14 -14
  101. package/lib/simple/Auth.js +404 -336
  102. package/lib/simple/Configuration.js +404 -336
  103. package/lib/simple/Directory.js +14 -14
  104. package/lib/simple/Phone.js +404 -336
  105. package/lib/simple/Websocket.js +18 -18
  106. package/lib/simple/index.js +408 -340
  107. package/lib/simple/room/LocalParticipant.js +408 -340
  108. package/lib/simple/room/Participant.js +408 -340
  109. package/lib/simple/room/RemoteParticipant.js +408 -340
  110. package/lib/simple/room/Room.js +409 -341
  111. package/lib/simple/room/SipRoom.js +408 -340
  112. package/lib/simple/room/Stream.js +408 -340
  113. package/lib/simple/room/__tests__/RemoteParticipant.test.js +408 -340
  114. package/lib/simple/utils.js +408 -340
  115. package/lib/utils/__tests__/api-requester.test.js +1 -1
  116. package/lib/utils/api-requester.js +1 -1
  117. package/lib/web-rtc-client.js +130 -108
  118. package/lib/websocket-client.js +16 -16
  119. package/package.json +1 -1
  120. package/src/domain/CallSession.js +16 -0
  121. package/src/domain/Contact.js +1 -1
  122. package/src/domain/Phone/WebRTCPhone.js +25 -4
  123. package/src/domain/SFUNotAvailableError.js +7 -0
  124. package/src/index.js +2 -0
  125. package/src/lib/WazoSessionDescriptionHandler.js +8 -3
  126. package/src/simple/Phone.js +2 -1
  127. package/src/simple/index.js +2 -0
  128. package/src/utils/api-requester.js +1 -1
  129. package/src/web-rtc-client.js +27 -10
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
@@ -364,11 +364,11 @@ var IssueReporter$1 = new IssueReporter();
364
364
 
365
365
  /* */
366
366
 
367
- const logger = IssueReporter$1 ? IssueReporter$1.loggerFor('api') : console;
367
+ 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
  }
@@ -365,11 +365,11 @@ var IssueReporter$1 = new IssueReporter();
365
365
 
366
366
  /* */
367
367
 
368
- const logger = IssueReporter$1 ? IssueReporter$1.loggerFor('api') : console;
368
+ 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
  }
@@ -416,7 +416,7 @@ BwIDAQAB
416
416
 
417
417
  //
418
418
 
419
- const swarmKey = KEYUTIL.getKey(swarmPublicKey);
419
+ KEYUTIL.getKey(swarmPublicKey);
420
420
 
421
421
  //
422
422
 
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
  }
@@ -1159,11 +1159,11 @@ BwIDAQAB
1159
1159
 
1160
1160
  //
1161
1161
 
1162
- const swarmKey = KEYUTIL.getKey(swarmPublicKey);
1162
+ KEYUTIL.getKey(swarmPublicKey);
1163
1163
 
1164
1164
  /* */
1165
1165
 
1166
- const logger$1 = IssueReporter$1 ? IssueReporter$1.loggerFor('api') : console;
1166
+ IssueReporter$1 ? IssueReporter$1.loggerFor('api') : console;
1167
1167
 
1168
1168
  /* eslint-disable dot-notation */
1169
1169
 
@@ -1185,7 +1185,7 @@ const TRANSFER_FLOW_BLIND = 'blind';
1185
1185
 
1186
1186
  // const MINIMUM_WAZO_ENGINE_VERSION_FOR_CTI_HOLD = '20.11';
1187
1187
 
1188
- const logger$2 = IssueReporter$1 ? IssueReporter$1.loggerFor('cti-phone') : console;
1188
+ IssueReporter$1 ? IssueReporter$1.loggerFor('cti-phone') : console;
1189
1189
 
1190
1190
  /* */
1191
1191
 
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
  }
@@ -734,7 +734,7 @@ const LINE_STATE = {
734
734
 
735
735
  //
736
736
 
737
- const swarmKey = KEYUTIL.getKey(swarmPublicKey);
737
+ KEYUTIL.getKey(swarmPublicKey);
738
738
 
739
739
  //
740
740
 
@@ -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
 
@@ -364,11 +364,11 @@ var IssueReporter$1 = new IssueReporter();
364
364
 
365
365
  /* */
366
366
 
367
- const logger = IssueReporter$1 ? IssueReporter$1.loggerFor('api') : console;
367
+ 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
@@ -440,11 +440,11 @@ var IssueReporter$1 = new IssueReporter();
440
440
 
441
441
  const methods = ['head', 'get', 'post', 'put', 'delete'];
442
442
 
443
- const logger = IssueReporter$1 ? IssueReporter$1.loggerFor('api') : console;
443
+ 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
  }
@@ -579,7 +579,7 @@ class ApiRequester {
579
579
  };
580
580
 
581
581
  if (this.refreshTokenPromise) {
582
- logger.info('A token is already refreshing, waiting ...', { url });
582
+ logger$1.info('A token is already refreshing, waiting ...', { url });
583
583
  await this.refreshTokenPromise;
584
584
  }
585
585
 
@@ -599,7 +599,7 @@ class ApiRequester {
599
599
  return promise.then(async (err ) => {
600
600
  // Check if the token is still valid
601
601
  if (firstCall && this._checkTokenExpired(response, err)) {
602
- logger.warn('token expired', { error: err.reason });
602
+ logger$1.warn('token expired', { error: err.reason });
603
603
  // Replay the call after refreshing the token
604
604
  return this._replayWithNewToken(err, path, method, body, headers, parse);
605
605
  }
@@ -609,7 +609,7 @@ class ApiRequester {
609
609
  : exceptionClass.fromResponse(err, response.status);
610
610
 
611
611
  if (this.shouldLogErrors) {
612
- logger.error('API error', error);
612
+ logger$1.error('API error', error);
613
613
  }
614
614
 
615
615
  throw error;
@@ -619,7 +619,7 @@ class ApiRequester {
619
619
  return newParse(response, isJson);
620
620
  }).catch(error => {
621
621
  if (this.shouldLogErrors) {
622
- logger.error('Fetch failed', { url, options, message: error.message, stack: error.stack });
622
+ logger$1.error('Fetch failed', { url, options, message: error.message, stack: error.stack });
623
623
  }
624
624
 
625
625
  throw error;
@@ -647,13 +647,13 @@ class ApiRequester {
647
647
  ) {
648
648
  const isTokenNotFound = this._isTokenNotFound(err);
649
649
  let newPath = path;
650
- logger.info('refreshing token', { inProgress: !!this.refreshTokenPromise });
650
+ logger$1.info('refreshing token', { inProgress: !!this.refreshTokenPromise });
651
651
 
652
652
  this.refreshTokenPromise = this.refreshTokenPromise || this.refreshTokenCallback();
653
653
 
654
654
  return this.refreshTokenPromise.then(() => {
655
655
  this.refreshTokenPromise = null;
656
- logger.info('token refreshed', { isTokenNotFound });
656
+ logger$1.info('token refreshed', { isTokenNotFound });
657
657
  if (isTokenNotFound) {
658
658
  const pathParts = path.split('/');
659
659
  pathParts.pop();
@@ -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
 
@@ -3595,7 +3595,7 @@ const TRANSFER_FLOW_BLIND = 'blind';
3595
3595
 
3596
3596
  // const MINIMUM_WAZO_ENGINE_VERSION_FOR_CTI_HOLD = '20.11';
3597
3597
 
3598
- const logger$1 = IssueReporter$1 ? IssueReporter$1.loggerFor('cti-phone') : console;
3598
+ IssueReporter$1 ? IssueReporter$1.loggerFor('cti-phone') : console;
3599
3599
 
3600
3600
  /* */
3601
3601
 
@@ -4514,7 +4514,7 @@ const AGENTD_VERSION = '1.0';
4514
4514
  const WEBHOOKD_VERSION = '1.0';
4515
4515
  const AMID_VERSION = '1.0';
4516
4516
 
4517
- const logger$2 = IssueReporter$1 ? IssueReporter$1.loggerFor('api') : console;
4517
+ const logger = IssueReporter$1 ? IssueReporter$1.loggerFor('api') : console;
4518
4518
 
4519
4519
  class ApiClient {
4520
4520
 
@@ -4566,12 +4566,12 @@ class ApiClient {
4566
4566
  }
4567
4567
 
4568
4568
  async forceRefreshToken() {
4569
- logger$2.info('forcing refresh token, calling callback');
4569
+ logger.info('forcing refresh token, calling callback');
4570
4570
  return this.refreshTokenCallback();
4571
4571
  }
4572
4572
 
4573
4573
  async refreshTokenCallback() {
4574
- logger$2.info('refresh token callback called', {
4574
+ logger.info('refresh token callback called', {
4575
4575
  refreshToken: this.refreshToken,
4576
4576
  refreshBackend: this.refreshBackend,
4577
4577
  refreshExpiration: this.refreshExpiration,
@@ -4589,7 +4589,7 @@ class ApiClient {
4589
4589
  this.isMobile,
4590
4590
  );
4591
4591
 
4592
- logger$2.info('token refreshed', { token: session.token });
4592
+ logger.info('token refreshed', { token: session.token });
4593
4593
 
4594
4594
  if (this.onRefreshToken) {
4595
4595
  this.onRefreshToken(session.token, session);