@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
package/lib/simple/Softphone.js
CHANGED
|
@@ -3,11 +3,41 @@
|
|
|
3
3
|
//
|
|
4
4
|
/* eslint-disable no-unused-vars */
|
|
5
5
|
/* global window, document */
|
|
6
|
+
const BRIDGE_CONFIG_RETRIEVED = 'bridge/CONFIG_RETRIEVED';
|
|
7
|
+
const BRIDGE_ENABLE_CARD = 'bridge/ENABLE_CARD';
|
|
8
|
+
const BRIDGE_CHANGE_REQUIRED_SUBSCRIPTION_TYPE = 'bridge/CHANGE_REQUIRED_SUBSCRIPTION_TYPE';
|
|
9
|
+
const BRIDGE_CREATE_OR_UPDATE_CARD = 'bridge/BRIDGE_CREATE_OR_UPDATE_CARD';
|
|
10
|
+
const BRIDGE_OPTIONS_FETCHED = 'bridge/BRIDGE_OPTIONS_FETCHED';
|
|
11
|
+
const BRIDGE_OPTIONS_FOUND = 'bridge/BRIDGE_OPTIONS_FOUND';
|
|
12
|
+
const BRIDGE_SEARCH_OPTIONS = 'bridge/BRIDGE_SEARCH_OPTIONS';
|
|
13
|
+
const BRIDGE_DISPLAY_LINKED_OPTION = 'bridge/DISPLAY_LINKED_OPTION';
|
|
14
|
+
const BRIDGE_UPDATE_FORM_SCHEMA = 'bridge/BRIDGE_UPDATE_FORM_SCHEMA';
|
|
15
|
+
const BRIDGE_WAZO_CONTACT_SEARCH = 'bridge/BRIDGE_WAZO_CONTACT_SEARCH';
|
|
16
|
+
const BRIDGE_ON_AGENT_LOGGED_IN = 'bridge/BRIDGE_ON_AGENT_LOGGED_IN';
|
|
17
|
+
const BRIDGE_ON_AGENT_LOGGED_OUT = 'bridge/BRIDGE_ON_AGENT_LOGGED_OUT';
|
|
18
|
+
const BRIDGE_ON_AGENT_PAUSED = 'bridge/BRIDGE_ON_AGENT_PAUSED';
|
|
19
|
+
const BRIDGE_ON_AGENT_RESUMED = 'bridge/BRIDGE_ON_AGENT_RESUMED';
|
|
20
|
+
const BRIDGE_ON_LANGUAGE_CHANGED = 'bridge/BRIDGE_ON_LANGUAGE_CHANGED';
|
|
21
|
+
const BRIDGE_ON_CALL_HELD = 'bridge/BRIDGE_ON_CALL_HELD';
|
|
22
|
+
const BRIDGE_ON_CALL_RESUMED = 'bridge/BRIDGE_ON_CALL_RESUMED';
|
|
23
|
+
const BRIDGE_ON_CALL_MUTED = 'bridge/BRIDGE_ON_CALL_MUTED';
|
|
24
|
+
const BRIDGE_ON_CALL_UN_MUTED = 'bridge/BRIDGE_ON_CALL_UN_MUTED';
|
|
25
|
+
const BRIDGE_ON_DTMF = 'bridge/BRIDGE_ON_DTMF';
|
|
26
|
+
const BRIDGE_ON_DIRECT_TRANSFER = 'bridge/BRIDGE_ON_DIRECT_TRANSFER';
|
|
27
|
+
const BRIDGE_ON_CREATE_INDIRECT_TRANSFER = 'bridge/BRIDGE_ON_CREATE_INDIRECT_TRANSFER';
|
|
28
|
+
const BRIDGE_ON_CANCEL_INDIRECT_TRANSFER = 'bridge/BRIDGE_ON_CANCEL_INDIRECT_TRANSFER';
|
|
29
|
+
const BRIDGE_ON_CONFIRM_INDIRECT_TRANSFER = 'bridge/BRIDGE_ON_CONFIRM_INDIRECT_TRANSFER';
|
|
30
|
+
const BRIDGE_ON_INDIRECT_TRANSFER_CALL_MADE = 'bridge/BRIDGE_ON_INDIRECT_TRANSFER_CALL_MADE';
|
|
31
|
+
const BRIDGE_ON_INDIRECT_TRANSFER_DONE = 'bridge/BRIDGE_ON_INDIRECT_TRANSFER_DONE';
|
|
32
|
+
const BRIDGE_ON_START_RECORDING = 'bridge/BRIDGE_ON_START_RECORDING';
|
|
33
|
+
const BRIDGE_ON_STOP_RECORDING = 'bridge/BRIDGE_ON_STOP_RECORDING';
|
|
34
|
+
|
|
6
35
|
const SDK_CLICK_TO_CALL = 'sdk/CLICK_TO_CALL';
|
|
7
36
|
const SDK_ON_CALL_MADE = 'sdk/SDK_ON_CALL_MADE';
|
|
8
37
|
const SDK_CALL_ENDED = 'sdk/ON_CALL_ENDED';
|
|
9
38
|
const SDK_CALL_INCOMING = 'sdk/SDK_CALL_INCOMING';
|
|
10
39
|
const SDK_AUTHENTICATED = 'sdk/SDK_AUTHENTICATED';
|
|
40
|
+
const SDK_LOGGED_OUT = 'sdk/SDK_LOGGED_OUT';
|
|
11
41
|
|
|
12
42
|
class Softphone {
|
|
13
43
|
url = 'https://softphone.wazo.io';
|
|
@@ -17,13 +47,39 @@ class Softphone {
|
|
|
17
47
|
iframe = null;
|
|
18
48
|
|
|
19
49
|
onLinkEnabled(link ) {}
|
|
50
|
+
onIFrameLoaded() {}
|
|
20
51
|
|
|
21
52
|
onCallMade(call ) {}
|
|
22
53
|
onCallIncoming(call ) {}
|
|
23
54
|
onCallEnded(call , card , direction , fromExtension ) {}
|
|
55
|
+
onCardSaved(card ) {}
|
|
24
56
|
onAuthenticated(session ) {}
|
|
57
|
+
onLoggedOut() {}
|
|
58
|
+
onSearchOptions(fieldId , query ) {}
|
|
59
|
+
onDisplayLinkedOption(optionId ) {}
|
|
60
|
+
onWazoContactSearch(query ) {}
|
|
61
|
+
onAgentLoggedIn() {}
|
|
62
|
+
onAgentLoggedOut() {}
|
|
63
|
+
onAgentPaused() {}
|
|
64
|
+
onAgentResumed() {}
|
|
65
|
+
onLanguageChanged(language ) {}
|
|
66
|
+
onCallHeld() {}
|
|
67
|
+
onCallResumed() {}
|
|
68
|
+
onCallMuted() {}
|
|
69
|
+
onCallUnMuted() {}
|
|
70
|
+
onDtmfSent(tone ) {}
|
|
71
|
+
onDirectTransfer(number ) {}
|
|
72
|
+
onCreateIndirectTransfer(number ) {}
|
|
73
|
+
onCancelIndirectTransfer() {}
|
|
74
|
+
onConfirmIndirectTransfer() {}
|
|
75
|
+
onIndirectCallMade(call ) {}
|
|
76
|
+
onIndirectTransferDone(call ) {}
|
|
77
|
+
onStartRecording() {}
|
|
78
|
+
onStopRecording() {}
|
|
79
|
+
onUnHandledEvent(event ) {}
|
|
25
80
|
|
|
26
|
-
init(url
|
|
81
|
+
init({ url, width, height, server, port, language, wrapUpDuration, shouldDisplayLinkedEntities,
|
|
82
|
+
allowContactCreation, withCard, subscriptionType, enableAgent } = {}) {
|
|
27
83
|
if (url) {
|
|
28
84
|
this.url = url;
|
|
29
85
|
}
|
|
@@ -36,7 +92,33 @@ class Softphone {
|
|
|
36
92
|
|
|
37
93
|
window.addEventListener('message', this._onMessage.bind(this), false);
|
|
38
94
|
|
|
39
|
-
|
|
95
|
+
if (!server) {
|
|
96
|
+
// eslint-disable-next-line no-param-reassign
|
|
97
|
+
server = 'stack.dev.wazo.io';
|
|
98
|
+
}
|
|
99
|
+
|
|
100
|
+
this._createIframe(() => {
|
|
101
|
+
this._sendMessage(BRIDGE_CONFIG_RETRIEVED, {
|
|
102
|
+
config: {
|
|
103
|
+
server,
|
|
104
|
+
port,
|
|
105
|
+
language,
|
|
106
|
+
wrapUpDuration,
|
|
107
|
+
shouldDisplayLinkedEntities,
|
|
108
|
+
allowContactCreation,
|
|
109
|
+
},
|
|
110
|
+
});
|
|
111
|
+
|
|
112
|
+
if (withCard) {
|
|
113
|
+
this._sendMessage(BRIDGE_ENABLE_CARD);
|
|
114
|
+
}
|
|
115
|
+
|
|
116
|
+
if (subscriptionType) {
|
|
117
|
+
this._sendMessage(BRIDGE_CHANGE_REQUIRED_SUBSCRIPTION_TYPE, { subscriptionType });
|
|
118
|
+
}
|
|
119
|
+
|
|
120
|
+
this.onIFrameLoaded();
|
|
121
|
+
});
|
|
40
122
|
}
|
|
41
123
|
|
|
42
124
|
parseLinks() {
|
|
@@ -52,9 +134,7 @@ class Softphone {
|
|
|
52
134
|
makeCall(number ) {
|
|
53
135
|
this.displaySoftphone();
|
|
54
136
|
|
|
55
|
-
|
|
56
|
-
this.iframe.contentWindow.postMessage({ type: SDK_CLICK_TO_CALL, number }, '*');
|
|
57
|
-
}
|
|
137
|
+
this._sendMessage(SDK_CLICK_TO_CALL, { number });
|
|
58
138
|
}
|
|
59
139
|
|
|
60
140
|
toggleSoftphoneDisplay() {
|
|
@@ -63,8 +143,6 @@ class Softphone {
|
|
|
63
143
|
} else {
|
|
64
144
|
this.displaySoftphone();
|
|
65
145
|
}
|
|
66
|
-
|
|
67
|
-
this.displayed = !this.displayed;
|
|
68
146
|
}
|
|
69
147
|
|
|
70
148
|
displaySoftphone() {
|
|
@@ -75,15 +153,30 @@ class Softphone {
|
|
|
75
153
|
if (this.iframe) {
|
|
76
154
|
this.iframe.style.display = 'block';
|
|
77
155
|
}
|
|
156
|
+
|
|
157
|
+
this.displayed = true;
|
|
78
158
|
}
|
|
79
159
|
|
|
80
160
|
hideSoftphone() {
|
|
81
161
|
if (this.iframe) {
|
|
82
162
|
this.iframe.style.display = 'none';
|
|
83
163
|
}
|
|
164
|
+
this.displayed = false;
|
|
84
165
|
}
|
|
85
166
|
|
|
86
|
-
|
|
167
|
+
optionsFetched(fieldId , options ) {
|
|
168
|
+
this._sendMessage(BRIDGE_OPTIONS_FETCHED, { fieldId, options });
|
|
169
|
+
}
|
|
170
|
+
|
|
171
|
+
onOptionsResults(fieldId , options ) {
|
|
172
|
+
this._sendMessage(BRIDGE_OPTIONS_FOUND, { fieldId, options });
|
|
173
|
+
}
|
|
174
|
+
|
|
175
|
+
setFormSchema(schema , uiSchema ) {
|
|
176
|
+
this._sendMessage(BRIDGE_UPDATE_FORM_SCHEMA, { schema, uiSchema });
|
|
177
|
+
}
|
|
178
|
+
|
|
179
|
+
_createIframe(cb = () => {}) {
|
|
87
180
|
this.iframe = document.createElement('iframe');
|
|
88
181
|
// $FlowFixMe
|
|
89
182
|
this.iframe.width = this.width;
|
|
@@ -95,10 +188,13 @@ class Softphone {
|
|
|
95
188
|
this.iframe.style.left = '0';
|
|
96
189
|
this.iframe.style.bottom = '0';
|
|
97
190
|
this.iframe.style.border = '1px solid #aaa';
|
|
191
|
+
this.iframe.style.backgroundColor = 'white';
|
|
98
192
|
this.iframe.src = this.url;
|
|
99
193
|
this.iframe.style.display = 'none';
|
|
100
194
|
this.iframe.id = 'wazo-softphone';
|
|
101
195
|
|
|
196
|
+
this.iframe.onload = cb;
|
|
197
|
+
|
|
102
198
|
// $FlowFixMe
|
|
103
199
|
document.body.appendChild(this.iframe);
|
|
104
200
|
}
|
|
@@ -141,8 +237,93 @@ class Softphone {
|
|
|
141
237
|
this._onAuthenticated(event.data.session);
|
|
142
238
|
this.onAuthenticated(event.data.session);
|
|
143
239
|
break;
|
|
240
|
+
case SDK_LOGGED_OUT:
|
|
241
|
+
this.onLoggedOut();
|
|
242
|
+
break;
|
|
243
|
+
case BRIDGE_CREATE_OR_UPDATE_CARD: {
|
|
244
|
+
const { content } = event.data;
|
|
245
|
+
this.onCardSaved(content);
|
|
246
|
+
break;
|
|
247
|
+
}
|
|
248
|
+
case BRIDGE_SEARCH_OPTIONS: {
|
|
249
|
+
const { fieldId, query } = event.data;
|
|
250
|
+
this.onSearchOptions(fieldId, query);
|
|
251
|
+
break;
|
|
252
|
+
}
|
|
253
|
+
case BRIDGE_DISPLAY_LINKED_OPTION:
|
|
254
|
+
this.onDisplayLinkedOption(event.data.linkedOptionId);
|
|
255
|
+
break;
|
|
256
|
+
case BRIDGE_WAZO_CONTACT_SEARCH:
|
|
257
|
+
this.onWazoContactSearch(event.data.query);
|
|
258
|
+
break;
|
|
259
|
+
case BRIDGE_ON_AGENT_LOGGED_IN:
|
|
260
|
+
this.onAgentLoggedIn();
|
|
261
|
+
break;
|
|
262
|
+
case BRIDGE_ON_AGENT_LOGGED_OUT:
|
|
263
|
+
this.onAgentLoggedOut();
|
|
264
|
+
break;
|
|
265
|
+
case BRIDGE_ON_AGENT_PAUSED:
|
|
266
|
+
this.onAgentPaused();
|
|
267
|
+
break;
|
|
268
|
+
case BRIDGE_ON_AGENT_RESUMED:
|
|
269
|
+
this.onAgentResumed();
|
|
270
|
+
break;
|
|
271
|
+
case BRIDGE_ON_LANGUAGE_CHANGED:
|
|
272
|
+
this.onLanguageChanged(event.data.language);
|
|
273
|
+
break;
|
|
274
|
+
case BRIDGE_ON_CALL_HELD:
|
|
275
|
+
this.onCallHeld();
|
|
276
|
+
break;
|
|
277
|
+
case BRIDGE_ON_CALL_RESUMED:
|
|
278
|
+
this.onCallResumed();
|
|
279
|
+
break;
|
|
280
|
+
case BRIDGE_ON_CALL_MUTED:
|
|
281
|
+
this.onCallMuted();
|
|
282
|
+
break;
|
|
283
|
+
case BRIDGE_ON_CALL_UN_MUTED:
|
|
284
|
+
this.onCallUnMuted();
|
|
285
|
+
break;
|
|
286
|
+
case BRIDGE_ON_DTMF:
|
|
287
|
+
this.onDtmfSent(event.data.tone);
|
|
288
|
+
break;
|
|
289
|
+
case BRIDGE_ON_DIRECT_TRANSFER:
|
|
290
|
+
this.onDirectTransfer(event.data.number);
|
|
291
|
+
break;
|
|
292
|
+
case BRIDGE_ON_CREATE_INDIRECT_TRANSFER:
|
|
293
|
+
this.onCreateIndirectTransfer(event.data.number);
|
|
294
|
+
break;
|
|
295
|
+
case BRIDGE_ON_CANCEL_INDIRECT_TRANSFER:
|
|
296
|
+
this.onCancelIndirectTransfer();
|
|
297
|
+
break;
|
|
298
|
+
case BRIDGE_ON_CONFIRM_INDIRECT_TRANSFER:
|
|
299
|
+
this.onConfirmIndirectTransfer();
|
|
300
|
+
break;
|
|
301
|
+
case BRIDGE_ON_INDIRECT_TRANSFER_CALL_MADE:
|
|
302
|
+
this.onIndirectCallMade(event.data.call);
|
|
303
|
+
break;
|
|
304
|
+
case BRIDGE_ON_INDIRECT_TRANSFER_DONE:
|
|
305
|
+
this.onIndirectTransferDone(event.data.call);
|
|
306
|
+
break;
|
|
307
|
+
case BRIDGE_ON_START_RECORDING:
|
|
308
|
+
this.onStartRecording();
|
|
309
|
+
break;
|
|
310
|
+
case BRIDGE_ON_STOP_RECORDING:
|
|
311
|
+
this.onStopRecording();
|
|
312
|
+
break;
|
|
313
|
+
default:
|
|
314
|
+
this.onUnHandledEvent(event);
|
|
315
|
+
break;
|
|
144
316
|
}
|
|
145
317
|
}
|
|
318
|
+
|
|
319
|
+
_sendMessage(type , payload = {}) {
|
|
320
|
+
if (!this.iframe) {
|
|
321
|
+
console.warn(`Could not send message of type ${type} to the Wazo Softphone, iframe not created yet`);
|
|
322
|
+
return;
|
|
323
|
+
}
|
|
324
|
+
|
|
325
|
+
this.iframe.contentWindow.postMessage({ type, ...payload }, '*');
|
|
326
|
+
}
|
|
146
327
|
}
|
|
147
328
|
|
|
148
329
|
var Softphone$1 = new Softphone();
|
package/lib/simple/index.js
CHANGED
|
@@ -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();
|
|
@@ -13982,11 +13982,41 @@ class Checker {
|
|
|
13982
13982
|
//
|
|
13983
13983
|
/* eslint-disable no-unused-vars */
|
|
13984
13984
|
/* global window, document */
|
|
13985
|
+
const BRIDGE_CONFIG_RETRIEVED = 'bridge/CONFIG_RETRIEVED';
|
|
13986
|
+
const BRIDGE_ENABLE_CARD = 'bridge/ENABLE_CARD';
|
|
13987
|
+
const BRIDGE_CHANGE_REQUIRED_SUBSCRIPTION_TYPE = 'bridge/CHANGE_REQUIRED_SUBSCRIPTION_TYPE';
|
|
13988
|
+
const BRIDGE_CREATE_OR_UPDATE_CARD = 'bridge/BRIDGE_CREATE_OR_UPDATE_CARD';
|
|
13989
|
+
const BRIDGE_OPTIONS_FETCHED = 'bridge/BRIDGE_OPTIONS_FETCHED';
|
|
13990
|
+
const BRIDGE_OPTIONS_FOUND = 'bridge/BRIDGE_OPTIONS_FOUND';
|
|
13991
|
+
const BRIDGE_SEARCH_OPTIONS = 'bridge/BRIDGE_SEARCH_OPTIONS';
|
|
13992
|
+
const BRIDGE_DISPLAY_LINKED_OPTION = 'bridge/DISPLAY_LINKED_OPTION';
|
|
13993
|
+
const BRIDGE_UPDATE_FORM_SCHEMA = 'bridge/BRIDGE_UPDATE_FORM_SCHEMA';
|
|
13994
|
+
const BRIDGE_WAZO_CONTACT_SEARCH = 'bridge/BRIDGE_WAZO_CONTACT_SEARCH';
|
|
13995
|
+
const BRIDGE_ON_AGENT_LOGGED_IN = 'bridge/BRIDGE_ON_AGENT_LOGGED_IN';
|
|
13996
|
+
const BRIDGE_ON_AGENT_LOGGED_OUT = 'bridge/BRIDGE_ON_AGENT_LOGGED_OUT';
|
|
13997
|
+
const BRIDGE_ON_AGENT_PAUSED = 'bridge/BRIDGE_ON_AGENT_PAUSED';
|
|
13998
|
+
const BRIDGE_ON_AGENT_RESUMED = 'bridge/BRIDGE_ON_AGENT_RESUMED';
|
|
13999
|
+
const BRIDGE_ON_LANGUAGE_CHANGED = 'bridge/BRIDGE_ON_LANGUAGE_CHANGED';
|
|
14000
|
+
const BRIDGE_ON_CALL_HELD = 'bridge/BRIDGE_ON_CALL_HELD';
|
|
14001
|
+
const BRIDGE_ON_CALL_RESUMED = 'bridge/BRIDGE_ON_CALL_RESUMED';
|
|
14002
|
+
const BRIDGE_ON_CALL_MUTED = 'bridge/BRIDGE_ON_CALL_MUTED';
|
|
14003
|
+
const BRIDGE_ON_CALL_UN_MUTED = 'bridge/BRIDGE_ON_CALL_UN_MUTED';
|
|
14004
|
+
const BRIDGE_ON_DTMF = 'bridge/BRIDGE_ON_DTMF';
|
|
14005
|
+
const BRIDGE_ON_DIRECT_TRANSFER = 'bridge/BRIDGE_ON_DIRECT_TRANSFER';
|
|
14006
|
+
const BRIDGE_ON_CREATE_INDIRECT_TRANSFER = 'bridge/BRIDGE_ON_CREATE_INDIRECT_TRANSFER';
|
|
14007
|
+
const BRIDGE_ON_CANCEL_INDIRECT_TRANSFER = 'bridge/BRIDGE_ON_CANCEL_INDIRECT_TRANSFER';
|
|
14008
|
+
const BRIDGE_ON_CONFIRM_INDIRECT_TRANSFER = 'bridge/BRIDGE_ON_CONFIRM_INDIRECT_TRANSFER';
|
|
14009
|
+
const BRIDGE_ON_INDIRECT_TRANSFER_CALL_MADE = 'bridge/BRIDGE_ON_INDIRECT_TRANSFER_CALL_MADE';
|
|
14010
|
+
const BRIDGE_ON_INDIRECT_TRANSFER_DONE = 'bridge/BRIDGE_ON_INDIRECT_TRANSFER_DONE';
|
|
14011
|
+
const BRIDGE_ON_START_RECORDING = 'bridge/BRIDGE_ON_START_RECORDING';
|
|
14012
|
+
const BRIDGE_ON_STOP_RECORDING = 'bridge/BRIDGE_ON_STOP_RECORDING';
|
|
14013
|
+
|
|
13985
14014
|
const SDK_CLICK_TO_CALL = 'sdk/CLICK_TO_CALL';
|
|
13986
14015
|
const SDK_ON_CALL_MADE = 'sdk/SDK_ON_CALL_MADE';
|
|
13987
14016
|
const SDK_CALL_ENDED = 'sdk/ON_CALL_ENDED';
|
|
13988
14017
|
const SDK_CALL_INCOMING = 'sdk/SDK_CALL_INCOMING';
|
|
13989
14018
|
const SDK_AUTHENTICATED = 'sdk/SDK_AUTHENTICATED';
|
|
14019
|
+
const SDK_LOGGED_OUT = 'sdk/SDK_LOGGED_OUT';
|
|
13990
14020
|
|
|
13991
14021
|
class Softphone {
|
|
13992
14022
|
url = 'https://softphone.wazo.io';
|
|
@@ -13996,13 +14026,39 @@ class Softphone {
|
|
|
13996
14026
|
iframe = null;
|
|
13997
14027
|
|
|
13998
14028
|
onLinkEnabled(link ) {}
|
|
14029
|
+
onIFrameLoaded() {}
|
|
13999
14030
|
|
|
14000
14031
|
onCallMade(call ) {}
|
|
14001
14032
|
onCallIncoming(call ) {}
|
|
14002
14033
|
onCallEnded(call , card , direction , fromExtension ) {}
|
|
14034
|
+
onCardSaved(card ) {}
|
|
14003
14035
|
onAuthenticated(session ) {}
|
|
14004
|
-
|
|
14005
|
-
|
|
14036
|
+
onLoggedOut() {}
|
|
14037
|
+
onSearchOptions(fieldId , query ) {}
|
|
14038
|
+
onDisplayLinkedOption(optionId ) {}
|
|
14039
|
+
onWazoContactSearch(query ) {}
|
|
14040
|
+
onAgentLoggedIn() {}
|
|
14041
|
+
onAgentLoggedOut() {}
|
|
14042
|
+
onAgentPaused() {}
|
|
14043
|
+
onAgentResumed() {}
|
|
14044
|
+
onLanguageChanged(language ) {}
|
|
14045
|
+
onCallHeld() {}
|
|
14046
|
+
onCallResumed() {}
|
|
14047
|
+
onCallMuted() {}
|
|
14048
|
+
onCallUnMuted() {}
|
|
14049
|
+
onDtmfSent(tone ) {}
|
|
14050
|
+
onDirectTransfer(number ) {}
|
|
14051
|
+
onCreateIndirectTransfer(number ) {}
|
|
14052
|
+
onCancelIndirectTransfer() {}
|
|
14053
|
+
onConfirmIndirectTransfer() {}
|
|
14054
|
+
onIndirectCallMade(call ) {}
|
|
14055
|
+
onIndirectTransferDone(call ) {}
|
|
14056
|
+
onStartRecording() {}
|
|
14057
|
+
onStopRecording() {}
|
|
14058
|
+
onUnHandledEvent(event ) {}
|
|
14059
|
+
|
|
14060
|
+
init({ url, width, height, server, port, language, wrapUpDuration, shouldDisplayLinkedEntities,
|
|
14061
|
+
allowContactCreation, withCard, subscriptionType, enableAgent } = {}) {
|
|
14006
14062
|
if (url) {
|
|
14007
14063
|
this.url = url;
|
|
14008
14064
|
}
|
|
@@ -14015,7 +14071,33 @@ class Softphone {
|
|
|
14015
14071
|
|
|
14016
14072
|
window.addEventListener('message', this._onMessage.bind(this), false);
|
|
14017
14073
|
|
|
14018
|
-
|
|
14074
|
+
if (!server) {
|
|
14075
|
+
// eslint-disable-next-line no-param-reassign
|
|
14076
|
+
server = 'stack.dev.wazo.io';
|
|
14077
|
+
}
|
|
14078
|
+
|
|
14079
|
+
this._createIframe(() => {
|
|
14080
|
+
this._sendMessage(BRIDGE_CONFIG_RETRIEVED, {
|
|
14081
|
+
config: {
|
|
14082
|
+
server,
|
|
14083
|
+
port,
|
|
14084
|
+
language,
|
|
14085
|
+
wrapUpDuration,
|
|
14086
|
+
shouldDisplayLinkedEntities,
|
|
14087
|
+
allowContactCreation,
|
|
14088
|
+
},
|
|
14089
|
+
});
|
|
14090
|
+
|
|
14091
|
+
if (withCard) {
|
|
14092
|
+
this._sendMessage(BRIDGE_ENABLE_CARD);
|
|
14093
|
+
}
|
|
14094
|
+
|
|
14095
|
+
if (subscriptionType) {
|
|
14096
|
+
this._sendMessage(BRIDGE_CHANGE_REQUIRED_SUBSCRIPTION_TYPE, { subscriptionType });
|
|
14097
|
+
}
|
|
14098
|
+
|
|
14099
|
+
this.onIFrameLoaded();
|
|
14100
|
+
});
|
|
14019
14101
|
}
|
|
14020
14102
|
|
|
14021
14103
|
parseLinks() {
|
|
@@ -14031,9 +14113,7 @@ class Softphone {
|
|
|
14031
14113
|
makeCall(number ) {
|
|
14032
14114
|
this.displaySoftphone();
|
|
14033
14115
|
|
|
14034
|
-
|
|
14035
|
-
this.iframe.contentWindow.postMessage({ type: SDK_CLICK_TO_CALL, number }, '*');
|
|
14036
|
-
}
|
|
14116
|
+
this._sendMessage(SDK_CLICK_TO_CALL, { number });
|
|
14037
14117
|
}
|
|
14038
14118
|
|
|
14039
14119
|
toggleSoftphoneDisplay() {
|
|
@@ -14042,8 +14122,6 @@ class Softphone {
|
|
|
14042
14122
|
} else {
|
|
14043
14123
|
this.displaySoftphone();
|
|
14044
14124
|
}
|
|
14045
|
-
|
|
14046
|
-
this.displayed = !this.displayed;
|
|
14047
14125
|
}
|
|
14048
14126
|
|
|
14049
14127
|
displaySoftphone() {
|
|
@@ -14054,15 +14132,30 @@ class Softphone {
|
|
|
14054
14132
|
if (this.iframe) {
|
|
14055
14133
|
this.iframe.style.display = 'block';
|
|
14056
14134
|
}
|
|
14135
|
+
|
|
14136
|
+
this.displayed = true;
|
|
14057
14137
|
}
|
|
14058
14138
|
|
|
14059
14139
|
hideSoftphone() {
|
|
14060
14140
|
if (this.iframe) {
|
|
14061
14141
|
this.iframe.style.display = 'none';
|
|
14062
14142
|
}
|
|
14143
|
+
this.displayed = false;
|
|
14144
|
+
}
|
|
14145
|
+
|
|
14146
|
+
optionsFetched(fieldId , options ) {
|
|
14147
|
+
this._sendMessage(BRIDGE_OPTIONS_FETCHED, { fieldId, options });
|
|
14148
|
+
}
|
|
14149
|
+
|
|
14150
|
+
onOptionsResults(fieldId , options ) {
|
|
14151
|
+
this._sendMessage(BRIDGE_OPTIONS_FOUND, { fieldId, options });
|
|
14152
|
+
}
|
|
14153
|
+
|
|
14154
|
+
setFormSchema(schema , uiSchema ) {
|
|
14155
|
+
this._sendMessage(BRIDGE_UPDATE_FORM_SCHEMA, { schema, uiSchema });
|
|
14063
14156
|
}
|
|
14064
14157
|
|
|
14065
|
-
_createIframe() {
|
|
14158
|
+
_createIframe(cb = () => {}) {
|
|
14066
14159
|
this.iframe = document.createElement('iframe');
|
|
14067
14160
|
// $FlowFixMe
|
|
14068
14161
|
this.iframe.width = this.width;
|
|
@@ -14074,10 +14167,13 @@ class Softphone {
|
|
|
14074
14167
|
this.iframe.style.left = '0';
|
|
14075
14168
|
this.iframe.style.bottom = '0';
|
|
14076
14169
|
this.iframe.style.border = '1px solid #aaa';
|
|
14170
|
+
this.iframe.style.backgroundColor = 'white';
|
|
14077
14171
|
this.iframe.src = this.url;
|
|
14078
14172
|
this.iframe.style.display = 'none';
|
|
14079
14173
|
this.iframe.id = 'wazo-softphone';
|
|
14080
14174
|
|
|
14175
|
+
this.iframe.onload = cb;
|
|
14176
|
+
|
|
14081
14177
|
// $FlowFixMe
|
|
14082
14178
|
document.body.appendChild(this.iframe);
|
|
14083
14179
|
}
|
|
@@ -14120,8 +14216,93 @@ class Softphone {
|
|
|
14120
14216
|
this._onAuthenticated(event.data.session);
|
|
14121
14217
|
this.onAuthenticated(event.data.session);
|
|
14122
14218
|
break;
|
|
14219
|
+
case SDK_LOGGED_OUT:
|
|
14220
|
+
this.onLoggedOut();
|
|
14221
|
+
break;
|
|
14222
|
+
case BRIDGE_CREATE_OR_UPDATE_CARD: {
|
|
14223
|
+
const { content } = event.data;
|
|
14224
|
+
this.onCardSaved(content);
|
|
14225
|
+
break;
|
|
14226
|
+
}
|
|
14227
|
+
case BRIDGE_SEARCH_OPTIONS: {
|
|
14228
|
+
const { fieldId, query } = event.data;
|
|
14229
|
+
this.onSearchOptions(fieldId, query);
|
|
14230
|
+
break;
|
|
14231
|
+
}
|
|
14232
|
+
case BRIDGE_DISPLAY_LINKED_OPTION:
|
|
14233
|
+
this.onDisplayLinkedOption(event.data.linkedOptionId);
|
|
14234
|
+
break;
|
|
14235
|
+
case BRIDGE_WAZO_CONTACT_SEARCH:
|
|
14236
|
+
this.onWazoContactSearch(event.data.query);
|
|
14237
|
+
break;
|
|
14238
|
+
case BRIDGE_ON_AGENT_LOGGED_IN:
|
|
14239
|
+
this.onAgentLoggedIn();
|
|
14240
|
+
break;
|
|
14241
|
+
case BRIDGE_ON_AGENT_LOGGED_OUT:
|
|
14242
|
+
this.onAgentLoggedOut();
|
|
14243
|
+
break;
|
|
14244
|
+
case BRIDGE_ON_AGENT_PAUSED:
|
|
14245
|
+
this.onAgentPaused();
|
|
14246
|
+
break;
|
|
14247
|
+
case BRIDGE_ON_AGENT_RESUMED:
|
|
14248
|
+
this.onAgentResumed();
|
|
14249
|
+
break;
|
|
14250
|
+
case BRIDGE_ON_LANGUAGE_CHANGED:
|
|
14251
|
+
this.onLanguageChanged(event.data.language);
|
|
14252
|
+
break;
|
|
14253
|
+
case BRIDGE_ON_CALL_HELD:
|
|
14254
|
+
this.onCallHeld();
|
|
14255
|
+
break;
|
|
14256
|
+
case BRIDGE_ON_CALL_RESUMED:
|
|
14257
|
+
this.onCallResumed();
|
|
14258
|
+
break;
|
|
14259
|
+
case BRIDGE_ON_CALL_MUTED:
|
|
14260
|
+
this.onCallMuted();
|
|
14261
|
+
break;
|
|
14262
|
+
case BRIDGE_ON_CALL_UN_MUTED:
|
|
14263
|
+
this.onCallUnMuted();
|
|
14264
|
+
break;
|
|
14265
|
+
case BRIDGE_ON_DTMF:
|
|
14266
|
+
this.onDtmfSent(event.data.tone);
|
|
14267
|
+
break;
|
|
14268
|
+
case BRIDGE_ON_DIRECT_TRANSFER:
|
|
14269
|
+
this.onDirectTransfer(event.data.number);
|
|
14270
|
+
break;
|
|
14271
|
+
case BRIDGE_ON_CREATE_INDIRECT_TRANSFER:
|
|
14272
|
+
this.onCreateIndirectTransfer(event.data.number);
|
|
14273
|
+
break;
|
|
14274
|
+
case BRIDGE_ON_CANCEL_INDIRECT_TRANSFER:
|
|
14275
|
+
this.onCancelIndirectTransfer();
|
|
14276
|
+
break;
|
|
14277
|
+
case BRIDGE_ON_CONFIRM_INDIRECT_TRANSFER:
|
|
14278
|
+
this.onConfirmIndirectTransfer();
|
|
14279
|
+
break;
|
|
14280
|
+
case BRIDGE_ON_INDIRECT_TRANSFER_CALL_MADE:
|
|
14281
|
+
this.onIndirectCallMade(event.data.call);
|
|
14282
|
+
break;
|
|
14283
|
+
case BRIDGE_ON_INDIRECT_TRANSFER_DONE:
|
|
14284
|
+
this.onIndirectTransferDone(event.data.call);
|
|
14285
|
+
break;
|
|
14286
|
+
case BRIDGE_ON_START_RECORDING:
|
|
14287
|
+
this.onStartRecording();
|
|
14288
|
+
break;
|
|
14289
|
+
case BRIDGE_ON_STOP_RECORDING:
|
|
14290
|
+
this.onStopRecording();
|
|
14291
|
+
break;
|
|
14292
|
+
default:
|
|
14293
|
+
this.onUnHandledEvent(event);
|
|
14294
|
+
break;
|
|
14123
14295
|
}
|
|
14124
14296
|
}
|
|
14297
|
+
|
|
14298
|
+
_sendMessage(type , payload = {}) {
|
|
14299
|
+
if (!this.iframe) {
|
|
14300
|
+
console.warn(`Could not send message of type ${type} to the Wazo Softphone, iframe not created yet`);
|
|
14301
|
+
return;
|
|
14302
|
+
}
|
|
14303
|
+
|
|
14304
|
+
this.iframe.contentWindow.postMessage({ type, ...payload }, '*');
|
|
14305
|
+
}
|
|
14125
14306
|
}
|
|
14126
14307
|
|
|
14127
14308
|
var Softphone$1 = new Softphone();
|