@wazo/sdk 0.37.41 → 0.38.0

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 (112) hide show
  1. package/dist/wazo-sdk.js +3 -3
  2. package/esm/__tests__/api-client.test.js +45 -22
  3. package/esm/__tests__/web-rtc-client.test.js +49 -24
  4. package/esm/api/agentd.js +12 -7
  5. package/esm/api/amid.js +12 -7
  6. package/esm/api/application.js +12 -7
  7. package/esm/api/auth.js +16 -8
  8. package/esm/api/call-logd.js +12 -7
  9. package/esm/api/calld.js +12 -7
  10. package/esm/api/chatd.js +12 -7
  11. package/esm/api/confd.js +12 -7
  12. package/esm/api/ctid-ng.js +14 -7
  13. package/esm/api/dird.js +12 -7
  14. package/esm/api/webhookd.js +12 -7
  15. package/esm/api-client.js +45 -22
  16. package/esm/checker/Checker.js +50 -25
  17. package/esm/checker/checks/aor.js +45 -22
  18. package/esm/checker/checks/api.js +45 -22
  19. package/esm/checker/checks/index.js +50 -25
  20. package/esm/checker/checks/wazo-websocket.js +13 -8
  21. package/esm/checker/checks/webrtc-transport.js +49 -24
  22. package/esm/checker/checks/webrtc.js +49 -24
  23. package/esm/domain/AdHocAPIConference.js +54 -23
  24. package/esm/domain/Features.js +54 -23
  25. package/esm/domain/Phone/CTIPhone.js +54 -23
  26. package/esm/domain/Phone/WebRTCPhone.js +14 -7
  27. package/esm/index.js +233 -25
  28. package/esm/lib/WazoSessionDescriptionHandler.js +12 -7
  29. package/esm/service/CallApi.js +54 -23
  30. package/esm/service/IssueReporter.js +12 -7
  31. package/esm/service/__tests__/IssueReporter.test.js +18 -7
  32. package/esm/service/getApiClient.js +63 -24
  33. package/esm/simple/Auth.js +233 -25
  34. package/esm/simple/Configuration.js +233 -25
  35. package/esm/simple/Directory.js +54 -23
  36. package/esm/simple/Phone.js +233 -25
  37. package/esm/simple/Softphone.js +148 -0
  38. package/esm/simple/Websocket.js +13 -8
  39. package/esm/simple/index.js +233 -25
  40. package/esm/simple/room/LocalParticipant.js +233 -25
  41. package/esm/simple/room/Participant.js +233 -25
  42. package/esm/simple/room/RemoteParticipant.js +233 -25
  43. package/esm/simple/room/Room.js +233 -25
  44. package/esm/simple/room/SipRoom.js +233 -25
  45. package/esm/simple/room/Stream.js +233 -25
  46. package/esm/simple/room/__tests__/RemoteParticipant.test.js +233 -25
  47. package/esm/simple/utils.js +233 -25
  48. package/esm/utils/__tests__/api-requester.test.js +12 -7
  49. package/esm/utils/api-requester.js +12 -7
  50. package/esm/web-rtc-client.js +49 -24
  51. package/esm/websocket-client.js +13 -8
  52. package/lib/__tests__/api-client.test.js +45 -22
  53. package/lib/__tests__/web-rtc-client.test.js +49 -24
  54. package/lib/api/agentd.js +12 -7
  55. package/lib/api/amid.js +12 -7
  56. package/lib/api/application.js +12 -7
  57. package/lib/api/auth.js +16 -8
  58. package/lib/api/call-logd.js +12 -7
  59. package/lib/api/calld.js +12 -7
  60. package/lib/api/chatd.js +12 -7
  61. package/lib/api/confd.js +12 -7
  62. package/lib/api/ctid-ng.js +14 -7
  63. package/lib/api/dird.js +12 -7
  64. package/lib/api/webhookd.js +12 -7
  65. package/lib/api-client.js +45 -22
  66. package/lib/checker/Checker.js +50 -25
  67. package/lib/checker/checks/aor.js +45 -22
  68. package/lib/checker/checks/api.js +45 -22
  69. package/lib/checker/checks/index.js +50 -25
  70. package/lib/checker/checks/wazo-websocket.js +13 -8
  71. package/lib/checker/checks/webrtc-transport.js +49 -24
  72. package/lib/checker/checks/webrtc.js +49 -24
  73. package/lib/domain/AdHocAPIConference.js +54 -23
  74. package/lib/domain/Features.js +54 -23
  75. package/lib/domain/Phone/CTIPhone.js +54 -23
  76. package/lib/domain/Phone/WebRTCPhone.js +14 -7
  77. package/lib/index.js +233 -25
  78. package/lib/lib/WazoSessionDescriptionHandler.js +12 -7
  79. package/lib/service/CallApi.js +54 -23
  80. package/lib/service/IssueReporter.js +12 -7
  81. package/lib/service/__tests__/IssueReporter.test.js +18 -7
  82. package/lib/service/getApiClient.js +64 -23
  83. package/lib/simple/Auth.js +233 -25
  84. package/lib/simple/Configuration.js +233 -25
  85. package/lib/simple/Directory.js +54 -23
  86. package/lib/simple/Phone.js +233 -25
  87. package/lib/simple/Softphone.js +150 -0
  88. package/lib/simple/Websocket.js +13 -8
  89. package/lib/simple/index.js +233 -25
  90. package/lib/simple/room/LocalParticipant.js +233 -25
  91. package/lib/simple/room/Participant.js +233 -25
  92. package/lib/simple/room/RemoteParticipant.js +233 -25
  93. package/lib/simple/room/Room.js +233 -25
  94. package/lib/simple/room/SipRoom.js +233 -25
  95. package/lib/simple/room/Stream.js +233 -25
  96. package/lib/simple/room/__tests__/RemoteParticipant.test.js +233 -25
  97. package/lib/simple/utils.js +233 -25
  98. package/lib/utils/__tests__/api-requester.test.js +12 -7
  99. package/lib/utils/api-requester.js +12 -7
  100. package/lib/web-rtc-client.js +49 -24
  101. package/lib/websocket-client.js +13 -8
  102. package/package.json +1 -1
  103. package/src/api/auth.js +4 -1
  104. package/src/api-client.js +26 -13
  105. package/src/service/IssueReporter.js +12 -7
  106. package/src/service/__tests__/IssueReporter.test.js +6 -0
  107. package/src/service/getApiClient.js +19 -1
  108. package/src/simple/Auth.js +21 -0
  109. package/src/simple/Softphone.js +148 -0
  110. package/src/simple/index.js +2 -0
  111. package/src/web-rtc-client.js +4 -2
  112. package/src/websocket-client.js +1 -1
@@ -1039,13 +1039,9 @@ class IssueReporter {
1039
1039
 
1040
1040
  setTimeout(() => {
1041
1041
  if (isArray) {
1042
- payload = payload.map(message => {
1043
- message._retry = retry + 1;
1044
- return message;
1045
- });
1046
- } else {
1047
- // $FlowFixMe
1048
- payload._retry = retry + 1;
1042
+ payload = payload.map(message => this._writeRetryCount(message, retry + 1));
1043
+ } else if (payload && typeof payload === 'object') {
1044
+ payload = this._writeRetryCount(payload, retry + 1);
1049
1045
  }
1050
1046
 
1051
1047
  this._sendDebugToGrafana(payload, retry + 1);
@@ -1053,6 +1049,15 @@ class IssueReporter {
1053
1049
  });
1054
1050
  }
1055
1051
 
1052
+ _writeRetryCount(message , count ) {
1053
+ if (message && typeof message === 'object') {
1054
+ // $FlowFixMe
1055
+ message._retry = count;
1056
+ }
1057
+
1058
+ return message;
1059
+ }
1060
+
1056
1061
  _isLevelAbove(level1 , level2 ) {
1057
1062
  const index1 = LOG_LEVELS.indexOf(level1);
1058
1063
  const index2 = LOG_LEVELS.indexOf(level2);
@@ -2878,9 +2883,12 @@ var authMethods = (client , baseUrl ) => ({
2878
2883
  expiration: expiration || DETAULT_EXPIRATION,
2879
2884
  refresh_token: refreshToken,
2880
2885
  client_id: client.clientId,
2881
- tenant_id: tenantId,
2882
2886
  };
2883
2887
 
2888
+ if (tenantId) {
2889
+ body.tenant_id = tenantId;
2890
+ }
2891
+
2884
2892
  const headers = {
2885
2893
  'Content-Type': 'application/json',
2886
2894
  ...(isMobile ? { 'Wazo-Session-Type': 'mobile' } : {}),
@@ -5425,6 +5433,7 @@ class ApiClient {
5425
5433
 
5426
5434
 
5427
5435
 
5436
+
5428
5437
 
5429
5438
 
5430
5439
 
@@ -5477,23 +5486,31 @@ class ApiClient {
5477
5486
  return null;
5478
5487
  }
5479
5488
 
5480
- const session = await this.auth.refreshToken(
5481
- this.refreshToken,
5482
- this.refreshBackend,
5483
- this.refreshExpiration,
5484
- this.isMobile,
5485
- this.refreshTenantId,
5486
- );
5489
+ try {
5490
+ const session = await this.auth.refreshToken(
5491
+ this.refreshToken,
5492
+ this.refreshBackend,
5493
+ this.refreshExpiration,
5494
+ this.isMobile,
5495
+ this.refreshTenantId,
5496
+ );
5487
5497
 
5488
- logger$a.info('token refreshed', { token: session.token });
5498
+ logger$a.info('token refreshed', { token: session.token });
5489
5499
 
5490
- if (this.onRefreshToken) {
5491
- this.onRefreshToken(session.token, session);
5492
- }
5500
+ if (this.onRefreshToken) {
5501
+ this.onRefreshToken(session.token, session);
5502
+ }
5493
5503
 
5494
- this.setToken(session.token);
5504
+ this.setToken(session.token);
5505
+
5506
+ return session.token;
5507
+ } catch (error) {
5508
+ logger$a.error('token refresh, error', error);
5495
5509
 
5496
- return session.token;
5510
+ if (this.onRefreshTokenError) {
5511
+ this.onRefreshTokenError(error);
5512
+ }
5513
+ }
5497
5514
  }
5498
5515
 
5499
5516
  setToken(token ) {
@@ -5516,6 +5533,10 @@ class ApiClient {
5516
5533
  this.onRefreshToken = onRefreshToken;
5517
5534
  }
5518
5535
 
5536
+ setOnRefreshTokenError(callback ) {
5537
+ this.onRefreshTokenError = callback;
5538
+ }
5539
+
5519
5540
  setRefreshExpiration(refreshExpiration ) {
5520
5541
  this.refreshExpiration = refreshExpiration;
5521
5542
  }
@@ -5551,7 +5572,9 @@ global.wazoClients = global.wazoClients || {};
5551
5572
  global.wazoClientId = global.wazoClientId || {};
5552
5573
  global.wazoClientToken = global.wazoClientToken || {};
5553
5574
  global.wazoRefreshToken = global.wazoRefreshToken || {};
5575
+ global.wazoRefreshTenantId = global.wazoRefreshTenantId || {};
5554
5576
  global.wazoOnRefreshToken = global.wazoOnRefreshToken || {};
5577
+ global.wazoOnRefreshTokenError = global.wazoOnRefreshTokenError || {};
5555
5578
  global.wazoRefreshExpiration = global.wazoRefreshExpiration || {};
5556
5579
  global.wazoRefreshBackend = global.wazoRefreshBackend || {};
5557
5580
  global.wazoIsMobile = global.wazoIsMobile || {};
@@ -5573,10 +5596,18 @@ const setRefreshToken = (newRefreshToken , forServer = null) =>
5573
5596
  global.wazoRefreshToken[forServer] = newRefreshToken;
5574
5597
  };
5575
5598
 
5599
+ const setRefreshTenantId = (refreshTenantId , forServer = null) => {
5600
+ global.wazoRefreshTenantId[forServer] = refreshTenantId;
5601
+ };
5602
+
5576
5603
  const setOnRefreshToken = (onRefreshToken , forServer = null) => {
5577
5604
  global.wazoOnRefreshToken[forServer] = onRefreshToken;
5578
5605
  };
5579
5606
 
5607
+ const setOnRefreshTokenError = (callback , forServer = null) => {
5608
+ global.wazoOnRefreshTokenError[forServer] = callback;
5609
+ };
5610
+
5580
5611
  const setRefreshExpiration = (refreshExpiration , forServer = null) => {
5581
5612
  global.wazoRefreshExpiration[forServer] = refreshExpiration;
5582
5613
  };
@@ -5595,12 +5626,20 @@ const fillClient = (apiClient ) => {
5595
5626
 
5596
5627
  apiClient.setRefreshToken(global.wazoRefreshToken[server] || global.wazoRefreshToken[null] || apiClient.refreshToken);
5597
5628
 
5629
+ apiClient.setRefreshTenantId(
5630
+ global.wazoRefreshTenantId[server] || global.wazoRefreshTenantId[null] || apiClient.refreshTenantId,
5631
+ );
5632
+
5598
5633
  apiClient.setFetchOptions(global.wazoFetchOptions[server] || global.wazoFetchOptions[null] || apiClient.fetchOptions);
5599
5634
 
5600
5635
  apiClient.setOnRefreshToken(
5601
5636
  global.wazoOnRefreshToken[server] || global.wazoOnRefreshToken[null] || apiClient.onRefreshToken,
5602
5637
  );
5603
5638
 
5639
+ apiClient.setOnRefreshTokenError(
5640
+ global.wazoOnRefreshTokenError[server] || global.wazoOnRefreshTokenError[null] || apiClient.onRefreshTokenError,
5641
+ );
5642
+
5604
5643
  apiClient.setRefreshExpiration(
5605
5644
  global.wazoRefreshExpiration[server] || global.wazoRefreshExpiration[null] || apiClient.refreshExpiration,
5606
5645
  );
@@ -5614,7 +5653,7 @@ const fillClient = (apiClient ) => {
5614
5653
  return apiClient;
5615
5654
  };
5616
5655
 
5617
- var getApiClient = (forServer ) => {
5656
+ var getApiClient = (forServer = null) => {
5618
5657
  const server = forServer || global.wazoCurrentServer || '';
5619
5658
  if (server in global.wazoClients) {
5620
5659
  return fillClient(global.wazoClients[server]);
@@ -7150,8 +7189,10 @@ class WebRTCClient extends Emitter {
7150
7189
  conference: isConference,
7151
7190
  };
7152
7191
 
7153
- // Avoid sdh to created a new stream
7154
- session.sessionDescriptionHandler.localMediaStreamConstraints = options.constraints;
7192
+ // Avoid sdh to create a new stream
7193
+ if (session.sessionDescriptionHandler) {
7194
+ session.sessionDescriptionHandler.localMediaStreamConstraints = options.constraints;
7195
+ }
7155
7196
 
7156
7197
  // Send re-INVITE
7157
7198
  return session.invite(options);
@@ -10412,6 +10453,7 @@ class Auth {
10412
10453
 
10413
10454
 
10414
10455
 
10456
+
10415
10457
 
10416
10458
 
10417
10459
 
@@ -10449,6 +10491,14 @@ class Auth {
10449
10491
  this.onRefreshTokenCallback(token, session);
10450
10492
  }
10451
10493
  });
10494
+
10495
+ setOnRefreshTokenError(error => {
10496
+ logger$7.error('on refresh token error', error);
10497
+
10498
+ if (this.onRefreshTokenCallbackError) {
10499
+ this.onRefreshTokenCallbackError(error);
10500
+ }
10501
+ });
10452
10502
  }
10453
10503
 
10454
10504
  setFetchOptions(options ) {
@@ -10537,6 +10587,10 @@ class Auth {
10537
10587
  this.onRefreshTokenCallback = callback;
10538
10588
  }
10539
10589
 
10590
+ setOnRefreshTokenError(callback ) {
10591
+ this.onRefreshTokenCallbackError = callback;
10592
+ }
10593
+
10540
10594
  checkAuthorizations(session , authorizationName ) {
10541
10595
  if (!authorizationName) {
10542
10596
  return;
@@ -10569,6 +10623,12 @@ class Auth {
10569
10623
  setRefreshToken(refreshToken);
10570
10624
  }
10571
10625
 
10626
+ setRefreshTenantId(refreshTenantId ) {
10627
+ setRefreshTenantId(refreshTenantId);
10628
+
10629
+ getApiClient().setRefreshTenantId(refreshTenantId);
10630
+ }
10631
+
10572
10632
  forceRefreshToken() {
10573
10633
  getApiClient().forceRefreshToken();
10574
10634
  }
@@ -11026,7 +11086,7 @@ class WebSocketClient extends Emitter {
11026
11086
  this.close();
11027
11087
  }
11028
11088
  const url = `wss://${this.host || ''}/api/websocketd/?token=${this.token || ''}&version=${this.version}`;
11029
- logger$6.log('Wazo WS url computed to reconnect', { url });
11089
+ logger$6.info('Wazo WS url computed to reconnect', { url });
11030
11090
 
11031
11091
  return url;
11032
11092
  }
@@ -13509,6 +13569,153 @@ class Checker {
13509
13569
  }
13510
13570
  }
13511
13571
 
13572
+ //
13573
+ /* eslint-disable no-unused-vars */
13574
+ /* global window, document */
13575
+ const SDK_CLICK_TO_CALL = 'sdk/CLICK_TO_CALL';
13576
+ const SDK_ON_CALL_MADE = 'sdk/SDK_ON_CALL_MADE';
13577
+ const SDK_CALL_ENDED = 'sdk/ON_CALL_ENDED';
13578
+ const SDK_CALL_INCOMING = 'sdk/SDK_CALL_INCOMING';
13579
+ const SDK_AUTHENTICATED = 'sdk/SDK_AUTHENTICATED';
13580
+
13581
+ class Softphone {
13582
+ url = 'https://softphone.wazo.io';
13583
+ width = 500;
13584
+ height = 600;
13585
+ displayed = false;
13586
+ iframe = null;
13587
+
13588
+ onLinkEnabled(link ) {}
13589
+
13590
+ onCallMade(call ) {}
13591
+ onCallIncoming(call ) {}
13592
+ onCallEnded(call , card , direction , fromExtension ) {}
13593
+ onAuthenticated(session ) {}
13594
+
13595
+ init(url , width , height ) {
13596
+ if (url) {
13597
+ this.url = url;
13598
+ }
13599
+ if (width) {
13600
+ this.width = width;
13601
+ }
13602
+ if (height) {
13603
+ this.height = height;
13604
+ }
13605
+
13606
+ window.addEventListener('message', this._onMessage.bind(this), false);
13607
+
13608
+ this._createIframe();
13609
+ }
13610
+
13611
+ parseLinks() {
13612
+ const links = this._getLinks();
13613
+
13614
+ links.forEach(link => {
13615
+ link.setAttribute('data-wazo-parsed', true);
13616
+ link.addEventListener('click', this._onLinkClick.bind(this));
13617
+ this.onLinkEnabled(link);
13618
+ });
13619
+ }
13620
+
13621
+ makeCall(number ) {
13622
+ this.displaySoftphone();
13623
+
13624
+ if (this.iframe) {
13625
+ this.iframe.contentWindow.postMessage({ type: SDK_CLICK_TO_CALL, number }, '*');
13626
+ }
13627
+ }
13628
+
13629
+ toggleSoftphoneDisplay() {
13630
+ if (this.displayed) {
13631
+ this.hideSoftphone();
13632
+ } else {
13633
+ this.displaySoftphone();
13634
+ }
13635
+
13636
+ this.displayed = !this.displayed;
13637
+ }
13638
+
13639
+ displaySoftphone() {
13640
+ if (!this.iframe) {
13641
+ this._createIframe();
13642
+ }
13643
+
13644
+ if (this.iframe) {
13645
+ this.iframe.style.display = 'block';
13646
+ }
13647
+ }
13648
+
13649
+ hideSoftphone() {
13650
+ if (this.iframe) {
13651
+ this.iframe.style.display = 'none';
13652
+ }
13653
+ }
13654
+
13655
+ _createIframe() {
13656
+ this.iframe = document.createElement('iframe');
13657
+ // $FlowFixMe
13658
+ this.iframe.width = this.width;
13659
+ // $FlowFixMe
13660
+ this.iframe.height = this.height;
13661
+ // $FlowFixMe
13662
+ this.iframe.allow = 'camera *; microphone *; autoplay *; display-capture *';
13663
+ this.iframe.style.position = 'absolute';
13664
+ this.iframe.style.left = '0';
13665
+ this.iframe.style.bottom = '0';
13666
+ this.iframe.style.border = '1px solid #aaa';
13667
+ this.iframe.src = this.url;
13668
+ this.iframe.style.display = 'none';
13669
+ this.iframe.id = 'wazo-softphone';
13670
+
13671
+ // $FlowFixMe
13672
+ document.body.appendChild(this.iframe);
13673
+ }
13674
+
13675
+ _getLinks() {
13676
+ return [].slice.call(document.querySelectorAll('a:not([data-wazo-parsed])'), 0)
13677
+ .filter(link => link.href.indexOf('tel:') === 0 || link.href.indexOf('callto:') === 0);
13678
+ }
13679
+
13680
+ _onLinkClick(e ) {
13681
+ e.preventDefault();
13682
+ const number = e.target.href.split(':')[1];
13683
+
13684
+ this.makeCall(number);
13685
+ }
13686
+
13687
+ _onAuthenticated() {
13688
+ this.parseLinks();
13689
+ }
13690
+
13691
+ _onMessage(event ) {
13692
+ if (!event.data) {
13693
+ return;
13694
+ }
13695
+
13696
+ switch (event.data.type) {
13697
+ case SDK_ON_CALL_MADE:
13698
+ this.onCallMade(event.data.callSession);
13699
+ break;
13700
+ case SDK_CALL_ENDED: {
13701
+ const { callSession, content, direction, userExtension } = event.data;
13702
+ this.onCallEnded(callSession, content, direction, userExtension);
13703
+ break;
13704
+ }
13705
+ case SDK_CALL_INCOMING:
13706
+ this.onCallIncoming(event.data.callSession);
13707
+ break;
13708
+ case SDK_AUTHENTICATED:
13709
+ // $FlowFixMe
13710
+ this._onAuthenticated(event.data.session);
13711
+ this.onAuthenticated(event.data.session);
13712
+ break;
13713
+ }
13714
+ }
13715
+ }
13716
+
13717
+ var Softphone$1 = new Softphone();
13718
+
13512
13719
  /* global window */
13513
13720
 
13514
13721
  const Wazo = {
@@ -13529,6 +13736,7 @@ const Wazo = {
13529
13736
  loggerFor: IssueReporter$1.loggerFor.bind(IssueReporter$1),
13530
13737
  Features: Features$1,
13531
13738
  Checker,
13739
+ Softphone: Softphone$1,
13532
13740
 
13533
13741
  // Domain
13534
13742
  domain: {
@@ -0,0 +1,150 @@
1
+ 'use strict';
2
+
3
+ //
4
+ /* eslint-disable no-unused-vars */
5
+ /* global window, document */
6
+ const SDK_CLICK_TO_CALL = 'sdk/CLICK_TO_CALL';
7
+ const SDK_ON_CALL_MADE = 'sdk/SDK_ON_CALL_MADE';
8
+ const SDK_CALL_ENDED = 'sdk/ON_CALL_ENDED';
9
+ const SDK_CALL_INCOMING = 'sdk/SDK_CALL_INCOMING';
10
+ const SDK_AUTHENTICATED = 'sdk/SDK_AUTHENTICATED';
11
+
12
+ class Softphone {
13
+ url = 'https://softphone.wazo.io';
14
+ width = 500;
15
+ height = 600;
16
+ displayed = false;
17
+ iframe = null;
18
+
19
+ onLinkEnabled(link ) {}
20
+
21
+ onCallMade(call ) {}
22
+ onCallIncoming(call ) {}
23
+ onCallEnded(call , card , direction , fromExtension ) {}
24
+ onAuthenticated(session ) {}
25
+
26
+ init(url , width , height ) {
27
+ if (url) {
28
+ this.url = url;
29
+ }
30
+ if (width) {
31
+ this.width = width;
32
+ }
33
+ if (height) {
34
+ this.height = height;
35
+ }
36
+
37
+ window.addEventListener('message', this._onMessage.bind(this), false);
38
+
39
+ this._createIframe();
40
+ }
41
+
42
+ parseLinks() {
43
+ const links = this._getLinks();
44
+
45
+ links.forEach(link => {
46
+ link.setAttribute('data-wazo-parsed', true);
47
+ link.addEventListener('click', this._onLinkClick.bind(this));
48
+ this.onLinkEnabled(link);
49
+ });
50
+ }
51
+
52
+ makeCall(number ) {
53
+ this.displaySoftphone();
54
+
55
+ if (this.iframe) {
56
+ this.iframe.contentWindow.postMessage({ type: SDK_CLICK_TO_CALL, number }, '*');
57
+ }
58
+ }
59
+
60
+ toggleSoftphoneDisplay() {
61
+ if (this.displayed) {
62
+ this.hideSoftphone();
63
+ } else {
64
+ this.displaySoftphone();
65
+ }
66
+
67
+ this.displayed = !this.displayed;
68
+ }
69
+
70
+ displaySoftphone() {
71
+ if (!this.iframe) {
72
+ this._createIframe();
73
+ }
74
+
75
+ if (this.iframe) {
76
+ this.iframe.style.display = 'block';
77
+ }
78
+ }
79
+
80
+ hideSoftphone() {
81
+ if (this.iframe) {
82
+ this.iframe.style.display = 'none';
83
+ }
84
+ }
85
+
86
+ _createIframe() {
87
+ this.iframe = document.createElement('iframe');
88
+ // $FlowFixMe
89
+ this.iframe.width = this.width;
90
+ // $FlowFixMe
91
+ this.iframe.height = this.height;
92
+ // $FlowFixMe
93
+ this.iframe.allow = 'camera *; microphone *; autoplay *; display-capture *';
94
+ this.iframe.style.position = 'absolute';
95
+ this.iframe.style.left = '0';
96
+ this.iframe.style.bottom = '0';
97
+ this.iframe.style.border = '1px solid #aaa';
98
+ this.iframe.src = this.url;
99
+ this.iframe.style.display = 'none';
100
+ this.iframe.id = 'wazo-softphone';
101
+
102
+ // $FlowFixMe
103
+ document.body.appendChild(this.iframe);
104
+ }
105
+
106
+ _getLinks() {
107
+ return [].slice.call(document.querySelectorAll('a:not([data-wazo-parsed])'), 0)
108
+ .filter(link => link.href.indexOf('tel:') === 0 || link.href.indexOf('callto:') === 0);
109
+ }
110
+
111
+ _onLinkClick(e ) {
112
+ e.preventDefault();
113
+ const number = e.target.href.split(':')[1];
114
+
115
+ this.makeCall(number);
116
+ }
117
+
118
+ _onAuthenticated() {
119
+ this.parseLinks();
120
+ }
121
+
122
+ _onMessage(event ) {
123
+ if (!event.data) {
124
+ return;
125
+ }
126
+
127
+ switch (event.data.type) {
128
+ case SDK_ON_CALL_MADE:
129
+ this.onCallMade(event.data.callSession);
130
+ break;
131
+ case SDK_CALL_ENDED: {
132
+ const { callSession, content, direction, userExtension } = event.data;
133
+ this.onCallEnded(callSession, content, direction, userExtension);
134
+ break;
135
+ }
136
+ case SDK_CALL_INCOMING:
137
+ this.onCallIncoming(event.data.callSession);
138
+ break;
139
+ case SDK_AUTHENTICATED:
140
+ // $FlowFixMe
141
+ this._onAuthenticated(event.data.session);
142
+ this.onAuthenticated(event.data.session);
143
+ break;
144
+ }
145
+ }
146
+ }
147
+
148
+ var Softphone$1 = new Softphone();
149
+
150
+ module.exports = Softphone$1;
@@ -395,13 +395,9 @@ class IssueReporter {
395
395
 
396
396
  setTimeout(() => {
397
397
  if (isArray) {
398
- payload = payload.map(message => {
399
- message._retry = retry + 1;
400
- return message;
401
- });
402
- } else {
403
- // $FlowFixMe
404
- payload._retry = retry + 1;
398
+ payload = payload.map(message => this._writeRetryCount(message, retry + 1));
399
+ } else if (payload && typeof payload === 'object') {
400
+ payload = this._writeRetryCount(payload, retry + 1);
405
401
  }
406
402
 
407
403
  this._sendDebugToGrafana(payload, retry + 1);
@@ -409,6 +405,15 @@ class IssueReporter {
409
405
  });
410
406
  }
411
407
 
408
+ _writeRetryCount(message , count ) {
409
+ if (message && typeof message === 'object') {
410
+ // $FlowFixMe
411
+ message._retry = count;
412
+ }
413
+
414
+ return message;
415
+ }
416
+
412
417
  _isLevelAbove(level1 , level2 ) {
413
418
  const index1 = LOG_LEVELS.indexOf(level1);
414
419
  const index2 = LOG_LEVELS.indexOf(level2);
@@ -869,7 +874,7 @@ class WebSocketClient extends Emitter {
869
874
  this.close();
870
875
  }
871
876
  const url = `wss://${this.host || ''}/api/websocketd/?token=${this.token || ''}&version=${this.version}`;
872
- logger$1.log('Wazo WS url computed to reconnect', { url });
877
+ logger$1.info('Wazo WS url computed to reconnect', { url });
873
878
 
874
879
  return url;
875
880
  }