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