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