@wazo/sdk 0.38.0 → 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.
- package/README.md +218 -0
- package/dist/wazo-sdk.js +5 -5
- package/esm/__tests__/web-rtc-client.test.js +1 -1
- package/esm/checker/Checker.js +1 -1
- package/esm/checker/checks/index.js +1 -1
- package/esm/checker/checks/webrtc-transport.js +1 -1
- package/esm/checker/checks/webrtc.js +1 -1
- package/esm/index.js +191 -10
- package/esm/simple/Auth.js +191 -10
- package/esm/simple/Configuration.js +191 -10
- package/esm/simple/Phone.js +191 -10
- package/esm/simple/Softphone.js +189 -8
- package/esm/simple/index.js +191 -10
- package/esm/simple/room/LocalParticipant.js +191 -10
- package/esm/simple/room/Participant.js +191 -10
- package/esm/simple/room/RemoteParticipant.js +191 -10
- package/esm/simple/room/Room.js +191 -10
- package/esm/simple/room/SipRoom.js +191 -10
- package/esm/simple/room/Stream.js +191 -10
- package/esm/simple/room/__tests__/RemoteParticipant.test.js +191 -10
- package/esm/simple/utils.js +191 -10
- package/esm/web-rtc-client.js +1 -1
- package/lib/__tests__/web-rtc-client.test.js +1 -1
- package/lib/checker/Checker.js +1 -1
- package/lib/checker/checks/index.js +1 -1
- package/lib/checker/checks/webrtc-transport.js +1 -1
- package/lib/checker/checks/webrtc.js +1 -1
- package/lib/index.js +191 -10
- package/lib/simple/Auth.js +191 -10
- package/lib/simple/Configuration.js +191 -10
- package/lib/simple/Phone.js +191 -10
- package/lib/simple/Softphone.js +189 -8
- package/lib/simple/index.js +191 -10
- package/lib/simple/room/LocalParticipant.js +191 -10
- package/lib/simple/room/Participant.js +191 -10
- package/lib/simple/room/RemoteParticipant.js +191 -10
- package/lib/simple/room/Room.js +191 -10
- package/lib/simple/room/SipRoom.js +191 -10
- package/lib/simple/room/Stream.js +191 -10
- package/lib/simple/room/__tests__/RemoteParticipant.test.js +191 -10
- package/lib/simple/utils.js +191 -10
- package/lib/web-rtc-client.js +1 -1
- package/package.json +1 -1
- package/src/simple/Softphone.js +187 -8
- package/src/web-rtc-client.js +1 -1
|
@@ -8336,7 +8336,7 @@ class WebRTCClient extends Emitter {
|
|
|
8336
8336
|
}
|
|
8337
8337
|
|
|
8338
8338
|
async _onHeartbeatTimeout() {
|
|
8339
|
-
logger$8.
|
|
8339
|
+
logger$8.warn('sdk webrtc heartbeat timed out', { userAgent: !!this.userAgent, cb: !!this.heartbeatTimeoutCb });
|
|
8340
8340
|
|
|
8341
8341
|
if (this.heartbeatTimeoutCb) {
|
|
8342
8342
|
this.heartbeatTimeoutCb();
|
|
@@ -13843,11 +13843,41 @@ class Checker {
|
|
|
13843
13843
|
//
|
|
13844
13844
|
/* eslint-disable no-unused-vars */
|
|
13845
13845
|
/* global window, document */
|
|
13846
|
+
const BRIDGE_CONFIG_RETRIEVED = 'bridge/CONFIG_RETRIEVED';
|
|
13847
|
+
const BRIDGE_ENABLE_CARD = 'bridge/ENABLE_CARD';
|
|
13848
|
+
const BRIDGE_CHANGE_REQUIRED_SUBSCRIPTION_TYPE = 'bridge/CHANGE_REQUIRED_SUBSCRIPTION_TYPE';
|
|
13849
|
+
const BRIDGE_CREATE_OR_UPDATE_CARD = 'bridge/BRIDGE_CREATE_OR_UPDATE_CARD';
|
|
13850
|
+
const BRIDGE_OPTIONS_FETCHED = 'bridge/BRIDGE_OPTIONS_FETCHED';
|
|
13851
|
+
const BRIDGE_OPTIONS_FOUND = 'bridge/BRIDGE_OPTIONS_FOUND';
|
|
13852
|
+
const BRIDGE_SEARCH_OPTIONS = 'bridge/BRIDGE_SEARCH_OPTIONS';
|
|
13853
|
+
const BRIDGE_DISPLAY_LINKED_OPTION = 'bridge/DISPLAY_LINKED_OPTION';
|
|
13854
|
+
const BRIDGE_UPDATE_FORM_SCHEMA = 'bridge/BRIDGE_UPDATE_FORM_SCHEMA';
|
|
13855
|
+
const BRIDGE_WAZO_CONTACT_SEARCH = 'bridge/BRIDGE_WAZO_CONTACT_SEARCH';
|
|
13856
|
+
const BRIDGE_ON_AGENT_LOGGED_IN = 'bridge/BRIDGE_ON_AGENT_LOGGED_IN';
|
|
13857
|
+
const BRIDGE_ON_AGENT_LOGGED_OUT = 'bridge/BRIDGE_ON_AGENT_LOGGED_OUT';
|
|
13858
|
+
const BRIDGE_ON_AGENT_PAUSED = 'bridge/BRIDGE_ON_AGENT_PAUSED';
|
|
13859
|
+
const BRIDGE_ON_AGENT_RESUMED = 'bridge/BRIDGE_ON_AGENT_RESUMED';
|
|
13860
|
+
const BRIDGE_ON_LANGUAGE_CHANGED = 'bridge/BRIDGE_ON_LANGUAGE_CHANGED';
|
|
13861
|
+
const BRIDGE_ON_CALL_HELD = 'bridge/BRIDGE_ON_CALL_HELD';
|
|
13862
|
+
const BRIDGE_ON_CALL_RESUMED = 'bridge/BRIDGE_ON_CALL_RESUMED';
|
|
13863
|
+
const BRIDGE_ON_CALL_MUTED = 'bridge/BRIDGE_ON_CALL_MUTED';
|
|
13864
|
+
const BRIDGE_ON_CALL_UN_MUTED = 'bridge/BRIDGE_ON_CALL_UN_MUTED';
|
|
13865
|
+
const BRIDGE_ON_DTMF = 'bridge/BRIDGE_ON_DTMF';
|
|
13866
|
+
const BRIDGE_ON_DIRECT_TRANSFER = 'bridge/BRIDGE_ON_DIRECT_TRANSFER';
|
|
13867
|
+
const BRIDGE_ON_CREATE_INDIRECT_TRANSFER = 'bridge/BRIDGE_ON_CREATE_INDIRECT_TRANSFER';
|
|
13868
|
+
const BRIDGE_ON_CANCEL_INDIRECT_TRANSFER = 'bridge/BRIDGE_ON_CANCEL_INDIRECT_TRANSFER';
|
|
13869
|
+
const BRIDGE_ON_CONFIRM_INDIRECT_TRANSFER = 'bridge/BRIDGE_ON_CONFIRM_INDIRECT_TRANSFER';
|
|
13870
|
+
const BRIDGE_ON_INDIRECT_TRANSFER_CALL_MADE = 'bridge/BRIDGE_ON_INDIRECT_TRANSFER_CALL_MADE';
|
|
13871
|
+
const BRIDGE_ON_INDIRECT_TRANSFER_DONE = 'bridge/BRIDGE_ON_INDIRECT_TRANSFER_DONE';
|
|
13872
|
+
const BRIDGE_ON_START_RECORDING = 'bridge/BRIDGE_ON_START_RECORDING';
|
|
13873
|
+
const BRIDGE_ON_STOP_RECORDING = 'bridge/BRIDGE_ON_STOP_RECORDING';
|
|
13874
|
+
|
|
13846
13875
|
const SDK_CLICK_TO_CALL = 'sdk/CLICK_TO_CALL';
|
|
13847
13876
|
const SDK_ON_CALL_MADE = 'sdk/SDK_ON_CALL_MADE';
|
|
13848
13877
|
const SDK_CALL_ENDED = 'sdk/ON_CALL_ENDED';
|
|
13849
13878
|
const SDK_CALL_INCOMING = 'sdk/SDK_CALL_INCOMING';
|
|
13850
13879
|
const SDK_AUTHENTICATED = 'sdk/SDK_AUTHENTICATED';
|
|
13880
|
+
const SDK_LOGGED_OUT = 'sdk/SDK_LOGGED_OUT';
|
|
13851
13881
|
|
|
13852
13882
|
class Softphone {
|
|
13853
13883
|
url = 'https://softphone.wazo.io';
|
|
@@ -13857,13 +13887,39 @@ class Softphone {
|
|
|
13857
13887
|
iframe = null;
|
|
13858
13888
|
|
|
13859
13889
|
onLinkEnabled(link ) {}
|
|
13890
|
+
onIFrameLoaded() {}
|
|
13860
13891
|
|
|
13861
13892
|
onCallMade(call ) {}
|
|
13862
13893
|
onCallIncoming(call ) {}
|
|
13863
13894
|
onCallEnded(call , card , direction , fromExtension ) {}
|
|
13895
|
+
onCardSaved(card ) {}
|
|
13864
13896
|
onAuthenticated(session ) {}
|
|
13865
|
-
|
|
13866
|
-
|
|
13897
|
+
onLoggedOut() {}
|
|
13898
|
+
onSearchOptions(fieldId , query ) {}
|
|
13899
|
+
onDisplayLinkedOption(optionId ) {}
|
|
13900
|
+
onWazoContactSearch(query ) {}
|
|
13901
|
+
onAgentLoggedIn() {}
|
|
13902
|
+
onAgentLoggedOut() {}
|
|
13903
|
+
onAgentPaused() {}
|
|
13904
|
+
onAgentResumed() {}
|
|
13905
|
+
onLanguageChanged(language ) {}
|
|
13906
|
+
onCallHeld() {}
|
|
13907
|
+
onCallResumed() {}
|
|
13908
|
+
onCallMuted() {}
|
|
13909
|
+
onCallUnMuted() {}
|
|
13910
|
+
onDtmfSent(tone ) {}
|
|
13911
|
+
onDirectTransfer(number ) {}
|
|
13912
|
+
onCreateIndirectTransfer(number ) {}
|
|
13913
|
+
onCancelIndirectTransfer() {}
|
|
13914
|
+
onConfirmIndirectTransfer() {}
|
|
13915
|
+
onIndirectCallMade(call ) {}
|
|
13916
|
+
onIndirectTransferDone(call ) {}
|
|
13917
|
+
onStartRecording() {}
|
|
13918
|
+
onStopRecording() {}
|
|
13919
|
+
onUnHandledEvent(event ) {}
|
|
13920
|
+
|
|
13921
|
+
init({ url, width, height, server, port, language, wrapUpDuration, shouldDisplayLinkedEntities,
|
|
13922
|
+
allowContactCreation, withCard, subscriptionType, enableAgent } = {}) {
|
|
13867
13923
|
if (url) {
|
|
13868
13924
|
this.url = url;
|
|
13869
13925
|
}
|
|
@@ -13876,7 +13932,33 @@ class Softphone {
|
|
|
13876
13932
|
|
|
13877
13933
|
window.addEventListener('message', this._onMessage.bind(this), false);
|
|
13878
13934
|
|
|
13879
|
-
|
|
13935
|
+
if (!server) {
|
|
13936
|
+
// eslint-disable-next-line no-param-reassign
|
|
13937
|
+
server = 'stack.dev.wazo.io';
|
|
13938
|
+
}
|
|
13939
|
+
|
|
13940
|
+
this._createIframe(() => {
|
|
13941
|
+
this._sendMessage(BRIDGE_CONFIG_RETRIEVED, {
|
|
13942
|
+
config: {
|
|
13943
|
+
server,
|
|
13944
|
+
port,
|
|
13945
|
+
language,
|
|
13946
|
+
wrapUpDuration,
|
|
13947
|
+
shouldDisplayLinkedEntities,
|
|
13948
|
+
allowContactCreation,
|
|
13949
|
+
},
|
|
13950
|
+
});
|
|
13951
|
+
|
|
13952
|
+
if (withCard) {
|
|
13953
|
+
this._sendMessage(BRIDGE_ENABLE_CARD);
|
|
13954
|
+
}
|
|
13955
|
+
|
|
13956
|
+
if (subscriptionType) {
|
|
13957
|
+
this._sendMessage(BRIDGE_CHANGE_REQUIRED_SUBSCRIPTION_TYPE, { subscriptionType });
|
|
13958
|
+
}
|
|
13959
|
+
|
|
13960
|
+
this.onIFrameLoaded();
|
|
13961
|
+
});
|
|
13880
13962
|
}
|
|
13881
13963
|
|
|
13882
13964
|
parseLinks() {
|
|
@@ -13892,9 +13974,7 @@ class Softphone {
|
|
|
13892
13974
|
makeCall(number ) {
|
|
13893
13975
|
this.displaySoftphone();
|
|
13894
13976
|
|
|
13895
|
-
|
|
13896
|
-
this.iframe.contentWindow.postMessage({ type: SDK_CLICK_TO_CALL, number }, '*');
|
|
13897
|
-
}
|
|
13977
|
+
this._sendMessage(SDK_CLICK_TO_CALL, { number });
|
|
13898
13978
|
}
|
|
13899
13979
|
|
|
13900
13980
|
toggleSoftphoneDisplay() {
|
|
@@ -13903,8 +13983,6 @@ class Softphone {
|
|
|
13903
13983
|
} else {
|
|
13904
13984
|
this.displaySoftphone();
|
|
13905
13985
|
}
|
|
13906
|
-
|
|
13907
|
-
this.displayed = !this.displayed;
|
|
13908
13986
|
}
|
|
13909
13987
|
|
|
13910
13988
|
displaySoftphone() {
|
|
@@ -13915,15 +13993,30 @@ class Softphone {
|
|
|
13915
13993
|
if (this.iframe) {
|
|
13916
13994
|
this.iframe.style.display = 'block';
|
|
13917
13995
|
}
|
|
13996
|
+
|
|
13997
|
+
this.displayed = true;
|
|
13918
13998
|
}
|
|
13919
13999
|
|
|
13920
14000
|
hideSoftphone() {
|
|
13921
14001
|
if (this.iframe) {
|
|
13922
14002
|
this.iframe.style.display = 'none';
|
|
13923
14003
|
}
|
|
14004
|
+
this.displayed = false;
|
|
14005
|
+
}
|
|
14006
|
+
|
|
14007
|
+
optionsFetched(fieldId , options ) {
|
|
14008
|
+
this._sendMessage(BRIDGE_OPTIONS_FETCHED, { fieldId, options });
|
|
14009
|
+
}
|
|
14010
|
+
|
|
14011
|
+
onOptionsResults(fieldId , options ) {
|
|
14012
|
+
this._sendMessage(BRIDGE_OPTIONS_FOUND, { fieldId, options });
|
|
14013
|
+
}
|
|
14014
|
+
|
|
14015
|
+
setFormSchema(schema , uiSchema ) {
|
|
14016
|
+
this._sendMessage(BRIDGE_UPDATE_FORM_SCHEMA, { schema, uiSchema });
|
|
13924
14017
|
}
|
|
13925
14018
|
|
|
13926
|
-
_createIframe() {
|
|
14019
|
+
_createIframe(cb = () => {}) {
|
|
13927
14020
|
this.iframe = document.createElement('iframe');
|
|
13928
14021
|
// $FlowFixMe
|
|
13929
14022
|
this.iframe.width = this.width;
|
|
@@ -13935,10 +14028,13 @@ class Softphone {
|
|
|
13935
14028
|
this.iframe.style.left = '0';
|
|
13936
14029
|
this.iframe.style.bottom = '0';
|
|
13937
14030
|
this.iframe.style.border = '1px solid #aaa';
|
|
14031
|
+
this.iframe.style.backgroundColor = 'white';
|
|
13938
14032
|
this.iframe.src = this.url;
|
|
13939
14033
|
this.iframe.style.display = 'none';
|
|
13940
14034
|
this.iframe.id = 'wazo-softphone';
|
|
13941
14035
|
|
|
14036
|
+
this.iframe.onload = cb;
|
|
14037
|
+
|
|
13942
14038
|
// $FlowFixMe
|
|
13943
14039
|
document.body.appendChild(this.iframe);
|
|
13944
14040
|
}
|
|
@@ -13981,8 +14077,93 @@ class Softphone {
|
|
|
13981
14077
|
this._onAuthenticated(event.data.session);
|
|
13982
14078
|
this.onAuthenticated(event.data.session);
|
|
13983
14079
|
break;
|
|
14080
|
+
case SDK_LOGGED_OUT:
|
|
14081
|
+
this.onLoggedOut();
|
|
14082
|
+
break;
|
|
14083
|
+
case BRIDGE_CREATE_OR_UPDATE_CARD: {
|
|
14084
|
+
const { content } = event.data;
|
|
14085
|
+
this.onCardSaved(content);
|
|
14086
|
+
break;
|
|
14087
|
+
}
|
|
14088
|
+
case BRIDGE_SEARCH_OPTIONS: {
|
|
14089
|
+
const { fieldId, query } = event.data;
|
|
14090
|
+
this.onSearchOptions(fieldId, query);
|
|
14091
|
+
break;
|
|
14092
|
+
}
|
|
14093
|
+
case BRIDGE_DISPLAY_LINKED_OPTION:
|
|
14094
|
+
this.onDisplayLinkedOption(event.data.linkedOptionId);
|
|
14095
|
+
break;
|
|
14096
|
+
case BRIDGE_WAZO_CONTACT_SEARCH:
|
|
14097
|
+
this.onWazoContactSearch(event.data.query);
|
|
14098
|
+
break;
|
|
14099
|
+
case BRIDGE_ON_AGENT_LOGGED_IN:
|
|
14100
|
+
this.onAgentLoggedIn();
|
|
14101
|
+
break;
|
|
14102
|
+
case BRIDGE_ON_AGENT_LOGGED_OUT:
|
|
14103
|
+
this.onAgentLoggedOut();
|
|
14104
|
+
break;
|
|
14105
|
+
case BRIDGE_ON_AGENT_PAUSED:
|
|
14106
|
+
this.onAgentPaused();
|
|
14107
|
+
break;
|
|
14108
|
+
case BRIDGE_ON_AGENT_RESUMED:
|
|
14109
|
+
this.onAgentResumed();
|
|
14110
|
+
break;
|
|
14111
|
+
case BRIDGE_ON_LANGUAGE_CHANGED:
|
|
14112
|
+
this.onLanguageChanged(event.data.language);
|
|
14113
|
+
break;
|
|
14114
|
+
case BRIDGE_ON_CALL_HELD:
|
|
14115
|
+
this.onCallHeld();
|
|
14116
|
+
break;
|
|
14117
|
+
case BRIDGE_ON_CALL_RESUMED:
|
|
14118
|
+
this.onCallResumed();
|
|
14119
|
+
break;
|
|
14120
|
+
case BRIDGE_ON_CALL_MUTED:
|
|
14121
|
+
this.onCallMuted();
|
|
14122
|
+
break;
|
|
14123
|
+
case BRIDGE_ON_CALL_UN_MUTED:
|
|
14124
|
+
this.onCallUnMuted();
|
|
14125
|
+
break;
|
|
14126
|
+
case BRIDGE_ON_DTMF:
|
|
14127
|
+
this.onDtmfSent(event.data.tone);
|
|
14128
|
+
break;
|
|
14129
|
+
case BRIDGE_ON_DIRECT_TRANSFER:
|
|
14130
|
+
this.onDirectTransfer(event.data.number);
|
|
14131
|
+
break;
|
|
14132
|
+
case BRIDGE_ON_CREATE_INDIRECT_TRANSFER:
|
|
14133
|
+
this.onCreateIndirectTransfer(event.data.number);
|
|
14134
|
+
break;
|
|
14135
|
+
case BRIDGE_ON_CANCEL_INDIRECT_TRANSFER:
|
|
14136
|
+
this.onCancelIndirectTransfer();
|
|
14137
|
+
break;
|
|
14138
|
+
case BRIDGE_ON_CONFIRM_INDIRECT_TRANSFER:
|
|
14139
|
+
this.onConfirmIndirectTransfer();
|
|
14140
|
+
break;
|
|
14141
|
+
case BRIDGE_ON_INDIRECT_TRANSFER_CALL_MADE:
|
|
14142
|
+
this.onIndirectCallMade(event.data.call);
|
|
14143
|
+
break;
|
|
14144
|
+
case BRIDGE_ON_INDIRECT_TRANSFER_DONE:
|
|
14145
|
+
this.onIndirectTransferDone(event.data.call);
|
|
14146
|
+
break;
|
|
14147
|
+
case BRIDGE_ON_START_RECORDING:
|
|
14148
|
+
this.onStartRecording();
|
|
14149
|
+
break;
|
|
14150
|
+
case BRIDGE_ON_STOP_RECORDING:
|
|
14151
|
+
this.onStopRecording();
|
|
14152
|
+
break;
|
|
14153
|
+
default:
|
|
14154
|
+
this.onUnHandledEvent(event);
|
|
14155
|
+
break;
|
|
13984
14156
|
}
|
|
13985
14157
|
}
|
|
14158
|
+
|
|
14159
|
+
_sendMessage(type , payload = {}) {
|
|
14160
|
+
if (!this.iframe) {
|
|
14161
|
+
console.warn(`Could not send message of type ${type} to the Wazo Softphone, iframe not created yet`);
|
|
14162
|
+
return;
|
|
14163
|
+
}
|
|
14164
|
+
|
|
14165
|
+
this.iframe.contentWindow.postMessage({ type, ...payload }, '*');
|
|
14166
|
+
}
|
|
13986
14167
|
}
|
|
13987
14168
|
|
|
13988
14169
|
var Softphone$1 = new Softphone();
|
|
@@ -8336,7 +8336,7 @@ class WebRTCClient extends Emitter {
|
|
|
8336
8336
|
}
|
|
8337
8337
|
|
|
8338
8338
|
async _onHeartbeatTimeout() {
|
|
8339
|
-
logger$8.
|
|
8339
|
+
logger$8.warn('sdk webrtc heartbeat timed out', { userAgent: !!this.userAgent, cb: !!this.heartbeatTimeoutCb });
|
|
8340
8340
|
|
|
8341
8341
|
if (this.heartbeatTimeoutCb) {
|
|
8342
8342
|
this.heartbeatTimeoutCb();
|
|
@@ -13924,11 +13924,41 @@ class Checker {
|
|
|
13924
13924
|
//
|
|
13925
13925
|
/* eslint-disable no-unused-vars */
|
|
13926
13926
|
/* global window, document */
|
|
13927
|
+
const BRIDGE_CONFIG_RETRIEVED = 'bridge/CONFIG_RETRIEVED';
|
|
13928
|
+
const BRIDGE_ENABLE_CARD = 'bridge/ENABLE_CARD';
|
|
13929
|
+
const BRIDGE_CHANGE_REQUIRED_SUBSCRIPTION_TYPE = 'bridge/CHANGE_REQUIRED_SUBSCRIPTION_TYPE';
|
|
13930
|
+
const BRIDGE_CREATE_OR_UPDATE_CARD = 'bridge/BRIDGE_CREATE_OR_UPDATE_CARD';
|
|
13931
|
+
const BRIDGE_OPTIONS_FETCHED = 'bridge/BRIDGE_OPTIONS_FETCHED';
|
|
13932
|
+
const BRIDGE_OPTIONS_FOUND = 'bridge/BRIDGE_OPTIONS_FOUND';
|
|
13933
|
+
const BRIDGE_SEARCH_OPTIONS = 'bridge/BRIDGE_SEARCH_OPTIONS';
|
|
13934
|
+
const BRIDGE_DISPLAY_LINKED_OPTION = 'bridge/DISPLAY_LINKED_OPTION';
|
|
13935
|
+
const BRIDGE_UPDATE_FORM_SCHEMA = 'bridge/BRIDGE_UPDATE_FORM_SCHEMA';
|
|
13936
|
+
const BRIDGE_WAZO_CONTACT_SEARCH = 'bridge/BRIDGE_WAZO_CONTACT_SEARCH';
|
|
13937
|
+
const BRIDGE_ON_AGENT_LOGGED_IN = 'bridge/BRIDGE_ON_AGENT_LOGGED_IN';
|
|
13938
|
+
const BRIDGE_ON_AGENT_LOGGED_OUT = 'bridge/BRIDGE_ON_AGENT_LOGGED_OUT';
|
|
13939
|
+
const BRIDGE_ON_AGENT_PAUSED = 'bridge/BRIDGE_ON_AGENT_PAUSED';
|
|
13940
|
+
const BRIDGE_ON_AGENT_RESUMED = 'bridge/BRIDGE_ON_AGENT_RESUMED';
|
|
13941
|
+
const BRIDGE_ON_LANGUAGE_CHANGED = 'bridge/BRIDGE_ON_LANGUAGE_CHANGED';
|
|
13942
|
+
const BRIDGE_ON_CALL_HELD = 'bridge/BRIDGE_ON_CALL_HELD';
|
|
13943
|
+
const BRIDGE_ON_CALL_RESUMED = 'bridge/BRIDGE_ON_CALL_RESUMED';
|
|
13944
|
+
const BRIDGE_ON_CALL_MUTED = 'bridge/BRIDGE_ON_CALL_MUTED';
|
|
13945
|
+
const BRIDGE_ON_CALL_UN_MUTED = 'bridge/BRIDGE_ON_CALL_UN_MUTED';
|
|
13946
|
+
const BRIDGE_ON_DTMF = 'bridge/BRIDGE_ON_DTMF';
|
|
13947
|
+
const BRIDGE_ON_DIRECT_TRANSFER = 'bridge/BRIDGE_ON_DIRECT_TRANSFER';
|
|
13948
|
+
const BRIDGE_ON_CREATE_INDIRECT_TRANSFER = 'bridge/BRIDGE_ON_CREATE_INDIRECT_TRANSFER';
|
|
13949
|
+
const BRIDGE_ON_CANCEL_INDIRECT_TRANSFER = 'bridge/BRIDGE_ON_CANCEL_INDIRECT_TRANSFER';
|
|
13950
|
+
const BRIDGE_ON_CONFIRM_INDIRECT_TRANSFER = 'bridge/BRIDGE_ON_CONFIRM_INDIRECT_TRANSFER';
|
|
13951
|
+
const BRIDGE_ON_INDIRECT_TRANSFER_CALL_MADE = 'bridge/BRIDGE_ON_INDIRECT_TRANSFER_CALL_MADE';
|
|
13952
|
+
const BRIDGE_ON_INDIRECT_TRANSFER_DONE = 'bridge/BRIDGE_ON_INDIRECT_TRANSFER_DONE';
|
|
13953
|
+
const BRIDGE_ON_START_RECORDING = 'bridge/BRIDGE_ON_START_RECORDING';
|
|
13954
|
+
const BRIDGE_ON_STOP_RECORDING = 'bridge/BRIDGE_ON_STOP_RECORDING';
|
|
13955
|
+
|
|
13927
13956
|
const SDK_CLICK_TO_CALL = 'sdk/CLICK_TO_CALL';
|
|
13928
13957
|
const SDK_ON_CALL_MADE = 'sdk/SDK_ON_CALL_MADE';
|
|
13929
13958
|
const SDK_CALL_ENDED = 'sdk/ON_CALL_ENDED';
|
|
13930
13959
|
const SDK_CALL_INCOMING = 'sdk/SDK_CALL_INCOMING';
|
|
13931
13960
|
const SDK_AUTHENTICATED = 'sdk/SDK_AUTHENTICATED';
|
|
13961
|
+
const SDK_LOGGED_OUT = 'sdk/SDK_LOGGED_OUT';
|
|
13932
13962
|
|
|
13933
13963
|
class Softphone {
|
|
13934
13964
|
url = 'https://softphone.wazo.io';
|
|
@@ -13938,13 +13968,39 @@ class Softphone {
|
|
|
13938
13968
|
iframe = null;
|
|
13939
13969
|
|
|
13940
13970
|
onLinkEnabled(link ) {}
|
|
13971
|
+
onIFrameLoaded() {}
|
|
13941
13972
|
|
|
13942
13973
|
onCallMade(call ) {}
|
|
13943
13974
|
onCallIncoming(call ) {}
|
|
13944
13975
|
onCallEnded(call , card , direction , fromExtension ) {}
|
|
13976
|
+
onCardSaved(card ) {}
|
|
13945
13977
|
onAuthenticated(session ) {}
|
|
13946
|
-
|
|
13947
|
-
|
|
13978
|
+
onLoggedOut() {}
|
|
13979
|
+
onSearchOptions(fieldId , query ) {}
|
|
13980
|
+
onDisplayLinkedOption(optionId ) {}
|
|
13981
|
+
onWazoContactSearch(query ) {}
|
|
13982
|
+
onAgentLoggedIn() {}
|
|
13983
|
+
onAgentLoggedOut() {}
|
|
13984
|
+
onAgentPaused() {}
|
|
13985
|
+
onAgentResumed() {}
|
|
13986
|
+
onLanguageChanged(language ) {}
|
|
13987
|
+
onCallHeld() {}
|
|
13988
|
+
onCallResumed() {}
|
|
13989
|
+
onCallMuted() {}
|
|
13990
|
+
onCallUnMuted() {}
|
|
13991
|
+
onDtmfSent(tone ) {}
|
|
13992
|
+
onDirectTransfer(number ) {}
|
|
13993
|
+
onCreateIndirectTransfer(number ) {}
|
|
13994
|
+
onCancelIndirectTransfer() {}
|
|
13995
|
+
onConfirmIndirectTransfer() {}
|
|
13996
|
+
onIndirectCallMade(call ) {}
|
|
13997
|
+
onIndirectTransferDone(call ) {}
|
|
13998
|
+
onStartRecording() {}
|
|
13999
|
+
onStopRecording() {}
|
|
14000
|
+
onUnHandledEvent(event ) {}
|
|
14001
|
+
|
|
14002
|
+
init({ url, width, height, server, port, language, wrapUpDuration, shouldDisplayLinkedEntities,
|
|
14003
|
+
allowContactCreation, withCard, subscriptionType, enableAgent } = {}) {
|
|
13948
14004
|
if (url) {
|
|
13949
14005
|
this.url = url;
|
|
13950
14006
|
}
|
|
@@ -13957,7 +14013,33 @@ class Softphone {
|
|
|
13957
14013
|
|
|
13958
14014
|
window.addEventListener('message', this._onMessage.bind(this), false);
|
|
13959
14015
|
|
|
13960
|
-
|
|
14016
|
+
if (!server) {
|
|
14017
|
+
// eslint-disable-next-line no-param-reassign
|
|
14018
|
+
server = 'stack.dev.wazo.io';
|
|
14019
|
+
}
|
|
14020
|
+
|
|
14021
|
+
this._createIframe(() => {
|
|
14022
|
+
this._sendMessage(BRIDGE_CONFIG_RETRIEVED, {
|
|
14023
|
+
config: {
|
|
14024
|
+
server,
|
|
14025
|
+
port,
|
|
14026
|
+
language,
|
|
14027
|
+
wrapUpDuration,
|
|
14028
|
+
shouldDisplayLinkedEntities,
|
|
14029
|
+
allowContactCreation,
|
|
14030
|
+
},
|
|
14031
|
+
});
|
|
14032
|
+
|
|
14033
|
+
if (withCard) {
|
|
14034
|
+
this._sendMessage(BRIDGE_ENABLE_CARD);
|
|
14035
|
+
}
|
|
14036
|
+
|
|
14037
|
+
if (subscriptionType) {
|
|
14038
|
+
this._sendMessage(BRIDGE_CHANGE_REQUIRED_SUBSCRIPTION_TYPE, { subscriptionType });
|
|
14039
|
+
}
|
|
14040
|
+
|
|
14041
|
+
this.onIFrameLoaded();
|
|
14042
|
+
});
|
|
13961
14043
|
}
|
|
13962
14044
|
|
|
13963
14045
|
parseLinks() {
|
|
@@ -13973,9 +14055,7 @@ class Softphone {
|
|
|
13973
14055
|
makeCall(number ) {
|
|
13974
14056
|
this.displaySoftphone();
|
|
13975
14057
|
|
|
13976
|
-
|
|
13977
|
-
this.iframe.contentWindow.postMessage({ type: SDK_CLICK_TO_CALL, number }, '*');
|
|
13978
|
-
}
|
|
14058
|
+
this._sendMessage(SDK_CLICK_TO_CALL, { number });
|
|
13979
14059
|
}
|
|
13980
14060
|
|
|
13981
14061
|
toggleSoftphoneDisplay() {
|
|
@@ -13984,8 +14064,6 @@ class Softphone {
|
|
|
13984
14064
|
} else {
|
|
13985
14065
|
this.displaySoftphone();
|
|
13986
14066
|
}
|
|
13987
|
-
|
|
13988
|
-
this.displayed = !this.displayed;
|
|
13989
14067
|
}
|
|
13990
14068
|
|
|
13991
14069
|
displaySoftphone() {
|
|
@@ -13996,15 +14074,30 @@ class Softphone {
|
|
|
13996
14074
|
if (this.iframe) {
|
|
13997
14075
|
this.iframe.style.display = 'block';
|
|
13998
14076
|
}
|
|
14077
|
+
|
|
14078
|
+
this.displayed = true;
|
|
13999
14079
|
}
|
|
14000
14080
|
|
|
14001
14081
|
hideSoftphone() {
|
|
14002
14082
|
if (this.iframe) {
|
|
14003
14083
|
this.iframe.style.display = 'none';
|
|
14004
14084
|
}
|
|
14085
|
+
this.displayed = false;
|
|
14086
|
+
}
|
|
14087
|
+
|
|
14088
|
+
optionsFetched(fieldId , options ) {
|
|
14089
|
+
this._sendMessage(BRIDGE_OPTIONS_FETCHED, { fieldId, options });
|
|
14090
|
+
}
|
|
14091
|
+
|
|
14092
|
+
onOptionsResults(fieldId , options ) {
|
|
14093
|
+
this._sendMessage(BRIDGE_OPTIONS_FOUND, { fieldId, options });
|
|
14094
|
+
}
|
|
14095
|
+
|
|
14096
|
+
setFormSchema(schema , uiSchema ) {
|
|
14097
|
+
this._sendMessage(BRIDGE_UPDATE_FORM_SCHEMA, { schema, uiSchema });
|
|
14005
14098
|
}
|
|
14006
14099
|
|
|
14007
|
-
_createIframe() {
|
|
14100
|
+
_createIframe(cb = () => {}) {
|
|
14008
14101
|
this.iframe = document.createElement('iframe');
|
|
14009
14102
|
// $FlowFixMe
|
|
14010
14103
|
this.iframe.width = this.width;
|
|
@@ -14016,10 +14109,13 @@ class Softphone {
|
|
|
14016
14109
|
this.iframe.style.left = '0';
|
|
14017
14110
|
this.iframe.style.bottom = '0';
|
|
14018
14111
|
this.iframe.style.border = '1px solid #aaa';
|
|
14112
|
+
this.iframe.style.backgroundColor = 'white';
|
|
14019
14113
|
this.iframe.src = this.url;
|
|
14020
14114
|
this.iframe.style.display = 'none';
|
|
14021
14115
|
this.iframe.id = 'wazo-softphone';
|
|
14022
14116
|
|
|
14117
|
+
this.iframe.onload = cb;
|
|
14118
|
+
|
|
14023
14119
|
// $FlowFixMe
|
|
14024
14120
|
document.body.appendChild(this.iframe);
|
|
14025
14121
|
}
|
|
@@ -14062,8 +14158,93 @@ class Softphone {
|
|
|
14062
14158
|
this._onAuthenticated(event.data.session);
|
|
14063
14159
|
this.onAuthenticated(event.data.session);
|
|
14064
14160
|
break;
|
|
14161
|
+
case SDK_LOGGED_OUT:
|
|
14162
|
+
this.onLoggedOut();
|
|
14163
|
+
break;
|
|
14164
|
+
case BRIDGE_CREATE_OR_UPDATE_CARD: {
|
|
14165
|
+
const { content } = event.data;
|
|
14166
|
+
this.onCardSaved(content);
|
|
14167
|
+
break;
|
|
14168
|
+
}
|
|
14169
|
+
case BRIDGE_SEARCH_OPTIONS: {
|
|
14170
|
+
const { fieldId, query } = event.data;
|
|
14171
|
+
this.onSearchOptions(fieldId, query);
|
|
14172
|
+
break;
|
|
14173
|
+
}
|
|
14174
|
+
case BRIDGE_DISPLAY_LINKED_OPTION:
|
|
14175
|
+
this.onDisplayLinkedOption(event.data.linkedOptionId);
|
|
14176
|
+
break;
|
|
14177
|
+
case BRIDGE_WAZO_CONTACT_SEARCH:
|
|
14178
|
+
this.onWazoContactSearch(event.data.query);
|
|
14179
|
+
break;
|
|
14180
|
+
case BRIDGE_ON_AGENT_LOGGED_IN:
|
|
14181
|
+
this.onAgentLoggedIn();
|
|
14182
|
+
break;
|
|
14183
|
+
case BRIDGE_ON_AGENT_LOGGED_OUT:
|
|
14184
|
+
this.onAgentLoggedOut();
|
|
14185
|
+
break;
|
|
14186
|
+
case BRIDGE_ON_AGENT_PAUSED:
|
|
14187
|
+
this.onAgentPaused();
|
|
14188
|
+
break;
|
|
14189
|
+
case BRIDGE_ON_AGENT_RESUMED:
|
|
14190
|
+
this.onAgentResumed();
|
|
14191
|
+
break;
|
|
14192
|
+
case BRIDGE_ON_LANGUAGE_CHANGED:
|
|
14193
|
+
this.onLanguageChanged(event.data.language);
|
|
14194
|
+
break;
|
|
14195
|
+
case BRIDGE_ON_CALL_HELD:
|
|
14196
|
+
this.onCallHeld();
|
|
14197
|
+
break;
|
|
14198
|
+
case BRIDGE_ON_CALL_RESUMED:
|
|
14199
|
+
this.onCallResumed();
|
|
14200
|
+
break;
|
|
14201
|
+
case BRIDGE_ON_CALL_MUTED:
|
|
14202
|
+
this.onCallMuted();
|
|
14203
|
+
break;
|
|
14204
|
+
case BRIDGE_ON_CALL_UN_MUTED:
|
|
14205
|
+
this.onCallUnMuted();
|
|
14206
|
+
break;
|
|
14207
|
+
case BRIDGE_ON_DTMF:
|
|
14208
|
+
this.onDtmfSent(event.data.tone);
|
|
14209
|
+
break;
|
|
14210
|
+
case BRIDGE_ON_DIRECT_TRANSFER:
|
|
14211
|
+
this.onDirectTransfer(event.data.number);
|
|
14212
|
+
break;
|
|
14213
|
+
case BRIDGE_ON_CREATE_INDIRECT_TRANSFER:
|
|
14214
|
+
this.onCreateIndirectTransfer(event.data.number);
|
|
14215
|
+
break;
|
|
14216
|
+
case BRIDGE_ON_CANCEL_INDIRECT_TRANSFER:
|
|
14217
|
+
this.onCancelIndirectTransfer();
|
|
14218
|
+
break;
|
|
14219
|
+
case BRIDGE_ON_CONFIRM_INDIRECT_TRANSFER:
|
|
14220
|
+
this.onConfirmIndirectTransfer();
|
|
14221
|
+
break;
|
|
14222
|
+
case BRIDGE_ON_INDIRECT_TRANSFER_CALL_MADE:
|
|
14223
|
+
this.onIndirectCallMade(event.data.call);
|
|
14224
|
+
break;
|
|
14225
|
+
case BRIDGE_ON_INDIRECT_TRANSFER_DONE:
|
|
14226
|
+
this.onIndirectTransferDone(event.data.call);
|
|
14227
|
+
break;
|
|
14228
|
+
case BRIDGE_ON_START_RECORDING:
|
|
14229
|
+
this.onStartRecording();
|
|
14230
|
+
break;
|
|
14231
|
+
case BRIDGE_ON_STOP_RECORDING:
|
|
14232
|
+
this.onStopRecording();
|
|
14233
|
+
break;
|
|
14234
|
+
default:
|
|
14235
|
+
this.onUnHandledEvent(event);
|
|
14236
|
+
break;
|
|
14065
14237
|
}
|
|
14066
14238
|
}
|
|
14239
|
+
|
|
14240
|
+
_sendMessage(type , payload = {}) {
|
|
14241
|
+
if (!this.iframe) {
|
|
14242
|
+
console.warn(`Could not send message of type ${type} to the Wazo Softphone, iframe not created yet`);
|
|
14243
|
+
return;
|
|
14244
|
+
}
|
|
14245
|
+
|
|
14246
|
+
this.iframe.contentWindow.postMessage({ type, ...payload }, '*');
|
|
14247
|
+
}
|
|
14067
14248
|
}
|
|
14068
14249
|
|
|
14069
14250
|
var Softphone$1 = new Softphone();
|