@wazo/sdk 0.37.43 → 0.38.2

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 (46) hide show
  1. package/README.md +246 -0
  2. package/dist/wazo-sdk.js +5 -5
  3. package/esm/__tests__/web-rtc-client.test.js +1 -1
  4. package/esm/checker/Checker.js +1 -1
  5. package/esm/checker/checks/index.js +1 -1
  6. package/esm/checker/checks/webrtc-transport.js +1 -1
  7. package/esm/checker/checks/webrtc.js +1 -1
  8. package/esm/index.js +361 -1
  9. package/esm/simple/Auth.js +361 -1
  10. package/esm/simple/Configuration.js +361 -1
  11. package/esm/simple/Phone.js +361 -1
  12. package/esm/simple/Softphone.js +360 -0
  13. package/esm/simple/index.js +361 -1
  14. package/esm/simple/room/LocalParticipant.js +361 -1
  15. package/esm/simple/room/Participant.js +361 -1
  16. package/esm/simple/room/RemoteParticipant.js +361 -1
  17. package/esm/simple/room/Room.js +361 -1
  18. package/esm/simple/room/SipRoom.js +361 -1
  19. package/esm/simple/room/Stream.js +361 -1
  20. package/esm/simple/room/__tests__/RemoteParticipant.test.js +361 -1
  21. package/esm/simple/utils.js +361 -1
  22. package/esm/web-rtc-client.js +1 -1
  23. package/lib/__tests__/web-rtc-client.test.js +1 -1
  24. package/lib/checker/Checker.js +1 -1
  25. package/lib/checker/checks/index.js +1 -1
  26. package/lib/checker/checks/webrtc-transport.js +1 -1
  27. package/lib/checker/checks/webrtc.js +1 -1
  28. package/lib/index.js +361 -1
  29. package/lib/simple/Auth.js +361 -1
  30. package/lib/simple/Configuration.js +361 -1
  31. package/lib/simple/Phone.js +361 -1
  32. package/lib/simple/Softphone.js +362 -0
  33. package/lib/simple/index.js +361 -1
  34. package/lib/simple/room/LocalParticipant.js +361 -1
  35. package/lib/simple/room/Participant.js +361 -1
  36. package/lib/simple/room/RemoteParticipant.js +361 -1
  37. package/lib/simple/room/Room.js +361 -1
  38. package/lib/simple/room/SipRoom.js +361 -1
  39. package/lib/simple/room/Stream.js +361 -1
  40. package/lib/simple/room/__tests__/RemoteParticipant.test.js +361 -1
  41. package/lib/simple/utils.js +361 -1
  42. package/lib/web-rtc-client.js +1 -1
  43. package/package.json +1 -1
  44. package/src/simple/Softphone.js +358 -0
  45. package/src/simple/index.js +2 -0
  46. package/src/web-rtc-client.js +1 -1
@@ -8326,7 +8326,7 @@ class WebRTCClient extends Emitter {
8326
8326
  }
8327
8327
 
8328
8328
  async _onHeartbeatTimeout() {
8329
- 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 });
8330
8330
 
8331
8331
  if (this.heartbeatTimeoutCb) {
8332
8332
  this.heartbeatTimeoutCb();
@@ -13133,6 +13133,365 @@ class Checker {
13133
13133
  }
13134
13134
  }
13135
13135
 
13136
+ //
13137
+ /* eslint-disable no-unused-vars */
13138
+ /* global window, document */
13139
+ const BRIDGE_CONFIG_RETRIEVED = 'bridge/CONFIG_RETRIEVED';
13140
+ const BRIDGE_CREATE_OR_UPDATE_CARD = 'bridge/BRIDGE_CREATE_OR_UPDATE_CARD';
13141
+ const BRIDGE_OPTIONS_FETCHED = 'bridge/BRIDGE_OPTIONS_FETCHED';
13142
+ const BRIDGE_OPTIONS_FOUND = 'bridge/BRIDGE_OPTIONS_FOUND';
13143
+ const BRIDGE_SEARCH_OPTIONS = 'bridge/BRIDGE_SEARCH_OPTIONS';
13144
+ const BRIDGE_DISPLAY_LINKED_OPTION = 'bridge/DISPLAY_LINKED_OPTION';
13145
+ const BRIDGE_UPDATE_FORM_SCHEMA = 'bridge/BRIDGE_UPDATE_FORM_SCHEMA';
13146
+ const BRIDGE_WAZO_CONTACT_SEARCH = 'bridge/BRIDGE_WAZO_CONTACT_SEARCH';
13147
+ const BRIDGE_ON_AGENT_LOGGED_IN = 'bridge/BRIDGE_ON_AGENT_LOGGED_IN';
13148
+ const BRIDGE_ON_AGENT_LOGGED_OUT = 'bridge/BRIDGE_ON_AGENT_LOGGED_OUT';
13149
+ const BRIDGE_ON_AGENT_PAUSED = 'bridge/BRIDGE_ON_AGENT_PAUSED';
13150
+ const BRIDGE_ON_AGENT_RESUMED = 'bridge/BRIDGE_ON_AGENT_RESUMED';
13151
+ const BRIDGE_ON_LANGUAGE_CHANGED = 'bridge/BRIDGE_ON_LANGUAGE_CHANGED';
13152
+ const BRIDGE_ON_CALL_ANSWERED = 'bridge/BRIDGE_ON_CALL_ANSWERED';
13153
+ const BRIDGE_ON_CALL_HELD = 'bridge/BRIDGE_ON_CALL_HELD';
13154
+ const BRIDGE_ON_CALL_RESUMED = 'bridge/BRIDGE_ON_CALL_RESUMED';
13155
+ const BRIDGE_ON_CALL_MUTED = 'bridge/BRIDGE_ON_CALL_MUTED';
13156
+ const BRIDGE_ON_CALL_UN_MUTED = 'bridge/BRIDGE_ON_CALL_UN_MUTED';
13157
+ const BRIDGE_ON_DTMF = 'bridge/BRIDGE_ON_DTMF';
13158
+ const BRIDGE_ON_DIRECT_TRANSFER = 'bridge/BRIDGE_ON_DIRECT_TRANSFER';
13159
+ const BRIDGE_ON_CREATE_INDIRECT_TRANSFER = 'bridge/BRIDGE_ON_CREATE_INDIRECT_TRANSFER';
13160
+ const BRIDGE_ON_CANCEL_INDIRECT_TRANSFER = 'bridge/BRIDGE_ON_CANCEL_INDIRECT_TRANSFER';
13161
+ const BRIDGE_ON_CONFIRM_INDIRECT_TRANSFER = 'bridge/BRIDGE_ON_CONFIRM_INDIRECT_TRANSFER';
13162
+ const BRIDGE_ON_INDIRECT_TRANSFER_CALL_MADE = 'bridge/BRIDGE_ON_INDIRECT_TRANSFER_CALL_MADE';
13163
+ const BRIDGE_ON_INDIRECT_TRANSFER_DONE = 'bridge/BRIDGE_ON_INDIRECT_TRANSFER_DONE';
13164
+ const BRIDGE_ON_START_RECORDING = 'bridge/BRIDGE_ON_START_RECORDING';
13165
+ const BRIDGE_ON_STOP_RECORDING = 'bridge/BRIDGE_ON_STOP_RECORDING';
13166
+ const BRIDGE_ON_CARD_CANCELED = 'bridge/BRIDGE_ON_CARD_CANCELED';
13167
+ const BRIDGE_ENABLE_AGENT = 'bridge/BRIDGE_ENABLE_AGENT';
13168
+ const BRIDGE_SET_CARD_CONTENT = 'bridge/BRIDGE_SET_CARD_CONTENT';
13169
+
13170
+ const BRIDGE_INJECT_CSS = 'bridge/BRIDGE_INJECT_CSS';
13171
+ const BRIDGE_CUSTOMIZE_APPEARANCE = 'bridge/BRIDGE_CUSTOMIZE_APPEARANCE';
13172
+
13173
+ const SDK_CLICK_TO_CALL = 'sdk/CLICK_TO_CALL';
13174
+ const SDK_ON_CALL_MADE = 'sdk/SDK_ON_CALL_MADE';
13175
+ const SDK_CALL_ENDED = 'sdk/ON_CALL_ENDED';
13176
+ const SDK_CALL_INCOMING = 'sdk/SDK_CALL_INCOMING';
13177
+ const SDK_AUTHENTICATED = 'sdk/SDK_AUTHENTICATED';
13178
+ const SDK_LOGGED_OUT = 'sdk/SDK_LOGGED_OUT';
13179
+
13180
+ class Softphone {
13181
+
13182
+
13183
+
13184
+
13185
+
13186
+
13187
+
13188
+ // Message waiting for the iframe to be loaded
13189
+
13190
+
13191
+ onLinkEnabled(link ) {}
13192
+ onIFrameLoaded() {}
13193
+
13194
+ onCallAnswered() {}
13195
+ onCallMade(call ) {}
13196
+ onCallIncoming(call ) {}
13197
+ onCallEnded(call , card , direction , fromExtension ) {}
13198
+ onCardSaved(card ) {}
13199
+ onCardCanceled() {}
13200
+ onAuthenticated(session ) {}
13201
+ onLoggedOut() {}
13202
+
13203
+ onSearchOptions(fieldId , query ) {
13204
+ this.onOptionsResults(fieldId, []);
13205
+ }
13206
+
13207
+ onDisplayLinkedOption(optionId ) {}
13208
+ onWazoContactSearch(query ) {}
13209
+ onAgentLoggedIn() {}
13210
+ onAgentLoggedOut() {}
13211
+ onAgentPaused() {}
13212
+ onAgentResumed() {}
13213
+ onLanguageChanged(language ) {}
13214
+ onCallHeld() {}
13215
+ onCallResumed() {}
13216
+ onCallMuted() {}
13217
+ onCallUnMuted() {}
13218
+ onDtmfSent(tone ) {}
13219
+ onDirectTransfer(number ) {}
13220
+ onCreateIndirectTransfer(number ) {}
13221
+ onCancelIndirectTransfer() {}
13222
+ onConfirmIndirectTransfer() {}
13223
+ onIndirectCallMade(call ) {}
13224
+ onIndirectTransferDone(call ) {}
13225
+ onStartRecording() {}
13226
+ onStopRecording() {}
13227
+ onUnHandledEvent(event ) {}
13228
+
13229
+ init({ url, width, height, server, port, language, wrapUpDuration, enableAgent = true } = {}) {
13230
+ this.url = url || 'https://softphone.wazo.io';
13231
+ this.width = width || 500;
13232
+ this.height = height || 600;
13233
+ this.displayed = false;
13234
+ this.iframeLoaded = false;
13235
+
13236
+ this.iframeLoaded = false;
13237
+ this._pendingMessages = [];
13238
+ window.addEventListener('message', this._onMessage.bind(this), false);
13239
+
13240
+ if (!server) {
13241
+ // eslint-disable-next-line no-param-reassign
13242
+ server = 'stack.dev.wazo.io';
13243
+ }
13244
+
13245
+ const config = { server };
13246
+ if (language) {
13247
+ config.language = language;
13248
+ }
13249
+ if (port) {
13250
+ config.port = port;
13251
+ }
13252
+ if (wrapUpDuration) {
13253
+ config.wrapUpDuration = wrapUpDuration;
13254
+ }
13255
+
13256
+ this._sendMessage(BRIDGE_CONFIG_RETRIEVED, { config });
13257
+
13258
+ if (enableAgent) {
13259
+ this._sendMessage(BRIDGE_ENABLE_AGENT);
13260
+ }
13261
+
13262
+ this._createIframe(() => {
13263
+ this.iframeLoaded = true;
13264
+ this._pendingMessages.forEach(([type, payload]) => this._sendMessage(type, payload));
13265
+
13266
+ this.onIFrameLoaded();
13267
+ });
13268
+ }
13269
+
13270
+ parseLinks() {
13271
+ const links = this._getLinks();
13272
+
13273
+ links.forEach(link => {
13274
+ link.setAttribute('data-wazo-parsed', true);
13275
+ link.addEventListener('click', this._onLinkClick.bind(this));
13276
+ this.onLinkEnabled(link);
13277
+ });
13278
+ }
13279
+
13280
+ makeCall(number ) {
13281
+ this.displaySoftphone();
13282
+
13283
+ this._sendMessage(SDK_CLICK_TO_CALL, { number });
13284
+ }
13285
+
13286
+ toggleSoftphoneDisplay() {
13287
+ if (this.displayed) {
13288
+ this.hideSoftphone();
13289
+ } else {
13290
+ this.displaySoftphone();
13291
+ }
13292
+ }
13293
+
13294
+ displaySoftphone() {
13295
+ if (!this.iframe) {
13296
+ this._createIframe();
13297
+ }
13298
+
13299
+ if (this.iframe) {
13300
+ this.iframe.style.display = 'block';
13301
+ }
13302
+
13303
+ this.displayed = true;
13304
+ }
13305
+
13306
+ hideSoftphone() {
13307
+ if (this.iframe) {
13308
+ this.iframe.style.display = 'none';
13309
+ }
13310
+ this.displayed = false;
13311
+ }
13312
+
13313
+ optionsFetched(fieldId , options ) {
13314
+ this._sendMessage(BRIDGE_OPTIONS_FETCHED, { fieldId, options });
13315
+ }
13316
+
13317
+ onOptionsResults(fieldId , options ) {
13318
+ this._sendMessage(BRIDGE_OPTIONS_FOUND, { fieldId, options });
13319
+ }
13320
+
13321
+ setFormSchema(schema , uiSchema ) {
13322
+ this._sendMessage(BRIDGE_UPDATE_FORM_SCHEMA, { schema, uiSchema });
13323
+ }
13324
+
13325
+ setCardValue(field , value ) {
13326
+ this._sendMessage(BRIDGE_SET_CARD_CONTENT, { field, value });
13327
+ }
13328
+
13329
+ injectCss(css ) {
13330
+ this._sendMessage(BRIDGE_INJECT_CSS, { css });
13331
+ }
13332
+
13333
+ customizeAppearance(themes , translations , assets ) {
13334
+ this._sendMessage(BRIDGE_CUSTOMIZE_APPEARANCE, { themes, translations, assets });
13335
+ }
13336
+
13337
+ _createIframe(cb = () => {}) {
13338
+ this.iframe = document.createElement('iframe');
13339
+ // $FlowFixMe
13340
+ this.iframe.width = this.width;
13341
+ // $FlowFixMe
13342
+ this.iframe.height = this.height;
13343
+ // $FlowFixMe
13344
+ this.iframe.allow = 'camera *; microphone *; autoplay *; display-capture *';
13345
+ this.iframe.style.position = 'absolute';
13346
+ this.iframe.style.left = '0';
13347
+ this.iframe.style.bottom = '0';
13348
+ this.iframe.style.border = '1px solid #aaa';
13349
+ this.iframe.style.backgroundColor = 'white';
13350
+ this.iframe.src = this.url;
13351
+ this.iframe.style.display = 'none';
13352
+ this.iframe.id = 'wazo-softphone';
13353
+
13354
+ this.iframe.onload = cb;
13355
+
13356
+ // $FlowFixMe
13357
+ document.body.appendChild(this.iframe);
13358
+ }
13359
+
13360
+ _getLinks() {
13361
+ return [].slice.call(document.querySelectorAll('a:not([data-wazo-parsed])'), 0)
13362
+ .filter(link => link.href.indexOf('tel:') === 0 || link.href.indexOf('callto:') === 0);
13363
+ }
13364
+
13365
+ _onLinkClick(e ) {
13366
+ e.preventDefault();
13367
+ const number = e.target.href.split(':')[1];
13368
+
13369
+ this.makeCall(number);
13370
+ }
13371
+
13372
+ _onAuthenticated() {
13373
+ this.parseLinks();
13374
+ }
13375
+
13376
+ _onMessage(event ) {
13377
+ if (!event.data) {
13378
+ return;
13379
+ }
13380
+
13381
+ switch (event.data.type) {
13382
+ case SDK_ON_CALL_MADE:
13383
+ this.onCallMade(event.data.callSession);
13384
+ break;
13385
+ case SDK_CALL_ENDED: {
13386
+ const { callSession, content, direction, userExtension } = event.data;
13387
+ this.onCallEnded(callSession, content, direction, userExtension);
13388
+ break;
13389
+ }
13390
+ case SDK_CALL_INCOMING:
13391
+ this.onCallIncoming(event.data.callSession);
13392
+ break;
13393
+ case SDK_AUTHENTICATED:
13394
+ // $FlowFixMe
13395
+ this._onAuthenticated(event.data.session);
13396
+ this.onAuthenticated(event.data.session);
13397
+ break;
13398
+ case SDK_LOGGED_OUT:
13399
+ this.onLoggedOut();
13400
+ break;
13401
+ case BRIDGE_CREATE_OR_UPDATE_CARD: {
13402
+ const { content } = event.data;
13403
+ this.onCardSaved(content);
13404
+ break;
13405
+ }
13406
+ case BRIDGE_SEARCH_OPTIONS: {
13407
+ const { fieldId, query } = event.data;
13408
+ this.onSearchOptions(fieldId, query);
13409
+ break;
13410
+ }
13411
+ case BRIDGE_DISPLAY_LINKED_OPTION:
13412
+ this.onDisplayLinkedOption(event.data.linkedOptionId);
13413
+ break;
13414
+ case BRIDGE_WAZO_CONTACT_SEARCH:
13415
+ this.onWazoContactSearch(event.data.query);
13416
+ break;
13417
+ case BRIDGE_ON_AGENT_LOGGED_IN:
13418
+ this.onAgentLoggedIn();
13419
+ break;
13420
+ case BRIDGE_ON_AGENT_LOGGED_OUT:
13421
+ this.onAgentLoggedOut();
13422
+ break;
13423
+ case BRIDGE_ON_AGENT_PAUSED:
13424
+ this.onAgentPaused();
13425
+ break;
13426
+ case BRIDGE_ON_AGENT_RESUMED:
13427
+ this.onAgentResumed();
13428
+ break;
13429
+ case BRIDGE_ON_LANGUAGE_CHANGED:
13430
+ this.onLanguageChanged(event.data.language);
13431
+ break;
13432
+ case BRIDGE_ON_CALL_HELD:
13433
+ this.onCallHeld();
13434
+ break;
13435
+ case BRIDGE_ON_CALL_RESUMED:
13436
+ this.onCallResumed();
13437
+ break;
13438
+ case BRIDGE_ON_CALL_MUTED:
13439
+ this.onCallMuted();
13440
+ break;
13441
+ case BRIDGE_ON_CALL_UN_MUTED:
13442
+ this.onCallUnMuted();
13443
+ break;
13444
+ case BRIDGE_ON_DTMF:
13445
+ this.onDtmfSent(event.data.tone);
13446
+ break;
13447
+ case BRIDGE_ON_DIRECT_TRANSFER:
13448
+ this.onDirectTransfer(event.data.number);
13449
+ break;
13450
+ case BRIDGE_ON_CREATE_INDIRECT_TRANSFER:
13451
+ this.onCreateIndirectTransfer(event.data.number);
13452
+ break;
13453
+ case BRIDGE_ON_CANCEL_INDIRECT_TRANSFER:
13454
+ this.onCancelIndirectTransfer();
13455
+ break;
13456
+ case BRIDGE_ON_CONFIRM_INDIRECT_TRANSFER:
13457
+ this.onConfirmIndirectTransfer();
13458
+ break;
13459
+ case BRIDGE_ON_INDIRECT_TRANSFER_CALL_MADE:
13460
+ this.onIndirectCallMade(event.data.call);
13461
+ break;
13462
+ case BRIDGE_ON_INDIRECT_TRANSFER_DONE:
13463
+ this.onIndirectTransferDone(event.data.call);
13464
+ break;
13465
+ case BRIDGE_ON_START_RECORDING:
13466
+ this.onStartRecording();
13467
+ break;
13468
+ case BRIDGE_ON_STOP_RECORDING:
13469
+ this.onStopRecording();
13470
+ break;
13471
+ case BRIDGE_ON_CARD_CANCELED:
13472
+ this.onCardCanceled();
13473
+ break;
13474
+ case BRIDGE_ON_CALL_ANSWERED:
13475
+ this.onCallAnswered();
13476
+ break;
13477
+ default:
13478
+ this.onUnHandledEvent(event);
13479
+ break;
13480
+ }
13481
+ }
13482
+
13483
+ _sendMessage(type , payload = {}) {
13484
+ if (!this.iframe || !this.iframeLoaded) {
13485
+ this._pendingMessages.push([type, payload]);
13486
+ return;
13487
+ }
13488
+
13489
+ this.iframe.contentWindow.postMessage({ type, ...payload }, '*');
13490
+ }
13491
+ }
13492
+
13493
+ var Softphone$1 = new Softphone();
13494
+
13136
13495
  /* global window */
13137
13496
 
13138
13497
  const Wazo = {
@@ -13153,6 +13512,7 @@ const Wazo = {
13153
13512
  loggerFor: IssueReporter$1.loggerFor.bind(IssueReporter$1),
13154
13513
  Features: Features$1,
13155
13514
  Checker,
13515
+ Softphone: Softphone$1,
13156
13516
 
13157
13517
  // Domain
13158
13518
  domain: {