@wazo/sdk 0.38.0 → 0.38.1
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/README.md +218 -0
- package/dist/wazo-sdk.js +5 -5
- package/esm/__tests__/web-rtc-client.test.js +1 -1
- package/esm/checker/Checker.js +1 -1
- package/esm/checker/checks/index.js +1 -1
- package/esm/checker/checks/webrtc-transport.js +1 -1
- package/esm/checker/checks/webrtc.js +1 -1
- package/esm/index.js +191 -10
- package/esm/simple/Auth.js +191 -10
- package/esm/simple/Configuration.js +191 -10
- package/esm/simple/Phone.js +191 -10
- package/esm/simple/Softphone.js +189 -8
- package/esm/simple/index.js +191 -10
- package/esm/simple/room/LocalParticipant.js +191 -10
- package/esm/simple/room/Participant.js +191 -10
- package/esm/simple/room/RemoteParticipant.js +191 -10
- package/esm/simple/room/Room.js +191 -10
- package/esm/simple/room/SipRoom.js +191 -10
- package/esm/simple/room/Stream.js +191 -10
- package/esm/simple/room/__tests__/RemoteParticipant.test.js +191 -10
- package/esm/simple/utils.js +191 -10
- package/esm/web-rtc-client.js +1 -1
- package/lib/__tests__/web-rtc-client.test.js +1 -1
- package/lib/checker/Checker.js +1 -1
- package/lib/checker/checks/index.js +1 -1
- package/lib/checker/checks/webrtc-transport.js +1 -1
- package/lib/checker/checks/webrtc.js +1 -1
- package/lib/index.js +191 -10
- package/lib/simple/Auth.js +191 -10
- package/lib/simple/Configuration.js +191 -10
- package/lib/simple/Phone.js +191 -10
- package/lib/simple/Softphone.js +189 -8
- package/lib/simple/index.js +191 -10
- package/lib/simple/room/LocalParticipant.js +191 -10
- package/lib/simple/room/Participant.js +191 -10
- package/lib/simple/room/RemoteParticipant.js +191 -10
- package/lib/simple/room/Room.js +191 -10
- package/lib/simple/room/SipRoom.js +191 -10
- package/lib/simple/room/Stream.js +191 -10
- package/lib/simple/room/__tests__/RemoteParticipant.test.js +191 -10
- package/lib/simple/utils.js +191 -10
- package/lib/web-rtc-client.js +1 -1
- package/package.json +1 -1
- package/src/simple/Softphone.js +187 -8
- package/src/web-rtc-client.js +1 -1
|
@@ -8326,7 +8326,7 @@ class WebRTCClient extends Emitter {
|
|
|
8326
8326
|
}
|
|
8327
8327
|
|
|
8328
8328
|
async _onHeartbeatTimeout() {
|
|
8329
|
-
logger$8.
|
|
8329
|
+
logger$8.warn('sdk webrtc heartbeat timed out', { userAgent: !!this.userAgent, cb: !!this.heartbeatTimeoutCb });
|
|
8330
8330
|
|
|
8331
8331
|
if (this.heartbeatTimeoutCb) {
|
|
8332
8332
|
this.heartbeatTimeoutCb();
|
|
@@ -13125,11 +13125,41 @@ class Checker {
|
|
|
13125
13125
|
//
|
|
13126
13126
|
/* eslint-disable no-unused-vars */
|
|
13127
13127
|
/* global window, document */
|
|
13128
|
+
const BRIDGE_CONFIG_RETRIEVED = 'bridge/CONFIG_RETRIEVED';
|
|
13129
|
+
const BRIDGE_ENABLE_CARD = 'bridge/ENABLE_CARD';
|
|
13130
|
+
const BRIDGE_CHANGE_REQUIRED_SUBSCRIPTION_TYPE = 'bridge/CHANGE_REQUIRED_SUBSCRIPTION_TYPE';
|
|
13131
|
+
const BRIDGE_CREATE_OR_UPDATE_CARD = 'bridge/BRIDGE_CREATE_OR_UPDATE_CARD';
|
|
13132
|
+
const BRIDGE_OPTIONS_FETCHED = 'bridge/BRIDGE_OPTIONS_FETCHED';
|
|
13133
|
+
const BRIDGE_OPTIONS_FOUND = 'bridge/BRIDGE_OPTIONS_FOUND';
|
|
13134
|
+
const BRIDGE_SEARCH_OPTIONS = 'bridge/BRIDGE_SEARCH_OPTIONS';
|
|
13135
|
+
const BRIDGE_DISPLAY_LINKED_OPTION = 'bridge/DISPLAY_LINKED_OPTION';
|
|
13136
|
+
const BRIDGE_UPDATE_FORM_SCHEMA = 'bridge/BRIDGE_UPDATE_FORM_SCHEMA';
|
|
13137
|
+
const BRIDGE_WAZO_CONTACT_SEARCH = 'bridge/BRIDGE_WAZO_CONTACT_SEARCH';
|
|
13138
|
+
const BRIDGE_ON_AGENT_LOGGED_IN = 'bridge/BRIDGE_ON_AGENT_LOGGED_IN';
|
|
13139
|
+
const BRIDGE_ON_AGENT_LOGGED_OUT = 'bridge/BRIDGE_ON_AGENT_LOGGED_OUT';
|
|
13140
|
+
const BRIDGE_ON_AGENT_PAUSED = 'bridge/BRIDGE_ON_AGENT_PAUSED';
|
|
13141
|
+
const BRIDGE_ON_AGENT_RESUMED = 'bridge/BRIDGE_ON_AGENT_RESUMED';
|
|
13142
|
+
const BRIDGE_ON_LANGUAGE_CHANGED = 'bridge/BRIDGE_ON_LANGUAGE_CHANGED';
|
|
13143
|
+
const BRIDGE_ON_CALL_HELD = 'bridge/BRIDGE_ON_CALL_HELD';
|
|
13144
|
+
const BRIDGE_ON_CALL_RESUMED = 'bridge/BRIDGE_ON_CALL_RESUMED';
|
|
13145
|
+
const BRIDGE_ON_CALL_MUTED = 'bridge/BRIDGE_ON_CALL_MUTED';
|
|
13146
|
+
const BRIDGE_ON_CALL_UN_MUTED = 'bridge/BRIDGE_ON_CALL_UN_MUTED';
|
|
13147
|
+
const BRIDGE_ON_DTMF = 'bridge/BRIDGE_ON_DTMF';
|
|
13148
|
+
const BRIDGE_ON_DIRECT_TRANSFER = 'bridge/BRIDGE_ON_DIRECT_TRANSFER';
|
|
13149
|
+
const BRIDGE_ON_CREATE_INDIRECT_TRANSFER = 'bridge/BRIDGE_ON_CREATE_INDIRECT_TRANSFER';
|
|
13150
|
+
const BRIDGE_ON_CANCEL_INDIRECT_TRANSFER = 'bridge/BRIDGE_ON_CANCEL_INDIRECT_TRANSFER';
|
|
13151
|
+
const BRIDGE_ON_CONFIRM_INDIRECT_TRANSFER = 'bridge/BRIDGE_ON_CONFIRM_INDIRECT_TRANSFER';
|
|
13152
|
+
const BRIDGE_ON_INDIRECT_TRANSFER_CALL_MADE = 'bridge/BRIDGE_ON_INDIRECT_TRANSFER_CALL_MADE';
|
|
13153
|
+
const BRIDGE_ON_INDIRECT_TRANSFER_DONE = 'bridge/BRIDGE_ON_INDIRECT_TRANSFER_DONE';
|
|
13154
|
+
const BRIDGE_ON_START_RECORDING = 'bridge/BRIDGE_ON_START_RECORDING';
|
|
13155
|
+
const BRIDGE_ON_STOP_RECORDING = 'bridge/BRIDGE_ON_STOP_RECORDING';
|
|
13156
|
+
|
|
13128
13157
|
const SDK_CLICK_TO_CALL = 'sdk/CLICK_TO_CALL';
|
|
13129
13158
|
const SDK_ON_CALL_MADE = 'sdk/SDK_ON_CALL_MADE';
|
|
13130
13159
|
const SDK_CALL_ENDED = 'sdk/ON_CALL_ENDED';
|
|
13131
13160
|
const SDK_CALL_INCOMING = 'sdk/SDK_CALL_INCOMING';
|
|
13132
13161
|
const SDK_AUTHENTICATED = 'sdk/SDK_AUTHENTICATED';
|
|
13162
|
+
const SDK_LOGGED_OUT = 'sdk/SDK_LOGGED_OUT';
|
|
13133
13163
|
|
|
13134
13164
|
class Softphone {
|
|
13135
13165
|
url = 'https://softphone.wazo.io';
|
|
@@ -13139,13 +13169,39 @@ class Softphone {
|
|
|
13139
13169
|
iframe = null;
|
|
13140
13170
|
|
|
13141
13171
|
onLinkEnabled(link ) {}
|
|
13172
|
+
onIFrameLoaded() {}
|
|
13142
13173
|
|
|
13143
13174
|
onCallMade(call ) {}
|
|
13144
13175
|
onCallIncoming(call ) {}
|
|
13145
13176
|
onCallEnded(call , card , direction , fromExtension ) {}
|
|
13177
|
+
onCardSaved(card ) {}
|
|
13146
13178
|
onAuthenticated(session ) {}
|
|
13147
|
-
|
|
13148
|
-
|
|
13179
|
+
onLoggedOut() {}
|
|
13180
|
+
onSearchOptions(fieldId , query ) {}
|
|
13181
|
+
onDisplayLinkedOption(optionId ) {}
|
|
13182
|
+
onWazoContactSearch(query ) {}
|
|
13183
|
+
onAgentLoggedIn() {}
|
|
13184
|
+
onAgentLoggedOut() {}
|
|
13185
|
+
onAgentPaused() {}
|
|
13186
|
+
onAgentResumed() {}
|
|
13187
|
+
onLanguageChanged(language ) {}
|
|
13188
|
+
onCallHeld() {}
|
|
13189
|
+
onCallResumed() {}
|
|
13190
|
+
onCallMuted() {}
|
|
13191
|
+
onCallUnMuted() {}
|
|
13192
|
+
onDtmfSent(tone ) {}
|
|
13193
|
+
onDirectTransfer(number ) {}
|
|
13194
|
+
onCreateIndirectTransfer(number ) {}
|
|
13195
|
+
onCancelIndirectTransfer() {}
|
|
13196
|
+
onConfirmIndirectTransfer() {}
|
|
13197
|
+
onIndirectCallMade(call ) {}
|
|
13198
|
+
onIndirectTransferDone(call ) {}
|
|
13199
|
+
onStartRecording() {}
|
|
13200
|
+
onStopRecording() {}
|
|
13201
|
+
onUnHandledEvent(event ) {}
|
|
13202
|
+
|
|
13203
|
+
init({ url, width, height, server, port, language, wrapUpDuration, shouldDisplayLinkedEntities,
|
|
13204
|
+
allowContactCreation, withCard, subscriptionType, enableAgent } = {}) {
|
|
13149
13205
|
if (url) {
|
|
13150
13206
|
this.url = url;
|
|
13151
13207
|
}
|
|
@@ -13158,7 +13214,33 @@ class Softphone {
|
|
|
13158
13214
|
|
|
13159
13215
|
window.addEventListener('message', this._onMessage.bind(this), false);
|
|
13160
13216
|
|
|
13161
|
-
|
|
13217
|
+
if (!server) {
|
|
13218
|
+
// eslint-disable-next-line no-param-reassign
|
|
13219
|
+
server = 'stack.dev.wazo.io';
|
|
13220
|
+
}
|
|
13221
|
+
|
|
13222
|
+
this._createIframe(() => {
|
|
13223
|
+
this._sendMessage(BRIDGE_CONFIG_RETRIEVED, {
|
|
13224
|
+
config: {
|
|
13225
|
+
server,
|
|
13226
|
+
port,
|
|
13227
|
+
language,
|
|
13228
|
+
wrapUpDuration,
|
|
13229
|
+
shouldDisplayLinkedEntities,
|
|
13230
|
+
allowContactCreation,
|
|
13231
|
+
},
|
|
13232
|
+
});
|
|
13233
|
+
|
|
13234
|
+
if (withCard) {
|
|
13235
|
+
this._sendMessage(BRIDGE_ENABLE_CARD);
|
|
13236
|
+
}
|
|
13237
|
+
|
|
13238
|
+
if (subscriptionType) {
|
|
13239
|
+
this._sendMessage(BRIDGE_CHANGE_REQUIRED_SUBSCRIPTION_TYPE, { subscriptionType });
|
|
13240
|
+
}
|
|
13241
|
+
|
|
13242
|
+
this.onIFrameLoaded();
|
|
13243
|
+
});
|
|
13162
13244
|
}
|
|
13163
13245
|
|
|
13164
13246
|
parseLinks() {
|
|
@@ -13174,9 +13256,7 @@ class Softphone {
|
|
|
13174
13256
|
makeCall(number ) {
|
|
13175
13257
|
this.displaySoftphone();
|
|
13176
13258
|
|
|
13177
|
-
|
|
13178
|
-
this.iframe.contentWindow.postMessage({ type: SDK_CLICK_TO_CALL, number }, '*');
|
|
13179
|
-
}
|
|
13259
|
+
this._sendMessage(SDK_CLICK_TO_CALL, { number });
|
|
13180
13260
|
}
|
|
13181
13261
|
|
|
13182
13262
|
toggleSoftphoneDisplay() {
|
|
@@ -13185,8 +13265,6 @@ class Softphone {
|
|
|
13185
13265
|
} else {
|
|
13186
13266
|
this.displaySoftphone();
|
|
13187
13267
|
}
|
|
13188
|
-
|
|
13189
|
-
this.displayed = !this.displayed;
|
|
13190
13268
|
}
|
|
13191
13269
|
|
|
13192
13270
|
displaySoftphone() {
|
|
@@ -13197,15 +13275,30 @@ class Softphone {
|
|
|
13197
13275
|
if (this.iframe) {
|
|
13198
13276
|
this.iframe.style.display = 'block';
|
|
13199
13277
|
}
|
|
13278
|
+
|
|
13279
|
+
this.displayed = true;
|
|
13200
13280
|
}
|
|
13201
13281
|
|
|
13202
13282
|
hideSoftphone() {
|
|
13203
13283
|
if (this.iframe) {
|
|
13204
13284
|
this.iframe.style.display = 'none';
|
|
13205
13285
|
}
|
|
13286
|
+
this.displayed = false;
|
|
13287
|
+
}
|
|
13288
|
+
|
|
13289
|
+
optionsFetched(fieldId , options ) {
|
|
13290
|
+
this._sendMessage(BRIDGE_OPTIONS_FETCHED, { fieldId, options });
|
|
13291
|
+
}
|
|
13292
|
+
|
|
13293
|
+
onOptionsResults(fieldId , options ) {
|
|
13294
|
+
this._sendMessage(BRIDGE_OPTIONS_FOUND, { fieldId, options });
|
|
13295
|
+
}
|
|
13296
|
+
|
|
13297
|
+
setFormSchema(schema , uiSchema ) {
|
|
13298
|
+
this._sendMessage(BRIDGE_UPDATE_FORM_SCHEMA, { schema, uiSchema });
|
|
13206
13299
|
}
|
|
13207
13300
|
|
|
13208
|
-
_createIframe() {
|
|
13301
|
+
_createIframe(cb = () => {}) {
|
|
13209
13302
|
this.iframe = document.createElement('iframe');
|
|
13210
13303
|
// $FlowFixMe
|
|
13211
13304
|
this.iframe.width = this.width;
|
|
@@ -13217,10 +13310,13 @@ class Softphone {
|
|
|
13217
13310
|
this.iframe.style.left = '0';
|
|
13218
13311
|
this.iframe.style.bottom = '0';
|
|
13219
13312
|
this.iframe.style.border = '1px solid #aaa';
|
|
13313
|
+
this.iframe.style.backgroundColor = 'white';
|
|
13220
13314
|
this.iframe.src = this.url;
|
|
13221
13315
|
this.iframe.style.display = 'none';
|
|
13222
13316
|
this.iframe.id = 'wazo-softphone';
|
|
13223
13317
|
|
|
13318
|
+
this.iframe.onload = cb;
|
|
13319
|
+
|
|
13224
13320
|
// $FlowFixMe
|
|
13225
13321
|
document.body.appendChild(this.iframe);
|
|
13226
13322
|
}
|
|
@@ -13263,8 +13359,93 @@ class Softphone {
|
|
|
13263
13359
|
this._onAuthenticated(event.data.session);
|
|
13264
13360
|
this.onAuthenticated(event.data.session);
|
|
13265
13361
|
break;
|
|
13362
|
+
case SDK_LOGGED_OUT:
|
|
13363
|
+
this.onLoggedOut();
|
|
13364
|
+
break;
|
|
13365
|
+
case BRIDGE_CREATE_OR_UPDATE_CARD: {
|
|
13366
|
+
const { content } = event.data;
|
|
13367
|
+
this.onCardSaved(content);
|
|
13368
|
+
break;
|
|
13369
|
+
}
|
|
13370
|
+
case BRIDGE_SEARCH_OPTIONS: {
|
|
13371
|
+
const { fieldId, query } = event.data;
|
|
13372
|
+
this.onSearchOptions(fieldId, query);
|
|
13373
|
+
break;
|
|
13374
|
+
}
|
|
13375
|
+
case BRIDGE_DISPLAY_LINKED_OPTION:
|
|
13376
|
+
this.onDisplayLinkedOption(event.data.linkedOptionId);
|
|
13377
|
+
break;
|
|
13378
|
+
case BRIDGE_WAZO_CONTACT_SEARCH:
|
|
13379
|
+
this.onWazoContactSearch(event.data.query);
|
|
13380
|
+
break;
|
|
13381
|
+
case BRIDGE_ON_AGENT_LOGGED_IN:
|
|
13382
|
+
this.onAgentLoggedIn();
|
|
13383
|
+
break;
|
|
13384
|
+
case BRIDGE_ON_AGENT_LOGGED_OUT:
|
|
13385
|
+
this.onAgentLoggedOut();
|
|
13386
|
+
break;
|
|
13387
|
+
case BRIDGE_ON_AGENT_PAUSED:
|
|
13388
|
+
this.onAgentPaused();
|
|
13389
|
+
break;
|
|
13390
|
+
case BRIDGE_ON_AGENT_RESUMED:
|
|
13391
|
+
this.onAgentResumed();
|
|
13392
|
+
break;
|
|
13393
|
+
case BRIDGE_ON_LANGUAGE_CHANGED:
|
|
13394
|
+
this.onLanguageChanged(event.data.language);
|
|
13395
|
+
break;
|
|
13396
|
+
case BRIDGE_ON_CALL_HELD:
|
|
13397
|
+
this.onCallHeld();
|
|
13398
|
+
break;
|
|
13399
|
+
case BRIDGE_ON_CALL_RESUMED:
|
|
13400
|
+
this.onCallResumed();
|
|
13401
|
+
break;
|
|
13402
|
+
case BRIDGE_ON_CALL_MUTED:
|
|
13403
|
+
this.onCallMuted();
|
|
13404
|
+
break;
|
|
13405
|
+
case BRIDGE_ON_CALL_UN_MUTED:
|
|
13406
|
+
this.onCallUnMuted();
|
|
13407
|
+
break;
|
|
13408
|
+
case BRIDGE_ON_DTMF:
|
|
13409
|
+
this.onDtmfSent(event.data.tone);
|
|
13410
|
+
break;
|
|
13411
|
+
case BRIDGE_ON_DIRECT_TRANSFER:
|
|
13412
|
+
this.onDirectTransfer(event.data.number);
|
|
13413
|
+
break;
|
|
13414
|
+
case BRIDGE_ON_CREATE_INDIRECT_TRANSFER:
|
|
13415
|
+
this.onCreateIndirectTransfer(event.data.number);
|
|
13416
|
+
break;
|
|
13417
|
+
case BRIDGE_ON_CANCEL_INDIRECT_TRANSFER:
|
|
13418
|
+
this.onCancelIndirectTransfer();
|
|
13419
|
+
break;
|
|
13420
|
+
case BRIDGE_ON_CONFIRM_INDIRECT_TRANSFER:
|
|
13421
|
+
this.onConfirmIndirectTransfer();
|
|
13422
|
+
break;
|
|
13423
|
+
case BRIDGE_ON_INDIRECT_TRANSFER_CALL_MADE:
|
|
13424
|
+
this.onIndirectCallMade(event.data.call);
|
|
13425
|
+
break;
|
|
13426
|
+
case BRIDGE_ON_INDIRECT_TRANSFER_DONE:
|
|
13427
|
+
this.onIndirectTransferDone(event.data.call);
|
|
13428
|
+
break;
|
|
13429
|
+
case BRIDGE_ON_START_RECORDING:
|
|
13430
|
+
this.onStartRecording();
|
|
13431
|
+
break;
|
|
13432
|
+
case BRIDGE_ON_STOP_RECORDING:
|
|
13433
|
+
this.onStopRecording();
|
|
13434
|
+
break;
|
|
13435
|
+
default:
|
|
13436
|
+
this.onUnHandledEvent(event);
|
|
13437
|
+
break;
|
|
13266
13438
|
}
|
|
13267
13439
|
}
|
|
13440
|
+
|
|
13441
|
+
_sendMessage(type , payload = {}) {
|
|
13442
|
+
if (!this.iframe) {
|
|
13443
|
+
console.warn(`Could not send message of type ${type} to the Wazo Softphone, iframe not created yet`);
|
|
13444
|
+
return;
|
|
13445
|
+
}
|
|
13446
|
+
|
|
13447
|
+
this.iframe.contentWindow.postMessage({ type, ...payload }, '*');
|
|
13448
|
+
}
|
|
13268
13449
|
}
|
|
13269
13450
|
|
|
13270
13451
|
var Softphone$1 = new Softphone();
|
package/esm/simple/room/Room.js
CHANGED
|
@@ -8326,7 +8326,7 @@ class WebRTCClient extends Emitter {
|
|
|
8326
8326
|
}
|
|
8327
8327
|
|
|
8328
8328
|
async _onHeartbeatTimeout() {
|
|
8329
|
-
logger$8.
|
|
8329
|
+
logger$8.warn('sdk webrtc heartbeat timed out', { userAgent: !!this.userAgent, cb: !!this.heartbeatTimeoutCb });
|
|
8330
8330
|
|
|
8331
8331
|
if (this.heartbeatTimeoutCb) {
|
|
8332
8332
|
this.heartbeatTimeoutCb();
|
|
@@ -13136,11 +13136,41 @@ class Checker {
|
|
|
13136
13136
|
//
|
|
13137
13137
|
/* eslint-disable no-unused-vars */
|
|
13138
13138
|
/* global window, document */
|
|
13139
|
+
const BRIDGE_CONFIG_RETRIEVED = 'bridge/CONFIG_RETRIEVED';
|
|
13140
|
+
const BRIDGE_ENABLE_CARD = 'bridge/ENABLE_CARD';
|
|
13141
|
+
const BRIDGE_CHANGE_REQUIRED_SUBSCRIPTION_TYPE = 'bridge/CHANGE_REQUIRED_SUBSCRIPTION_TYPE';
|
|
13142
|
+
const BRIDGE_CREATE_OR_UPDATE_CARD = 'bridge/BRIDGE_CREATE_OR_UPDATE_CARD';
|
|
13143
|
+
const BRIDGE_OPTIONS_FETCHED = 'bridge/BRIDGE_OPTIONS_FETCHED';
|
|
13144
|
+
const BRIDGE_OPTIONS_FOUND = 'bridge/BRIDGE_OPTIONS_FOUND';
|
|
13145
|
+
const BRIDGE_SEARCH_OPTIONS = 'bridge/BRIDGE_SEARCH_OPTIONS';
|
|
13146
|
+
const BRIDGE_DISPLAY_LINKED_OPTION = 'bridge/DISPLAY_LINKED_OPTION';
|
|
13147
|
+
const BRIDGE_UPDATE_FORM_SCHEMA = 'bridge/BRIDGE_UPDATE_FORM_SCHEMA';
|
|
13148
|
+
const BRIDGE_WAZO_CONTACT_SEARCH = 'bridge/BRIDGE_WAZO_CONTACT_SEARCH';
|
|
13149
|
+
const BRIDGE_ON_AGENT_LOGGED_IN = 'bridge/BRIDGE_ON_AGENT_LOGGED_IN';
|
|
13150
|
+
const BRIDGE_ON_AGENT_LOGGED_OUT = 'bridge/BRIDGE_ON_AGENT_LOGGED_OUT';
|
|
13151
|
+
const BRIDGE_ON_AGENT_PAUSED = 'bridge/BRIDGE_ON_AGENT_PAUSED';
|
|
13152
|
+
const BRIDGE_ON_AGENT_RESUMED = 'bridge/BRIDGE_ON_AGENT_RESUMED';
|
|
13153
|
+
const BRIDGE_ON_LANGUAGE_CHANGED = 'bridge/BRIDGE_ON_LANGUAGE_CHANGED';
|
|
13154
|
+
const BRIDGE_ON_CALL_HELD = 'bridge/BRIDGE_ON_CALL_HELD';
|
|
13155
|
+
const BRIDGE_ON_CALL_RESUMED = 'bridge/BRIDGE_ON_CALL_RESUMED';
|
|
13156
|
+
const BRIDGE_ON_CALL_MUTED = 'bridge/BRIDGE_ON_CALL_MUTED';
|
|
13157
|
+
const BRIDGE_ON_CALL_UN_MUTED = 'bridge/BRIDGE_ON_CALL_UN_MUTED';
|
|
13158
|
+
const BRIDGE_ON_DTMF = 'bridge/BRIDGE_ON_DTMF';
|
|
13159
|
+
const BRIDGE_ON_DIRECT_TRANSFER = 'bridge/BRIDGE_ON_DIRECT_TRANSFER';
|
|
13160
|
+
const BRIDGE_ON_CREATE_INDIRECT_TRANSFER = 'bridge/BRIDGE_ON_CREATE_INDIRECT_TRANSFER';
|
|
13161
|
+
const BRIDGE_ON_CANCEL_INDIRECT_TRANSFER = 'bridge/BRIDGE_ON_CANCEL_INDIRECT_TRANSFER';
|
|
13162
|
+
const BRIDGE_ON_CONFIRM_INDIRECT_TRANSFER = 'bridge/BRIDGE_ON_CONFIRM_INDIRECT_TRANSFER';
|
|
13163
|
+
const BRIDGE_ON_INDIRECT_TRANSFER_CALL_MADE = 'bridge/BRIDGE_ON_INDIRECT_TRANSFER_CALL_MADE';
|
|
13164
|
+
const BRIDGE_ON_INDIRECT_TRANSFER_DONE = 'bridge/BRIDGE_ON_INDIRECT_TRANSFER_DONE';
|
|
13165
|
+
const BRIDGE_ON_START_RECORDING = 'bridge/BRIDGE_ON_START_RECORDING';
|
|
13166
|
+
const BRIDGE_ON_STOP_RECORDING = 'bridge/BRIDGE_ON_STOP_RECORDING';
|
|
13167
|
+
|
|
13139
13168
|
const SDK_CLICK_TO_CALL = 'sdk/CLICK_TO_CALL';
|
|
13140
13169
|
const SDK_ON_CALL_MADE = 'sdk/SDK_ON_CALL_MADE';
|
|
13141
13170
|
const SDK_CALL_ENDED = 'sdk/ON_CALL_ENDED';
|
|
13142
13171
|
const SDK_CALL_INCOMING = 'sdk/SDK_CALL_INCOMING';
|
|
13143
13172
|
const SDK_AUTHENTICATED = 'sdk/SDK_AUTHENTICATED';
|
|
13173
|
+
const SDK_LOGGED_OUT = 'sdk/SDK_LOGGED_OUT';
|
|
13144
13174
|
|
|
13145
13175
|
class Softphone {
|
|
13146
13176
|
url = 'https://softphone.wazo.io';
|
|
@@ -13150,13 +13180,39 @@ class Softphone {
|
|
|
13150
13180
|
iframe = null;
|
|
13151
13181
|
|
|
13152
13182
|
onLinkEnabled(link ) {}
|
|
13183
|
+
onIFrameLoaded() {}
|
|
13153
13184
|
|
|
13154
13185
|
onCallMade(call ) {}
|
|
13155
13186
|
onCallIncoming(call ) {}
|
|
13156
13187
|
onCallEnded(call , card , direction , fromExtension ) {}
|
|
13188
|
+
onCardSaved(card ) {}
|
|
13157
13189
|
onAuthenticated(session ) {}
|
|
13158
|
-
|
|
13159
|
-
|
|
13190
|
+
onLoggedOut() {}
|
|
13191
|
+
onSearchOptions(fieldId , query ) {}
|
|
13192
|
+
onDisplayLinkedOption(optionId ) {}
|
|
13193
|
+
onWazoContactSearch(query ) {}
|
|
13194
|
+
onAgentLoggedIn() {}
|
|
13195
|
+
onAgentLoggedOut() {}
|
|
13196
|
+
onAgentPaused() {}
|
|
13197
|
+
onAgentResumed() {}
|
|
13198
|
+
onLanguageChanged(language ) {}
|
|
13199
|
+
onCallHeld() {}
|
|
13200
|
+
onCallResumed() {}
|
|
13201
|
+
onCallMuted() {}
|
|
13202
|
+
onCallUnMuted() {}
|
|
13203
|
+
onDtmfSent(tone ) {}
|
|
13204
|
+
onDirectTransfer(number ) {}
|
|
13205
|
+
onCreateIndirectTransfer(number ) {}
|
|
13206
|
+
onCancelIndirectTransfer() {}
|
|
13207
|
+
onConfirmIndirectTransfer() {}
|
|
13208
|
+
onIndirectCallMade(call ) {}
|
|
13209
|
+
onIndirectTransferDone(call ) {}
|
|
13210
|
+
onStartRecording() {}
|
|
13211
|
+
onStopRecording() {}
|
|
13212
|
+
onUnHandledEvent(event ) {}
|
|
13213
|
+
|
|
13214
|
+
init({ url, width, height, server, port, language, wrapUpDuration, shouldDisplayLinkedEntities,
|
|
13215
|
+
allowContactCreation, withCard, subscriptionType, enableAgent } = {}) {
|
|
13160
13216
|
if (url) {
|
|
13161
13217
|
this.url = url;
|
|
13162
13218
|
}
|
|
@@ -13169,7 +13225,33 @@ class Softphone {
|
|
|
13169
13225
|
|
|
13170
13226
|
window.addEventListener('message', this._onMessage.bind(this), false);
|
|
13171
13227
|
|
|
13172
|
-
|
|
13228
|
+
if (!server) {
|
|
13229
|
+
// eslint-disable-next-line no-param-reassign
|
|
13230
|
+
server = 'stack.dev.wazo.io';
|
|
13231
|
+
}
|
|
13232
|
+
|
|
13233
|
+
this._createIframe(() => {
|
|
13234
|
+
this._sendMessage(BRIDGE_CONFIG_RETRIEVED, {
|
|
13235
|
+
config: {
|
|
13236
|
+
server,
|
|
13237
|
+
port,
|
|
13238
|
+
language,
|
|
13239
|
+
wrapUpDuration,
|
|
13240
|
+
shouldDisplayLinkedEntities,
|
|
13241
|
+
allowContactCreation,
|
|
13242
|
+
},
|
|
13243
|
+
});
|
|
13244
|
+
|
|
13245
|
+
if (withCard) {
|
|
13246
|
+
this._sendMessage(BRIDGE_ENABLE_CARD);
|
|
13247
|
+
}
|
|
13248
|
+
|
|
13249
|
+
if (subscriptionType) {
|
|
13250
|
+
this._sendMessage(BRIDGE_CHANGE_REQUIRED_SUBSCRIPTION_TYPE, { subscriptionType });
|
|
13251
|
+
}
|
|
13252
|
+
|
|
13253
|
+
this.onIFrameLoaded();
|
|
13254
|
+
});
|
|
13173
13255
|
}
|
|
13174
13256
|
|
|
13175
13257
|
parseLinks() {
|
|
@@ -13185,9 +13267,7 @@ class Softphone {
|
|
|
13185
13267
|
makeCall(number ) {
|
|
13186
13268
|
this.displaySoftphone();
|
|
13187
13269
|
|
|
13188
|
-
|
|
13189
|
-
this.iframe.contentWindow.postMessage({ type: SDK_CLICK_TO_CALL, number }, '*');
|
|
13190
|
-
}
|
|
13270
|
+
this._sendMessage(SDK_CLICK_TO_CALL, { number });
|
|
13191
13271
|
}
|
|
13192
13272
|
|
|
13193
13273
|
toggleSoftphoneDisplay() {
|
|
@@ -13196,8 +13276,6 @@ class Softphone {
|
|
|
13196
13276
|
} else {
|
|
13197
13277
|
this.displaySoftphone();
|
|
13198
13278
|
}
|
|
13199
|
-
|
|
13200
|
-
this.displayed = !this.displayed;
|
|
13201
13279
|
}
|
|
13202
13280
|
|
|
13203
13281
|
displaySoftphone() {
|
|
@@ -13208,15 +13286,30 @@ class Softphone {
|
|
|
13208
13286
|
if (this.iframe) {
|
|
13209
13287
|
this.iframe.style.display = 'block';
|
|
13210
13288
|
}
|
|
13289
|
+
|
|
13290
|
+
this.displayed = true;
|
|
13211
13291
|
}
|
|
13212
13292
|
|
|
13213
13293
|
hideSoftphone() {
|
|
13214
13294
|
if (this.iframe) {
|
|
13215
13295
|
this.iframe.style.display = 'none';
|
|
13216
13296
|
}
|
|
13297
|
+
this.displayed = false;
|
|
13298
|
+
}
|
|
13299
|
+
|
|
13300
|
+
optionsFetched(fieldId , options ) {
|
|
13301
|
+
this._sendMessage(BRIDGE_OPTIONS_FETCHED, { fieldId, options });
|
|
13302
|
+
}
|
|
13303
|
+
|
|
13304
|
+
onOptionsResults(fieldId , options ) {
|
|
13305
|
+
this._sendMessage(BRIDGE_OPTIONS_FOUND, { fieldId, options });
|
|
13306
|
+
}
|
|
13307
|
+
|
|
13308
|
+
setFormSchema(schema , uiSchema ) {
|
|
13309
|
+
this._sendMessage(BRIDGE_UPDATE_FORM_SCHEMA, { schema, uiSchema });
|
|
13217
13310
|
}
|
|
13218
13311
|
|
|
13219
|
-
_createIframe() {
|
|
13312
|
+
_createIframe(cb = () => {}) {
|
|
13220
13313
|
this.iframe = document.createElement('iframe');
|
|
13221
13314
|
// $FlowFixMe
|
|
13222
13315
|
this.iframe.width = this.width;
|
|
@@ -13228,10 +13321,13 @@ class Softphone {
|
|
|
13228
13321
|
this.iframe.style.left = '0';
|
|
13229
13322
|
this.iframe.style.bottom = '0';
|
|
13230
13323
|
this.iframe.style.border = '1px solid #aaa';
|
|
13324
|
+
this.iframe.style.backgroundColor = 'white';
|
|
13231
13325
|
this.iframe.src = this.url;
|
|
13232
13326
|
this.iframe.style.display = 'none';
|
|
13233
13327
|
this.iframe.id = 'wazo-softphone';
|
|
13234
13328
|
|
|
13329
|
+
this.iframe.onload = cb;
|
|
13330
|
+
|
|
13235
13331
|
// $FlowFixMe
|
|
13236
13332
|
document.body.appendChild(this.iframe);
|
|
13237
13333
|
}
|
|
@@ -13274,8 +13370,93 @@ class Softphone {
|
|
|
13274
13370
|
this._onAuthenticated(event.data.session);
|
|
13275
13371
|
this.onAuthenticated(event.data.session);
|
|
13276
13372
|
break;
|
|
13373
|
+
case SDK_LOGGED_OUT:
|
|
13374
|
+
this.onLoggedOut();
|
|
13375
|
+
break;
|
|
13376
|
+
case BRIDGE_CREATE_OR_UPDATE_CARD: {
|
|
13377
|
+
const { content } = event.data;
|
|
13378
|
+
this.onCardSaved(content);
|
|
13379
|
+
break;
|
|
13380
|
+
}
|
|
13381
|
+
case BRIDGE_SEARCH_OPTIONS: {
|
|
13382
|
+
const { fieldId, query } = event.data;
|
|
13383
|
+
this.onSearchOptions(fieldId, query);
|
|
13384
|
+
break;
|
|
13385
|
+
}
|
|
13386
|
+
case BRIDGE_DISPLAY_LINKED_OPTION:
|
|
13387
|
+
this.onDisplayLinkedOption(event.data.linkedOptionId);
|
|
13388
|
+
break;
|
|
13389
|
+
case BRIDGE_WAZO_CONTACT_SEARCH:
|
|
13390
|
+
this.onWazoContactSearch(event.data.query);
|
|
13391
|
+
break;
|
|
13392
|
+
case BRIDGE_ON_AGENT_LOGGED_IN:
|
|
13393
|
+
this.onAgentLoggedIn();
|
|
13394
|
+
break;
|
|
13395
|
+
case BRIDGE_ON_AGENT_LOGGED_OUT:
|
|
13396
|
+
this.onAgentLoggedOut();
|
|
13397
|
+
break;
|
|
13398
|
+
case BRIDGE_ON_AGENT_PAUSED:
|
|
13399
|
+
this.onAgentPaused();
|
|
13400
|
+
break;
|
|
13401
|
+
case BRIDGE_ON_AGENT_RESUMED:
|
|
13402
|
+
this.onAgentResumed();
|
|
13403
|
+
break;
|
|
13404
|
+
case BRIDGE_ON_LANGUAGE_CHANGED:
|
|
13405
|
+
this.onLanguageChanged(event.data.language);
|
|
13406
|
+
break;
|
|
13407
|
+
case BRIDGE_ON_CALL_HELD:
|
|
13408
|
+
this.onCallHeld();
|
|
13409
|
+
break;
|
|
13410
|
+
case BRIDGE_ON_CALL_RESUMED:
|
|
13411
|
+
this.onCallResumed();
|
|
13412
|
+
break;
|
|
13413
|
+
case BRIDGE_ON_CALL_MUTED:
|
|
13414
|
+
this.onCallMuted();
|
|
13415
|
+
break;
|
|
13416
|
+
case BRIDGE_ON_CALL_UN_MUTED:
|
|
13417
|
+
this.onCallUnMuted();
|
|
13418
|
+
break;
|
|
13419
|
+
case BRIDGE_ON_DTMF:
|
|
13420
|
+
this.onDtmfSent(event.data.tone);
|
|
13421
|
+
break;
|
|
13422
|
+
case BRIDGE_ON_DIRECT_TRANSFER:
|
|
13423
|
+
this.onDirectTransfer(event.data.number);
|
|
13424
|
+
break;
|
|
13425
|
+
case BRIDGE_ON_CREATE_INDIRECT_TRANSFER:
|
|
13426
|
+
this.onCreateIndirectTransfer(event.data.number);
|
|
13427
|
+
break;
|
|
13428
|
+
case BRIDGE_ON_CANCEL_INDIRECT_TRANSFER:
|
|
13429
|
+
this.onCancelIndirectTransfer();
|
|
13430
|
+
break;
|
|
13431
|
+
case BRIDGE_ON_CONFIRM_INDIRECT_TRANSFER:
|
|
13432
|
+
this.onConfirmIndirectTransfer();
|
|
13433
|
+
break;
|
|
13434
|
+
case BRIDGE_ON_INDIRECT_TRANSFER_CALL_MADE:
|
|
13435
|
+
this.onIndirectCallMade(event.data.call);
|
|
13436
|
+
break;
|
|
13437
|
+
case BRIDGE_ON_INDIRECT_TRANSFER_DONE:
|
|
13438
|
+
this.onIndirectTransferDone(event.data.call);
|
|
13439
|
+
break;
|
|
13440
|
+
case BRIDGE_ON_START_RECORDING:
|
|
13441
|
+
this.onStartRecording();
|
|
13442
|
+
break;
|
|
13443
|
+
case BRIDGE_ON_STOP_RECORDING:
|
|
13444
|
+
this.onStopRecording();
|
|
13445
|
+
break;
|
|
13446
|
+
default:
|
|
13447
|
+
this.onUnHandledEvent(event);
|
|
13448
|
+
break;
|
|
13277
13449
|
}
|
|
13278
13450
|
}
|
|
13451
|
+
|
|
13452
|
+
_sendMessage(type , payload = {}) {
|
|
13453
|
+
if (!this.iframe) {
|
|
13454
|
+
console.warn(`Could not send message of type ${type} to the Wazo Softphone, iframe not created yet`);
|
|
13455
|
+
return;
|
|
13456
|
+
}
|
|
13457
|
+
|
|
13458
|
+
this.iframe.contentWindow.postMessage({ type, ...payload }, '*');
|
|
13459
|
+
}
|
|
13279
13460
|
}
|
|
13280
13461
|
|
|
13281
13462
|
var Softphone$1 = new Softphone();
|