@wazo/sdk 0.38.1 → 0.38.4
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 +82 -7
- package/dist/wazo-sdk.js +5 -5
- package/esm/index.js +103 -42
- package/esm/simple/Auth.js +103 -42
- package/esm/simple/Configuration.js +103 -42
- package/esm/simple/Phone.js +103 -42
- package/esm/simple/Softphone.js +104 -43
- package/esm/simple/index.js +103 -42
- package/esm/simple/room/LocalParticipant.js +103 -42
- package/esm/simple/room/Participant.js +103 -42
- package/esm/simple/room/RemoteParticipant.js +103 -42
- package/esm/simple/room/Room.js +103 -42
- package/esm/simple/room/SipRoom.js +103 -42
- package/esm/simple/room/Stream.js +103 -42
- package/esm/simple/room/__tests__/RemoteParticipant.test.js +103 -42
- package/esm/simple/utils.js +103 -42
- package/lib/index.js +103 -42
- package/lib/simple/Auth.js +103 -42
- package/lib/simple/Configuration.js +103 -42
- package/lib/simple/Phone.js +103 -42
- package/lib/simple/Softphone.js +104 -43
- package/lib/simple/index.js +103 -42
- package/lib/simple/room/LocalParticipant.js +103 -42
- package/lib/simple/room/Participant.js +103 -42
- package/lib/simple/room/RemoteParticipant.js +103 -42
- package/lib/simple/room/Room.js +103 -42
- package/lib/simple/room/SipRoom.js +103 -42
- package/lib/simple/room/Stream.js +103 -42
- package/lib/simple/room/__tests__/RemoteParticipant.test.js +103 -42
- package/lib/simple/utils.js +103 -42
- package/package.json +1 -1
- package/src/simple/Softphone.js +104 -43
package/lib/simple/Softphone.js
CHANGED
|
@@ -4,8 +4,6 @@
|
|
|
4
4
|
/* eslint-disable no-unused-vars */
|
|
5
5
|
/* global window, document */
|
|
6
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
7
|
const BRIDGE_CREATE_OR_UPDATE_CARD = 'bridge/BRIDGE_CREATE_OR_UPDATE_CARD';
|
|
10
8
|
const BRIDGE_OPTIONS_FETCHED = 'bridge/BRIDGE_OPTIONS_FETCHED';
|
|
11
9
|
const BRIDGE_OPTIONS_FOUND = 'bridge/BRIDGE_OPTIONS_FOUND';
|
|
@@ -18,6 +16,9 @@ const BRIDGE_ON_AGENT_LOGGED_OUT = 'bridge/BRIDGE_ON_AGENT_LOGGED_OUT';
|
|
|
18
16
|
const BRIDGE_ON_AGENT_PAUSED = 'bridge/BRIDGE_ON_AGENT_PAUSED';
|
|
19
17
|
const BRIDGE_ON_AGENT_RESUMED = 'bridge/BRIDGE_ON_AGENT_RESUMED';
|
|
20
18
|
const BRIDGE_ON_LANGUAGE_CHANGED = 'bridge/BRIDGE_ON_LANGUAGE_CHANGED';
|
|
19
|
+
const BRIDGE_ON_CALL_LOCALLY_ACCEPTED = 'bridge/BRIDGE_ON_CALL_LOCALLY_ACCEPTED';
|
|
20
|
+
const BRIDGE_ON_CALL_REJECTED = 'bridge/BRIDGE_ON_CALL_REJECTED';
|
|
21
|
+
const BRIDGE_ON_CALL_ESTABLISHED = 'bridge/BRIDGE_ON_CALL_ESTABLISHED';
|
|
21
22
|
const BRIDGE_ON_CALL_HELD = 'bridge/BRIDGE_ON_CALL_HELD';
|
|
22
23
|
const BRIDGE_ON_CALL_RESUMED = 'bridge/BRIDGE_ON_CALL_RESUMED';
|
|
23
24
|
const BRIDGE_ON_CALL_MUTED = 'bridge/BRIDGE_ON_CALL_MUTED';
|
|
@@ -31,31 +32,51 @@ const BRIDGE_ON_INDIRECT_TRANSFER_CALL_MADE = 'bridge/BRIDGE_ON_INDIRECT_TRANSFE
|
|
|
31
32
|
const BRIDGE_ON_INDIRECT_TRANSFER_DONE = 'bridge/BRIDGE_ON_INDIRECT_TRANSFER_DONE';
|
|
32
33
|
const BRIDGE_ON_START_RECORDING = 'bridge/BRIDGE_ON_START_RECORDING';
|
|
33
34
|
const BRIDGE_ON_STOP_RECORDING = 'bridge/BRIDGE_ON_STOP_RECORDING';
|
|
35
|
+
const BRIDGE_ON_CARD_CANCELED = 'bridge/BRIDGE_ON_CARD_CANCELED';
|
|
36
|
+
const BRIDGE_ENABLE_AGENT = 'bridge/BRIDGE_ENABLE_AGENT';
|
|
37
|
+
const BRIDGE_SET_CARD_CONTENT = 'bridge/BRIDGE_SET_CARD_CONTENT';
|
|
38
|
+
const BRIDGE_ENABLE_DEBUG = 'bridge/BRIDGE_ENABLE_DEBUG';
|
|
39
|
+
|
|
40
|
+
const BRIDGE_INJECT_CSS = 'bridge/BRIDGE_INJECT_CSS';
|
|
41
|
+
const BRIDGE_CUSTOMIZE_APPEARANCE = 'bridge/BRIDGE_CUSTOMIZE_APPEARANCE';
|
|
34
42
|
|
|
35
43
|
const SDK_CLICK_TO_CALL = 'sdk/CLICK_TO_CALL';
|
|
36
|
-
const
|
|
44
|
+
const SDK_ON_OUTGOING_CALL_MADE = 'sdk/SDK_ON_OUTGOING_CALL_MADE';
|
|
37
45
|
const SDK_CALL_ENDED = 'sdk/ON_CALL_ENDED';
|
|
38
46
|
const SDK_CALL_INCOMING = 'sdk/SDK_CALL_INCOMING';
|
|
39
47
|
const SDK_AUTHENTICATED = 'sdk/SDK_AUTHENTICATED';
|
|
40
48
|
const SDK_LOGGED_OUT = 'sdk/SDK_LOGGED_OUT';
|
|
41
49
|
|
|
42
50
|
class Softphone {
|
|
43
|
-
|
|
44
|
-
|
|
45
|
-
|
|
46
|
-
|
|
47
|
-
|
|
51
|
+
|
|
52
|
+
|
|
53
|
+
|
|
54
|
+
|
|
55
|
+
|
|
56
|
+
|
|
57
|
+
|
|
58
|
+
// Message waiting for the iframe to be loaded
|
|
59
|
+
|
|
48
60
|
|
|
49
61
|
onLinkEnabled(link ) {}
|
|
50
62
|
onIFrameLoaded() {}
|
|
51
63
|
|
|
52
|
-
|
|
64
|
+
onCallLocallyAnswered(call ) {}
|
|
65
|
+
onCallEstablished(call ) {}
|
|
66
|
+
onOutgoingCallMade(call ) {}
|
|
53
67
|
onCallIncoming(call ) {}
|
|
68
|
+
onCallRejected(call ) {}
|
|
54
69
|
onCallEnded(call , card , direction , fromExtension ) {}
|
|
70
|
+
|
|
55
71
|
onCardSaved(card ) {}
|
|
72
|
+
onCardCanceled() {}
|
|
56
73
|
onAuthenticated(session ) {}
|
|
57
74
|
onLoggedOut() {}
|
|
58
|
-
|
|
75
|
+
|
|
76
|
+
onSearchOptions(fieldId , query ) {
|
|
77
|
+
this.onOptionsResults(fieldId, []);
|
|
78
|
+
}
|
|
79
|
+
|
|
59
80
|
onDisplayLinkedOption(optionId ) {}
|
|
60
81
|
onWazoContactSearch(query ) {}
|
|
61
82
|
onAgentLoggedIn() {}
|
|
@@ -78,18 +99,26 @@ class Softphone {
|
|
|
78
99
|
onStopRecording() {}
|
|
79
100
|
onUnHandledEvent(event ) {}
|
|
80
101
|
|
|
81
|
-
init({
|
|
82
|
-
|
|
83
|
-
|
|
84
|
-
|
|
85
|
-
|
|
86
|
-
|
|
87
|
-
|
|
88
|
-
|
|
89
|
-
|
|
90
|
-
|
|
91
|
-
|
|
102
|
+
init({
|
|
103
|
+
url,
|
|
104
|
+
width,
|
|
105
|
+
height,
|
|
106
|
+
server,
|
|
107
|
+
port,
|
|
108
|
+
language,
|
|
109
|
+
wrapUpDuration,
|
|
110
|
+
enableAgent = true,
|
|
111
|
+
tenantId,
|
|
112
|
+
debug = false,
|
|
113
|
+
} = {}) {
|
|
114
|
+
this.url = url || 'https://softphone.wazo.io';
|
|
115
|
+
this.width = width || 500;
|
|
116
|
+
this.height = height || 600;
|
|
117
|
+
this.displayed = false;
|
|
118
|
+
this.iframeLoaded = false;
|
|
92
119
|
|
|
120
|
+
this.iframeLoaded = false;
|
|
121
|
+
this._pendingMessages = [];
|
|
93
122
|
window.addEventListener('message', this._onMessage.bind(this), false);
|
|
94
123
|
|
|
95
124
|
if (!server) {
|
|
@@ -97,25 +126,33 @@ class Softphone {
|
|
|
97
126
|
server = 'stack.dev.wazo.io';
|
|
98
127
|
}
|
|
99
128
|
|
|
100
|
-
|
|
101
|
-
|
|
102
|
-
|
|
103
|
-
|
|
104
|
-
|
|
105
|
-
|
|
106
|
-
|
|
107
|
-
|
|
108
|
-
|
|
109
|
-
|
|
110
|
-
|
|
111
|
-
|
|
112
|
-
|
|
113
|
-
this._sendMessage(BRIDGE_ENABLE_CARD);
|
|
114
|
-
}
|
|
129
|
+
const config = { server };
|
|
130
|
+
if (language) {
|
|
131
|
+
config.language = language;
|
|
132
|
+
}
|
|
133
|
+
if (port) {
|
|
134
|
+
config.port = port;
|
|
135
|
+
}
|
|
136
|
+
if (tenantId) {
|
|
137
|
+
config.tenantId = tenantId;
|
|
138
|
+
}
|
|
139
|
+
if (wrapUpDuration) {
|
|
140
|
+
config.wrapUpDuration = wrapUpDuration;
|
|
141
|
+
}
|
|
115
142
|
|
|
116
|
-
|
|
117
|
-
|
|
118
|
-
|
|
143
|
+
this._sendMessage(BRIDGE_CONFIG_RETRIEVED, { config });
|
|
144
|
+
|
|
145
|
+
if (enableAgent) {
|
|
146
|
+
this._sendMessage(BRIDGE_ENABLE_AGENT);
|
|
147
|
+
}
|
|
148
|
+
|
|
149
|
+
if (debug) {
|
|
150
|
+
this._sendMessage(BRIDGE_ENABLE_DEBUG);
|
|
151
|
+
}
|
|
152
|
+
|
|
153
|
+
this._createIframe(() => {
|
|
154
|
+
this.iframeLoaded = true;
|
|
155
|
+
this._pendingMessages.forEach(([type, payload]) => this._sendMessage(type, payload));
|
|
119
156
|
|
|
120
157
|
this.onIFrameLoaded();
|
|
121
158
|
});
|
|
@@ -176,6 +213,18 @@ class Softphone {
|
|
|
176
213
|
this._sendMessage(BRIDGE_UPDATE_FORM_SCHEMA, { schema, uiSchema });
|
|
177
214
|
}
|
|
178
215
|
|
|
216
|
+
setCardValue(field , value ) {
|
|
217
|
+
this._sendMessage(BRIDGE_SET_CARD_CONTENT, { field, value });
|
|
218
|
+
}
|
|
219
|
+
|
|
220
|
+
injectCss(css ) {
|
|
221
|
+
this._sendMessage(BRIDGE_INJECT_CSS, { css });
|
|
222
|
+
}
|
|
223
|
+
|
|
224
|
+
customizeAppearance(themes , translations , assets ) {
|
|
225
|
+
this._sendMessage(BRIDGE_CUSTOMIZE_APPEARANCE, { themes, translations, assets });
|
|
226
|
+
}
|
|
227
|
+
|
|
179
228
|
_createIframe(cb = () => {}) {
|
|
180
229
|
this.iframe = document.createElement('iframe');
|
|
181
230
|
// $FlowFixMe
|
|
@@ -221,8 +270,8 @@ class Softphone {
|
|
|
221
270
|
}
|
|
222
271
|
|
|
223
272
|
switch (event.data.type) {
|
|
224
|
-
case
|
|
225
|
-
this.
|
|
273
|
+
case SDK_ON_OUTGOING_CALL_MADE:
|
|
274
|
+
this.onOutgoingCallMade(event.data.callSession);
|
|
226
275
|
break;
|
|
227
276
|
case SDK_CALL_ENDED: {
|
|
228
277
|
const { callSession, content, direction, userExtension } = event.data;
|
|
@@ -310,6 +359,18 @@ class Softphone {
|
|
|
310
359
|
case BRIDGE_ON_STOP_RECORDING:
|
|
311
360
|
this.onStopRecording();
|
|
312
361
|
break;
|
|
362
|
+
case BRIDGE_ON_CARD_CANCELED:
|
|
363
|
+
this.onCardCanceled();
|
|
364
|
+
break;
|
|
365
|
+
case BRIDGE_ON_CALL_LOCALLY_ACCEPTED:
|
|
366
|
+
this.onCallLocallyAnswered(event.data.call);
|
|
367
|
+
break;
|
|
368
|
+
case BRIDGE_ON_CALL_REJECTED:
|
|
369
|
+
this.onCallRejected(event.data.call);
|
|
370
|
+
break;
|
|
371
|
+
case BRIDGE_ON_CALL_ESTABLISHED:
|
|
372
|
+
this.onCallEstablished(event.data.call);
|
|
373
|
+
break;
|
|
313
374
|
default:
|
|
314
375
|
this.onUnHandledEvent(event);
|
|
315
376
|
break;
|
|
@@ -317,8 +378,8 @@ class Softphone {
|
|
|
317
378
|
}
|
|
318
379
|
|
|
319
380
|
_sendMessage(type , payload = {}) {
|
|
320
|
-
if (!this.iframe) {
|
|
321
|
-
|
|
381
|
+
if (!this.iframe || !this.iframeLoaded) {
|
|
382
|
+
this._pendingMessages.push([type, payload]);
|
|
322
383
|
return;
|
|
323
384
|
}
|
|
324
385
|
|
package/lib/simple/index.js
CHANGED
|
@@ -13983,8 +13983,6 @@ class Checker {
|
|
|
13983
13983
|
/* eslint-disable no-unused-vars */
|
|
13984
13984
|
/* global window, document */
|
|
13985
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
13986
|
const BRIDGE_CREATE_OR_UPDATE_CARD = 'bridge/BRIDGE_CREATE_OR_UPDATE_CARD';
|
|
13989
13987
|
const BRIDGE_OPTIONS_FETCHED = 'bridge/BRIDGE_OPTIONS_FETCHED';
|
|
13990
13988
|
const BRIDGE_OPTIONS_FOUND = 'bridge/BRIDGE_OPTIONS_FOUND';
|
|
@@ -13997,6 +13995,9 @@ const BRIDGE_ON_AGENT_LOGGED_OUT = 'bridge/BRIDGE_ON_AGENT_LOGGED_OUT';
|
|
|
13997
13995
|
const BRIDGE_ON_AGENT_PAUSED = 'bridge/BRIDGE_ON_AGENT_PAUSED';
|
|
13998
13996
|
const BRIDGE_ON_AGENT_RESUMED = 'bridge/BRIDGE_ON_AGENT_RESUMED';
|
|
13999
13997
|
const BRIDGE_ON_LANGUAGE_CHANGED = 'bridge/BRIDGE_ON_LANGUAGE_CHANGED';
|
|
13998
|
+
const BRIDGE_ON_CALL_LOCALLY_ACCEPTED = 'bridge/BRIDGE_ON_CALL_LOCALLY_ACCEPTED';
|
|
13999
|
+
const BRIDGE_ON_CALL_REJECTED = 'bridge/BRIDGE_ON_CALL_REJECTED';
|
|
14000
|
+
const BRIDGE_ON_CALL_ESTABLISHED = 'bridge/BRIDGE_ON_CALL_ESTABLISHED';
|
|
14000
14001
|
const BRIDGE_ON_CALL_HELD = 'bridge/BRIDGE_ON_CALL_HELD';
|
|
14001
14002
|
const BRIDGE_ON_CALL_RESUMED = 'bridge/BRIDGE_ON_CALL_RESUMED';
|
|
14002
14003
|
const BRIDGE_ON_CALL_MUTED = 'bridge/BRIDGE_ON_CALL_MUTED';
|
|
@@ -14010,31 +14011,51 @@ const BRIDGE_ON_INDIRECT_TRANSFER_CALL_MADE = 'bridge/BRIDGE_ON_INDIRECT_TRANSFE
|
|
|
14010
14011
|
const BRIDGE_ON_INDIRECT_TRANSFER_DONE = 'bridge/BRIDGE_ON_INDIRECT_TRANSFER_DONE';
|
|
14011
14012
|
const BRIDGE_ON_START_RECORDING = 'bridge/BRIDGE_ON_START_RECORDING';
|
|
14012
14013
|
const BRIDGE_ON_STOP_RECORDING = 'bridge/BRIDGE_ON_STOP_RECORDING';
|
|
14014
|
+
const BRIDGE_ON_CARD_CANCELED = 'bridge/BRIDGE_ON_CARD_CANCELED';
|
|
14015
|
+
const BRIDGE_ENABLE_AGENT = 'bridge/BRIDGE_ENABLE_AGENT';
|
|
14016
|
+
const BRIDGE_SET_CARD_CONTENT = 'bridge/BRIDGE_SET_CARD_CONTENT';
|
|
14017
|
+
const BRIDGE_ENABLE_DEBUG = 'bridge/BRIDGE_ENABLE_DEBUG';
|
|
14018
|
+
|
|
14019
|
+
const BRIDGE_INJECT_CSS = 'bridge/BRIDGE_INJECT_CSS';
|
|
14020
|
+
const BRIDGE_CUSTOMIZE_APPEARANCE = 'bridge/BRIDGE_CUSTOMIZE_APPEARANCE';
|
|
14013
14021
|
|
|
14014
14022
|
const SDK_CLICK_TO_CALL = 'sdk/CLICK_TO_CALL';
|
|
14015
|
-
const
|
|
14023
|
+
const SDK_ON_OUTGOING_CALL_MADE = 'sdk/SDK_ON_OUTGOING_CALL_MADE';
|
|
14016
14024
|
const SDK_CALL_ENDED = 'sdk/ON_CALL_ENDED';
|
|
14017
14025
|
const SDK_CALL_INCOMING = 'sdk/SDK_CALL_INCOMING';
|
|
14018
14026
|
const SDK_AUTHENTICATED = 'sdk/SDK_AUTHENTICATED';
|
|
14019
14027
|
const SDK_LOGGED_OUT = 'sdk/SDK_LOGGED_OUT';
|
|
14020
14028
|
|
|
14021
14029
|
class Softphone {
|
|
14022
|
-
|
|
14023
|
-
|
|
14024
|
-
|
|
14025
|
-
|
|
14026
|
-
|
|
14030
|
+
|
|
14031
|
+
|
|
14032
|
+
|
|
14033
|
+
|
|
14034
|
+
|
|
14035
|
+
|
|
14036
|
+
|
|
14037
|
+
// Message waiting for the iframe to be loaded
|
|
14038
|
+
|
|
14027
14039
|
|
|
14028
14040
|
onLinkEnabled(link ) {}
|
|
14029
14041
|
onIFrameLoaded() {}
|
|
14030
14042
|
|
|
14031
|
-
|
|
14043
|
+
onCallLocallyAnswered(call ) {}
|
|
14044
|
+
onCallEstablished(call ) {}
|
|
14045
|
+
onOutgoingCallMade(call ) {}
|
|
14032
14046
|
onCallIncoming(call ) {}
|
|
14047
|
+
onCallRejected(call ) {}
|
|
14033
14048
|
onCallEnded(call , card , direction , fromExtension ) {}
|
|
14049
|
+
|
|
14034
14050
|
onCardSaved(card ) {}
|
|
14051
|
+
onCardCanceled() {}
|
|
14035
14052
|
onAuthenticated(session ) {}
|
|
14036
14053
|
onLoggedOut() {}
|
|
14037
|
-
|
|
14054
|
+
|
|
14055
|
+
onSearchOptions(fieldId , query ) {
|
|
14056
|
+
this.onOptionsResults(fieldId, []);
|
|
14057
|
+
}
|
|
14058
|
+
|
|
14038
14059
|
onDisplayLinkedOption(optionId ) {}
|
|
14039
14060
|
onWazoContactSearch(query ) {}
|
|
14040
14061
|
onAgentLoggedIn() {}
|
|
@@ -14057,18 +14078,26 @@ class Softphone {
|
|
|
14057
14078
|
onStopRecording() {}
|
|
14058
14079
|
onUnHandledEvent(event ) {}
|
|
14059
14080
|
|
|
14060
|
-
init({
|
|
14061
|
-
|
|
14062
|
-
|
|
14063
|
-
|
|
14064
|
-
|
|
14065
|
-
|
|
14066
|
-
|
|
14067
|
-
|
|
14068
|
-
|
|
14069
|
-
|
|
14070
|
-
|
|
14081
|
+
init({
|
|
14082
|
+
url,
|
|
14083
|
+
width,
|
|
14084
|
+
height,
|
|
14085
|
+
server,
|
|
14086
|
+
port,
|
|
14087
|
+
language,
|
|
14088
|
+
wrapUpDuration,
|
|
14089
|
+
enableAgent = true,
|
|
14090
|
+
tenantId,
|
|
14091
|
+
debug = false,
|
|
14092
|
+
} = {}) {
|
|
14093
|
+
this.url = url || 'https://softphone.wazo.io';
|
|
14094
|
+
this.width = width || 500;
|
|
14095
|
+
this.height = height || 600;
|
|
14096
|
+
this.displayed = false;
|
|
14097
|
+
this.iframeLoaded = false;
|
|
14071
14098
|
|
|
14099
|
+
this.iframeLoaded = false;
|
|
14100
|
+
this._pendingMessages = [];
|
|
14072
14101
|
window.addEventListener('message', this._onMessage.bind(this), false);
|
|
14073
14102
|
|
|
14074
14103
|
if (!server) {
|
|
@@ -14076,25 +14105,33 @@ class Softphone {
|
|
|
14076
14105
|
server = 'stack.dev.wazo.io';
|
|
14077
14106
|
}
|
|
14078
14107
|
|
|
14079
|
-
|
|
14080
|
-
|
|
14081
|
-
|
|
14082
|
-
|
|
14083
|
-
|
|
14084
|
-
|
|
14085
|
-
|
|
14086
|
-
|
|
14087
|
-
|
|
14088
|
-
|
|
14089
|
-
|
|
14108
|
+
const config = { server };
|
|
14109
|
+
if (language) {
|
|
14110
|
+
config.language = language;
|
|
14111
|
+
}
|
|
14112
|
+
if (port) {
|
|
14113
|
+
config.port = port;
|
|
14114
|
+
}
|
|
14115
|
+
if (tenantId) {
|
|
14116
|
+
config.tenantId = tenantId;
|
|
14117
|
+
}
|
|
14118
|
+
if (wrapUpDuration) {
|
|
14119
|
+
config.wrapUpDuration = wrapUpDuration;
|
|
14120
|
+
}
|
|
14090
14121
|
|
|
14091
|
-
|
|
14092
|
-
this._sendMessage(BRIDGE_ENABLE_CARD);
|
|
14093
|
-
}
|
|
14122
|
+
this._sendMessage(BRIDGE_CONFIG_RETRIEVED, { config });
|
|
14094
14123
|
|
|
14095
|
-
|
|
14096
|
-
|
|
14097
|
-
|
|
14124
|
+
if (enableAgent) {
|
|
14125
|
+
this._sendMessage(BRIDGE_ENABLE_AGENT);
|
|
14126
|
+
}
|
|
14127
|
+
|
|
14128
|
+
if (debug) {
|
|
14129
|
+
this._sendMessage(BRIDGE_ENABLE_DEBUG);
|
|
14130
|
+
}
|
|
14131
|
+
|
|
14132
|
+
this._createIframe(() => {
|
|
14133
|
+
this.iframeLoaded = true;
|
|
14134
|
+
this._pendingMessages.forEach(([type, payload]) => this._sendMessage(type, payload));
|
|
14098
14135
|
|
|
14099
14136
|
this.onIFrameLoaded();
|
|
14100
14137
|
});
|
|
@@ -14155,6 +14192,18 @@ class Softphone {
|
|
|
14155
14192
|
this._sendMessage(BRIDGE_UPDATE_FORM_SCHEMA, { schema, uiSchema });
|
|
14156
14193
|
}
|
|
14157
14194
|
|
|
14195
|
+
setCardValue(field , value ) {
|
|
14196
|
+
this._sendMessage(BRIDGE_SET_CARD_CONTENT, { field, value });
|
|
14197
|
+
}
|
|
14198
|
+
|
|
14199
|
+
injectCss(css ) {
|
|
14200
|
+
this._sendMessage(BRIDGE_INJECT_CSS, { css });
|
|
14201
|
+
}
|
|
14202
|
+
|
|
14203
|
+
customizeAppearance(themes , translations , assets ) {
|
|
14204
|
+
this._sendMessage(BRIDGE_CUSTOMIZE_APPEARANCE, { themes, translations, assets });
|
|
14205
|
+
}
|
|
14206
|
+
|
|
14158
14207
|
_createIframe(cb = () => {}) {
|
|
14159
14208
|
this.iframe = document.createElement('iframe');
|
|
14160
14209
|
// $FlowFixMe
|
|
@@ -14200,8 +14249,8 @@ class Softphone {
|
|
|
14200
14249
|
}
|
|
14201
14250
|
|
|
14202
14251
|
switch (event.data.type) {
|
|
14203
|
-
case
|
|
14204
|
-
this.
|
|
14252
|
+
case SDK_ON_OUTGOING_CALL_MADE:
|
|
14253
|
+
this.onOutgoingCallMade(event.data.callSession);
|
|
14205
14254
|
break;
|
|
14206
14255
|
case SDK_CALL_ENDED: {
|
|
14207
14256
|
const { callSession, content, direction, userExtension } = event.data;
|
|
@@ -14289,6 +14338,18 @@ class Softphone {
|
|
|
14289
14338
|
case BRIDGE_ON_STOP_RECORDING:
|
|
14290
14339
|
this.onStopRecording();
|
|
14291
14340
|
break;
|
|
14341
|
+
case BRIDGE_ON_CARD_CANCELED:
|
|
14342
|
+
this.onCardCanceled();
|
|
14343
|
+
break;
|
|
14344
|
+
case BRIDGE_ON_CALL_LOCALLY_ACCEPTED:
|
|
14345
|
+
this.onCallLocallyAnswered(event.data.call);
|
|
14346
|
+
break;
|
|
14347
|
+
case BRIDGE_ON_CALL_REJECTED:
|
|
14348
|
+
this.onCallRejected(event.data.call);
|
|
14349
|
+
break;
|
|
14350
|
+
case BRIDGE_ON_CALL_ESTABLISHED:
|
|
14351
|
+
this.onCallEstablished(event.data.call);
|
|
14352
|
+
break;
|
|
14292
14353
|
default:
|
|
14293
14354
|
this.onUnHandledEvent(event);
|
|
14294
14355
|
break;
|
|
@@ -14296,8 +14357,8 @@ class Softphone {
|
|
|
14296
14357
|
}
|
|
14297
14358
|
|
|
14298
14359
|
_sendMessage(type , payload = {}) {
|
|
14299
|
-
if (!this.iframe) {
|
|
14300
|
-
|
|
14360
|
+
if (!this.iframe || !this.iframeLoaded) {
|
|
14361
|
+
this._pendingMessages.push([type, payload]);
|
|
14301
14362
|
return;
|
|
14302
14363
|
}
|
|
14303
14364
|
|
|
@@ -12852,8 +12852,6 @@ class Checker {
|
|
|
12852
12852
|
/* eslint-disable no-unused-vars */
|
|
12853
12853
|
/* global window, document */
|
|
12854
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
12855
|
const BRIDGE_CREATE_OR_UPDATE_CARD = 'bridge/BRIDGE_CREATE_OR_UPDATE_CARD';
|
|
12858
12856
|
const BRIDGE_OPTIONS_FETCHED = 'bridge/BRIDGE_OPTIONS_FETCHED';
|
|
12859
12857
|
const BRIDGE_OPTIONS_FOUND = 'bridge/BRIDGE_OPTIONS_FOUND';
|
|
@@ -12866,6 +12864,9 @@ const BRIDGE_ON_AGENT_LOGGED_OUT = 'bridge/BRIDGE_ON_AGENT_LOGGED_OUT';
|
|
|
12866
12864
|
const BRIDGE_ON_AGENT_PAUSED = 'bridge/BRIDGE_ON_AGENT_PAUSED';
|
|
12867
12865
|
const BRIDGE_ON_AGENT_RESUMED = 'bridge/BRIDGE_ON_AGENT_RESUMED';
|
|
12868
12866
|
const BRIDGE_ON_LANGUAGE_CHANGED = 'bridge/BRIDGE_ON_LANGUAGE_CHANGED';
|
|
12867
|
+
const BRIDGE_ON_CALL_LOCALLY_ACCEPTED = 'bridge/BRIDGE_ON_CALL_LOCALLY_ACCEPTED';
|
|
12868
|
+
const BRIDGE_ON_CALL_REJECTED = 'bridge/BRIDGE_ON_CALL_REJECTED';
|
|
12869
|
+
const BRIDGE_ON_CALL_ESTABLISHED = 'bridge/BRIDGE_ON_CALL_ESTABLISHED';
|
|
12869
12870
|
const BRIDGE_ON_CALL_HELD = 'bridge/BRIDGE_ON_CALL_HELD';
|
|
12870
12871
|
const BRIDGE_ON_CALL_RESUMED = 'bridge/BRIDGE_ON_CALL_RESUMED';
|
|
12871
12872
|
const BRIDGE_ON_CALL_MUTED = 'bridge/BRIDGE_ON_CALL_MUTED';
|
|
@@ -12879,31 +12880,51 @@ const BRIDGE_ON_INDIRECT_TRANSFER_CALL_MADE = 'bridge/BRIDGE_ON_INDIRECT_TRANSFE
|
|
|
12879
12880
|
const BRIDGE_ON_INDIRECT_TRANSFER_DONE = 'bridge/BRIDGE_ON_INDIRECT_TRANSFER_DONE';
|
|
12880
12881
|
const BRIDGE_ON_START_RECORDING = 'bridge/BRIDGE_ON_START_RECORDING';
|
|
12881
12882
|
const BRIDGE_ON_STOP_RECORDING = 'bridge/BRIDGE_ON_STOP_RECORDING';
|
|
12883
|
+
const BRIDGE_ON_CARD_CANCELED = 'bridge/BRIDGE_ON_CARD_CANCELED';
|
|
12884
|
+
const BRIDGE_ENABLE_AGENT = 'bridge/BRIDGE_ENABLE_AGENT';
|
|
12885
|
+
const BRIDGE_SET_CARD_CONTENT = 'bridge/BRIDGE_SET_CARD_CONTENT';
|
|
12886
|
+
const BRIDGE_ENABLE_DEBUG = 'bridge/BRIDGE_ENABLE_DEBUG';
|
|
12887
|
+
|
|
12888
|
+
const BRIDGE_INJECT_CSS = 'bridge/BRIDGE_INJECT_CSS';
|
|
12889
|
+
const BRIDGE_CUSTOMIZE_APPEARANCE = 'bridge/BRIDGE_CUSTOMIZE_APPEARANCE';
|
|
12882
12890
|
|
|
12883
12891
|
const SDK_CLICK_TO_CALL = 'sdk/CLICK_TO_CALL';
|
|
12884
|
-
const
|
|
12892
|
+
const SDK_ON_OUTGOING_CALL_MADE = 'sdk/SDK_ON_OUTGOING_CALL_MADE';
|
|
12885
12893
|
const SDK_CALL_ENDED = 'sdk/ON_CALL_ENDED';
|
|
12886
12894
|
const SDK_CALL_INCOMING = 'sdk/SDK_CALL_INCOMING';
|
|
12887
12895
|
const SDK_AUTHENTICATED = 'sdk/SDK_AUTHENTICATED';
|
|
12888
12896
|
const SDK_LOGGED_OUT = 'sdk/SDK_LOGGED_OUT';
|
|
12889
12897
|
|
|
12890
12898
|
class Softphone {
|
|
12891
|
-
|
|
12892
|
-
|
|
12893
|
-
|
|
12894
|
-
|
|
12895
|
-
|
|
12899
|
+
|
|
12900
|
+
|
|
12901
|
+
|
|
12902
|
+
|
|
12903
|
+
|
|
12904
|
+
|
|
12905
|
+
|
|
12906
|
+
// Message waiting for the iframe to be loaded
|
|
12907
|
+
|
|
12896
12908
|
|
|
12897
12909
|
onLinkEnabled(link ) {}
|
|
12898
12910
|
onIFrameLoaded() {}
|
|
12899
12911
|
|
|
12900
|
-
|
|
12912
|
+
onCallLocallyAnswered(call ) {}
|
|
12913
|
+
onCallEstablished(call ) {}
|
|
12914
|
+
onOutgoingCallMade(call ) {}
|
|
12901
12915
|
onCallIncoming(call ) {}
|
|
12916
|
+
onCallRejected(call ) {}
|
|
12902
12917
|
onCallEnded(call , card , direction , fromExtension ) {}
|
|
12918
|
+
|
|
12903
12919
|
onCardSaved(card ) {}
|
|
12920
|
+
onCardCanceled() {}
|
|
12904
12921
|
onAuthenticated(session ) {}
|
|
12905
12922
|
onLoggedOut() {}
|
|
12906
|
-
|
|
12923
|
+
|
|
12924
|
+
onSearchOptions(fieldId , query ) {
|
|
12925
|
+
this.onOptionsResults(fieldId, []);
|
|
12926
|
+
}
|
|
12927
|
+
|
|
12907
12928
|
onDisplayLinkedOption(optionId ) {}
|
|
12908
12929
|
onWazoContactSearch(query ) {}
|
|
12909
12930
|
onAgentLoggedIn() {}
|
|
@@ -12926,18 +12947,26 @@ class Softphone {
|
|
|
12926
12947
|
onStopRecording() {}
|
|
12927
12948
|
onUnHandledEvent(event ) {}
|
|
12928
12949
|
|
|
12929
|
-
init({
|
|
12930
|
-
|
|
12931
|
-
|
|
12932
|
-
|
|
12933
|
-
|
|
12934
|
-
|
|
12935
|
-
|
|
12936
|
-
|
|
12937
|
-
|
|
12938
|
-
|
|
12939
|
-
|
|
12950
|
+
init({
|
|
12951
|
+
url,
|
|
12952
|
+
width,
|
|
12953
|
+
height,
|
|
12954
|
+
server,
|
|
12955
|
+
port,
|
|
12956
|
+
language,
|
|
12957
|
+
wrapUpDuration,
|
|
12958
|
+
enableAgent = true,
|
|
12959
|
+
tenantId,
|
|
12960
|
+
debug = false,
|
|
12961
|
+
} = {}) {
|
|
12962
|
+
this.url = url || 'https://softphone.wazo.io';
|
|
12963
|
+
this.width = width || 500;
|
|
12964
|
+
this.height = height || 600;
|
|
12965
|
+
this.displayed = false;
|
|
12966
|
+
this.iframeLoaded = false;
|
|
12940
12967
|
|
|
12968
|
+
this.iframeLoaded = false;
|
|
12969
|
+
this._pendingMessages = [];
|
|
12941
12970
|
window.addEventListener('message', this._onMessage.bind(this), false);
|
|
12942
12971
|
|
|
12943
12972
|
if (!server) {
|
|
@@ -12945,25 +12974,33 @@ class Softphone {
|
|
|
12945
12974
|
server = 'stack.dev.wazo.io';
|
|
12946
12975
|
}
|
|
12947
12976
|
|
|
12948
|
-
|
|
12949
|
-
|
|
12950
|
-
|
|
12951
|
-
|
|
12952
|
-
|
|
12953
|
-
|
|
12954
|
-
|
|
12955
|
-
|
|
12956
|
-
|
|
12957
|
-
|
|
12958
|
-
|
|
12977
|
+
const config = { server };
|
|
12978
|
+
if (language) {
|
|
12979
|
+
config.language = language;
|
|
12980
|
+
}
|
|
12981
|
+
if (port) {
|
|
12982
|
+
config.port = port;
|
|
12983
|
+
}
|
|
12984
|
+
if (tenantId) {
|
|
12985
|
+
config.tenantId = tenantId;
|
|
12986
|
+
}
|
|
12987
|
+
if (wrapUpDuration) {
|
|
12988
|
+
config.wrapUpDuration = wrapUpDuration;
|
|
12989
|
+
}
|
|
12959
12990
|
|
|
12960
|
-
|
|
12961
|
-
this._sendMessage(BRIDGE_ENABLE_CARD);
|
|
12962
|
-
}
|
|
12991
|
+
this._sendMessage(BRIDGE_CONFIG_RETRIEVED, { config });
|
|
12963
12992
|
|
|
12964
|
-
|
|
12965
|
-
|
|
12966
|
-
|
|
12993
|
+
if (enableAgent) {
|
|
12994
|
+
this._sendMessage(BRIDGE_ENABLE_AGENT);
|
|
12995
|
+
}
|
|
12996
|
+
|
|
12997
|
+
if (debug) {
|
|
12998
|
+
this._sendMessage(BRIDGE_ENABLE_DEBUG);
|
|
12999
|
+
}
|
|
13000
|
+
|
|
13001
|
+
this._createIframe(() => {
|
|
13002
|
+
this.iframeLoaded = true;
|
|
13003
|
+
this._pendingMessages.forEach(([type, payload]) => this._sendMessage(type, payload));
|
|
12967
13004
|
|
|
12968
13005
|
this.onIFrameLoaded();
|
|
12969
13006
|
});
|
|
@@ -13024,6 +13061,18 @@ class Softphone {
|
|
|
13024
13061
|
this._sendMessage(BRIDGE_UPDATE_FORM_SCHEMA, { schema, uiSchema });
|
|
13025
13062
|
}
|
|
13026
13063
|
|
|
13064
|
+
setCardValue(field , value ) {
|
|
13065
|
+
this._sendMessage(BRIDGE_SET_CARD_CONTENT, { field, value });
|
|
13066
|
+
}
|
|
13067
|
+
|
|
13068
|
+
injectCss(css ) {
|
|
13069
|
+
this._sendMessage(BRIDGE_INJECT_CSS, { css });
|
|
13070
|
+
}
|
|
13071
|
+
|
|
13072
|
+
customizeAppearance(themes , translations , assets ) {
|
|
13073
|
+
this._sendMessage(BRIDGE_CUSTOMIZE_APPEARANCE, { themes, translations, assets });
|
|
13074
|
+
}
|
|
13075
|
+
|
|
13027
13076
|
_createIframe(cb = () => {}) {
|
|
13028
13077
|
this.iframe = document.createElement('iframe');
|
|
13029
13078
|
// $FlowFixMe
|
|
@@ -13069,8 +13118,8 @@ class Softphone {
|
|
|
13069
13118
|
}
|
|
13070
13119
|
|
|
13071
13120
|
switch (event.data.type) {
|
|
13072
|
-
case
|
|
13073
|
-
this.
|
|
13121
|
+
case SDK_ON_OUTGOING_CALL_MADE:
|
|
13122
|
+
this.onOutgoingCallMade(event.data.callSession);
|
|
13074
13123
|
break;
|
|
13075
13124
|
case SDK_CALL_ENDED: {
|
|
13076
13125
|
const { callSession, content, direction, userExtension } = event.data;
|
|
@@ -13158,6 +13207,18 @@ class Softphone {
|
|
|
13158
13207
|
case BRIDGE_ON_STOP_RECORDING:
|
|
13159
13208
|
this.onStopRecording();
|
|
13160
13209
|
break;
|
|
13210
|
+
case BRIDGE_ON_CARD_CANCELED:
|
|
13211
|
+
this.onCardCanceled();
|
|
13212
|
+
break;
|
|
13213
|
+
case BRIDGE_ON_CALL_LOCALLY_ACCEPTED:
|
|
13214
|
+
this.onCallLocallyAnswered(event.data.call);
|
|
13215
|
+
break;
|
|
13216
|
+
case BRIDGE_ON_CALL_REJECTED:
|
|
13217
|
+
this.onCallRejected(event.data.call);
|
|
13218
|
+
break;
|
|
13219
|
+
case BRIDGE_ON_CALL_ESTABLISHED:
|
|
13220
|
+
this.onCallEstablished(event.data.call);
|
|
13221
|
+
break;
|
|
13161
13222
|
default:
|
|
13162
13223
|
this.onUnHandledEvent(event);
|
|
13163
13224
|
break;
|
|
@@ -13165,8 +13226,8 @@ class Softphone {
|
|
|
13165
13226
|
}
|
|
13166
13227
|
|
|
13167
13228
|
_sendMessage(type , payload = {}) {
|
|
13168
|
-
if (!this.iframe) {
|
|
13169
|
-
|
|
13229
|
+
if (!this.iframe || !this.iframeLoaded) {
|
|
13230
|
+
this._pendingMessages.push([type, payload]);
|
|
13170
13231
|
return;
|
|
13171
13232
|
}
|
|
13172
13233
|
|