@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
|
@@ -8326,7 +8326,7 @@ class WebRTCClient extends Emitter {
|
|
|
8326
8326
|
}
|
|
8327
8327
|
|
|
8328
8328
|
async _onHeartbeatTimeout() {
|
|
8329
|
-
logger$8.
|
|
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();
|
|
@@ -12841,11 +12841,41 @@ class Checker {
|
|
|
12841
12841
|
//
|
|
12842
12842
|
/* eslint-disable no-unused-vars */
|
|
12843
12843
|
/* global window, document */
|
|
12844
|
+
const BRIDGE_CONFIG_RETRIEVED = 'bridge/CONFIG_RETRIEVED';
|
|
12845
|
+
const BRIDGE_ENABLE_CARD = 'bridge/ENABLE_CARD';
|
|
12846
|
+
const BRIDGE_CHANGE_REQUIRED_SUBSCRIPTION_TYPE = 'bridge/CHANGE_REQUIRED_SUBSCRIPTION_TYPE';
|
|
12847
|
+
const BRIDGE_CREATE_OR_UPDATE_CARD = 'bridge/BRIDGE_CREATE_OR_UPDATE_CARD';
|
|
12848
|
+
const BRIDGE_OPTIONS_FETCHED = 'bridge/BRIDGE_OPTIONS_FETCHED';
|
|
12849
|
+
const BRIDGE_OPTIONS_FOUND = 'bridge/BRIDGE_OPTIONS_FOUND';
|
|
12850
|
+
const BRIDGE_SEARCH_OPTIONS = 'bridge/BRIDGE_SEARCH_OPTIONS';
|
|
12851
|
+
const BRIDGE_DISPLAY_LINKED_OPTION = 'bridge/DISPLAY_LINKED_OPTION';
|
|
12852
|
+
const BRIDGE_UPDATE_FORM_SCHEMA = 'bridge/BRIDGE_UPDATE_FORM_SCHEMA';
|
|
12853
|
+
const BRIDGE_WAZO_CONTACT_SEARCH = 'bridge/BRIDGE_WAZO_CONTACT_SEARCH';
|
|
12854
|
+
const BRIDGE_ON_AGENT_LOGGED_IN = 'bridge/BRIDGE_ON_AGENT_LOGGED_IN';
|
|
12855
|
+
const BRIDGE_ON_AGENT_LOGGED_OUT = 'bridge/BRIDGE_ON_AGENT_LOGGED_OUT';
|
|
12856
|
+
const BRIDGE_ON_AGENT_PAUSED = 'bridge/BRIDGE_ON_AGENT_PAUSED';
|
|
12857
|
+
const BRIDGE_ON_AGENT_RESUMED = 'bridge/BRIDGE_ON_AGENT_RESUMED';
|
|
12858
|
+
const BRIDGE_ON_LANGUAGE_CHANGED = 'bridge/BRIDGE_ON_LANGUAGE_CHANGED';
|
|
12859
|
+
const BRIDGE_ON_CALL_HELD = 'bridge/BRIDGE_ON_CALL_HELD';
|
|
12860
|
+
const BRIDGE_ON_CALL_RESUMED = 'bridge/BRIDGE_ON_CALL_RESUMED';
|
|
12861
|
+
const BRIDGE_ON_CALL_MUTED = 'bridge/BRIDGE_ON_CALL_MUTED';
|
|
12862
|
+
const BRIDGE_ON_CALL_UN_MUTED = 'bridge/BRIDGE_ON_CALL_UN_MUTED';
|
|
12863
|
+
const BRIDGE_ON_DTMF = 'bridge/BRIDGE_ON_DTMF';
|
|
12864
|
+
const BRIDGE_ON_DIRECT_TRANSFER = 'bridge/BRIDGE_ON_DIRECT_TRANSFER';
|
|
12865
|
+
const BRIDGE_ON_CREATE_INDIRECT_TRANSFER = 'bridge/BRIDGE_ON_CREATE_INDIRECT_TRANSFER';
|
|
12866
|
+
const BRIDGE_ON_CANCEL_INDIRECT_TRANSFER = 'bridge/BRIDGE_ON_CANCEL_INDIRECT_TRANSFER';
|
|
12867
|
+
const BRIDGE_ON_CONFIRM_INDIRECT_TRANSFER = 'bridge/BRIDGE_ON_CONFIRM_INDIRECT_TRANSFER';
|
|
12868
|
+
const BRIDGE_ON_INDIRECT_TRANSFER_CALL_MADE = 'bridge/BRIDGE_ON_INDIRECT_TRANSFER_CALL_MADE';
|
|
12869
|
+
const BRIDGE_ON_INDIRECT_TRANSFER_DONE = 'bridge/BRIDGE_ON_INDIRECT_TRANSFER_DONE';
|
|
12870
|
+
const BRIDGE_ON_START_RECORDING = 'bridge/BRIDGE_ON_START_RECORDING';
|
|
12871
|
+
const BRIDGE_ON_STOP_RECORDING = 'bridge/BRIDGE_ON_STOP_RECORDING';
|
|
12872
|
+
|
|
12844
12873
|
const SDK_CLICK_TO_CALL = 'sdk/CLICK_TO_CALL';
|
|
12845
12874
|
const SDK_ON_CALL_MADE = 'sdk/SDK_ON_CALL_MADE';
|
|
12846
12875
|
const SDK_CALL_ENDED = 'sdk/ON_CALL_ENDED';
|
|
12847
12876
|
const SDK_CALL_INCOMING = 'sdk/SDK_CALL_INCOMING';
|
|
12848
12877
|
const SDK_AUTHENTICATED = 'sdk/SDK_AUTHENTICATED';
|
|
12878
|
+
const SDK_LOGGED_OUT = 'sdk/SDK_LOGGED_OUT';
|
|
12849
12879
|
|
|
12850
12880
|
class Softphone {
|
|
12851
12881
|
url = 'https://softphone.wazo.io';
|
|
@@ -12855,13 +12885,39 @@ class Softphone {
|
|
|
12855
12885
|
iframe = null;
|
|
12856
12886
|
|
|
12857
12887
|
onLinkEnabled(link ) {}
|
|
12888
|
+
onIFrameLoaded() {}
|
|
12858
12889
|
|
|
12859
12890
|
onCallMade(call ) {}
|
|
12860
12891
|
onCallIncoming(call ) {}
|
|
12861
12892
|
onCallEnded(call , card , direction , fromExtension ) {}
|
|
12893
|
+
onCardSaved(card ) {}
|
|
12862
12894
|
onAuthenticated(session ) {}
|
|
12863
|
-
|
|
12864
|
-
|
|
12895
|
+
onLoggedOut() {}
|
|
12896
|
+
onSearchOptions(fieldId , query ) {}
|
|
12897
|
+
onDisplayLinkedOption(optionId ) {}
|
|
12898
|
+
onWazoContactSearch(query ) {}
|
|
12899
|
+
onAgentLoggedIn() {}
|
|
12900
|
+
onAgentLoggedOut() {}
|
|
12901
|
+
onAgentPaused() {}
|
|
12902
|
+
onAgentResumed() {}
|
|
12903
|
+
onLanguageChanged(language ) {}
|
|
12904
|
+
onCallHeld() {}
|
|
12905
|
+
onCallResumed() {}
|
|
12906
|
+
onCallMuted() {}
|
|
12907
|
+
onCallUnMuted() {}
|
|
12908
|
+
onDtmfSent(tone ) {}
|
|
12909
|
+
onDirectTransfer(number ) {}
|
|
12910
|
+
onCreateIndirectTransfer(number ) {}
|
|
12911
|
+
onCancelIndirectTransfer() {}
|
|
12912
|
+
onConfirmIndirectTransfer() {}
|
|
12913
|
+
onIndirectCallMade(call ) {}
|
|
12914
|
+
onIndirectTransferDone(call ) {}
|
|
12915
|
+
onStartRecording() {}
|
|
12916
|
+
onStopRecording() {}
|
|
12917
|
+
onUnHandledEvent(event ) {}
|
|
12918
|
+
|
|
12919
|
+
init({ url, width, height, server, port, language, wrapUpDuration, shouldDisplayLinkedEntities,
|
|
12920
|
+
allowContactCreation, withCard, subscriptionType, enableAgent } = {}) {
|
|
12865
12921
|
if (url) {
|
|
12866
12922
|
this.url = url;
|
|
12867
12923
|
}
|
|
@@ -12874,7 +12930,33 @@ class Softphone {
|
|
|
12874
12930
|
|
|
12875
12931
|
window.addEventListener('message', this._onMessage.bind(this), false);
|
|
12876
12932
|
|
|
12877
|
-
|
|
12933
|
+
if (!server) {
|
|
12934
|
+
// eslint-disable-next-line no-param-reassign
|
|
12935
|
+
server = 'stack.dev.wazo.io';
|
|
12936
|
+
}
|
|
12937
|
+
|
|
12938
|
+
this._createIframe(() => {
|
|
12939
|
+
this._sendMessage(BRIDGE_CONFIG_RETRIEVED, {
|
|
12940
|
+
config: {
|
|
12941
|
+
server,
|
|
12942
|
+
port,
|
|
12943
|
+
language,
|
|
12944
|
+
wrapUpDuration,
|
|
12945
|
+
shouldDisplayLinkedEntities,
|
|
12946
|
+
allowContactCreation,
|
|
12947
|
+
},
|
|
12948
|
+
});
|
|
12949
|
+
|
|
12950
|
+
if (withCard) {
|
|
12951
|
+
this._sendMessage(BRIDGE_ENABLE_CARD);
|
|
12952
|
+
}
|
|
12953
|
+
|
|
12954
|
+
if (subscriptionType) {
|
|
12955
|
+
this._sendMessage(BRIDGE_CHANGE_REQUIRED_SUBSCRIPTION_TYPE, { subscriptionType });
|
|
12956
|
+
}
|
|
12957
|
+
|
|
12958
|
+
this.onIFrameLoaded();
|
|
12959
|
+
});
|
|
12878
12960
|
}
|
|
12879
12961
|
|
|
12880
12962
|
parseLinks() {
|
|
@@ -12890,9 +12972,7 @@ class Softphone {
|
|
|
12890
12972
|
makeCall(number ) {
|
|
12891
12973
|
this.displaySoftphone();
|
|
12892
12974
|
|
|
12893
|
-
|
|
12894
|
-
this.iframe.contentWindow.postMessage({ type: SDK_CLICK_TO_CALL, number }, '*');
|
|
12895
|
-
}
|
|
12975
|
+
this._sendMessage(SDK_CLICK_TO_CALL, { number });
|
|
12896
12976
|
}
|
|
12897
12977
|
|
|
12898
12978
|
toggleSoftphoneDisplay() {
|
|
@@ -12901,8 +12981,6 @@ class Softphone {
|
|
|
12901
12981
|
} else {
|
|
12902
12982
|
this.displaySoftphone();
|
|
12903
12983
|
}
|
|
12904
|
-
|
|
12905
|
-
this.displayed = !this.displayed;
|
|
12906
12984
|
}
|
|
12907
12985
|
|
|
12908
12986
|
displaySoftphone() {
|
|
@@ -12913,15 +12991,30 @@ class Softphone {
|
|
|
12913
12991
|
if (this.iframe) {
|
|
12914
12992
|
this.iframe.style.display = 'block';
|
|
12915
12993
|
}
|
|
12994
|
+
|
|
12995
|
+
this.displayed = true;
|
|
12916
12996
|
}
|
|
12917
12997
|
|
|
12918
12998
|
hideSoftphone() {
|
|
12919
12999
|
if (this.iframe) {
|
|
12920
13000
|
this.iframe.style.display = 'none';
|
|
12921
13001
|
}
|
|
13002
|
+
this.displayed = false;
|
|
13003
|
+
}
|
|
13004
|
+
|
|
13005
|
+
optionsFetched(fieldId , options ) {
|
|
13006
|
+
this._sendMessage(BRIDGE_OPTIONS_FETCHED, { fieldId, options });
|
|
13007
|
+
}
|
|
13008
|
+
|
|
13009
|
+
onOptionsResults(fieldId , options ) {
|
|
13010
|
+
this._sendMessage(BRIDGE_OPTIONS_FOUND, { fieldId, options });
|
|
13011
|
+
}
|
|
13012
|
+
|
|
13013
|
+
setFormSchema(schema , uiSchema ) {
|
|
13014
|
+
this._sendMessage(BRIDGE_UPDATE_FORM_SCHEMA, { schema, uiSchema });
|
|
12922
13015
|
}
|
|
12923
13016
|
|
|
12924
|
-
_createIframe() {
|
|
13017
|
+
_createIframe(cb = () => {}) {
|
|
12925
13018
|
this.iframe = document.createElement('iframe');
|
|
12926
13019
|
// $FlowFixMe
|
|
12927
13020
|
this.iframe.width = this.width;
|
|
@@ -12933,10 +13026,13 @@ class Softphone {
|
|
|
12933
13026
|
this.iframe.style.left = '0';
|
|
12934
13027
|
this.iframe.style.bottom = '0';
|
|
12935
13028
|
this.iframe.style.border = '1px solid #aaa';
|
|
13029
|
+
this.iframe.style.backgroundColor = 'white';
|
|
12936
13030
|
this.iframe.src = this.url;
|
|
12937
13031
|
this.iframe.style.display = 'none';
|
|
12938
13032
|
this.iframe.id = 'wazo-softphone';
|
|
12939
13033
|
|
|
13034
|
+
this.iframe.onload = cb;
|
|
13035
|
+
|
|
12940
13036
|
// $FlowFixMe
|
|
12941
13037
|
document.body.appendChild(this.iframe);
|
|
12942
13038
|
}
|
|
@@ -12979,8 +13075,93 @@ class Softphone {
|
|
|
12979
13075
|
this._onAuthenticated(event.data.session);
|
|
12980
13076
|
this.onAuthenticated(event.data.session);
|
|
12981
13077
|
break;
|
|
13078
|
+
case SDK_LOGGED_OUT:
|
|
13079
|
+
this.onLoggedOut();
|
|
13080
|
+
break;
|
|
13081
|
+
case BRIDGE_CREATE_OR_UPDATE_CARD: {
|
|
13082
|
+
const { content } = event.data;
|
|
13083
|
+
this.onCardSaved(content);
|
|
13084
|
+
break;
|
|
13085
|
+
}
|
|
13086
|
+
case BRIDGE_SEARCH_OPTIONS: {
|
|
13087
|
+
const { fieldId, query } = event.data;
|
|
13088
|
+
this.onSearchOptions(fieldId, query);
|
|
13089
|
+
break;
|
|
13090
|
+
}
|
|
13091
|
+
case BRIDGE_DISPLAY_LINKED_OPTION:
|
|
13092
|
+
this.onDisplayLinkedOption(event.data.linkedOptionId);
|
|
13093
|
+
break;
|
|
13094
|
+
case BRIDGE_WAZO_CONTACT_SEARCH:
|
|
13095
|
+
this.onWazoContactSearch(event.data.query);
|
|
13096
|
+
break;
|
|
13097
|
+
case BRIDGE_ON_AGENT_LOGGED_IN:
|
|
13098
|
+
this.onAgentLoggedIn();
|
|
13099
|
+
break;
|
|
13100
|
+
case BRIDGE_ON_AGENT_LOGGED_OUT:
|
|
13101
|
+
this.onAgentLoggedOut();
|
|
13102
|
+
break;
|
|
13103
|
+
case BRIDGE_ON_AGENT_PAUSED:
|
|
13104
|
+
this.onAgentPaused();
|
|
13105
|
+
break;
|
|
13106
|
+
case BRIDGE_ON_AGENT_RESUMED:
|
|
13107
|
+
this.onAgentResumed();
|
|
13108
|
+
break;
|
|
13109
|
+
case BRIDGE_ON_LANGUAGE_CHANGED:
|
|
13110
|
+
this.onLanguageChanged(event.data.language);
|
|
13111
|
+
break;
|
|
13112
|
+
case BRIDGE_ON_CALL_HELD:
|
|
13113
|
+
this.onCallHeld();
|
|
13114
|
+
break;
|
|
13115
|
+
case BRIDGE_ON_CALL_RESUMED:
|
|
13116
|
+
this.onCallResumed();
|
|
13117
|
+
break;
|
|
13118
|
+
case BRIDGE_ON_CALL_MUTED:
|
|
13119
|
+
this.onCallMuted();
|
|
13120
|
+
break;
|
|
13121
|
+
case BRIDGE_ON_CALL_UN_MUTED:
|
|
13122
|
+
this.onCallUnMuted();
|
|
13123
|
+
break;
|
|
13124
|
+
case BRIDGE_ON_DTMF:
|
|
13125
|
+
this.onDtmfSent(event.data.tone);
|
|
13126
|
+
break;
|
|
13127
|
+
case BRIDGE_ON_DIRECT_TRANSFER:
|
|
13128
|
+
this.onDirectTransfer(event.data.number);
|
|
13129
|
+
break;
|
|
13130
|
+
case BRIDGE_ON_CREATE_INDIRECT_TRANSFER:
|
|
13131
|
+
this.onCreateIndirectTransfer(event.data.number);
|
|
13132
|
+
break;
|
|
13133
|
+
case BRIDGE_ON_CANCEL_INDIRECT_TRANSFER:
|
|
13134
|
+
this.onCancelIndirectTransfer();
|
|
13135
|
+
break;
|
|
13136
|
+
case BRIDGE_ON_CONFIRM_INDIRECT_TRANSFER:
|
|
13137
|
+
this.onConfirmIndirectTransfer();
|
|
13138
|
+
break;
|
|
13139
|
+
case BRIDGE_ON_INDIRECT_TRANSFER_CALL_MADE:
|
|
13140
|
+
this.onIndirectCallMade(event.data.call);
|
|
13141
|
+
break;
|
|
13142
|
+
case BRIDGE_ON_INDIRECT_TRANSFER_DONE:
|
|
13143
|
+
this.onIndirectTransferDone(event.data.call);
|
|
13144
|
+
break;
|
|
13145
|
+
case BRIDGE_ON_START_RECORDING:
|
|
13146
|
+
this.onStartRecording();
|
|
13147
|
+
break;
|
|
13148
|
+
case BRIDGE_ON_STOP_RECORDING:
|
|
13149
|
+
this.onStopRecording();
|
|
13150
|
+
break;
|
|
13151
|
+
default:
|
|
13152
|
+
this.onUnHandledEvent(event);
|
|
13153
|
+
break;
|
|
12982
13154
|
}
|
|
12983
13155
|
}
|
|
13156
|
+
|
|
13157
|
+
_sendMessage(type , payload = {}) {
|
|
13158
|
+
if (!this.iframe) {
|
|
13159
|
+
console.warn(`Could not send message of type ${type} to the Wazo Softphone, iframe not created yet`);
|
|
13160
|
+
return;
|
|
13161
|
+
}
|
|
13162
|
+
|
|
13163
|
+
this.iframe.contentWindow.postMessage({ type, ...payload }, '*');
|
|
13164
|
+
}
|
|
12984
13165
|
}
|
|
12985
13166
|
|
|
12986
13167
|
var Softphone$1 = new Softphone();
|
|
@@ -8326,7 +8326,7 @@ class WebRTCClient extends Emitter {
|
|
|
8326
8326
|
}
|
|
8327
8327
|
|
|
8328
8328
|
async _onHeartbeatTimeout() {
|
|
8329
|
-
logger$8.
|
|
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();
|
|
@@ -12846,11 +12846,41 @@ class Checker {
|
|
|
12846
12846
|
//
|
|
12847
12847
|
/* eslint-disable no-unused-vars */
|
|
12848
12848
|
/* global window, document */
|
|
12849
|
+
const BRIDGE_CONFIG_RETRIEVED = 'bridge/CONFIG_RETRIEVED';
|
|
12850
|
+
const BRIDGE_ENABLE_CARD = 'bridge/ENABLE_CARD';
|
|
12851
|
+
const BRIDGE_CHANGE_REQUIRED_SUBSCRIPTION_TYPE = 'bridge/CHANGE_REQUIRED_SUBSCRIPTION_TYPE';
|
|
12852
|
+
const BRIDGE_CREATE_OR_UPDATE_CARD = 'bridge/BRIDGE_CREATE_OR_UPDATE_CARD';
|
|
12853
|
+
const BRIDGE_OPTIONS_FETCHED = 'bridge/BRIDGE_OPTIONS_FETCHED';
|
|
12854
|
+
const BRIDGE_OPTIONS_FOUND = 'bridge/BRIDGE_OPTIONS_FOUND';
|
|
12855
|
+
const BRIDGE_SEARCH_OPTIONS = 'bridge/BRIDGE_SEARCH_OPTIONS';
|
|
12856
|
+
const BRIDGE_DISPLAY_LINKED_OPTION = 'bridge/DISPLAY_LINKED_OPTION';
|
|
12857
|
+
const BRIDGE_UPDATE_FORM_SCHEMA = 'bridge/BRIDGE_UPDATE_FORM_SCHEMA';
|
|
12858
|
+
const BRIDGE_WAZO_CONTACT_SEARCH = 'bridge/BRIDGE_WAZO_CONTACT_SEARCH';
|
|
12859
|
+
const BRIDGE_ON_AGENT_LOGGED_IN = 'bridge/BRIDGE_ON_AGENT_LOGGED_IN';
|
|
12860
|
+
const BRIDGE_ON_AGENT_LOGGED_OUT = 'bridge/BRIDGE_ON_AGENT_LOGGED_OUT';
|
|
12861
|
+
const BRIDGE_ON_AGENT_PAUSED = 'bridge/BRIDGE_ON_AGENT_PAUSED';
|
|
12862
|
+
const BRIDGE_ON_AGENT_RESUMED = 'bridge/BRIDGE_ON_AGENT_RESUMED';
|
|
12863
|
+
const BRIDGE_ON_LANGUAGE_CHANGED = 'bridge/BRIDGE_ON_LANGUAGE_CHANGED';
|
|
12864
|
+
const BRIDGE_ON_CALL_HELD = 'bridge/BRIDGE_ON_CALL_HELD';
|
|
12865
|
+
const BRIDGE_ON_CALL_RESUMED = 'bridge/BRIDGE_ON_CALL_RESUMED';
|
|
12866
|
+
const BRIDGE_ON_CALL_MUTED = 'bridge/BRIDGE_ON_CALL_MUTED';
|
|
12867
|
+
const BRIDGE_ON_CALL_UN_MUTED = 'bridge/BRIDGE_ON_CALL_UN_MUTED';
|
|
12868
|
+
const BRIDGE_ON_DTMF = 'bridge/BRIDGE_ON_DTMF';
|
|
12869
|
+
const BRIDGE_ON_DIRECT_TRANSFER = 'bridge/BRIDGE_ON_DIRECT_TRANSFER';
|
|
12870
|
+
const BRIDGE_ON_CREATE_INDIRECT_TRANSFER = 'bridge/BRIDGE_ON_CREATE_INDIRECT_TRANSFER';
|
|
12871
|
+
const BRIDGE_ON_CANCEL_INDIRECT_TRANSFER = 'bridge/BRIDGE_ON_CANCEL_INDIRECT_TRANSFER';
|
|
12872
|
+
const BRIDGE_ON_CONFIRM_INDIRECT_TRANSFER = 'bridge/BRIDGE_ON_CONFIRM_INDIRECT_TRANSFER';
|
|
12873
|
+
const BRIDGE_ON_INDIRECT_TRANSFER_CALL_MADE = 'bridge/BRIDGE_ON_INDIRECT_TRANSFER_CALL_MADE';
|
|
12874
|
+
const BRIDGE_ON_INDIRECT_TRANSFER_DONE = 'bridge/BRIDGE_ON_INDIRECT_TRANSFER_DONE';
|
|
12875
|
+
const BRIDGE_ON_START_RECORDING = 'bridge/BRIDGE_ON_START_RECORDING';
|
|
12876
|
+
const BRIDGE_ON_STOP_RECORDING = 'bridge/BRIDGE_ON_STOP_RECORDING';
|
|
12877
|
+
|
|
12849
12878
|
const SDK_CLICK_TO_CALL = 'sdk/CLICK_TO_CALL';
|
|
12850
12879
|
const SDK_ON_CALL_MADE = 'sdk/SDK_ON_CALL_MADE';
|
|
12851
12880
|
const SDK_CALL_ENDED = 'sdk/ON_CALL_ENDED';
|
|
12852
12881
|
const SDK_CALL_INCOMING = 'sdk/SDK_CALL_INCOMING';
|
|
12853
12882
|
const SDK_AUTHENTICATED = 'sdk/SDK_AUTHENTICATED';
|
|
12883
|
+
const SDK_LOGGED_OUT = 'sdk/SDK_LOGGED_OUT';
|
|
12854
12884
|
|
|
12855
12885
|
class Softphone {
|
|
12856
12886
|
url = 'https://softphone.wazo.io';
|
|
@@ -12860,13 +12890,39 @@ class Softphone {
|
|
|
12860
12890
|
iframe = null;
|
|
12861
12891
|
|
|
12862
12892
|
onLinkEnabled(link ) {}
|
|
12893
|
+
onIFrameLoaded() {}
|
|
12863
12894
|
|
|
12864
12895
|
onCallMade(call ) {}
|
|
12865
12896
|
onCallIncoming(call ) {}
|
|
12866
12897
|
onCallEnded(call , card , direction , fromExtension ) {}
|
|
12898
|
+
onCardSaved(card ) {}
|
|
12867
12899
|
onAuthenticated(session ) {}
|
|
12868
|
-
|
|
12869
|
-
|
|
12900
|
+
onLoggedOut() {}
|
|
12901
|
+
onSearchOptions(fieldId , query ) {}
|
|
12902
|
+
onDisplayLinkedOption(optionId ) {}
|
|
12903
|
+
onWazoContactSearch(query ) {}
|
|
12904
|
+
onAgentLoggedIn() {}
|
|
12905
|
+
onAgentLoggedOut() {}
|
|
12906
|
+
onAgentPaused() {}
|
|
12907
|
+
onAgentResumed() {}
|
|
12908
|
+
onLanguageChanged(language ) {}
|
|
12909
|
+
onCallHeld() {}
|
|
12910
|
+
onCallResumed() {}
|
|
12911
|
+
onCallMuted() {}
|
|
12912
|
+
onCallUnMuted() {}
|
|
12913
|
+
onDtmfSent(tone ) {}
|
|
12914
|
+
onDirectTransfer(number ) {}
|
|
12915
|
+
onCreateIndirectTransfer(number ) {}
|
|
12916
|
+
onCancelIndirectTransfer() {}
|
|
12917
|
+
onConfirmIndirectTransfer() {}
|
|
12918
|
+
onIndirectCallMade(call ) {}
|
|
12919
|
+
onIndirectTransferDone(call ) {}
|
|
12920
|
+
onStartRecording() {}
|
|
12921
|
+
onStopRecording() {}
|
|
12922
|
+
onUnHandledEvent(event ) {}
|
|
12923
|
+
|
|
12924
|
+
init({ url, width, height, server, port, language, wrapUpDuration, shouldDisplayLinkedEntities,
|
|
12925
|
+
allowContactCreation, withCard, subscriptionType, enableAgent } = {}) {
|
|
12870
12926
|
if (url) {
|
|
12871
12927
|
this.url = url;
|
|
12872
12928
|
}
|
|
@@ -12879,7 +12935,33 @@ class Softphone {
|
|
|
12879
12935
|
|
|
12880
12936
|
window.addEventListener('message', this._onMessage.bind(this), false);
|
|
12881
12937
|
|
|
12882
|
-
|
|
12938
|
+
if (!server) {
|
|
12939
|
+
// eslint-disable-next-line no-param-reassign
|
|
12940
|
+
server = 'stack.dev.wazo.io';
|
|
12941
|
+
}
|
|
12942
|
+
|
|
12943
|
+
this._createIframe(() => {
|
|
12944
|
+
this._sendMessage(BRIDGE_CONFIG_RETRIEVED, {
|
|
12945
|
+
config: {
|
|
12946
|
+
server,
|
|
12947
|
+
port,
|
|
12948
|
+
language,
|
|
12949
|
+
wrapUpDuration,
|
|
12950
|
+
shouldDisplayLinkedEntities,
|
|
12951
|
+
allowContactCreation,
|
|
12952
|
+
},
|
|
12953
|
+
});
|
|
12954
|
+
|
|
12955
|
+
if (withCard) {
|
|
12956
|
+
this._sendMessage(BRIDGE_ENABLE_CARD);
|
|
12957
|
+
}
|
|
12958
|
+
|
|
12959
|
+
if (subscriptionType) {
|
|
12960
|
+
this._sendMessage(BRIDGE_CHANGE_REQUIRED_SUBSCRIPTION_TYPE, { subscriptionType });
|
|
12961
|
+
}
|
|
12962
|
+
|
|
12963
|
+
this.onIFrameLoaded();
|
|
12964
|
+
});
|
|
12883
12965
|
}
|
|
12884
12966
|
|
|
12885
12967
|
parseLinks() {
|
|
@@ -12895,9 +12977,7 @@ class Softphone {
|
|
|
12895
12977
|
makeCall(number ) {
|
|
12896
12978
|
this.displaySoftphone();
|
|
12897
12979
|
|
|
12898
|
-
|
|
12899
|
-
this.iframe.contentWindow.postMessage({ type: SDK_CLICK_TO_CALL, number }, '*');
|
|
12900
|
-
}
|
|
12980
|
+
this._sendMessage(SDK_CLICK_TO_CALL, { number });
|
|
12901
12981
|
}
|
|
12902
12982
|
|
|
12903
12983
|
toggleSoftphoneDisplay() {
|
|
@@ -12906,8 +12986,6 @@ class Softphone {
|
|
|
12906
12986
|
} else {
|
|
12907
12987
|
this.displaySoftphone();
|
|
12908
12988
|
}
|
|
12909
|
-
|
|
12910
|
-
this.displayed = !this.displayed;
|
|
12911
12989
|
}
|
|
12912
12990
|
|
|
12913
12991
|
displaySoftphone() {
|
|
@@ -12918,15 +12996,30 @@ class Softphone {
|
|
|
12918
12996
|
if (this.iframe) {
|
|
12919
12997
|
this.iframe.style.display = 'block';
|
|
12920
12998
|
}
|
|
12999
|
+
|
|
13000
|
+
this.displayed = true;
|
|
12921
13001
|
}
|
|
12922
13002
|
|
|
12923
13003
|
hideSoftphone() {
|
|
12924
13004
|
if (this.iframe) {
|
|
12925
13005
|
this.iframe.style.display = 'none';
|
|
12926
13006
|
}
|
|
13007
|
+
this.displayed = false;
|
|
13008
|
+
}
|
|
13009
|
+
|
|
13010
|
+
optionsFetched(fieldId , options ) {
|
|
13011
|
+
this._sendMessage(BRIDGE_OPTIONS_FETCHED, { fieldId, options });
|
|
13012
|
+
}
|
|
13013
|
+
|
|
13014
|
+
onOptionsResults(fieldId , options ) {
|
|
13015
|
+
this._sendMessage(BRIDGE_OPTIONS_FOUND, { fieldId, options });
|
|
13016
|
+
}
|
|
13017
|
+
|
|
13018
|
+
setFormSchema(schema , uiSchema ) {
|
|
13019
|
+
this._sendMessage(BRIDGE_UPDATE_FORM_SCHEMA, { schema, uiSchema });
|
|
12927
13020
|
}
|
|
12928
13021
|
|
|
12929
|
-
_createIframe() {
|
|
13022
|
+
_createIframe(cb = () => {}) {
|
|
12930
13023
|
this.iframe = document.createElement('iframe');
|
|
12931
13024
|
// $FlowFixMe
|
|
12932
13025
|
this.iframe.width = this.width;
|
|
@@ -12938,10 +13031,13 @@ class Softphone {
|
|
|
12938
13031
|
this.iframe.style.left = '0';
|
|
12939
13032
|
this.iframe.style.bottom = '0';
|
|
12940
13033
|
this.iframe.style.border = '1px solid #aaa';
|
|
13034
|
+
this.iframe.style.backgroundColor = 'white';
|
|
12941
13035
|
this.iframe.src = this.url;
|
|
12942
13036
|
this.iframe.style.display = 'none';
|
|
12943
13037
|
this.iframe.id = 'wazo-softphone';
|
|
12944
13038
|
|
|
13039
|
+
this.iframe.onload = cb;
|
|
13040
|
+
|
|
12945
13041
|
// $FlowFixMe
|
|
12946
13042
|
document.body.appendChild(this.iframe);
|
|
12947
13043
|
}
|
|
@@ -12984,8 +13080,93 @@ class Softphone {
|
|
|
12984
13080
|
this._onAuthenticated(event.data.session);
|
|
12985
13081
|
this.onAuthenticated(event.data.session);
|
|
12986
13082
|
break;
|
|
13083
|
+
case SDK_LOGGED_OUT:
|
|
13084
|
+
this.onLoggedOut();
|
|
13085
|
+
break;
|
|
13086
|
+
case BRIDGE_CREATE_OR_UPDATE_CARD: {
|
|
13087
|
+
const { content } = event.data;
|
|
13088
|
+
this.onCardSaved(content);
|
|
13089
|
+
break;
|
|
13090
|
+
}
|
|
13091
|
+
case BRIDGE_SEARCH_OPTIONS: {
|
|
13092
|
+
const { fieldId, query } = event.data;
|
|
13093
|
+
this.onSearchOptions(fieldId, query);
|
|
13094
|
+
break;
|
|
13095
|
+
}
|
|
13096
|
+
case BRIDGE_DISPLAY_LINKED_OPTION:
|
|
13097
|
+
this.onDisplayLinkedOption(event.data.linkedOptionId);
|
|
13098
|
+
break;
|
|
13099
|
+
case BRIDGE_WAZO_CONTACT_SEARCH:
|
|
13100
|
+
this.onWazoContactSearch(event.data.query);
|
|
13101
|
+
break;
|
|
13102
|
+
case BRIDGE_ON_AGENT_LOGGED_IN:
|
|
13103
|
+
this.onAgentLoggedIn();
|
|
13104
|
+
break;
|
|
13105
|
+
case BRIDGE_ON_AGENT_LOGGED_OUT:
|
|
13106
|
+
this.onAgentLoggedOut();
|
|
13107
|
+
break;
|
|
13108
|
+
case BRIDGE_ON_AGENT_PAUSED:
|
|
13109
|
+
this.onAgentPaused();
|
|
13110
|
+
break;
|
|
13111
|
+
case BRIDGE_ON_AGENT_RESUMED:
|
|
13112
|
+
this.onAgentResumed();
|
|
13113
|
+
break;
|
|
13114
|
+
case BRIDGE_ON_LANGUAGE_CHANGED:
|
|
13115
|
+
this.onLanguageChanged(event.data.language);
|
|
13116
|
+
break;
|
|
13117
|
+
case BRIDGE_ON_CALL_HELD:
|
|
13118
|
+
this.onCallHeld();
|
|
13119
|
+
break;
|
|
13120
|
+
case BRIDGE_ON_CALL_RESUMED:
|
|
13121
|
+
this.onCallResumed();
|
|
13122
|
+
break;
|
|
13123
|
+
case BRIDGE_ON_CALL_MUTED:
|
|
13124
|
+
this.onCallMuted();
|
|
13125
|
+
break;
|
|
13126
|
+
case BRIDGE_ON_CALL_UN_MUTED:
|
|
13127
|
+
this.onCallUnMuted();
|
|
13128
|
+
break;
|
|
13129
|
+
case BRIDGE_ON_DTMF:
|
|
13130
|
+
this.onDtmfSent(event.data.tone);
|
|
13131
|
+
break;
|
|
13132
|
+
case BRIDGE_ON_DIRECT_TRANSFER:
|
|
13133
|
+
this.onDirectTransfer(event.data.number);
|
|
13134
|
+
break;
|
|
13135
|
+
case BRIDGE_ON_CREATE_INDIRECT_TRANSFER:
|
|
13136
|
+
this.onCreateIndirectTransfer(event.data.number);
|
|
13137
|
+
break;
|
|
13138
|
+
case BRIDGE_ON_CANCEL_INDIRECT_TRANSFER:
|
|
13139
|
+
this.onCancelIndirectTransfer();
|
|
13140
|
+
break;
|
|
13141
|
+
case BRIDGE_ON_CONFIRM_INDIRECT_TRANSFER:
|
|
13142
|
+
this.onConfirmIndirectTransfer();
|
|
13143
|
+
break;
|
|
13144
|
+
case BRIDGE_ON_INDIRECT_TRANSFER_CALL_MADE:
|
|
13145
|
+
this.onIndirectCallMade(event.data.call);
|
|
13146
|
+
break;
|
|
13147
|
+
case BRIDGE_ON_INDIRECT_TRANSFER_DONE:
|
|
13148
|
+
this.onIndirectTransferDone(event.data.call);
|
|
13149
|
+
break;
|
|
13150
|
+
case BRIDGE_ON_START_RECORDING:
|
|
13151
|
+
this.onStartRecording();
|
|
13152
|
+
break;
|
|
13153
|
+
case BRIDGE_ON_STOP_RECORDING:
|
|
13154
|
+
this.onStopRecording();
|
|
13155
|
+
break;
|
|
13156
|
+
default:
|
|
13157
|
+
this.onUnHandledEvent(event);
|
|
13158
|
+
break;
|
|
12987
13159
|
}
|
|
12988
13160
|
}
|
|
13161
|
+
|
|
13162
|
+
_sendMessage(type , payload = {}) {
|
|
13163
|
+
if (!this.iframe) {
|
|
13164
|
+
console.warn(`Could not send message of type ${type} to the Wazo Softphone, iframe not created yet`);
|
|
13165
|
+
return;
|
|
13166
|
+
}
|
|
13167
|
+
|
|
13168
|
+
this.iframe.contentWindow.postMessage({ type, ...payload }, '*');
|
|
13169
|
+
}
|
|
12989
13170
|
}
|
|
12990
13171
|
|
|
12991
13172
|
var Softphone$1 = new Softphone();
|