@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
@@ -6953,7 +6953,7 @@ class WebRTCClient extends Emitter {
6953
6953
  }
6954
6954
 
6955
6955
  async _onHeartbeatTimeout() {
6956
- logger.info('sdk webrtc heartbeat timed out', { userAgent: !!this.userAgent, cb: !!this.heartbeatTimeoutCb });
6956
+ logger.warn('sdk webrtc heartbeat timed out', { userAgent: !!this.userAgent, cb: !!this.heartbeatTimeoutCb });
6957
6957
 
6958
6958
  if (this.heartbeatTimeoutCb) {
6959
6959
  this.heartbeatTimeoutCb();
@@ -7538,7 +7538,7 @@ class WebRTCClient extends Emitter {
7538
7538
  }
7539
7539
 
7540
7540
  async _onHeartbeatTimeout() {
7541
- logger$1.info('sdk webrtc heartbeat timed out', { userAgent: !!this.userAgent, cb: !!this.heartbeatTimeoutCb });
7541
+ logger$1.warn('sdk webrtc heartbeat timed out', { userAgent: !!this.userAgent, cb: !!this.heartbeatTimeoutCb });
7542
7542
 
7543
7543
  if (this.heartbeatTimeoutCb) {
7544
7544
  this.heartbeatTimeoutCb();
@@ -7538,7 +7538,7 @@ class WebRTCClient extends Emitter {
7538
7538
  }
7539
7539
 
7540
7540
  async _onHeartbeatTimeout() {
7541
- logger.info('sdk webrtc heartbeat timed out', { userAgent: !!this.userAgent, cb: !!this.heartbeatTimeoutCb });
7541
+ logger.warn('sdk webrtc heartbeat timed out', { userAgent: !!this.userAgent, cb: !!this.heartbeatTimeoutCb });
7542
7542
 
7543
7543
  if (this.heartbeatTimeoutCb) {
7544
7544
  this.heartbeatTimeoutCb();
@@ -6953,7 +6953,7 @@ class WebRTCClient extends Emitter {
6953
6953
  }
6954
6954
 
6955
6955
  async _onHeartbeatTimeout() {
6956
- logger.info('sdk webrtc heartbeat timed out', { userAgent: !!this.userAgent, cb: !!this.heartbeatTimeoutCb });
6956
+ logger.warn('sdk webrtc heartbeat timed out', { userAgent: !!this.userAgent, cb: !!this.heartbeatTimeoutCb });
6957
6957
 
6958
6958
  if (this.heartbeatTimeoutCb) {
6959
6959
  this.heartbeatTimeoutCb();
@@ -6953,7 +6953,7 @@ class WebRTCClient extends Emitter {
6953
6953
  }
6954
6954
 
6955
6955
  async _onHeartbeatTimeout() {
6956
- logger.info('sdk webrtc heartbeat timed out', { userAgent: !!this.userAgent, cb: !!this.heartbeatTimeoutCb });
6956
+ logger.warn('sdk webrtc heartbeat timed out', { userAgent: !!this.userAgent, cb: !!this.heartbeatTimeoutCb });
6957
6957
 
6958
6958
  if (this.heartbeatTimeoutCb) {
6959
6959
  this.heartbeatTimeoutCb();
package/esm/index.js CHANGED
@@ -7847,7 +7847,7 @@ class WebRTCClient extends Emitter {
7847
7847
  }
7848
7848
 
7849
7849
  async _onHeartbeatTimeout() {
7850
- 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 });
7851
7851
 
7852
7852
  if (this.heartbeatTimeoutCb) {
7853
7853
  this.heartbeatTimeoutCb();
@@ -14107,6 +14107,365 @@ const createLocalVideoStream = async (options ) => createLocalStream('vid
14107
14107
 
14108
14108
  const createLocalAudioStream = async (options ) => createLocalStream('audio', options);
14109
14109
 
14110
+ //
14111
+ /* eslint-disable no-unused-vars */
14112
+ /* global window, document */
14113
+ const BRIDGE_CONFIG_RETRIEVED = 'bridge/CONFIG_RETRIEVED';
14114
+ const BRIDGE_CREATE_OR_UPDATE_CARD = 'bridge/BRIDGE_CREATE_OR_UPDATE_CARD';
14115
+ const BRIDGE_OPTIONS_FETCHED = 'bridge/BRIDGE_OPTIONS_FETCHED';
14116
+ const BRIDGE_OPTIONS_FOUND = 'bridge/BRIDGE_OPTIONS_FOUND';
14117
+ const BRIDGE_SEARCH_OPTIONS = 'bridge/BRIDGE_SEARCH_OPTIONS';
14118
+ const BRIDGE_DISPLAY_LINKED_OPTION = 'bridge/DISPLAY_LINKED_OPTION';
14119
+ const BRIDGE_UPDATE_FORM_SCHEMA = 'bridge/BRIDGE_UPDATE_FORM_SCHEMA';
14120
+ const BRIDGE_WAZO_CONTACT_SEARCH = 'bridge/BRIDGE_WAZO_CONTACT_SEARCH';
14121
+ const BRIDGE_ON_AGENT_LOGGED_IN = 'bridge/BRIDGE_ON_AGENT_LOGGED_IN';
14122
+ const BRIDGE_ON_AGENT_LOGGED_OUT = 'bridge/BRIDGE_ON_AGENT_LOGGED_OUT';
14123
+ const BRIDGE_ON_AGENT_PAUSED = 'bridge/BRIDGE_ON_AGENT_PAUSED';
14124
+ const BRIDGE_ON_AGENT_RESUMED = 'bridge/BRIDGE_ON_AGENT_RESUMED';
14125
+ const BRIDGE_ON_LANGUAGE_CHANGED = 'bridge/BRIDGE_ON_LANGUAGE_CHANGED';
14126
+ const BRIDGE_ON_CALL_ANSWERED = 'bridge/BRIDGE_ON_CALL_ANSWERED';
14127
+ const BRIDGE_ON_CALL_HELD = 'bridge/BRIDGE_ON_CALL_HELD';
14128
+ const BRIDGE_ON_CALL_RESUMED = 'bridge/BRIDGE_ON_CALL_RESUMED';
14129
+ const BRIDGE_ON_CALL_MUTED = 'bridge/BRIDGE_ON_CALL_MUTED';
14130
+ const BRIDGE_ON_CALL_UN_MUTED = 'bridge/BRIDGE_ON_CALL_UN_MUTED';
14131
+ const BRIDGE_ON_DTMF = 'bridge/BRIDGE_ON_DTMF';
14132
+ const BRIDGE_ON_DIRECT_TRANSFER = 'bridge/BRIDGE_ON_DIRECT_TRANSFER';
14133
+ const BRIDGE_ON_CREATE_INDIRECT_TRANSFER = 'bridge/BRIDGE_ON_CREATE_INDIRECT_TRANSFER';
14134
+ const BRIDGE_ON_CANCEL_INDIRECT_TRANSFER = 'bridge/BRIDGE_ON_CANCEL_INDIRECT_TRANSFER';
14135
+ const BRIDGE_ON_CONFIRM_INDIRECT_TRANSFER = 'bridge/BRIDGE_ON_CONFIRM_INDIRECT_TRANSFER';
14136
+ const BRIDGE_ON_INDIRECT_TRANSFER_CALL_MADE = 'bridge/BRIDGE_ON_INDIRECT_TRANSFER_CALL_MADE';
14137
+ const BRIDGE_ON_INDIRECT_TRANSFER_DONE = 'bridge/BRIDGE_ON_INDIRECT_TRANSFER_DONE';
14138
+ const BRIDGE_ON_START_RECORDING = 'bridge/BRIDGE_ON_START_RECORDING';
14139
+ const BRIDGE_ON_STOP_RECORDING = 'bridge/BRIDGE_ON_STOP_RECORDING';
14140
+ const BRIDGE_ON_CARD_CANCELED = 'bridge/BRIDGE_ON_CARD_CANCELED';
14141
+ const BRIDGE_ENABLE_AGENT = 'bridge/BRIDGE_ENABLE_AGENT';
14142
+ const BRIDGE_SET_CARD_CONTENT = 'bridge/BRIDGE_SET_CARD_CONTENT';
14143
+
14144
+ const BRIDGE_INJECT_CSS = 'bridge/BRIDGE_INJECT_CSS';
14145
+ const BRIDGE_CUSTOMIZE_APPEARANCE = 'bridge/BRIDGE_CUSTOMIZE_APPEARANCE';
14146
+
14147
+ const SDK_CLICK_TO_CALL = 'sdk/CLICK_TO_CALL';
14148
+ const SDK_ON_CALL_MADE = 'sdk/SDK_ON_CALL_MADE';
14149
+ const SDK_CALL_ENDED = 'sdk/ON_CALL_ENDED';
14150
+ const SDK_CALL_INCOMING = 'sdk/SDK_CALL_INCOMING';
14151
+ const SDK_AUTHENTICATED = 'sdk/SDK_AUTHENTICATED';
14152
+ const SDK_LOGGED_OUT = 'sdk/SDK_LOGGED_OUT';
14153
+
14154
+ class Softphone {
14155
+
14156
+
14157
+
14158
+
14159
+
14160
+
14161
+
14162
+ // Message waiting for the iframe to be loaded
14163
+
14164
+
14165
+ onLinkEnabled(link ) {}
14166
+ onIFrameLoaded() {}
14167
+
14168
+ onCallAnswered() {}
14169
+ onCallMade(call ) {}
14170
+ onCallIncoming(call ) {}
14171
+ onCallEnded(call , card , direction , fromExtension ) {}
14172
+ onCardSaved(card ) {}
14173
+ onCardCanceled() {}
14174
+ onAuthenticated(session ) {}
14175
+ onLoggedOut() {}
14176
+
14177
+ onSearchOptions(fieldId , query ) {
14178
+ this.onOptionsResults(fieldId, []);
14179
+ }
14180
+
14181
+ onDisplayLinkedOption(optionId ) {}
14182
+ onWazoContactSearch(query ) {}
14183
+ onAgentLoggedIn() {}
14184
+ onAgentLoggedOut() {}
14185
+ onAgentPaused() {}
14186
+ onAgentResumed() {}
14187
+ onLanguageChanged(language ) {}
14188
+ onCallHeld() {}
14189
+ onCallResumed() {}
14190
+ onCallMuted() {}
14191
+ onCallUnMuted() {}
14192
+ onDtmfSent(tone ) {}
14193
+ onDirectTransfer(number ) {}
14194
+ onCreateIndirectTransfer(number ) {}
14195
+ onCancelIndirectTransfer() {}
14196
+ onConfirmIndirectTransfer() {}
14197
+ onIndirectCallMade(call ) {}
14198
+ onIndirectTransferDone(call ) {}
14199
+ onStartRecording() {}
14200
+ onStopRecording() {}
14201
+ onUnHandledEvent(event ) {}
14202
+
14203
+ init({ url, width, height, server, port, language, wrapUpDuration, enableAgent = true } = {}) {
14204
+ this.url = url || 'https://softphone.wazo.io';
14205
+ this.width = width || 500;
14206
+ this.height = height || 600;
14207
+ this.displayed = false;
14208
+ this.iframeLoaded = false;
14209
+
14210
+ this.iframeLoaded = false;
14211
+ this._pendingMessages = [];
14212
+ window.addEventListener('message', this._onMessage.bind(this), false);
14213
+
14214
+ if (!server) {
14215
+ // eslint-disable-next-line no-param-reassign
14216
+ server = 'stack.dev.wazo.io';
14217
+ }
14218
+
14219
+ const config = { server };
14220
+ if (language) {
14221
+ config.language = language;
14222
+ }
14223
+ if (port) {
14224
+ config.port = port;
14225
+ }
14226
+ if (wrapUpDuration) {
14227
+ config.wrapUpDuration = wrapUpDuration;
14228
+ }
14229
+
14230
+ this._sendMessage(BRIDGE_CONFIG_RETRIEVED, { config });
14231
+
14232
+ if (enableAgent) {
14233
+ this._sendMessage(BRIDGE_ENABLE_AGENT);
14234
+ }
14235
+
14236
+ this._createIframe(() => {
14237
+ this.iframeLoaded = true;
14238
+ this._pendingMessages.forEach(([type, payload]) => this._sendMessage(type, payload));
14239
+
14240
+ this.onIFrameLoaded();
14241
+ });
14242
+ }
14243
+
14244
+ parseLinks() {
14245
+ const links = this._getLinks();
14246
+
14247
+ links.forEach(link => {
14248
+ link.setAttribute('data-wazo-parsed', true);
14249
+ link.addEventListener('click', this._onLinkClick.bind(this));
14250
+ this.onLinkEnabled(link);
14251
+ });
14252
+ }
14253
+
14254
+ makeCall(number ) {
14255
+ this.displaySoftphone();
14256
+
14257
+ this._sendMessage(SDK_CLICK_TO_CALL, { number });
14258
+ }
14259
+
14260
+ toggleSoftphoneDisplay() {
14261
+ if (this.displayed) {
14262
+ this.hideSoftphone();
14263
+ } else {
14264
+ this.displaySoftphone();
14265
+ }
14266
+ }
14267
+
14268
+ displaySoftphone() {
14269
+ if (!this.iframe) {
14270
+ this._createIframe();
14271
+ }
14272
+
14273
+ if (this.iframe) {
14274
+ this.iframe.style.display = 'block';
14275
+ }
14276
+
14277
+ this.displayed = true;
14278
+ }
14279
+
14280
+ hideSoftphone() {
14281
+ if (this.iframe) {
14282
+ this.iframe.style.display = 'none';
14283
+ }
14284
+ this.displayed = false;
14285
+ }
14286
+
14287
+ optionsFetched(fieldId , options ) {
14288
+ this._sendMessage(BRIDGE_OPTIONS_FETCHED, { fieldId, options });
14289
+ }
14290
+
14291
+ onOptionsResults(fieldId , options ) {
14292
+ this._sendMessage(BRIDGE_OPTIONS_FOUND, { fieldId, options });
14293
+ }
14294
+
14295
+ setFormSchema(schema , uiSchema ) {
14296
+ this._sendMessage(BRIDGE_UPDATE_FORM_SCHEMA, { schema, uiSchema });
14297
+ }
14298
+
14299
+ setCardValue(field , value ) {
14300
+ this._sendMessage(BRIDGE_SET_CARD_CONTENT, { field, value });
14301
+ }
14302
+
14303
+ injectCss(css ) {
14304
+ this._sendMessage(BRIDGE_INJECT_CSS, { css });
14305
+ }
14306
+
14307
+ customizeAppearance(themes , translations , assets ) {
14308
+ this._sendMessage(BRIDGE_CUSTOMIZE_APPEARANCE, { themes, translations, assets });
14309
+ }
14310
+
14311
+ _createIframe(cb = () => {}) {
14312
+ this.iframe = document.createElement('iframe');
14313
+ // $FlowFixMe
14314
+ this.iframe.width = this.width;
14315
+ // $FlowFixMe
14316
+ this.iframe.height = this.height;
14317
+ // $FlowFixMe
14318
+ this.iframe.allow = 'camera *; microphone *; autoplay *; display-capture *';
14319
+ this.iframe.style.position = 'absolute';
14320
+ this.iframe.style.left = '0';
14321
+ this.iframe.style.bottom = '0';
14322
+ this.iframe.style.border = '1px solid #aaa';
14323
+ this.iframe.style.backgroundColor = 'white';
14324
+ this.iframe.src = this.url;
14325
+ this.iframe.style.display = 'none';
14326
+ this.iframe.id = 'wazo-softphone';
14327
+
14328
+ this.iframe.onload = cb;
14329
+
14330
+ // $FlowFixMe
14331
+ document.body.appendChild(this.iframe);
14332
+ }
14333
+
14334
+ _getLinks() {
14335
+ return [].slice.call(document.querySelectorAll('a:not([data-wazo-parsed])'), 0)
14336
+ .filter(link => link.href.indexOf('tel:') === 0 || link.href.indexOf('callto:') === 0);
14337
+ }
14338
+
14339
+ _onLinkClick(e ) {
14340
+ e.preventDefault();
14341
+ const number = e.target.href.split(':')[1];
14342
+
14343
+ this.makeCall(number);
14344
+ }
14345
+
14346
+ _onAuthenticated() {
14347
+ this.parseLinks();
14348
+ }
14349
+
14350
+ _onMessage(event ) {
14351
+ if (!event.data) {
14352
+ return;
14353
+ }
14354
+
14355
+ switch (event.data.type) {
14356
+ case SDK_ON_CALL_MADE:
14357
+ this.onCallMade(event.data.callSession);
14358
+ break;
14359
+ case SDK_CALL_ENDED: {
14360
+ const { callSession, content, direction, userExtension } = event.data;
14361
+ this.onCallEnded(callSession, content, direction, userExtension);
14362
+ break;
14363
+ }
14364
+ case SDK_CALL_INCOMING:
14365
+ this.onCallIncoming(event.data.callSession);
14366
+ break;
14367
+ case SDK_AUTHENTICATED:
14368
+ // $FlowFixMe
14369
+ this._onAuthenticated(event.data.session);
14370
+ this.onAuthenticated(event.data.session);
14371
+ break;
14372
+ case SDK_LOGGED_OUT:
14373
+ this.onLoggedOut();
14374
+ break;
14375
+ case BRIDGE_CREATE_OR_UPDATE_CARD: {
14376
+ const { content } = event.data;
14377
+ this.onCardSaved(content);
14378
+ break;
14379
+ }
14380
+ case BRIDGE_SEARCH_OPTIONS: {
14381
+ const { fieldId, query } = event.data;
14382
+ this.onSearchOptions(fieldId, query);
14383
+ break;
14384
+ }
14385
+ case BRIDGE_DISPLAY_LINKED_OPTION:
14386
+ this.onDisplayLinkedOption(event.data.linkedOptionId);
14387
+ break;
14388
+ case BRIDGE_WAZO_CONTACT_SEARCH:
14389
+ this.onWazoContactSearch(event.data.query);
14390
+ break;
14391
+ case BRIDGE_ON_AGENT_LOGGED_IN:
14392
+ this.onAgentLoggedIn();
14393
+ break;
14394
+ case BRIDGE_ON_AGENT_LOGGED_OUT:
14395
+ this.onAgentLoggedOut();
14396
+ break;
14397
+ case BRIDGE_ON_AGENT_PAUSED:
14398
+ this.onAgentPaused();
14399
+ break;
14400
+ case BRIDGE_ON_AGENT_RESUMED:
14401
+ this.onAgentResumed();
14402
+ break;
14403
+ case BRIDGE_ON_LANGUAGE_CHANGED:
14404
+ this.onLanguageChanged(event.data.language);
14405
+ break;
14406
+ case BRIDGE_ON_CALL_HELD:
14407
+ this.onCallHeld();
14408
+ break;
14409
+ case BRIDGE_ON_CALL_RESUMED:
14410
+ this.onCallResumed();
14411
+ break;
14412
+ case BRIDGE_ON_CALL_MUTED:
14413
+ this.onCallMuted();
14414
+ break;
14415
+ case BRIDGE_ON_CALL_UN_MUTED:
14416
+ this.onCallUnMuted();
14417
+ break;
14418
+ case BRIDGE_ON_DTMF:
14419
+ this.onDtmfSent(event.data.tone);
14420
+ break;
14421
+ case BRIDGE_ON_DIRECT_TRANSFER:
14422
+ this.onDirectTransfer(event.data.number);
14423
+ break;
14424
+ case BRIDGE_ON_CREATE_INDIRECT_TRANSFER:
14425
+ this.onCreateIndirectTransfer(event.data.number);
14426
+ break;
14427
+ case BRIDGE_ON_CANCEL_INDIRECT_TRANSFER:
14428
+ this.onCancelIndirectTransfer();
14429
+ break;
14430
+ case BRIDGE_ON_CONFIRM_INDIRECT_TRANSFER:
14431
+ this.onConfirmIndirectTransfer();
14432
+ break;
14433
+ case BRIDGE_ON_INDIRECT_TRANSFER_CALL_MADE:
14434
+ this.onIndirectCallMade(event.data.call);
14435
+ break;
14436
+ case BRIDGE_ON_INDIRECT_TRANSFER_DONE:
14437
+ this.onIndirectTransferDone(event.data.call);
14438
+ break;
14439
+ case BRIDGE_ON_START_RECORDING:
14440
+ this.onStartRecording();
14441
+ break;
14442
+ case BRIDGE_ON_STOP_RECORDING:
14443
+ this.onStopRecording();
14444
+ break;
14445
+ case BRIDGE_ON_CARD_CANCELED:
14446
+ this.onCardCanceled();
14447
+ break;
14448
+ case BRIDGE_ON_CALL_ANSWERED:
14449
+ this.onCallAnswered();
14450
+ break;
14451
+ default:
14452
+ this.onUnHandledEvent(event);
14453
+ break;
14454
+ }
14455
+ }
14456
+
14457
+ _sendMessage(type , payload = {}) {
14458
+ if (!this.iframe || !this.iframeLoaded) {
14459
+ this._pendingMessages.push([type, payload]);
14460
+ return;
14461
+ }
14462
+
14463
+ this.iframe.contentWindow.postMessage({ type, ...payload }, '*');
14464
+ }
14465
+ }
14466
+
14467
+ var Softphone$1 = new Softphone();
14468
+
14110
14469
  /* global window */
14111
14470
 
14112
14471
  const Wazo = {
@@ -14127,6 +14486,7 @@ const Wazo = {
14127
14486
  loggerFor: IssueReporter$1.loggerFor.bind(IssueReporter$1),
14128
14487
  Features: Features$1,
14129
14488
  Checker,
14489
+ Softphone: Softphone$1,
14130
14490
 
14131
14491
  // Domain
14132
14492
  domain: {