@wazo/sdk 0.38.1 → 0.38.2
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 +31 -3
- package/dist/wazo-sdk.js +1 -1
- package/esm/index.js +69 -38
- package/esm/simple/Auth.js +69 -38
- package/esm/simple/Configuration.js +69 -38
- package/esm/simple/Phone.js +69 -38
- package/esm/simple/Softphone.js +70 -39
- package/esm/simple/index.js +69 -38
- package/esm/simple/room/LocalParticipant.js +69 -38
- package/esm/simple/room/Participant.js +69 -38
- package/esm/simple/room/RemoteParticipant.js +69 -38
- package/esm/simple/room/Room.js +69 -38
- package/esm/simple/room/SipRoom.js +69 -38
- package/esm/simple/room/Stream.js +69 -38
- package/esm/simple/room/__tests__/RemoteParticipant.test.js +69 -38
- package/esm/simple/utils.js +69 -38
- package/lib/index.js +69 -38
- package/lib/simple/Auth.js +69 -38
- package/lib/simple/Configuration.js +69 -38
- package/lib/simple/Phone.js +69 -38
- package/lib/simple/Softphone.js +70 -39
- package/lib/simple/index.js +69 -38
- package/lib/simple/room/LocalParticipant.js +69 -38
- package/lib/simple/room/Participant.js +69 -38
- package/lib/simple/room/RemoteParticipant.js +69 -38
- package/lib/simple/room/Room.js +69 -38
- package/lib/simple/room/SipRoom.js +69 -38
- package/lib/simple/room/Stream.js +69 -38
- package/lib/simple/room/__tests__/RemoteParticipant.test.js +69 -38
- package/lib/simple/utils.js +69 -38
- package/package.json +1 -1
- package/src/simple/Softphone.js +70 -39
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,7 @@ 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_ANSWERED = 'bridge/BRIDGE_ON_CALL_ANSWERED';
|
|
21
20
|
const BRIDGE_ON_CALL_HELD = 'bridge/BRIDGE_ON_CALL_HELD';
|
|
22
21
|
const BRIDGE_ON_CALL_RESUMED = 'bridge/BRIDGE_ON_CALL_RESUMED';
|
|
23
22
|
const BRIDGE_ON_CALL_MUTED = 'bridge/BRIDGE_ON_CALL_MUTED';
|
|
@@ -31,6 +30,12 @@ const BRIDGE_ON_INDIRECT_TRANSFER_CALL_MADE = 'bridge/BRIDGE_ON_INDIRECT_TRANSFE
|
|
|
31
30
|
const BRIDGE_ON_INDIRECT_TRANSFER_DONE = 'bridge/BRIDGE_ON_INDIRECT_TRANSFER_DONE';
|
|
32
31
|
const BRIDGE_ON_START_RECORDING = 'bridge/BRIDGE_ON_START_RECORDING';
|
|
33
32
|
const BRIDGE_ON_STOP_RECORDING = 'bridge/BRIDGE_ON_STOP_RECORDING';
|
|
33
|
+
const BRIDGE_ON_CARD_CANCELED = 'bridge/BRIDGE_ON_CARD_CANCELED';
|
|
34
|
+
const BRIDGE_ENABLE_AGENT = 'bridge/BRIDGE_ENABLE_AGENT';
|
|
35
|
+
const BRIDGE_SET_CARD_CONTENT = 'bridge/BRIDGE_SET_CARD_CONTENT';
|
|
36
|
+
|
|
37
|
+
const BRIDGE_INJECT_CSS = 'bridge/BRIDGE_INJECT_CSS';
|
|
38
|
+
const BRIDGE_CUSTOMIZE_APPEARANCE = 'bridge/BRIDGE_CUSTOMIZE_APPEARANCE';
|
|
34
39
|
|
|
35
40
|
const SDK_CLICK_TO_CALL = 'sdk/CLICK_TO_CALL';
|
|
36
41
|
const SDK_ON_CALL_MADE = 'sdk/SDK_ON_CALL_MADE';
|
|
@@ -40,22 +45,32 @@ const SDK_AUTHENTICATED = 'sdk/SDK_AUTHENTICATED';
|
|
|
40
45
|
const SDK_LOGGED_OUT = 'sdk/SDK_LOGGED_OUT';
|
|
41
46
|
|
|
42
47
|
class Softphone {
|
|
43
|
-
|
|
44
|
-
|
|
45
|
-
|
|
46
|
-
|
|
47
|
-
|
|
48
|
+
|
|
49
|
+
|
|
50
|
+
|
|
51
|
+
|
|
52
|
+
|
|
53
|
+
|
|
54
|
+
|
|
55
|
+
// Message waiting for the iframe to be loaded
|
|
56
|
+
|
|
48
57
|
|
|
49
58
|
onLinkEnabled(link ) {}
|
|
50
59
|
onIFrameLoaded() {}
|
|
51
60
|
|
|
61
|
+
onCallAnswered() {}
|
|
52
62
|
onCallMade(call ) {}
|
|
53
63
|
onCallIncoming(call ) {}
|
|
54
64
|
onCallEnded(call , card , direction , fromExtension ) {}
|
|
55
65
|
onCardSaved(card ) {}
|
|
66
|
+
onCardCanceled() {}
|
|
56
67
|
onAuthenticated(session ) {}
|
|
57
68
|
onLoggedOut() {}
|
|
58
|
-
|
|
69
|
+
|
|
70
|
+
onSearchOptions(fieldId , query ) {
|
|
71
|
+
this.onOptionsResults(fieldId, []);
|
|
72
|
+
}
|
|
73
|
+
|
|
59
74
|
onDisplayLinkedOption(optionId ) {}
|
|
60
75
|
onWazoContactSearch(query ) {}
|
|
61
76
|
onAgentLoggedIn() {}
|
|
@@ -78,18 +93,15 @@ class Softphone {
|
|
|
78
93
|
onStopRecording() {}
|
|
79
94
|
onUnHandledEvent(event ) {}
|
|
80
95
|
|
|
81
|
-
init({ url, width, height, server, port, language, wrapUpDuration,
|
|
82
|
-
|
|
83
|
-
|
|
84
|
-
|
|
85
|
-
|
|
86
|
-
|
|
87
|
-
this.width = width;
|
|
88
|
-
}
|
|
89
|
-
if (height) {
|
|
90
|
-
this.height = height;
|
|
91
|
-
}
|
|
96
|
+
init({ url, width, height, server, port, language, wrapUpDuration, enableAgent = true } = {}) {
|
|
97
|
+
this.url = url || 'https://softphone.wazo.io';
|
|
98
|
+
this.width = width || 500;
|
|
99
|
+
this.height = height || 600;
|
|
100
|
+
this.displayed = false;
|
|
101
|
+
this.iframeLoaded = false;
|
|
92
102
|
|
|
103
|
+
this.iframeLoaded = false;
|
|
104
|
+
this._pendingMessages = [];
|
|
93
105
|
window.addEventListener('message', this._onMessage.bind(this), false);
|
|
94
106
|
|
|
95
107
|
if (!server) {
|
|
@@ -97,25 +109,26 @@ class Softphone {
|
|
|
97
109
|
server = 'stack.dev.wazo.io';
|
|
98
110
|
}
|
|
99
111
|
|
|
100
|
-
|
|
101
|
-
|
|
102
|
-
|
|
103
|
-
|
|
104
|
-
|
|
105
|
-
|
|
106
|
-
|
|
107
|
-
|
|
108
|
-
|
|
109
|
-
|
|
110
|
-
});
|
|
111
|
-
|
|
112
|
-
if (withCard) {
|
|
113
|
-
this._sendMessage(BRIDGE_ENABLE_CARD);
|
|
114
|
-
}
|
|
112
|
+
const config = { server };
|
|
113
|
+
if (language) {
|
|
114
|
+
config.language = language;
|
|
115
|
+
}
|
|
116
|
+
if (port) {
|
|
117
|
+
config.port = port;
|
|
118
|
+
}
|
|
119
|
+
if (wrapUpDuration) {
|
|
120
|
+
config.wrapUpDuration = wrapUpDuration;
|
|
121
|
+
}
|
|
115
122
|
|
|
116
|
-
|
|
117
|
-
|
|
118
|
-
|
|
123
|
+
this._sendMessage(BRIDGE_CONFIG_RETRIEVED, { config });
|
|
124
|
+
|
|
125
|
+
if (enableAgent) {
|
|
126
|
+
this._sendMessage(BRIDGE_ENABLE_AGENT);
|
|
127
|
+
}
|
|
128
|
+
|
|
129
|
+
this._createIframe(() => {
|
|
130
|
+
this.iframeLoaded = true;
|
|
131
|
+
this._pendingMessages.forEach(([type, payload]) => this._sendMessage(type, payload));
|
|
119
132
|
|
|
120
133
|
this.onIFrameLoaded();
|
|
121
134
|
});
|
|
@@ -176,6 +189,18 @@ class Softphone {
|
|
|
176
189
|
this._sendMessage(BRIDGE_UPDATE_FORM_SCHEMA, { schema, uiSchema });
|
|
177
190
|
}
|
|
178
191
|
|
|
192
|
+
setCardValue(field , value ) {
|
|
193
|
+
this._sendMessage(BRIDGE_SET_CARD_CONTENT, { field, value });
|
|
194
|
+
}
|
|
195
|
+
|
|
196
|
+
injectCss(css ) {
|
|
197
|
+
this._sendMessage(BRIDGE_INJECT_CSS, { css });
|
|
198
|
+
}
|
|
199
|
+
|
|
200
|
+
customizeAppearance(themes , translations , assets ) {
|
|
201
|
+
this._sendMessage(BRIDGE_CUSTOMIZE_APPEARANCE, { themes, translations, assets });
|
|
202
|
+
}
|
|
203
|
+
|
|
179
204
|
_createIframe(cb = () => {}) {
|
|
180
205
|
this.iframe = document.createElement('iframe');
|
|
181
206
|
// $FlowFixMe
|
|
@@ -310,6 +335,12 @@ class Softphone {
|
|
|
310
335
|
case BRIDGE_ON_STOP_RECORDING:
|
|
311
336
|
this.onStopRecording();
|
|
312
337
|
break;
|
|
338
|
+
case BRIDGE_ON_CARD_CANCELED:
|
|
339
|
+
this.onCardCanceled();
|
|
340
|
+
break;
|
|
341
|
+
case BRIDGE_ON_CALL_ANSWERED:
|
|
342
|
+
this.onCallAnswered();
|
|
343
|
+
break;
|
|
313
344
|
default:
|
|
314
345
|
this.onUnHandledEvent(event);
|
|
315
346
|
break;
|
|
@@ -317,8 +348,8 @@ class Softphone {
|
|
|
317
348
|
}
|
|
318
349
|
|
|
319
350
|
_sendMessage(type , payload = {}) {
|
|
320
|
-
if (!this.iframe) {
|
|
321
|
-
|
|
351
|
+
if (!this.iframe || !this.iframeLoaded) {
|
|
352
|
+
this._pendingMessages.push([type, payload]);
|
|
322
353
|
return;
|
|
323
354
|
}
|
|
324
355
|
|
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,7 @@ 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_ANSWERED = 'bridge/BRIDGE_ON_CALL_ANSWERED';
|
|
14000
13999
|
const BRIDGE_ON_CALL_HELD = 'bridge/BRIDGE_ON_CALL_HELD';
|
|
14001
14000
|
const BRIDGE_ON_CALL_RESUMED = 'bridge/BRIDGE_ON_CALL_RESUMED';
|
|
14002
14001
|
const BRIDGE_ON_CALL_MUTED = 'bridge/BRIDGE_ON_CALL_MUTED';
|
|
@@ -14010,6 +14009,12 @@ const BRIDGE_ON_INDIRECT_TRANSFER_CALL_MADE = 'bridge/BRIDGE_ON_INDIRECT_TRANSFE
|
|
|
14010
14009
|
const BRIDGE_ON_INDIRECT_TRANSFER_DONE = 'bridge/BRIDGE_ON_INDIRECT_TRANSFER_DONE';
|
|
14011
14010
|
const BRIDGE_ON_START_RECORDING = 'bridge/BRIDGE_ON_START_RECORDING';
|
|
14012
14011
|
const BRIDGE_ON_STOP_RECORDING = 'bridge/BRIDGE_ON_STOP_RECORDING';
|
|
14012
|
+
const BRIDGE_ON_CARD_CANCELED = 'bridge/BRIDGE_ON_CARD_CANCELED';
|
|
14013
|
+
const BRIDGE_ENABLE_AGENT = 'bridge/BRIDGE_ENABLE_AGENT';
|
|
14014
|
+
const BRIDGE_SET_CARD_CONTENT = 'bridge/BRIDGE_SET_CARD_CONTENT';
|
|
14015
|
+
|
|
14016
|
+
const BRIDGE_INJECT_CSS = 'bridge/BRIDGE_INJECT_CSS';
|
|
14017
|
+
const BRIDGE_CUSTOMIZE_APPEARANCE = 'bridge/BRIDGE_CUSTOMIZE_APPEARANCE';
|
|
14013
14018
|
|
|
14014
14019
|
const SDK_CLICK_TO_CALL = 'sdk/CLICK_TO_CALL';
|
|
14015
14020
|
const SDK_ON_CALL_MADE = 'sdk/SDK_ON_CALL_MADE';
|
|
@@ -14019,22 +14024,32 @@ const SDK_AUTHENTICATED = 'sdk/SDK_AUTHENTICATED';
|
|
|
14019
14024
|
const SDK_LOGGED_OUT = 'sdk/SDK_LOGGED_OUT';
|
|
14020
14025
|
|
|
14021
14026
|
class Softphone {
|
|
14022
|
-
|
|
14023
|
-
|
|
14024
|
-
|
|
14025
|
-
|
|
14026
|
-
|
|
14027
|
+
|
|
14028
|
+
|
|
14029
|
+
|
|
14030
|
+
|
|
14031
|
+
|
|
14032
|
+
|
|
14033
|
+
|
|
14034
|
+
// Message waiting for the iframe to be loaded
|
|
14035
|
+
|
|
14027
14036
|
|
|
14028
14037
|
onLinkEnabled(link ) {}
|
|
14029
14038
|
onIFrameLoaded() {}
|
|
14030
14039
|
|
|
14040
|
+
onCallAnswered() {}
|
|
14031
14041
|
onCallMade(call ) {}
|
|
14032
14042
|
onCallIncoming(call ) {}
|
|
14033
14043
|
onCallEnded(call , card , direction , fromExtension ) {}
|
|
14034
14044
|
onCardSaved(card ) {}
|
|
14045
|
+
onCardCanceled() {}
|
|
14035
14046
|
onAuthenticated(session ) {}
|
|
14036
14047
|
onLoggedOut() {}
|
|
14037
|
-
|
|
14048
|
+
|
|
14049
|
+
onSearchOptions(fieldId , query ) {
|
|
14050
|
+
this.onOptionsResults(fieldId, []);
|
|
14051
|
+
}
|
|
14052
|
+
|
|
14038
14053
|
onDisplayLinkedOption(optionId ) {}
|
|
14039
14054
|
onWazoContactSearch(query ) {}
|
|
14040
14055
|
onAgentLoggedIn() {}
|
|
@@ -14057,18 +14072,15 @@ class Softphone {
|
|
|
14057
14072
|
onStopRecording() {}
|
|
14058
14073
|
onUnHandledEvent(event ) {}
|
|
14059
14074
|
|
|
14060
|
-
init({ url, width, height, server, port, language, wrapUpDuration,
|
|
14061
|
-
|
|
14062
|
-
|
|
14063
|
-
|
|
14064
|
-
|
|
14065
|
-
|
|
14066
|
-
this.width = width;
|
|
14067
|
-
}
|
|
14068
|
-
if (height) {
|
|
14069
|
-
this.height = height;
|
|
14070
|
-
}
|
|
14075
|
+
init({ url, width, height, server, port, language, wrapUpDuration, enableAgent = true } = {}) {
|
|
14076
|
+
this.url = url || 'https://softphone.wazo.io';
|
|
14077
|
+
this.width = width || 500;
|
|
14078
|
+
this.height = height || 600;
|
|
14079
|
+
this.displayed = false;
|
|
14080
|
+
this.iframeLoaded = false;
|
|
14071
14081
|
|
|
14082
|
+
this.iframeLoaded = false;
|
|
14083
|
+
this._pendingMessages = [];
|
|
14072
14084
|
window.addEventListener('message', this._onMessage.bind(this), false);
|
|
14073
14085
|
|
|
14074
14086
|
if (!server) {
|
|
@@ -14076,25 +14088,26 @@ class Softphone {
|
|
|
14076
14088
|
server = 'stack.dev.wazo.io';
|
|
14077
14089
|
}
|
|
14078
14090
|
|
|
14079
|
-
|
|
14080
|
-
|
|
14081
|
-
|
|
14082
|
-
|
|
14083
|
-
|
|
14084
|
-
|
|
14085
|
-
|
|
14086
|
-
|
|
14087
|
-
|
|
14088
|
-
|
|
14089
|
-
});
|
|
14091
|
+
const config = { server };
|
|
14092
|
+
if (language) {
|
|
14093
|
+
config.language = language;
|
|
14094
|
+
}
|
|
14095
|
+
if (port) {
|
|
14096
|
+
config.port = port;
|
|
14097
|
+
}
|
|
14098
|
+
if (wrapUpDuration) {
|
|
14099
|
+
config.wrapUpDuration = wrapUpDuration;
|
|
14100
|
+
}
|
|
14090
14101
|
|
|
14091
|
-
|
|
14092
|
-
this._sendMessage(BRIDGE_ENABLE_CARD);
|
|
14093
|
-
}
|
|
14102
|
+
this._sendMessage(BRIDGE_CONFIG_RETRIEVED, { config });
|
|
14094
14103
|
|
|
14095
|
-
|
|
14096
|
-
|
|
14097
|
-
|
|
14104
|
+
if (enableAgent) {
|
|
14105
|
+
this._sendMessage(BRIDGE_ENABLE_AGENT);
|
|
14106
|
+
}
|
|
14107
|
+
|
|
14108
|
+
this._createIframe(() => {
|
|
14109
|
+
this.iframeLoaded = true;
|
|
14110
|
+
this._pendingMessages.forEach(([type, payload]) => this._sendMessage(type, payload));
|
|
14098
14111
|
|
|
14099
14112
|
this.onIFrameLoaded();
|
|
14100
14113
|
});
|
|
@@ -14155,6 +14168,18 @@ class Softphone {
|
|
|
14155
14168
|
this._sendMessage(BRIDGE_UPDATE_FORM_SCHEMA, { schema, uiSchema });
|
|
14156
14169
|
}
|
|
14157
14170
|
|
|
14171
|
+
setCardValue(field , value ) {
|
|
14172
|
+
this._sendMessage(BRIDGE_SET_CARD_CONTENT, { field, value });
|
|
14173
|
+
}
|
|
14174
|
+
|
|
14175
|
+
injectCss(css ) {
|
|
14176
|
+
this._sendMessage(BRIDGE_INJECT_CSS, { css });
|
|
14177
|
+
}
|
|
14178
|
+
|
|
14179
|
+
customizeAppearance(themes , translations , assets ) {
|
|
14180
|
+
this._sendMessage(BRIDGE_CUSTOMIZE_APPEARANCE, { themes, translations, assets });
|
|
14181
|
+
}
|
|
14182
|
+
|
|
14158
14183
|
_createIframe(cb = () => {}) {
|
|
14159
14184
|
this.iframe = document.createElement('iframe');
|
|
14160
14185
|
// $FlowFixMe
|
|
@@ -14289,6 +14314,12 @@ class Softphone {
|
|
|
14289
14314
|
case BRIDGE_ON_STOP_RECORDING:
|
|
14290
14315
|
this.onStopRecording();
|
|
14291
14316
|
break;
|
|
14317
|
+
case BRIDGE_ON_CARD_CANCELED:
|
|
14318
|
+
this.onCardCanceled();
|
|
14319
|
+
break;
|
|
14320
|
+
case BRIDGE_ON_CALL_ANSWERED:
|
|
14321
|
+
this.onCallAnswered();
|
|
14322
|
+
break;
|
|
14292
14323
|
default:
|
|
14293
14324
|
this.onUnHandledEvent(event);
|
|
14294
14325
|
break;
|
|
@@ -14296,8 +14327,8 @@ class Softphone {
|
|
|
14296
14327
|
}
|
|
14297
14328
|
|
|
14298
14329
|
_sendMessage(type , payload = {}) {
|
|
14299
|
-
if (!this.iframe) {
|
|
14300
|
-
|
|
14330
|
+
if (!this.iframe || !this.iframeLoaded) {
|
|
14331
|
+
this._pendingMessages.push([type, payload]);
|
|
14301
14332
|
return;
|
|
14302
14333
|
}
|
|
14303
14334
|
|
|
@@ -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,7 @@ 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_ANSWERED = 'bridge/BRIDGE_ON_CALL_ANSWERED';
|
|
12869
12868
|
const BRIDGE_ON_CALL_HELD = 'bridge/BRIDGE_ON_CALL_HELD';
|
|
12870
12869
|
const BRIDGE_ON_CALL_RESUMED = 'bridge/BRIDGE_ON_CALL_RESUMED';
|
|
12871
12870
|
const BRIDGE_ON_CALL_MUTED = 'bridge/BRIDGE_ON_CALL_MUTED';
|
|
@@ -12879,6 +12878,12 @@ const BRIDGE_ON_INDIRECT_TRANSFER_CALL_MADE = 'bridge/BRIDGE_ON_INDIRECT_TRANSFE
|
|
|
12879
12878
|
const BRIDGE_ON_INDIRECT_TRANSFER_DONE = 'bridge/BRIDGE_ON_INDIRECT_TRANSFER_DONE';
|
|
12880
12879
|
const BRIDGE_ON_START_RECORDING = 'bridge/BRIDGE_ON_START_RECORDING';
|
|
12881
12880
|
const BRIDGE_ON_STOP_RECORDING = 'bridge/BRIDGE_ON_STOP_RECORDING';
|
|
12881
|
+
const BRIDGE_ON_CARD_CANCELED = 'bridge/BRIDGE_ON_CARD_CANCELED';
|
|
12882
|
+
const BRIDGE_ENABLE_AGENT = 'bridge/BRIDGE_ENABLE_AGENT';
|
|
12883
|
+
const BRIDGE_SET_CARD_CONTENT = 'bridge/BRIDGE_SET_CARD_CONTENT';
|
|
12884
|
+
|
|
12885
|
+
const BRIDGE_INJECT_CSS = 'bridge/BRIDGE_INJECT_CSS';
|
|
12886
|
+
const BRIDGE_CUSTOMIZE_APPEARANCE = 'bridge/BRIDGE_CUSTOMIZE_APPEARANCE';
|
|
12882
12887
|
|
|
12883
12888
|
const SDK_CLICK_TO_CALL = 'sdk/CLICK_TO_CALL';
|
|
12884
12889
|
const SDK_ON_CALL_MADE = 'sdk/SDK_ON_CALL_MADE';
|
|
@@ -12888,22 +12893,32 @@ const SDK_AUTHENTICATED = 'sdk/SDK_AUTHENTICATED';
|
|
|
12888
12893
|
const SDK_LOGGED_OUT = 'sdk/SDK_LOGGED_OUT';
|
|
12889
12894
|
|
|
12890
12895
|
class Softphone {
|
|
12891
|
-
|
|
12892
|
-
|
|
12893
|
-
|
|
12894
|
-
|
|
12895
|
-
|
|
12896
|
+
|
|
12897
|
+
|
|
12898
|
+
|
|
12899
|
+
|
|
12900
|
+
|
|
12901
|
+
|
|
12902
|
+
|
|
12903
|
+
// Message waiting for the iframe to be loaded
|
|
12904
|
+
|
|
12896
12905
|
|
|
12897
12906
|
onLinkEnabled(link ) {}
|
|
12898
12907
|
onIFrameLoaded() {}
|
|
12899
12908
|
|
|
12909
|
+
onCallAnswered() {}
|
|
12900
12910
|
onCallMade(call ) {}
|
|
12901
12911
|
onCallIncoming(call ) {}
|
|
12902
12912
|
onCallEnded(call , card , direction , fromExtension ) {}
|
|
12903
12913
|
onCardSaved(card ) {}
|
|
12914
|
+
onCardCanceled() {}
|
|
12904
12915
|
onAuthenticated(session ) {}
|
|
12905
12916
|
onLoggedOut() {}
|
|
12906
|
-
|
|
12917
|
+
|
|
12918
|
+
onSearchOptions(fieldId , query ) {
|
|
12919
|
+
this.onOptionsResults(fieldId, []);
|
|
12920
|
+
}
|
|
12921
|
+
|
|
12907
12922
|
onDisplayLinkedOption(optionId ) {}
|
|
12908
12923
|
onWazoContactSearch(query ) {}
|
|
12909
12924
|
onAgentLoggedIn() {}
|
|
@@ -12926,18 +12941,15 @@ class Softphone {
|
|
|
12926
12941
|
onStopRecording() {}
|
|
12927
12942
|
onUnHandledEvent(event ) {}
|
|
12928
12943
|
|
|
12929
|
-
init({ url, width, height, server, port, language, wrapUpDuration,
|
|
12930
|
-
|
|
12931
|
-
|
|
12932
|
-
|
|
12933
|
-
|
|
12934
|
-
|
|
12935
|
-
this.width = width;
|
|
12936
|
-
}
|
|
12937
|
-
if (height) {
|
|
12938
|
-
this.height = height;
|
|
12939
|
-
}
|
|
12944
|
+
init({ url, width, height, server, port, language, wrapUpDuration, enableAgent = true } = {}) {
|
|
12945
|
+
this.url = url || 'https://softphone.wazo.io';
|
|
12946
|
+
this.width = width || 500;
|
|
12947
|
+
this.height = height || 600;
|
|
12948
|
+
this.displayed = false;
|
|
12949
|
+
this.iframeLoaded = false;
|
|
12940
12950
|
|
|
12951
|
+
this.iframeLoaded = false;
|
|
12952
|
+
this._pendingMessages = [];
|
|
12941
12953
|
window.addEventListener('message', this._onMessage.bind(this), false);
|
|
12942
12954
|
|
|
12943
12955
|
if (!server) {
|
|
@@ -12945,25 +12957,26 @@ class Softphone {
|
|
|
12945
12957
|
server = 'stack.dev.wazo.io';
|
|
12946
12958
|
}
|
|
12947
12959
|
|
|
12948
|
-
|
|
12949
|
-
|
|
12950
|
-
|
|
12951
|
-
|
|
12952
|
-
|
|
12953
|
-
|
|
12954
|
-
|
|
12955
|
-
|
|
12956
|
-
|
|
12957
|
-
|
|
12958
|
-
});
|
|
12960
|
+
const config = { server };
|
|
12961
|
+
if (language) {
|
|
12962
|
+
config.language = language;
|
|
12963
|
+
}
|
|
12964
|
+
if (port) {
|
|
12965
|
+
config.port = port;
|
|
12966
|
+
}
|
|
12967
|
+
if (wrapUpDuration) {
|
|
12968
|
+
config.wrapUpDuration = wrapUpDuration;
|
|
12969
|
+
}
|
|
12959
12970
|
|
|
12960
|
-
|
|
12961
|
-
this._sendMessage(BRIDGE_ENABLE_CARD);
|
|
12962
|
-
}
|
|
12971
|
+
this._sendMessage(BRIDGE_CONFIG_RETRIEVED, { config });
|
|
12963
12972
|
|
|
12964
|
-
|
|
12965
|
-
|
|
12966
|
-
|
|
12973
|
+
if (enableAgent) {
|
|
12974
|
+
this._sendMessage(BRIDGE_ENABLE_AGENT);
|
|
12975
|
+
}
|
|
12976
|
+
|
|
12977
|
+
this._createIframe(() => {
|
|
12978
|
+
this.iframeLoaded = true;
|
|
12979
|
+
this._pendingMessages.forEach(([type, payload]) => this._sendMessage(type, payload));
|
|
12967
12980
|
|
|
12968
12981
|
this.onIFrameLoaded();
|
|
12969
12982
|
});
|
|
@@ -13024,6 +13037,18 @@ class Softphone {
|
|
|
13024
13037
|
this._sendMessage(BRIDGE_UPDATE_FORM_SCHEMA, { schema, uiSchema });
|
|
13025
13038
|
}
|
|
13026
13039
|
|
|
13040
|
+
setCardValue(field , value ) {
|
|
13041
|
+
this._sendMessage(BRIDGE_SET_CARD_CONTENT, { field, value });
|
|
13042
|
+
}
|
|
13043
|
+
|
|
13044
|
+
injectCss(css ) {
|
|
13045
|
+
this._sendMessage(BRIDGE_INJECT_CSS, { css });
|
|
13046
|
+
}
|
|
13047
|
+
|
|
13048
|
+
customizeAppearance(themes , translations , assets ) {
|
|
13049
|
+
this._sendMessage(BRIDGE_CUSTOMIZE_APPEARANCE, { themes, translations, assets });
|
|
13050
|
+
}
|
|
13051
|
+
|
|
13027
13052
|
_createIframe(cb = () => {}) {
|
|
13028
13053
|
this.iframe = document.createElement('iframe');
|
|
13029
13054
|
// $FlowFixMe
|
|
@@ -13158,6 +13183,12 @@ class Softphone {
|
|
|
13158
13183
|
case BRIDGE_ON_STOP_RECORDING:
|
|
13159
13184
|
this.onStopRecording();
|
|
13160
13185
|
break;
|
|
13186
|
+
case BRIDGE_ON_CARD_CANCELED:
|
|
13187
|
+
this.onCardCanceled();
|
|
13188
|
+
break;
|
|
13189
|
+
case BRIDGE_ON_CALL_ANSWERED:
|
|
13190
|
+
this.onCallAnswered();
|
|
13191
|
+
break;
|
|
13161
13192
|
default:
|
|
13162
13193
|
this.onUnHandledEvent(event);
|
|
13163
13194
|
break;
|
|
@@ -13165,8 +13196,8 @@ class Softphone {
|
|
|
13165
13196
|
}
|
|
13166
13197
|
|
|
13167
13198
|
_sendMessage(type , payload = {}) {
|
|
13168
|
-
if (!this.iframe) {
|
|
13169
|
-
|
|
13199
|
+
if (!this.iframe || !this.iframeLoaded) {
|
|
13200
|
+
this._pendingMessages.push([type, payload]);
|
|
13170
13201
|
return;
|
|
13171
13202
|
}
|
|
13172
13203
|
|