@wazo/sdk 0.37.42 → 0.38.1

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 (109) hide show
  1. package/README.md +218 -0
  2. package/dist/wazo-sdk.js +5 -5
  3. package/esm/__tests__/api-client.test.js +12 -7
  4. package/esm/__tests__/web-rtc-client.test.js +17 -10
  5. package/esm/api/agentd.js +12 -7
  6. package/esm/api/amid.js +12 -7
  7. package/esm/api/application.js +12 -7
  8. package/esm/api/auth.js +12 -7
  9. package/esm/api/call-logd.js +12 -7
  10. package/esm/api/calld.js +12 -7
  11. package/esm/api/chatd.js +12 -7
  12. package/esm/api/confd.js +12 -7
  13. package/esm/api/ctid-ng.js +12 -7
  14. package/esm/api/dird.js +12 -7
  15. package/esm/api/webhookd.js +12 -7
  16. package/esm/api-client.js +12 -7
  17. package/esm/checker/Checker.js +18 -11
  18. package/esm/checker/checks/aor.js +12 -7
  19. package/esm/checker/checks/api.js +12 -7
  20. package/esm/checker/checks/index.js +18 -11
  21. package/esm/checker/checks/wazo-websocket.js +13 -8
  22. package/esm/checker/checks/webrtc-transport.js +17 -10
  23. package/esm/checker/checks/webrtc.js +17 -10
  24. package/esm/domain/AdHocAPIConference.js +12 -7
  25. package/esm/domain/Features.js +12 -7
  26. package/esm/domain/Phone/CTIPhone.js +12 -7
  27. package/esm/domain/Phone/WebRTCPhone.js +12 -7
  28. package/esm/index.js +347 -11
  29. package/esm/lib/WazoSessionDescriptionHandler.js +12 -7
  30. package/esm/service/CallApi.js +12 -7
  31. package/esm/service/IssueReporter.js +12 -7
  32. package/esm/service/__tests__/IssueReporter.test.js +18 -7
  33. package/esm/service/getApiClient.js +12 -7
  34. package/esm/simple/Auth.js +347 -11
  35. package/esm/simple/Configuration.js +347 -11
  36. package/esm/simple/Directory.js +12 -7
  37. package/esm/simple/Phone.js +347 -11
  38. package/esm/simple/Softphone.js +329 -0
  39. package/esm/simple/Websocket.js +13 -8
  40. package/esm/simple/index.js +347 -11
  41. package/esm/simple/room/LocalParticipant.js +347 -11
  42. package/esm/simple/room/Participant.js +347 -11
  43. package/esm/simple/room/RemoteParticipant.js +347 -11
  44. package/esm/simple/room/Room.js +347 -11
  45. package/esm/simple/room/SipRoom.js +347 -11
  46. package/esm/simple/room/Stream.js +347 -11
  47. package/esm/simple/room/__tests__/RemoteParticipant.test.js +347 -11
  48. package/esm/simple/utils.js +347 -11
  49. package/esm/utils/__tests__/api-requester.test.js +12 -7
  50. package/esm/utils/api-requester.js +12 -7
  51. package/esm/web-rtc-client.js +17 -10
  52. package/esm/websocket-client.js +13 -8
  53. package/lib/__tests__/api-client.test.js +12 -7
  54. package/lib/__tests__/web-rtc-client.test.js +17 -10
  55. package/lib/api/agentd.js +12 -7
  56. package/lib/api/amid.js +12 -7
  57. package/lib/api/application.js +12 -7
  58. package/lib/api/auth.js +12 -7
  59. package/lib/api/call-logd.js +12 -7
  60. package/lib/api/calld.js +12 -7
  61. package/lib/api/chatd.js +12 -7
  62. package/lib/api/confd.js +12 -7
  63. package/lib/api/ctid-ng.js +12 -7
  64. package/lib/api/dird.js +12 -7
  65. package/lib/api/webhookd.js +12 -7
  66. package/lib/api-client.js +12 -7
  67. package/lib/checker/Checker.js +18 -11
  68. package/lib/checker/checks/aor.js +12 -7
  69. package/lib/checker/checks/api.js +12 -7
  70. package/lib/checker/checks/index.js +18 -11
  71. package/lib/checker/checks/wazo-websocket.js +13 -8
  72. package/lib/checker/checks/webrtc-transport.js +17 -10
  73. package/lib/checker/checks/webrtc.js +17 -10
  74. package/lib/domain/AdHocAPIConference.js +12 -7
  75. package/lib/domain/Features.js +12 -7
  76. package/lib/domain/Phone/CTIPhone.js +12 -7
  77. package/lib/domain/Phone/WebRTCPhone.js +12 -7
  78. package/lib/index.js +347 -11
  79. package/lib/lib/WazoSessionDescriptionHandler.js +12 -7
  80. package/lib/service/CallApi.js +12 -7
  81. package/lib/service/IssueReporter.js +12 -7
  82. package/lib/service/__tests__/IssueReporter.test.js +18 -7
  83. package/lib/service/getApiClient.js +12 -7
  84. package/lib/simple/Auth.js +347 -11
  85. package/lib/simple/Configuration.js +347 -11
  86. package/lib/simple/Directory.js +12 -7
  87. package/lib/simple/Phone.js +347 -11
  88. package/lib/simple/Softphone.js +331 -0
  89. package/lib/simple/Websocket.js +13 -8
  90. package/lib/simple/index.js +347 -11
  91. package/lib/simple/room/LocalParticipant.js +347 -11
  92. package/lib/simple/room/Participant.js +347 -11
  93. package/lib/simple/room/RemoteParticipant.js +347 -11
  94. package/lib/simple/room/Room.js +347 -11
  95. package/lib/simple/room/SipRoom.js +347 -11
  96. package/lib/simple/room/Stream.js +347 -11
  97. package/lib/simple/room/__tests__/RemoteParticipant.test.js +347 -11
  98. package/lib/simple/utils.js +347 -11
  99. package/lib/utils/__tests__/api-requester.test.js +12 -7
  100. package/lib/utils/api-requester.js +12 -7
  101. package/lib/web-rtc-client.js +17 -10
  102. package/lib/websocket-client.js +13 -8
  103. package/package.json +1 -1
  104. package/src/service/IssueReporter.js +12 -7
  105. package/src/service/__tests__/IssueReporter.test.js +6 -0
  106. package/src/simple/Softphone.js +327 -0
  107. package/src/simple/index.js +2 -0
  108. package/src/web-rtc-client.js +5 -3
  109. package/src/websocket-client.js +1 -1
@@ -1909,13 +1909,9 @@ class IssueReporter {
1909
1909
 
1910
1910
  setTimeout(() => {
1911
1911
  if (isArray) {
1912
- payload = payload.map(message => {
1913
- message._retry = retry + 1;
1914
- return message;
1915
- });
1916
- } else {
1917
- // $FlowFixMe
1918
- payload._retry = retry + 1;
1912
+ payload = payload.map(message => this._writeRetryCount(message, retry + 1));
1913
+ } else if (payload && typeof payload === 'object') {
1914
+ payload = this._writeRetryCount(payload, retry + 1);
1919
1915
  }
1920
1916
 
1921
1917
  this._sendDebugToGrafana(payload, retry + 1);
@@ -1923,6 +1919,15 @@ class IssueReporter {
1923
1919
  });
1924
1920
  }
1925
1921
 
1922
+ _writeRetryCount(message , count ) {
1923
+ if (message && typeof message === 'object') {
1924
+ // $FlowFixMe
1925
+ message._retry = count;
1926
+ }
1927
+
1928
+ return message;
1929
+ }
1930
+
1926
1931
  _isLevelAbove(level1 , level2 ) {
1927
1932
  const index1 = LOG_LEVELS.indexOf(level1);
1928
1933
  const index2 = LOG_LEVELS.indexOf(level2);
@@ -7475,8 +7480,10 @@ class WebRTCClient extends Emitter {
7475
7480
  conference: isConference,
7476
7481
  };
7477
7482
 
7478
- // Avoid sdh to created a new stream
7479
- session.sessionDescriptionHandler.localMediaStreamConstraints = options.constraints;
7483
+ // Avoid sdh to create a new stream
7484
+ if (session.sessionDescriptionHandler) {
7485
+ session.sessionDescriptionHandler.localMediaStreamConstraints = options.constraints;
7486
+ }
7480
7487
 
7481
7488
  // Send re-INVITE
7482
7489
  return session.invite(options);
@@ -8319,7 +8326,7 @@ class WebRTCClient extends Emitter {
8319
8326
  }
8320
8327
 
8321
8328
  async _onHeartbeatTimeout() {
8322
- logger$8.info('sdk webrtc heartbeat timed out', { userAgent: !!this.userAgent, cb: !!this.heartbeatTimeoutCb });
8329
+ logger$8.warn('sdk webrtc heartbeat timed out', { userAgent: !!this.userAgent, cb: !!this.heartbeatTimeoutCb });
8323
8330
 
8324
8331
  if (this.heartbeatTimeoutCb) {
8325
8332
  this.heartbeatTimeoutCb();
@@ -11487,7 +11494,7 @@ class WebSocketClient extends Emitter {
11487
11494
  this.close();
11488
11495
  }
11489
11496
  const url = `wss://${this.host || ''}/api/websocketd/?token=${this.token || ''}&version=${this.version}`;
11490
- logger$5.log('Wazo WS url computed to reconnect', { url });
11497
+ logger$5.info('Wazo WS url computed to reconnect', { url });
11491
11498
 
11492
11499
  return url;
11493
11500
  }
@@ -13946,6 +13953,334 @@ class Checker {
13946
13953
  }
13947
13954
  }
13948
13955
 
13956
+ //
13957
+ /* eslint-disable no-unused-vars */
13958
+ /* global window, document */
13959
+ const BRIDGE_CONFIG_RETRIEVED = 'bridge/CONFIG_RETRIEVED';
13960
+ const BRIDGE_ENABLE_CARD = 'bridge/ENABLE_CARD';
13961
+ const BRIDGE_CHANGE_REQUIRED_SUBSCRIPTION_TYPE = 'bridge/CHANGE_REQUIRED_SUBSCRIPTION_TYPE';
13962
+ const BRIDGE_CREATE_OR_UPDATE_CARD = 'bridge/BRIDGE_CREATE_OR_UPDATE_CARD';
13963
+ const BRIDGE_OPTIONS_FETCHED = 'bridge/BRIDGE_OPTIONS_FETCHED';
13964
+ const BRIDGE_OPTIONS_FOUND = 'bridge/BRIDGE_OPTIONS_FOUND';
13965
+ const BRIDGE_SEARCH_OPTIONS = 'bridge/BRIDGE_SEARCH_OPTIONS';
13966
+ const BRIDGE_DISPLAY_LINKED_OPTION = 'bridge/DISPLAY_LINKED_OPTION';
13967
+ const BRIDGE_UPDATE_FORM_SCHEMA = 'bridge/BRIDGE_UPDATE_FORM_SCHEMA';
13968
+ const BRIDGE_WAZO_CONTACT_SEARCH = 'bridge/BRIDGE_WAZO_CONTACT_SEARCH';
13969
+ const BRIDGE_ON_AGENT_LOGGED_IN = 'bridge/BRIDGE_ON_AGENT_LOGGED_IN';
13970
+ const BRIDGE_ON_AGENT_LOGGED_OUT = 'bridge/BRIDGE_ON_AGENT_LOGGED_OUT';
13971
+ const BRIDGE_ON_AGENT_PAUSED = 'bridge/BRIDGE_ON_AGENT_PAUSED';
13972
+ const BRIDGE_ON_AGENT_RESUMED = 'bridge/BRIDGE_ON_AGENT_RESUMED';
13973
+ const BRIDGE_ON_LANGUAGE_CHANGED = 'bridge/BRIDGE_ON_LANGUAGE_CHANGED';
13974
+ const BRIDGE_ON_CALL_HELD = 'bridge/BRIDGE_ON_CALL_HELD';
13975
+ const BRIDGE_ON_CALL_RESUMED = 'bridge/BRIDGE_ON_CALL_RESUMED';
13976
+ const BRIDGE_ON_CALL_MUTED = 'bridge/BRIDGE_ON_CALL_MUTED';
13977
+ const BRIDGE_ON_CALL_UN_MUTED = 'bridge/BRIDGE_ON_CALL_UN_MUTED';
13978
+ const BRIDGE_ON_DTMF = 'bridge/BRIDGE_ON_DTMF';
13979
+ const BRIDGE_ON_DIRECT_TRANSFER = 'bridge/BRIDGE_ON_DIRECT_TRANSFER';
13980
+ const BRIDGE_ON_CREATE_INDIRECT_TRANSFER = 'bridge/BRIDGE_ON_CREATE_INDIRECT_TRANSFER';
13981
+ const BRIDGE_ON_CANCEL_INDIRECT_TRANSFER = 'bridge/BRIDGE_ON_CANCEL_INDIRECT_TRANSFER';
13982
+ const BRIDGE_ON_CONFIRM_INDIRECT_TRANSFER = 'bridge/BRIDGE_ON_CONFIRM_INDIRECT_TRANSFER';
13983
+ const BRIDGE_ON_INDIRECT_TRANSFER_CALL_MADE = 'bridge/BRIDGE_ON_INDIRECT_TRANSFER_CALL_MADE';
13984
+ const BRIDGE_ON_INDIRECT_TRANSFER_DONE = 'bridge/BRIDGE_ON_INDIRECT_TRANSFER_DONE';
13985
+ const BRIDGE_ON_START_RECORDING = 'bridge/BRIDGE_ON_START_RECORDING';
13986
+ const BRIDGE_ON_STOP_RECORDING = 'bridge/BRIDGE_ON_STOP_RECORDING';
13987
+
13988
+ const SDK_CLICK_TO_CALL = 'sdk/CLICK_TO_CALL';
13989
+ const SDK_ON_CALL_MADE = 'sdk/SDK_ON_CALL_MADE';
13990
+ const SDK_CALL_ENDED = 'sdk/ON_CALL_ENDED';
13991
+ const SDK_CALL_INCOMING = 'sdk/SDK_CALL_INCOMING';
13992
+ const SDK_AUTHENTICATED = 'sdk/SDK_AUTHENTICATED';
13993
+ const SDK_LOGGED_OUT = 'sdk/SDK_LOGGED_OUT';
13994
+
13995
+ class Softphone {
13996
+ url = 'https://softphone.wazo.io';
13997
+ width = 500;
13998
+ height = 600;
13999
+ displayed = false;
14000
+ iframe = null;
14001
+
14002
+ onLinkEnabled(link ) {}
14003
+ onIFrameLoaded() {}
14004
+
14005
+ onCallMade(call ) {}
14006
+ onCallIncoming(call ) {}
14007
+ onCallEnded(call , card , direction , fromExtension ) {}
14008
+ onCardSaved(card ) {}
14009
+ onAuthenticated(session ) {}
14010
+ onLoggedOut() {}
14011
+ onSearchOptions(fieldId , query ) {}
14012
+ onDisplayLinkedOption(optionId ) {}
14013
+ onWazoContactSearch(query ) {}
14014
+ onAgentLoggedIn() {}
14015
+ onAgentLoggedOut() {}
14016
+ onAgentPaused() {}
14017
+ onAgentResumed() {}
14018
+ onLanguageChanged(language ) {}
14019
+ onCallHeld() {}
14020
+ onCallResumed() {}
14021
+ onCallMuted() {}
14022
+ onCallUnMuted() {}
14023
+ onDtmfSent(tone ) {}
14024
+ onDirectTransfer(number ) {}
14025
+ onCreateIndirectTransfer(number ) {}
14026
+ onCancelIndirectTransfer() {}
14027
+ onConfirmIndirectTransfer() {}
14028
+ onIndirectCallMade(call ) {}
14029
+ onIndirectTransferDone(call ) {}
14030
+ onStartRecording() {}
14031
+ onStopRecording() {}
14032
+ onUnHandledEvent(event ) {}
14033
+
14034
+ init({ url, width, height, server, port, language, wrapUpDuration, shouldDisplayLinkedEntities,
14035
+ allowContactCreation, withCard, subscriptionType, enableAgent } = {}) {
14036
+ if (url) {
14037
+ this.url = url;
14038
+ }
14039
+ if (width) {
14040
+ this.width = width;
14041
+ }
14042
+ if (height) {
14043
+ this.height = height;
14044
+ }
14045
+
14046
+ window.addEventListener('message', this._onMessage.bind(this), false);
14047
+
14048
+ if (!server) {
14049
+ // eslint-disable-next-line no-param-reassign
14050
+ server = 'stack.dev.wazo.io';
14051
+ }
14052
+
14053
+ this._createIframe(() => {
14054
+ this._sendMessage(BRIDGE_CONFIG_RETRIEVED, {
14055
+ config: {
14056
+ server,
14057
+ port,
14058
+ language,
14059
+ wrapUpDuration,
14060
+ shouldDisplayLinkedEntities,
14061
+ allowContactCreation,
14062
+ },
14063
+ });
14064
+
14065
+ if (withCard) {
14066
+ this._sendMessage(BRIDGE_ENABLE_CARD);
14067
+ }
14068
+
14069
+ if (subscriptionType) {
14070
+ this._sendMessage(BRIDGE_CHANGE_REQUIRED_SUBSCRIPTION_TYPE, { subscriptionType });
14071
+ }
14072
+
14073
+ this.onIFrameLoaded();
14074
+ });
14075
+ }
14076
+
14077
+ parseLinks() {
14078
+ const links = this._getLinks();
14079
+
14080
+ links.forEach(link => {
14081
+ link.setAttribute('data-wazo-parsed', true);
14082
+ link.addEventListener('click', this._onLinkClick.bind(this));
14083
+ this.onLinkEnabled(link);
14084
+ });
14085
+ }
14086
+
14087
+ makeCall(number ) {
14088
+ this.displaySoftphone();
14089
+
14090
+ this._sendMessage(SDK_CLICK_TO_CALL, { number });
14091
+ }
14092
+
14093
+ toggleSoftphoneDisplay() {
14094
+ if (this.displayed) {
14095
+ this.hideSoftphone();
14096
+ } else {
14097
+ this.displaySoftphone();
14098
+ }
14099
+ }
14100
+
14101
+ displaySoftphone() {
14102
+ if (!this.iframe) {
14103
+ this._createIframe();
14104
+ }
14105
+
14106
+ if (this.iframe) {
14107
+ this.iframe.style.display = 'block';
14108
+ }
14109
+
14110
+ this.displayed = true;
14111
+ }
14112
+
14113
+ hideSoftphone() {
14114
+ if (this.iframe) {
14115
+ this.iframe.style.display = 'none';
14116
+ }
14117
+ this.displayed = false;
14118
+ }
14119
+
14120
+ optionsFetched(fieldId , options ) {
14121
+ this._sendMessage(BRIDGE_OPTIONS_FETCHED, { fieldId, options });
14122
+ }
14123
+
14124
+ onOptionsResults(fieldId , options ) {
14125
+ this._sendMessage(BRIDGE_OPTIONS_FOUND, { fieldId, options });
14126
+ }
14127
+
14128
+ setFormSchema(schema , uiSchema ) {
14129
+ this._sendMessage(BRIDGE_UPDATE_FORM_SCHEMA, { schema, uiSchema });
14130
+ }
14131
+
14132
+ _createIframe(cb = () => {}) {
14133
+ this.iframe = document.createElement('iframe');
14134
+ // $FlowFixMe
14135
+ this.iframe.width = this.width;
14136
+ // $FlowFixMe
14137
+ this.iframe.height = this.height;
14138
+ // $FlowFixMe
14139
+ this.iframe.allow = 'camera *; microphone *; autoplay *; display-capture *';
14140
+ this.iframe.style.position = 'absolute';
14141
+ this.iframe.style.left = '0';
14142
+ this.iframe.style.bottom = '0';
14143
+ this.iframe.style.border = '1px solid #aaa';
14144
+ this.iframe.style.backgroundColor = 'white';
14145
+ this.iframe.src = this.url;
14146
+ this.iframe.style.display = 'none';
14147
+ this.iframe.id = 'wazo-softphone';
14148
+
14149
+ this.iframe.onload = cb;
14150
+
14151
+ // $FlowFixMe
14152
+ document.body.appendChild(this.iframe);
14153
+ }
14154
+
14155
+ _getLinks() {
14156
+ return [].slice.call(document.querySelectorAll('a:not([data-wazo-parsed])'), 0)
14157
+ .filter(link => link.href.indexOf('tel:') === 0 || link.href.indexOf('callto:') === 0);
14158
+ }
14159
+
14160
+ _onLinkClick(e ) {
14161
+ e.preventDefault();
14162
+ const number = e.target.href.split(':')[1];
14163
+
14164
+ this.makeCall(number);
14165
+ }
14166
+
14167
+ _onAuthenticated() {
14168
+ this.parseLinks();
14169
+ }
14170
+
14171
+ _onMessage(event ) {
14172
+ if (!event.data) {
14173
+ return;
14174
+ }
14175
+
14176
+ switch (event.data.type) {
14177
+ case SDK_ON_CALL_MADE:
14178
+ this.onCallMade(event.data.callSession);
14179
+ break;
14180
+ case SDK_CALL_ENDED: {
14181
+ const { callSession, content, direction, userExtension } = event.data;
14182
+ this.onCallEnded(callSession, content, direction, userExtension);
14183
+ break;
14184
+ }
14185
+ case SDK_CALL_INCOMING:
14186
+ this.onCallIncoming(event.data.callSession);
14187
+ break;
14188
+ case SDK_AUTHENTICATED:
14189
+ // $FlowFixMe
14190
+ this._onAuthenticated(event.data.session);
14191
+ this.onAuthenticated(event.data.session);
14192
+ break;
14193
+ case SDK_LOGGED_OUT:
14194
+ this.onLoggedOut();
14195
+ break;
14196
+ case BRIDGE_CREATE_OR_UPDATE_CARD: {
14197
+ const { content } = event.data;
14198
+ this.onCardSaved(content);
14199
+ break;
14200
+ }
14201
+ case BRIDGE_SEARCH_OPTIONS: {
14202
+ const { fieldId, query } = event.data;
14203
+ this.onSearchOptions(fieldId, query);
14204
+ break;
14205
+ }
14206
+ case BRIDGE_DISPLAY_LINKED_OPTION:
14207
+ this.onDisplayLinkedOption(event.data.linkedOptionId);
14208
+ break;
14209
+ case BRIDGE_WAZO_CONTACT_SEARCH:
14210
+ this.onWazoContactSearch(event.data.query);
14211
+ break;
14212
+ case BRIDGE_ON_AGENT_LOGGED_IN:
14213
+ this.onAgentLoggedIn();
14214
+ break;
14215
+ case BRIDGE_ON_AGENT_LOGGED_OUT:
14216
+ this.onAgentLoggedOut();
14217
+ break;
14218
+ case BRIDGE_ON_AGENT_PAUSED:
14219
+ this.onAgentPaused();
14220
+ break;
14221
+ case BRIDGE_ON_AGENT_RESUMED:
14222
+ this.onAgentResumed();
14223
+ break;
14224
+ case BRIDGE_ON_LANGUAGE_CHANGED:
14225
+ this.onLanguageChanged(event.data.language);
14226
+ break;
14227
+ case BRIDGE_ON_CALL_HELD:
14228
+ this.onCallHeld();
14229
+ break;
14230
+ case BRIDGE_ON_CALL_RESUMED:
14231
+ this.onCallResumed();
14232
+ break;
14233
+ case BRIDGE_ON_CALL_MUTED:
14234
+ this.onCallMuted();
14235
+ break;
14236
+ case BRIDGE_ON_CALL_UN_MUTED:
14237
+ this.onCallUnMuted();
14238
+ break;
14239
+ case BRIDGE_ON_DTMF:
14240
+ this.onDtmfSent(event.data.tone);
14241
+ break;
14242
+ case BRIDGE_ON_DIRECT_TRANSFER:
14243
+ this.onDirectTransfer(event.data.number);
14244
+ break;
14245
+ case BRIDGE_ON_CREATE_INDIRECT_TRANSFER:
14246
+ this.onCreateIndirectTransfer(event.data.number);
14247
+ break;
14248
+ case BRIDGE_ON_CANCEL_INDIRECT_TRANSFER:
14249
+ this.onCancelIndirectTransfer();
14250
+ break;
14251
+ case BRIDGE_ON_CONFIRM_INDIRECT_TRANSFER:
14252
+ this.onConfirmIndirectTransfer();
14253
+ break;
14254
+ case BRIDGE_ON_INDIRECT_TRANSFER_CALL_MADE:
14255
+ this.onIndirectCallMade(event.data.call);
14256
+ break;
14257
+ case BRIDGE_ON_INDIRECT_TRANSFER_DONE:
14258
+ this.onIndirectTransferDone(event.data.call);
14259
+ break;
14260
+ case BRIDGE_ON_START_RECORDING:
14261
+ this.onStartRecording();
14262
+ break;
14263
+ case BRIDGE_ON_STOP_RECORDING:
14264
+ this.onStopRecording();
14265
+ break;
14266
+ default:
14267
+ this.onUnHandledEvent(event);
14268
+ break;
14269
+ }
14270
+ }
14271
+
14272
+ _sendMessage(type , payload = {}) {
14273
+ if (!this.iframe) {
14274
+ console.warn(`Could not send message of type ${type} to the Wazo Softphone, iframe not created yet`);
14275
+ return;
14276
+ }
14277
+
14278
+ this.iframe.contentWindow.postMessage({ type, ...payload }, '*');
14279
+ }
14280
+ }
14281
+
14282
+ var Softphone$1 = new Softphone();
14283
+
13949
14284
  /* global window */
13950
14285
 
13951
14286
  const Wazo = {
@@ -13966,6 +14301,7 @@ const Wazo = {
13966
14301
  loggerFor: IssueReporter$1.loggerFor.bind(IssueReporter$1),
13967
14302
  Features: Features$1,
13968
14303
  Checker,
14304
+ Softphone: Softphone$1,
13969
14305
 
13970
14306
  // Domain
13971
14307
  domain: {
@@ -392,13 +392,9 @@ class IssueReporter {
392
392
 
393
393
  setTimeout(() => {
394
394
  if (isArray) {
395
- payload = payload.map(message => {
396
- message._retry = retry + 1;
397
- return message;
398
- });
399
- } else {
400
- // $FlowFixMe
401
- payload._retry = retry + 1;
395
+ payload = payload.map(message => this._writeRetryCount(message, retry + 1));
396
+ } else if (payload && typeof payload === 'object') {
397
+ payload = this._writeRetryCount(payload, retry + 1);
402
398
  }
403
399
 
404
400
  this._sendDebugToGrafana(payload, retry + 1);
@@ -406,6 +402,15 @@ class IssueReporter {
406
402
  });
407
403
  }
408
404
 
405
+ _writeRetryCount(message , count ) {
406
+ if (message && typeof message === 'object') {
407
+ // $FlowFixMe
408
+ message._retry = count;
409
+ }
410
+
411
+ return message;
412
+ }
413
+
409
414
  _isLevelAbove(level1 , level2 ) {
410
415
  const index1 = LOG_LEVELS.indexOf(level1);
411
416
  const index2 = LOG_LEVELS.indexOf(level2);
@@ -392,13 +392,9 @@ class IssueReporter {
392
392
 
393
393
  setTimeout(() => {
394
394
  if (isArray) {
395
- payload = payload.map(message => {
396
- message._retry = retry + 1;
397
- return message;
398
- });
399
- } else {
400
- // $FlowFixMe
401
- payload._retry = retry + 1;
395
+ payload = payload.map(message => this._writeRetryCount(message, retry + 1));
396
+ } else if (payload && typeof payload === 'object') {
397
+ payload = this._writeRetryCount(payload, retry + 1);
402
398
  }
403
399
 
404
400
  this._sendDebugToGrafana(payload, retry + 1);
@@ -406,6 +402,15 @@ class IssueReporter {
406
402
  });
407
403
  }
408
404
 
405
+ _writeRetryCount(message , count ) {
406
+ if (message && typeof message === 'object') {
407
+ // $FlowFixMe
408
+ message._retry = count;
409
+ }
410
+
411
+ return message;
412
+ }
413
+
409
414
  _isLevelAbove(level1 , level2 ) {
410
415
  const index1 = LOG_LEVELS.indexOf(level1);
411
416
  const index2 = LOG_LEVELS.indexOf(level2);
@@ -678,13 +678,9 @@ class IssueReporter {
678
678
 
679
679
  setTimeout(() => {
680
680
  if (isArray) {
681
- payload = payload.map(message => {
682
- message._retry = retry + 1;
683
- return message;
684
- });
685
- } else {
686
- // $FlowFixMe
687
- payload._retry = retry + 1;
681
+ payload = payload.map(message => this._writeRetryCount(message, retry + 1));
682
+ } else if (payload && typeof payload === 'object') {
683
+ payload = this._writeRetryCount(payload, retry + 1);
688
684
  }
689
685
 
690
686
  this._sendDebugToGrafana(payload, retry + 1);
@@ -692,6 +688,15 @@ class IssueReporter {
692
688
  });
693
689
  }
694
690
 
691
+ _writeRetryCount(message , count ) {
692
+ if (message && typeof message === 'object') {
693
+ // $FlowFixMe
694
+ message._retry = count;
695
+ }
696
+
697
+ return message;
698
+ }
699
+
695
700
  _isLevelAbove(level1 , level2 ) {
696
701
  const index1 = LOG_LEVELS.indexOf(level1);
697
702
  const index2 = LOG_LEVELS.indexOf(level2);
@@ -6105,8 +6110,10 @@ class WebRTCClient extends Emitter {
6105
6110
  conference: isConference,
6106
6111
  };
6107
6112
 
6108
- // Avoid sdh to created a new stream
6109
- session.sessionDescriptionHandler.localMediaStreamConstraints = options.constraints;
6113
+ // Avoid sdh to create a new stream
6114
+ if (session.sessionDescriptionHandler) {
6115
+ session.sessionDescriptionHandler.localMediaStreamConstraints = options.constraints;
6116
+ }
6110
6117
 
6111
6118
  // Send re-INVITE
6112
6119
  return session.invite(options);
@@ -6949,7 +6956,7 @@ class WebRTCClient extends Emitter {
6949
6956
  }
6950
6957
 
6951
6958
  async _onHeartbeatTimeout() {
6952
- logger.info('sdk webrtc heartbeat timed out', { userAgent: !!this.userAgent, cb: !!this.heartbeatTimeoutCb });
6959
+ logger.warn('sdk webrtc heartbeat timed out', { userAgent: !!this.userAgent, cb: !!this.heartbeatTimeoutCb });
6953
6960
 
6954
6961
  if (this.heartbeatTimeoutCb) {
6955
6962
  this.heartbeatTimeoutCb();
@@ -387,13 +387,9 @@ class IssueReporter {
387
387
 
388
388
  setTimeout(() => {
389
389
  if (isArray) {
390
- payload = payload.map(message => {
391
- message._retry = retry + 1;
392
- return message;
393
- });
394
- } else {
395
- // $FlowFixMe
396
- payload._retry = retry + 1;
390
+ payload = payload.map(message => this._writeRetryCount(message, retry + 1));
391
+ } else if (payload && typeof payload === 'object') {
392
+ payload = this._writeRetryCount(payload, retry + 1);
397
393
  }
398
394
 
399
395
  this._sendDebugToGrafana(payload, retry + 1);
@@ -401,6 +397,15 @@ class IssueReporter {
401
397
  });
402
398
  }
403
399
 
400
+ _writeRetryCount(message , count ) {
401
+ if (message && typeof message === 'object') {
402
+ // $FlowFixMe
403
+ message._retry = count;
404
+ }
405
+
406
+ return message;
407
+ }
408
+
404
409
  _isLevelAbove(level1 , level2 ) {
405
410
  const index1 = LOG_LEVELS.indexOf(level1);
406
411
  const index2 = LOG_LEVELS.indexOf(level2);
@@ -861,7 +866,7 @@ class WebSocketClient extends Emitter {
861
866
  this.close();
862
867
  }
863
868
  const url = `wss://${this.host || ''}/api/websocketd/?token=${this.token || ''}&version=${this.version}`;
864
- logger.log('Wazo WS url computed to reconnect', { url });
869
+ logger.info('Wazo WS url computed to reconnect', { url });
865
870
 
866
871
  return url;
867
872
  }
@@ -402,13 +402,9 @@ class IssueReporter {
402
402
 
403
403
  setTimeout(() => {
404
404
  if (isArray) {
405
- payload = payload.map(message => {
406
- message._retry = retry + 1;
407
- return message;
408
- });
409
- } else {
410
- // $FlowFixMe
411
- payload._retry = retry + 1;
405
+ payload = payload.map(message => this._writeRetryCount(message, retry + 1));
406
+ } else if (payload && typeof payload === 'object') {
407
+ payload = this._writeRetryCount(payload, retry + 1);
412
408
  }
413
409
 
414
410
  this._sendDebugToGrafana(payload, retry + 1);
@@ -416,6 +412,15 @@ class IssueReporter {
416
412
  });
417
413
  }
418
414
 
415
+ _writeRetryCount(message , count ) {
416
+ if (message && typeof message === 'object') {
417
+ // $FlowFixMe
418
+ message._retry = count;
419
+ }
420
+
421
+ return message;
422
+ }
423
+
419
424
  _isLevelAbove(level1 , level2 ) {
420
425
  const index1 = LOG_LEVELS.indexOf(level1);
421
426
  const index2 = LOG_LEVELS.indexOf(level2);
@@ -687,13 +687,9 @@ class IssueReporter {
687
687
 
688
688
  setTimeout(() => {
689
689
  if (isArray) {
690
- payload = payload.map(message => {
691
- message._retry = retry + 1;
692
- return message;
693
- });
694
- } else {
695
- // $FlowFixMe
696
- payload._retry = retry + 1;
690
+ payload = payload.map(message => this._writeRetryCount(message, retry + 1));
691
+ } else if (payload && typeof payload === 'object') {
692
+ payload = this._writeRetryCount(payload, retry + 1);
697
693
  }
698
694
 
699
695
  this._sendDebugToGrafana(payload, retry + 1);
@@ -701,6 +697,15 @@ class IssueReporter {
701
697
  });
702
698
  }
703
699
 
700
+ _writeRetryCount(message , count ) {
701
+ if (message && typeof message === 'object') {
702
+ // $FlowFixMe
703
+ message._retry = count;
704
+ }
705
+
706
+ return message;
707
+ }
708
+
704
709
  _isLevelAbove(level1 , level2 ) {
705
710
  const index1 = LOG_LEVELS.indexOf(level1);
706
711
  const index2 = LOG_LEVELS.indexOf(level2);
@@ -6111,8 +6116,10 @@ class WebRTCClient extends Emitter {
6111
6116
  conference: isConference,
6112
6117
  };
6113
6118
 
6114
- // Avoid sdh to created a new stream
6115
- session.sessionDescriptionHandler.localMediaStreamConstraints = options.constraints;
6119
+ // Avoid sdh to create a new stream
6120
+ if (session.sessionDescriptionHandler) {
6121
+ session.sessionDescriptionHandler.localMediaStreamConstraints = options.constraints;
6122
+ }
6116
6123
 
6117
6124
  // Send re-INVITE
6118
6125
  return session.invite(options);
@@ -6955,7 +6962,7 @@ class WebRTCClient extends Emitter {
6955
6962
  }
6956
6963
 
6957
6964
  async _onHeartbeatTimeout() {
6958
- logger.info('sdk webrtc heartbeat timed out', { userAgent: !!this.userAgent, cb: !!this.heartbeatTimeoutCb });
6965
+ logger.warn('sdk webrtc heartbeat timed out', { userAgent: !!this.userAgent, cb: !!this.heartbeatTimeoutCb });
6959
6966
 
6960
6967
  if (this.heartbeatTimeoutCb) {
6961
6968
  this.heartbeatTimeoutCb();
package/lib/api/agentd.js CHANGED
@@ -398,13 +398,9 @@ class IssueReporter {
398
398
 
399
399
  setTimeout(() => {
400
400
  if (isArray) {
401
- payload = payload.map(message => {
402
- message._retry = retry + 1;
403
- return message;
404
- });
405
- } else {
406
- // $FlowFixMe
407
- payload._retry = retry + 1;
401
+ payload = payload.map(message => this._writeRetryCount(message, retry + 1));
402
+ } else if (payload && typeof payload === 'object') {
403
+ payload = this._writeRetryCount(payload, retry + 1);
408
404
  }
409
405
 
410
406
  this._sendDebugToGrafana(payload, retry + 1);
@@ -412,6 +408,15 @@ class IssueReporter {
412
408
  });
413
409
  }
414
410
 
411
+ _writeRetryCount(message , count ) {
412
+ if (message && typeof message === 'object') {
413
+ // $FlowFixMe
414
+ message._retry = count;
415
+ }
416
+
417
+ return message;
418
+ }
419
+
415
420
  _isLevelAbove(level1 , level2 ) {
416
421
  const index1 = LOG_LEVELS.indexOf(level1);
417
422
  const index2 = LOG_LEVELS.indexOf(level2);