@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
package/esm/index.js CHANGED
@@ -416,13 +416,9 @@ class IssueReporter {
416
416
 
417
417
  setTimeout(() => {
418
418
  if (isArray) {
419
- payload = payload.map(message => {
420
- message._retry = retry + 1;
421
- return message;
422
- });
423
- } else {
424
- // $FlowFixMe
425
- payload._retry = retry + 1;
419
+ payload = payload.map(message => this._writeRetryCount(message, retry + 1));
420
+ } else if (payload && typeof payload === 'object') {
421
+ payload = this._writeRetryCount(payload, retry + 1);
426
422
  }
427
423
 
428
424
  this._sendDebugToGrafana(payload, retry + 1);
@@ -430,6 +426,15 @@ class IssueReporter {
430
426
  });
431
427
  }
432
428
 
429
+ _writeRetryCount(message , count ) {
430
+ if (message && typeof message === 'object') {
431
+ // $FlowFixMe
432
+ message._retry = count;
433
+ }
434
+
435
+ return message;
436
+ }
437
+
433
438
  _isLevelAbove(level1 , level2 ) {
434
439
  const index1 = LOG_LEVELS.indexOf(level1);
435
440
  const index2 = LOG_LEVELS.indexOf(level2);
@@ -6996,8 +7001,10 @@ class WebRTCClient extends Emitter {
6996
7001
  conference: isConference,
6997
7002
  };
6998
7003
 
6999
- // Avoid sdh to created a new stream
7000
- session.sessionDescriptionHandler.localMediaStreamConstraints = options.constraints;
7004
+ // Avoid sdh to create a new stream
7005
+ if (session.sessionDescriptionHandler) {
7006
+ session.sessionDescriptionHandler.localMediaStreamConstraints = options.constraints;
7007
+ }
7001
7008
 
7002
7009
  // Send re-INVITE
7003
7010
  return session.invite(options);
@@ -7840,7 +7847,7 @@ class WebRTCClient extends Emitter {
7840
7847
  }
7841
7848
 
7842
7849
  async _onHeartbeatTimeout() {
7843
- logger$9.info('sdk webrtc heartbeat timed out', { userAgent: !!this.userAgent, cb: !!this.heartbeatTimeoutCb });
7850
+ logger$9.warn('sdk webrtc heartbeat timed out', { userAgent: !!this.userAgent, cb: !!this.heartbeatTimeoutCb });
7844
7851
 
7845
7852
  if (this.heartbeatTimeoutCb) {
7846
7853
  this.heartbeatTimeoutCb();
@@ -8786,7 +8793,7 @@ class WebSocketClient extends Emitter {
8786
8793
  this.close();
8787
8794
  }
8788
8795
  const url = `wss://${this.host || ''}/api/websocketd/?token=${this.token || ''}&version=${this.version}`;
8789
- logger$8.log('Wazo WS url computed to reconnect', { url });
8796
+ logger$8.info('Wazo WS url computed to reconnect', { url });
8790
8797
 
8791
8798
  return url;
8792
8799
  }
@@ -14100,6 +14107,334 @@ const createLocalVideoStream = async (options ) => createLocalStream('vid
14100
14107
 
14101
14108
  const createLocalAudioStream = async (options ) => createLocalStream('audio', options);
14102
14109
 
14110
+ //
14111
+ /* eslint-disable no-unused-vars */
14112
+ /* global window, document */
14113
+ const BRIDGE_CONFIG_RETRIEVED = 'bridge/CONFIG_RETRIEVED';
14114
+ const BRIDGE_ENABLE_CARD = 'bridge/ENABLE_CARD';
14115
+ const BRIDGE_CHANGE_REQUIRED_SUBSCRIPTION_TYPE = 'bridge/CHANGE_REQUIRED_SUBSCRIPTION_TYPE';
14116
+ const BRIDGE_CREATE_OR_UPDATE_CARD = 'bridge/BRIDGE_CREATE_OR_UPDATE_CARD';
14117
+ const BRIDGE_OPTIONS_FETCHED = 'bridge/BRIDGE_OPTIONS_FETCHED';
14118
+ const BRIDGE_OPTIONS_FOUND = 'bridge/BRIDGE_OPTIONS_FOUND';
14119
+ const BRIDGE_SEARCH_OPTIONS = 'bridge/BRIDGE_SEARCH_OPTIONS';
14120
+ const BRIDGE_DISPLAY_LINKED_OPTION = 'bridge/DISPLAY_LINKED_OPTION';
14121
+ const BRIDGE_UPDATE_FORM_SCHEMA = 'bridge/BRIDGE_UPDATE_FORM_SCHEMA';
14122
+ const BRIDGE_WAZO_CONTACT_SEARCH = 'bridge/BRIDGE_WAZO_CONTACT_SEARCH';
14123
+ const BRIDGE_ON_AGENT_LOGGED_IN = 'bridge/BRIDGE_ON_AGENT_LOGGED_IN';
14124
+ const BRIDGE_ON_AGENT_LOGGED_OUT = 'bridge/BRIDGE_ON_AGENT_LOGGED_OUT';
14125
+ const BRIDGE_ON_AGENT_PAUSED = 'bridge/BRIDGE_ON_AGENT_PAUSED';
14126
+ const BRIDGE_ON_AGENT_RESUMED = 'bridge/BRIDGE_ON_AGENT_RESUMED';
14127
+ const BRIDGE_ON_LANGUAGE_CHANGED = 'bridge/BRIDGE_ON_LANGUAGE_CHANGED';
14128
+ const BRIDGE_ON_CALL_HELD = 'bridge/BRIDGE_ON_CALL_HELD';
14129
+ const BRIDGE_ON_CALL_RESUMED = 'bridge/BRIDGE_ON_CALL_RESUMED';
14130
+ const BRIDGE_ON_CALL_MUTED = 'bridge/BRIDGE_ON_CALL_MUTED';
14131
+ const BRIDGE_ON_CALL_UN_MUTED = 'bridge/BRIDGE_ON_CALL_UN_MUTED';
14132
+ const BRIDGE_ON_DTMF = 'bridge/BRIDGE_ON_DTMF';
14133
+ const BRIDGE_ON_DIRECT_TRANSFER = 'bridge/BRIDGE_ON_DIRECT_TRANSFER';
14134
+ const BRIDGE_ON_CREATE_INDIRECT_TRANSFER = 'bridge/BRIDGE_ON_CREATE_INDIRECT_TRANSFER';
14135
+ const BRIDGE_ON_CANCEL_INDIRECT_TRANSFER = 'bridge/BRIDGE_ON_CANCEL_INDIRECT_TRANSFER';
14136
+ const BRIDGE_ON_CONFIRM_INDIRECT_TRANSFER = 'bridge/BRIDGE_ON_CONFIRM_INDIRECT_TRANSFER';
14137
+ const BRIDGE_ON_INDIRECT_TRANSFER_CALL_MADE = 'bridge/BRIDGE_ON_INDIRECT_TRANSFER_CALL_MADE';
14138
+ const BRIDGE_ON_INDIRECT_TRANSFER_DONE = 'bridge/BRIDGE_ON_INDIRECT_TRANSFER_DONE';
14139
+ const BRIDGE_ON_START_RECORDING = 'bridge/BRIDGE_ON_START_RECORDING';
14140
+ const BRIDGE_ON_STOP_RECORDING = 'bridge/BRIDGE_ON_STOP_RECORDING';
14141
+
14142
+ const SDK_CLICK_TO_CALL = 'sdk/CLICK_TO_CALL';
14143
+ const SDK_ON_CALL_MADE = 'sdk/SDK_ON_CALL_MADE';
14144
+ const SDK_CALL_ENDED = 'sdk/ON_CALL_ENDED';
14145
+ const SDK_CALL_INCOMING = 'sdk/SDK_CALL_INCOMING';
14146
+ const SDK_AUTHENTICATED = 'sdk/SDK_AUTHENTICATED';
14147
+ const SDK_LOGGED_OUT = 'sdk/SDK_LOGGED_OUT';
14148
+
14149
+ class Softphone {
14150
+ url = 'https://softphone.wazo.io';
14151
+ width = 500;
14152
+ height = 600;
14153
+ displayed = false;
14154
+ iframe = null;
14155
+
14156
+ onLinkEnabled(link ) {}
14157
+ onIFrameLoaded() {}
14158
+
14159
+ onCallMade(call ) {}
14160
+ onCallIncoming(call ) {}
14161
+ onCallEnded(call , card , direction , fromExtension ) {}
14162
+ onCardSaved(card ) {}
14163
+ onAuthenticated(session ) {}
14164
+ onLoggedOut() {}
14165
+ onSearchOptions(fieldId , query ) {}
14166
+ onDisplayLinkedOption(optionId ) {}
14167
+ onWazoContactSearch(query ) {}
14168
+ onAgentLoggedIn() {}
14169
+ onAgentLoggedOut() {}
14170
+ onAgentPaused() {}
14171
+ onAgentResumed() {}
14172
+ onLanguageChanged(language ) {}
14173
+ onCallHeld() {}
14174
+ onCallResumed() {}
14175
+ onCallMuted() {}
14176
+ onCallUnMuted() {}
14177
+ onDtmfSent(tone ) {}
14178
+ onDirectTransfer(number ) {}
14179
+ onCreateIndirectTransfer(number ) {}
14180
+ onCancelIndirectTransfer() {}
14181
+ onConfirmIndirectTransfer() {}
14182
+ onIndirectCallMade(call ) {}
14183
+ onIndirectTransferDone(call ) {}
14184
+ onStartRecording() {}
14185
+ onStopRecording() {}
14186
+ onUnHandledEvent(event ) {}
14187
+
14188
+ init({ url, width, height, server, port, language, wrapUpDuration, shouldDisplayLinkedEntities,
14189
+ allowContactCreation, withCard, subscriptionType, enableAgent } = {}) {
14190
+ if (url) {
14191
+ this.url = url;
14192
+ }
14193
+ if (width) {
14194
+ this.width = width;
14195
+ }
14196
+ if (height) {
14197
+ this.height = height;
14198
+ }
14199
+
14200
+ window.addEventListener('message', this._onMessage.bind(this), false);
14201
+
14202
+ if (!server) {
14203
+ // eslint-disable-next-line no-param-reassign
14204
+ server = 'stack.dev.wazo.io';
14205
+ }
14206
+
14207
+ this._createIframe(() => {
14208
+ this._sendMessage(BRIDGE_CONFIG_RETRIEVED, {
14209
+ config: {
14210
+ server,
14211
+ port,
14212
+ language,
14213
+ wrapUpDuration,
14214
+ shouldDisplayLinkedEntities,
14215
+ allowContactCreation,
14216
+ },
14217
+ });
14218
+
14219
+ if (withCard) {
14220
+ this._sendMessage(BRIDGE_ENABLE_CARD);
14221
+ }
14222
+
14223
+ if (subscriptionType) {
14224
+ this._sendMessage(BRIDGE_CHANGE_REQUIRED_SUBSCRIPTION_TYPE, { subscriptionType });
14225
+ }
14226
+
14227
+ this.onIFrameLoaded();
14228
+ });
14229
+ }
14230
+
14231
+ parseLinks() {
14232
+ const links = this._getLinks();
14233
+
14234
+ links.forEach(link => {
14235
+ link.setAttribute('data-wazo-parsed', true);
14236
+ link.addEventListener('click', this._onLinkClick.bind(this));
14237
+ this.onLinkEnabled(link);
14238
+ });
14239
+ }
14240
+
14241
+ makeCall(number ) {
14242
+ this.displaySoftphone();
14243
+
14244
+ this._sendMessage(SDK_CLICK_TO_CALL, { number });
14245
+ }
14246
+
14247
+ toggleSoftphoneDisplay() {
14248
+ if (this.displayed) {
14249
+ this.hideSoftphone();
14250
+ } else {
14251
+ this.displaySoftphone();
14252
+ }
14253
+ }
14254
+
14255
+ displaySoftphone() {
14256
+ if (!this.iframe) {
14257
+ this._createIframe();
14258
+ }
14259
+
14260
+ if (this.iframe) {
14261
+ this.iframe.style.display = 'block';
14262
+ }
14263
+
14264
+ this.displayed = true;
14265
+ }
14266
+
14267
+ hideSoftphone() {
14268
+ if (this.iframe) {
14269
+ this.iframe.style.display = 'none';
14270
+ }
14271
+ this.displayed = false;
14272
+ }
14273
+
14274
+ optionsFetched(fieldId , options ) {
14275
+ this._sendMessage(BRIDGE_OPTIONS_FETCHED, { fieldId, options });
14276
+ }
14277
+
14278
+ onOptionsResults(fieldId , options ) {
14279
+ this._sendMessage(BRIDGE_OPTIONS_FOUND, { fieldId, options });
14280
+ }
14281
+
14282
+ setFormSchema(schema , uiSchema ) {
14283
+ this._sendMessage(BRIDGE_UPDATE_FORM_SCHEMA, { schema, uiSchema });
14284
+ }
14285
+
14286
+ _createIframe(cb = () => {}) {
14287
+ this.iframe = document.createElement('iframe');
14288
+ // $FlowFixMe
14289
+ this.iframe.width = this.width;
14290
+ // $FlowFixMe
14291
+ this.iframe.height = this.height;
14292
+ // $FlowFixMe
14293
+ this.iframe.allow = 'camera *; microphone *; autoplay *; display-capture *';
14294
+ this.iframe.style.position = 'absolute';
14295
+ this.iframe.style.left = '0';
14296
+ this.iframe.style.bottom = '0';
14297
+ this.iframe.style.border = '1px solid #aaa';
14298
+ this.iframe.style.backgroundColor = 'white';
14299
+ this.iframe.src = this.url;
14300
+ this.iframe.style.display = 'none';
14301
+ this.iframe.id = 'wazo-softphone';
14302
+
14303
+ this.iframe.onload = cb;
14304
+
14305
+ // $FlowFixMe
14306
+ document.body.appendChild(this.iframe);
14307
+ }
14308
+
14309
+ _getLinks() {
14310
+ return [].slice.call(document.querySelectorAll('a:not([data-wazo-parsed])'), 0)
14311
+ .filter(link => link.href.indexOf('tel:') === 0 || link.href.indexOf('callto:') === 0);
14312
+ }
14313
+
14314
+ _onLinkClick(e ) {
14315
+ e.preventDefault();
14316
+ const number = e.target.href.split(':')[1];
14317
+
14318
+ this.makeCall(number);
14319
+ }
14320
+
14321
+ _onAuthenticated() {
14322
+ this.parseLinks();
14323
+ }
14324
+
14325
+ _onMessage(event ) {
14326
+ if (!event.data) {
14327
+ return;
14328
+ }
14329
+
14330
+ switch (event.data.type) {
14331
+ case SDK_ON_CALL_MADE:
14332
+ this.onCallMade(event.data.callSession);
14333
+ break;
14334
+ case SDK_CALL_ENDED: {
14335
+ const { callSession, content, direction, userExtension } = event.data;
14336
+ this.onCallEnded(callSession, content, direction, userExtension);
14337
+ break;
14338
+ }
14339
+ case SDK_CALL_INCOMING:
14340
+ this.onCallIncoming(event.data.callSession);
14341
+ break;
14342
+ case SDK_AUTHENTICATED:
14343
+ // $FlowFixMe
14344
+ this._onAuthenticated(event.data.session);
14345
+ this.onAuthenticated(event.data.session);
14346
+ break;
14347
+ case SDK_LOGGED_OUT:
14348
+ this.onLoggedOut();
14349
+ break;
14350
+ case BRIDGE_CREATE_OR_UPDATE_CARD: {
14351
+ const { content } = event.data;
14352
+ this.onCardSaved(content);
14353
+ break;
14354
+ }
14355
+ case BRIDGE_SEARCH_OPTIONS: {
14356
+ const { fieldId, query } = event.data;
14357
+ this.onSearchOptions(fieldId, query);
14358
+ break;
14359
+ }
14360
+ case BRIDGE_DISPLAY_LINKED_OPTION:
14361
+ this.onDisplayLinkedOption(event.data.linkedOptionId);
14362
+ break;
14363
+ case BRIDGE_WAZO_CONTACT_SEARCH:
14364
+ this.onWazoContactSearch(event.data.query);
14365
+ break;
14366
+ case BRIDGE_ON_AGENT_LOGGED_IN:
14367
+ this.onAgentLoggedIn();
14368
+ break;
14369
+ case BRIDGE_ON_AGENT_LOGGED_OUT:
14370
+ this.onAgentLoggedOut();
14371
+ break;
14372
+ case BRIDGE_ON_AGENT_PAUSED:
14373
+ this.onAgentPaused();
14374
+ break;
14375
+ case BRIDGE_ON_AGENT_RESUMED:
14376
+ this.onAgentResumed();
14377
+ break;
14378
+ case BRIDGE_ON_LANGUAGE_CHANGED:
14379
+ this.onLanguageChanged(event.data.language);
14380
+ break;
14381
+ case BRIDGE_ON_CALL_HELD:
14382
+ this.onCallHeld();
14383
+ break;
14384
+ case BRIDGE_ON_CALL_RESUMED:
14385
+ this.onCallResumed();
14386
+ break;
14387
+ case BRIDGE_ON_CALL_MUTED:
14388
+ this.onCallMuted();
14389
+ break;
14390
+ case BRIDGE_ON_CALL_UN_MUTED:
14391
+ this.onCallUnMuted();
14392
+ break;
14393
+ case BRIDGE_ON_DTMF:
14394
+ this.onDtmfSent(event.data.tone);
14395
+ break;
14396
+ case BRIDGE_ON_DIRECT_TRANSFER:
14397
+ this.onDirectTransfer(event.data.number);
14398
+ break;
14399
+ case BRIDGE_ON_CREATE_INDIRECT_TRANSFER:
14400
+ this.onCreateIndirectTransfer(event.data.number);
14401
+ break;
14402
+ case BRIDGE_ON_CANCEL_INDIRECT_TRANSFER:
14403
+ this.onCancelIndirectTransfer();
14404
+ break;
14405
+ case BRIDGE_ON_CONFIRM_INDIRECT_TRANSFER:
14406
+ this.onConfirmIndirectTransfer();
14407
+ break;
14408
+ case BRIDGE_ON_INDIRECT_TRANSFER_CALL_MADE:
14409
+ this.onIndirectCallMade(event.data.call);
14410
+ break;
14411
+ case BRIDGE_ON_INDIRECT_TRANSFER_DONE:
14412
+ this.onIndirectTransferDone(event.data.call);
14413
+ break;
14414
+ case BRIDGE_ON_START_RECORDING:
14415
+ this.onStartRecording();
14416
+ break;
14417
+ case BRIDGE_ON_STOP_RECORDING:
14418
+ this.onStopRecording();
14419
+ break;
14420
+ default:
14421
+ this.onUnHandledEvent(event);
14422
+ break;
14423
+ }
14424
+ }
14425
+
14426
+ _sendMessage(type , payload = {}) {
14427
+ if (!this.iframe) {
14428
+ console.warn(`Could not send message of type ${type} to the Wazo Softphone, iframe not created yet`);
14429
+ return;
14430
+ }
14431
+
14432
+ this.iframe.contentWindow.postMessage({ type, ...payload }, '*');
14433
+ }
14434
+ }
14435
+
14436
+ var Softphone$1 = new Softphone();
14437
+
14103
14438
  /* global window */
14104
14439
 
14105
14440
  const Wazo = {
@@ -14120,6 +14455,7 @@ const Wazo = {
14120
14455
  loggerFor: IssueReporter$1.loggerFor.bind(IssueReporter$1),
14121
14456
  Features: Features$1,
14122
14457
  Checker,
14458
+ Softphone: Softphone$1,
14123
14459
 
14124
14460
  // Domain
14125
14461
  domain: {
@@ -363,13 +363,9 @@ class IssueReporter {
363
363
 
364
364
  setTimeout(() => {
365
365
  if (isArray) {
366
- payload = payload.map(message => {
367
- message._retry = retry + 1;
368
- return message;
369
- });
370
- } else {
371
- // $FlowFixMe
372
- payload._retry = retry + 1;
366
+ payload = payload.map(message => this._writeRetryCount(message, retry + 1));
367
+ } else if (payload && typeof payload === 'object') {
368
+ payload = this._writeRetryCount(payload, retry + 1);
373
369
  }
374
370
 
375
371
  this._sendDebugToGrafana(payload, retry + 1);
@@ -377,6 +373,15 @@ class IssueReporter {
377
373
  });
378
374
  }
379
375
 
376
+ _writeRetryCount(message , count ) {
377
+ if (message && typeof message === 'object') {
378
+ // $FlowFixMe
379
+ message._retry = count;
380
+ }
381
+
382
+ return message;
383
+ }
384
+
380
385
  _isLevelAbove(level1 , level2 ) {
381
386
  const index1 = LOG_LEVELS.indexOf(level1);
382
387
  const index2 = LOG_LEVELS.indexOf(level2);
@@ -2430,13 +2430,9 @@ class IssueReporter {
2430
2430
 
2431
2431
  setTimeout(() => {
2432
2432
  if (isArray) {
2433
- payload = payload.map(message => {
2434
- message._retry = retry + 1;
2435
- return message;
2436
- });
2437
- } else {
2438
- // $FlowFixMe
2439
- payload._retry = retry + 1;
2433
+ payload = payload.map(message => this._writeRetryCount(message, retry + 1));
2434
+ } else if (payload && typeof payload === 'object') {
2435
+ payload = this._writeRetryCount(payload, retry + 1);
2440
2436
  }
2441
2437
 
2442
2438
  this._sendDebugToGrafana(payload, retry + 1);
@@ -2444,6 +2440,15 @@ class IssueReporter {
2444
2440
  });
2445
2441
  }
2446
2442
 
2443
+ _writeRetryCount(message , count ) {
2444
+ if (message && typeof message === 'object') {
2445
+ // $FlowFixMe
2446
+ message._retry = count;
2447
+ }
2448
+
2449
+ return message;
2450
+ }
2451
+
2447
2452
  _isLevelAbove(level1 , level2 ) {
2448
2453
  const index1 = LOG_LEVELS.indexOf(level1);
2449
2454
  const index2 = LOG_LEVELS.indexOf(level2);
@@ -359,13 +359,9 @@ class IssueReporter {
359
359
 
360
360
  setTimeout(() => {
361
361
  if (isArray) {
362
- payload = payload.map(message => {
363
- message._retry = retry + 1;
364
- return message;
365
- });
366
- } else {
367
- // $FlowFixMe
368
- payload._retry = retry + 1;
362
+ payload = payload.map(message => this._writeRetryCount(message, retry + 1));
363
+ } else if (payload && typeof payload === 'object') {
364
+ payload = this._writeRetryCount(payload, retry + 1);
369
365
  }
370
366
 
371
367
  this._sendDebugToGrafana(payload, retry + 1);
@@ -373,6 +369,15 @@ class IssueReporter {
373
369
  });
374
370
  }
375
371
 
372
+ _writeRetryCount(message , count ) {
373
+ if (message && typeof message === 'object') {
374
+ // $FlowFixMe
375
+ message._retry = count;
376
+ }
377
+
378
+ return message;
379
+ }
380
+
376
381
  _isLevelAbove(level1 , level2 ) {
377
382
  const index1 = LOG_LEVELS.indexOf(level1);
378
383
  const index2 = LOG_LEVELS.indexOf(level2);
@@ -359,13 +359,9 @@ class IssueReporter {
359
359
 
360
360
  setTimeout(() => {
361
361
  if (isArray) {
362
- payload = payload.map(message => {
363
- message._retry = retry + 1;
364
- return message;
365
- });
366
- } else {
367
- // $FlowFixMe
368
- payload._retry = retry + 1;
362
+ payload = payload.map(message => this._writeRetryCount(message, retry + 1));
363
+ } else if (payload && typeof payload === 'object') {
364
+ payload = this._writeRetryCount(payload, retry + 1);
369
365
  }
370
366
 
371
367
  this._sendDebugToGrafana(payload, retry + 1);
@@ -373,6 +369,15 @@ class IssueReporter {
373
369
  });
374
370
  }
375
371
 
372
+ _writeRetryCount(message , count ) {
373
+ if (message && typeof message === 'object') {
374
+ // $FlowFixMe
375
+ message._retry = count;
376
+ }
377
+
378
+ return message;
379
+ }
380
+
376
381
  _isLevelAbove(level1 , level2 ) {
377
382
  const index1 = LOG_LEVELS.indexOf(level1);
378
383
  const index2 = LOG_LEVELS.indexOf(level2);
@@ -488,4 +493,10 @@ describe('IssueReporter', () => {
488
493
  expect(IssueReporter$1.removeSlashes('\"')).toBe("'");
489
494
  expect(IssueReporter$1.removeSlashes('\\\"')).toBe("'");
490
495
  });
496
+
497
+ it('Add retry count', () => {
498
+ expect(IssueReporter$1._writeRetryCount('', 1)).toBe('');
499
+ expect(IssueReporter$1._writeRetryCount('{}', 1)).toBe('{}');
500
+ expect(IssueReporter$1._writeRetryCount({}, 1)).toEqual({ _retry: 1 });
501
+ });
491
502
  });
@@ -396,13 +396,9 @@ class IssueReporter {
396
396
 
397
397
  setTimeout(() => {
398
398
  if (isArray) {
399
- payload = payload.map(message => {
400
- message._retry = retry + 1;
401
- return message;
402
- });
403
- } else {
404
- // $FlowFixMe
405
- payload._retry = retry + 1;
399
+ payload = payload.map(message => this._writeRetryCount(message, retry + 1));
400
+ } else if (payload && typeof payload === 'object') {
401
+ payload = this._writeRetryCount(payload, retry + 1);
406
402
  }
407
403
 
408
404
  this._sendDebugToGrafana(payload, retry + 1);
@@ -410,6 +406,15 @@ class IssueReporter {
410
406
  });
411
407
  }
412
408
 
409
+ _writeRetryCount(message , count ) {
410
+ if (message && typeof message === 'object') {
411
+ // $FlowFixMe
412
+ message._retry = count;
413
+ }
414
+
415
+ return message;
416
+ }
417
+
413
418
  _isLevelAbove(level1 , level2 ) {
414
419
  const index1 = LOG_LEVELS.indexOf(level1);
415
420
  const index2 = LOG_LEVELS.indexOf(level2);