@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
@@ -8338,7 +8338,7 @@ class WebRTCClient extends Emitter {
8338
8338
  }
8339
8339
 
8340
8340
  async _onHeartbeatTimeout() {
8341
- logger$8.info('sdk webrtc heartbeat timed out', { userAgent: !!this.userAgent, cb: !!this.heartbeatTimeoutCb });
8341
+ logger$8.warn('sdk webrtc heartbeat timed out', { userAgent: !!this.userAgent, cb: !!this.heartbeatTimeoutCb });
8342
8342
 
8343
8343
  if (this.heartbeatTimeoutCb) {
8344
8344
  this.heartbeatTimeoutCb();
@@ -13965,6 +13965,365 @@ class Checker {
13965
13965
  }
13966
13966
  }
13967
13967
 
13968
+ //
13969
+ /* eslint-disable no-unused-vars */
13970
+ /* global window, document */
13971
+ const BRIDGE_CONFIG_RETRIEVED = 'bridge/CONFIG_RETRIEVED';
13972
+ const BRIDGE_CREATE_OR_UPDATE_CARD = 'bridge/BRIDGE_CREATE_OR_UPDATE_CARD';
13973
+ const BRIDGE_OPTIONS_FETCHED = 'bridge/BRIDGE_OPTIONS_FETCHED';
13974
+ const BRIDGE_OPTIONS_FOUND = 'bridge/BRIDGE_OPTIONS_FOUND';
13975
+ const BRIDGE_SEARCH_OPTIONS = 'bridge/BRIDGE_SEARCH_OPTIONS';
13976
+ const BRIDGE_DISPLAY_LINKED_OPTION = 'bridge/DISPLAY_LINKED_OPTION';
13977
+ const BRIDGE_UPDATE_FORM_SCHEMA = 'bridge/BRIDGE_UPDATE_FORM_SCHEMA';
13978
+ const BRIDGE_WAZO_CONTACT_SEARCH = 'bridge/BRIDGE_WAZO_CONTACT_SEARCH';
13979
+ const BRIDGE_ON_AGENT_LOGGED_IN = 'bridge/BRIDGE_ON_AGENT_LOGGED_IN';
13980
+ const BRIDGE_ON_AGENT_LOGGED_OUT = 'bridge/BRIDGE_ON_AGENT_LOGGED_OUT';
13981
+ const BRIDGE_ON_AGENT_PAUSED = 'bridge/BRIDGE_ON_AGENT_PAUSED';
13982
+ const BRIDGE_ON_AGENT_RESUMED = 'bridge/BRIDGE_ON_AGENT_RESUMED';
13983
+ const BRIDGE_ON_LANGUAGE_CHANGED = 'bridge/BRIDGE_ON_LANGUAGE_CHANGED';
13984
+ const BRIDGE_ON_CALL_ANSWERED = 'bridge/BRIDGE_ON_CALL_ANSWERED';
13985
+ const BRIDGE_ON_CALL_HELD = 'bridge/BRIDGE_ON_CALL_HELD';
13986
+ const BRIDGE_ON_CALL_RESUMED = 'bridge/BRIDGE_ON_CALL_RESUMED';
13987
+ const BRIDGE_ON_CALL_MUTED = 'bridge/BRIDGE_ON_CALL_MUTED';
13988
+ const BRIDGE_ON_CALL_UN_MUTED = 'bridge/BRIDGE_ON_CALL_UN_MUTED';
13989
+ const BRIDGE_ON_DTMF = 'bridge/BRIDGE_ON_DTMF';
13990
+ const BRIDGE_ON_DIRECT_TRANSFER = 'bridge/BRIDGE_ON_DIRECT_TRANSFER';
13991
+ const BRIDGE_ON_CREATE_INDIRECT_TRANSFER = 'bridge/BRIDGE_ON_CREATE_INDIRECT_TRANSFER';
13992
+ const BRIDGE_ON_CANCEL_INDIRECT_TRANSFER = 'bridge/BRIDGE_ON_CANCEL_INDIRECT_TRANSFER';
13993
+ const BRIDGE_ON_CONFIRM_INDIRECT_TRANSFER = 'bridge/BRIDGE_ON_CONFIRM_INDIRECT_TRANSFER';
13994
+ const BRIDGE_ON_INDIRECT_TRANSFER_CALL_MADE = 'bridge/BRIDGE_ON_INDIRECT_TRANSFER_CALL_MADE';
13995
+ const BRIDGE_ON_INDIRECT_TRANSFER_DONE = 'bridge/BRIDGE_ON_INDIRECT_TRANSFER_DONE';
13996
+ const BRIDGE_ON_START_RECORDING = 'bridge/BRIDGE_ON_START_RECORDING';
13997
+ const BRIDGE_ON_STOP_RECORDING = 'bridge/BRIDGE_ON_STOP_RECORDING';
13998
+ const BRIDGE_ON_CARD_CANCELED = 'bridge/BRIDGE_ON_CARD_CANCELED';
13999
+ const BRIDGE_ENABLE_AGENT = 'bridge/BRIDGE_ENABLE_AGENT';
14000
+ const BRIDGE_SET_CARD_CONTENT = 'bridge/BRIDGE_SET_CARD_CONTENT';
14001
+
14002
+ const BRIDGE_INJECT_CSS = 'bridge/BRIDGE_INJECT_CSS';
14003
+ const BRIDGE_CUSTOMIZE_APPEARANCE = 'bridge/BRIDGE_CUSTOMIZE_APPEARANCE';
14004
+
14005
+ const SDK_CLICK_TO_CALL = 'sdk/CLICK_TO_CALL';
14006
+ const SDK_ON_CALL_MADE = 'sdk/SDK_ON_CALL_MADE';
14007
+ const SDK_CALL_ENDED = 'sdk/ON_CALL_ENDED';
14008
+ const SDK_CALL_INCOMING = 'sdk/SDK_CALL_INCOMING';
14009
+ const SDK_AUTHENTICATED = 'sdk/SDK_AUTHENTICATED';
14010
+ const SDK_LOGGED_OUT = 'sdk/SDK_LOGGED_OUT';
14011
+
14012
+ class Softphone {
14013
+
14014
+
14015
+
14016
+
14017
+
14018
+
14019
+
14020
+ // Message waiting for the iframe to be loaded
14021
+
14022
+
14023
+ onLinkEnabled(link ) {}
14024
+ onIFrameLoaded() {}
14025
+
14026
+ onCallAnswered() {}
14027
+ onCallMade(call ) {}
14028
+ onCallIncoming(call ) {}
14029
+ onCallEnded(call , card , direction , fromExtension ) {}
14030
+ onCardSaved(card ) {}
14031
+ onCardCanceled() {}
14032
+ onAuthenticated(session ) {}
14033
+ onLoggedOut() {}
14034
+
14035
+ onSearchOptions(fieldId , query ) {
14036
+ this.onOptionsResults(fieldId, []);
14037
+ }
14038
+
14039
+ onDisplayLinkedOption(optionId ) {}
14040
+ onWazoContactSearch(query ) {}
14041
+ onAgentLoggedIn() {}
14042
+ onAgentLoggedOut() {}
14043
+ onAgentPaused() {}
14044
+ onAgentResumed() {}
14045
+ onLanguageChanged(language ) {}
14046
+ onCallHeld() {}
14047
+ onCallResumed() {}
14048
+ onCallMuted() {}
14049
+ onCallUnMuted() {}
14050
+ onDtmfSent(tone ) {}
14051
+ onDirectTransfer(number ) {}
14052
+ onCreateIndirectTransfer(number ) {}
14053
+ onCancelIndirectTransfer() {}
14054
+ onConfirmIndirectTransfer() {}
14055
+ onIndirectCallMade(call ) {}
14056
+ onIndirectTransferDone(call ) {}
14057
+ onStartRecording() {}
14058
+ onStopRecording() {}
14059
+ onUnHandledEvent(event ) {}
14060
+
14061
+ init({ url, width, height, server, port, language, wrapUpDuration, enableAgent = true } = {}) {
14062
+ this.url = url || 'https://softphone.wazo.io';
14063
+ this.width = width || 500;
14064
+ this.height = height || 600;
14065
+ this.displayed = false;
14066
+ this.iframeLoaded = false;
14067
+
14068
+ this.iframeLoaded = false;
14069
+ this._pendingMessages = [];
14070
+ window.addEventListener('message', this._onMessage.bind(this), false);
14071
+
14072
+ if (!server) {
14073
+ // eslint-disable-next-line no-param-reassign
14074
+ server = 'stack.dev.wazo.io';
14075
+ }
14076
+
14077
+ const config = { server };
14078
+ if (language) {
14079
+ config.language = language;
14080
+ }
14081
+ if (port) {
14082
+ config.port = port;
14083
+ }
14084
+ if (wrapUpDuration) {
14085
+ config.wrapUpDuration = wrapUpDuration;
14086
+ }
14087
+
14088
+ this._sendMessage(BRIDGE_CONFIG_RETRIEVED, { config });
14089
+
14090
+ if (enableAgent) {
14091
+ this._sendMessage(BRIDGE_ENABLE_AGENT);
14092
+ }
14093
+
14094
+ this._createIframe(() => {
14095
+ this.iframeLoaded = true;
14096
+ this._pendingMessages.forEach(([type, payload]) => this._sendMessage(type, payload));
14097
+
14098
+ this.onIFrameLoaded();
14099
+ });
14100
+ }
14101
+
14102
+ parseLinks() {
14103
+ const links = this._getLinks();
14104
+
14105
+ links.forEach(link => {
14106
+ link.setAttribute('data-wazo-parsed', true);
14107
+ link.addEventListener('click', this._onLinkClick.bind(this));
14108
+ this.onLinkEnabled(link);
14109
+ });
14110
+ }
14111
+
14112
+ makeCall(number ) {
14113
+ this.displaySoftphone();
14114
+
14115
+ this._sendMessage(SDK_CLICK_TO_CALL, { number });
14116
+ }
14117
+
14118
+ toggleSoftphoneDisplay() {
14119
+ if (this.displayed) {
14120
+ this.hideSoftphone();
14121
+ } else {
14122
+ this.displaySoftphone();
14123
+ }
14124
+ }
14125
+
14126
+ displaySoftphone() {
14127
+ if (!this.iframe) {
14128
+ this._createIframe();
14129
+ }
14130
+
14131
+ if (this.iframe) {
14132
+ this.iframe.style.display = 'block';
14133
+ }
14134
+
14135
+ this.displayed = true;
14136
+ }
14137
+
14138
+ hideSoftphone() {
14139
+ if (this.iframe) {
14140
+ this.iframe.style.display = 'none';
14141
+ }
14142
+ this.displayed = false;
14143
+ }
14144
+
14145
+ optionsFetched(fieldId , options ) {
14146
+ this._sendMessage(BRIDGE_OPTIONS_FETCHED, { fieldId, options });
14147
+ }
14148
+
14149
+ onOptionsResults(fieldId , options ) {
14150
+ this._sendMessage(BRIDGE_OPTIONS_FOUND, { fieldId, options });
14151
+ }
14152
+
14153
+ setFormSchema(schema , uiSchema ) {
14154
+ this._sendMessage(BRIDGE_UPDATE_FORM_SCHEMA, { schema, uiSchema });
14155
+ }
14156
+
14157
+ setCardValue(field , value ) {
14158
+ this._sendMessage(BRIDGE_SET_CARD_CONTENT, { field, value });
14159
+ }
14160
+
14161
+ injectCss(css ) {
14162
+ this._sendMessage(BRIDGE_INJECT_CSS, { css });
14163
+ }
14164
+
14165
+ customizeAppearance(themes , translations , assets ) {
14166
+ this._sendMessage(BRIDGE_CUSTOMIZE_APPEARANCE, { themes, translations, assets });
14167
+ }
14168
+
14169
+ _createIframe(cb = () => {}) {
14170
+ this.iframe = document.createElement('iframe');
14171
+ // $FlowFixMe
14172
+ this.iframe.width = this.width;
14173
+ // $FlowFixMe
14174
+ this.iframe.height = this.height;
14175
+ // $FlowFixMe
14176
+ this.iframe.allow = 'camera *; microphone *; autoplay *; display-capture *';
14177
+ this.iframe.style.position = 'absolute';
14178
+ this.iframe.style.left = '0';
14179
+ this.iframe.style.bottom = '0';
14180
+ this.iframe.style.border = '1px solid #aaa';
14181
+ this.iframe.style.backgroundColor = 'white';
14182
+ this.iframe.src = this.url;
14183
+ this.iframe.style.display = 'none';
14184
+ this.iframe.id = 'wazo-softphone';
14185
+
14186
+ this.iframe.onload = cb;
14187
+
14188
+ // $FlowFixMe
14189
+ document.body.appendChild(this.iframe);
14190
+ }
14191
+
14192
+ _getLinks() {
14193
+ return [].slice.call(document.querySelectorAll('a:not([data-wazo-parsed])'), 0)
14194
+ .filter(link => link.href.indexOf('tel:') === 0 || link.href.indexOf('callto:') === 0);
14195
+ }
14196
+
14197
+ _onLinkClick(e ) {
14198
+ e.preventDefault();
14199
+ const number = e.target.href.split(':')[1];
14200
+
14201
+ this.makeCall(number);
14202
+ }
14203
+
14204
+ _onAuthenticated() {
14205
+ this.parseLinks();
14206
+ }
14207
+
14208
+ _onMessage(event ) {
14209
+ if (!event.data) {
14210
+ return;
14211
+ }
14212
+
14213
+ switch (event.data.type) {
14214
+ case SDK_ON_CALL_MADE:
14215
+ this.onCallMade(event.data.callSession);
14216
+ break;
14217
+ case SDK_CALL_ENDED: {
14218
+ const { callSession, content, direction, userExtension } = event.data;
14219
+ this.onCallEnded(callSession, content, direction, userExtension);
14220
+ break;
14221
+ }
14222
+ case SDK_CALL_INCOMING:
14223
+ this.onCallIncoming(event.data.callSession);
14224
+ break;
14225
+ case SDK_AUTHENTICATED:
14226
+ // $FlowFixMe
14227
+ this._onAuthenticated(event.data.session);
14228
+ this.onAuthenticated(event.data.session);
14229
+ break;
14230
+ case SDK_LOGGED_OUT:
14231
+ this.onLoggedOut();
14232
+ break;
14233
+ case BRIDGE_CREATE_OR_UPDATE_CARD: {
14234
+ const { content } = event.data;
14235
+ this.onCardSaved(content);
14236
+ break;
14237
+ }
14238
+ case BRIDGE_SEARCH_OPTIONS: {
14239
+ const { fieldId, query } = event.data;
14240
+ this.onSearchOptions(fieldId, query);
14241
+ break;
14242
+ }
14243
+ case BRIDGE_DISPLAY_LINKED_OPTION:
14244
+ this.onDisplayLinkedOption(event.data.linkedOptionId);
14245
+ break;
14246
+ case BRIDGE_WAZO_CONTACT_SEARCH:
14247
+ this.onWazoContactSearch(event.data.query);
14248
+ break;
14249
+ case BRIDGE_ON_AGENT_LOGGED_IN:
14250
+ this.onAgentLoggedIn();
14251
+ break;
14252
+ case BRIDGE_ON_AGENT_LOGGED_OUT:
14253
+ this.onAgentLoggedOut();
14254
+ break;
14255
+ case BRIDGE_ON_AGENT_PAUSED:
14256
+ this.onAgentPaused();
14257
+ break;
14258
+ case BRIDGE_ON_AGENT_RESUMED:
14259
+ this.onAgentResumed();
14260
+ break;
14261
+ case BRIDGE_ON_LANGUAGE_CHANGED:
14262
+ this.onLanguageChanged(event.data.language);
14263
+ break;
14264
+ case BRIDGE_ON_CALL_HELD:
14265
+ this.onCallHeld();
14266
+ break;
14267
+ case BRIDGE_ON_CALL_RESUMED:
14268
+ this.onCallResumed();
14269
+ break;
14270
+ case BRIDGE_ON_CALL_MUTED:
14271
+ this.onCallMuted();
14272
+ break;
14273
+ case BRIDGE_ON_CALL_UN_MUTED:
14274
+ this.onCallUnMuted();
14275
+ break;
14276
+ case BRIDGE_ON_DTMF:
14277
+ this.onDtmfSent(event.data.tone);
14278
+ break;
14279
+ case BRIDGE_ON_DIRECT_TRANSFER:
14280
+ this.onDirectTransfer(event.data.number);
14281
+ break;
14282
+ case BRIDGE_ON_CREATE_INDIRECT_TRANSFER:
14283
+ this.onCreateIndirectTransfer(event.data.number);
14284
+ break;
14285
+ case BRIDGE_ON_CANCEL_INDIRECT_TRANSFER:
14286
+ this.onCancelIndirectTransfer();
14287
+ break;
14288
+ case BRIDGE_ON_CONFIRM_INDIRECT_TRANSFER:
14289
+ this.onConfirmIndirectTransfer();
14290
+ break;
14291
+ case BRIDGE_ON_INDIRECT_TRANSFER_CALL_MADE:
14292
+ this.onIndirectCallMade(event.data.call);
14293
+ break;
14294
+ case BRIDGE_ON_INDIRECT_TRANSFER_DONE:
14295
+ this.onIndirectTransferDone(event.data.call);
14296
+ break;
14297
+ case BRIDGE_ON_START_RECORDING:
14298
+ this.onStartRecording();
14299
+ break;
14300
+ case BRIDGE_ON_STOP_RECORDING:
14301
+ this.onStopRecording();
14302
+ break;
14303
+ case BRIDGE_ON_CARD_CANCELED:
14304
+ this.onCardCanceled();
14305
+ break;
14306
+ case BRIDGE_ON_CALL_ANSWERED:
14307
+ this.onCallAnswered();
14308
+ break;
14309
+ default:
14310
+ this.onUnHandledEvent(event);
14311
+ break;
14312
+ }
14313
+ }
14314
+
14315
+ _sendMessage(type , payload = {}) {
14316
+ if (!this.iframe || !this.iframeLoaded) {
14317
+ this._pendingMessages.push([type, payload]);
14318
+ return;
14319
+ }
14320
+
14321
+ this.iframe.contentWindow.postMessage({ type, ...payload }, '*');
14322
+ }
14323
+ }
14324
+
14325
+ var Softphone$1 = new Softphone();
14326
+
13968
14327
  /* global window */
13969
14328
 
13970
14329
  const Wazo = {
@@ -13985,6 +14344,7 @@ const Wazo = {
13985
14344
  loggerFor: IssueReporter$1.loggerFor.bind(IssueReporter$1),
13986
14345
  Features: Features$1,
13987
14346
  Checker,
14347
+ Softphone: Softphone$1,
13988
14348
 
13989
14349
  // Domain
13990
14350
  domain: {
@@ -6967,7 +6967,7 @@ class WebRTCClient extends Emitter {
6967
6967
  }
6968
6968
 
6969
6969
  async _onHeartbeatTimeout() {
6970
- logger.info('sdk webrtc heartbeat timed out', { userAgent: !!this.userAgent, cb: !!this.heartbeatTimeoutCb });
6970
+ logger.warn('sdk webrtc heartbeat timed out', { userAgent: !!this.userAgent, cb: !!this.heartbeatTimeoutCb });
6971
6971
 
6972
6972
  if (this.heartbeatTimeoutCb) {
6973
6973
  this.heartbeatTimeoutCb();
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@wazo/sdk",
3
- "version": "0.37.43",
3
+ "version": "0.38.2",
4
4
  "description": "Wazo's JavaScript Software Development Kit.",
5
5
  "main": "dist/wazo-sdk.js",
6
6
  "author": "Wazo (http://wazo.io)",