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