@wazo/sdk 0.37.43 → 0.38.0
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/dist/wazo-sdk.js +1 -1
- package/esm/index.js +148 -0
- package/esm/simple/Auth.js +148 -0
- package/esm/simple/Configuration.js +148 -0
- package/esm/simple/Phone.js +148 -0
- package/esm/simple/Softphone.js +148 -0
- package/esm/simple/index.js +148 -0
- package/esm/simple/room/LocalParticipant.js +148 -0
- package/esm/simple/room/Participant.js +148 -0
- package/esm/simple/room/RemoteParticipant.js +148 -0
- package/esm/simple/room/Room.js +148 -0
- package/esm/simple/room/SipRoom.js +148 -0
- package/esm/simple/room/Stream.js +148 -0
- package/esm/simple/room/__tests__/RemoteParticipant.test.js +148 -0
- package/esm/simple/utils.js +148 -0
- package/lib/index.js +148 -0
- package/lib/simple/Auth.js +148 -0
- package/lib/simple/Configuration.js +148 -0
- package/lib/simple/Phone.js +148 -0
- package/lib/simple/Softphone.js +150 -0
- package/lib/simple/index.js +148 -0
- package/lib/simple/room/LocalParticipant.js +148 -0
- package/lib/simple/room/Participant.js +148 -0
- package/lib/simple/room/RemoteParticipant.js +148 -0
- package/lib/simple/room/Room.js +148 -0
- package/lib/simple/room/SipRoom.js +148 -0
- package/lib/simple/room/Stream.js +148 -0
- package/lib/simple/room/__tests__/RemoteParticipant.test.js +148 -0
- package/lib/simple/utils.js +148 -0
- package/package.json +1 -1
- package/src/simple/Softphone.js +148 -0
- package/src/simple/index.js +2 -0
|
@@ -13122,6 +13122,153 @@ class Checker {
|
|
|
13122
13122
|
}
|
|
13123
13123
|
}
|
|
13124
13124
|
|
|
13125
|
+
//
|
|
13126
|
+
/* eslint-disable no-unused-vars */
|
|
13127
|
+
/* global window, document */
|
|
13128
|
+
const SDK_CLICK_TO_CALL = 'sdk/CLICK_TO_CALL';
|
|
13129
|
+
const SDK_ON_CALL_MADE = 'sdk/SDK_ON_CALL_MADE';
|
|
13130
|
+
const SDK_CALL_ENDED = 'sdk/ON_CALL_ENDED';
|
|
13131
|
+
const SDK_CALL_INCOMING = 'sdk/SDK_CALL_INCOMING';
|
|
13132
|
+
const SDK_AUTHENTICATED = 'sdk/SDK_AUTHENTICATED';
|
|
13133
|
+
|
|
13134
|
+
class Softphone {
|
|
13135
|
+
url = 'https://softphone.wazo.io';
|
|
13136
|
+
width = 500;
|
|
13137
|
+
height = 600;
|
|
13138
|
+
displayed = false;
|
|
13139
|
+
iframe = null;
|
|
13140
|
+
|
|
13141
|
+
onLinkEnabled(link ) {}
|
|
13142
|
+
|
|
13143
|
+
onCallMade(call ) {}
|
|
13144
|
+
onCallIncoming(call ) {}
|
|
13145
|
+
onCallEnded(call , card , direction , fromExtension ) {}
|
|
13146
|
+
onAuthenticated(session ) {}
|
|
13147
|
+
|
|
13148
|
+
init(url , width , height ) {
|
|
13149
|
+
if (url) {
|
|
13150
|
+
this.url = url;
|
|
13151
|
+
}
|
|
13152
|
+
if (width) {
|
|
13153
|
+
this.width = width;
|
|
13154
|
+
}
|
|
13155
|
+
if (height) {
|
|
13156
|
+
this.height = height;
|
|
13157
|
+
}
|
|
13158
|
+
|
|
13159
|
+
window.addEventListener('message', this._onMessage.bind(this), false);
|
|
13160
|
+
|
|
13161
|
+
this._createIframe();
|
|
13162
|
+
}
|
|
13163
|
+
|
|
13164
|
+
parseLinks() {
|
|
13165
|
+
const links = this._getLinks();
|
|
13166
|
+
|
|
13167
|
+
links.forEach(link => {
|
|
13168
|
+
link.setAttribute('data-wazo-parsed', true);
|
|
13169
|
+
link.addEventListener('click', this._onLinkClick.bind(this));
|
|
13170
|
+
this.onLinkEnabled(link);
|
|
13171
|
+
});
|
|
13172
|
+
}
|
|
13173
|
+
|
|
13174
|
+
makeCall(number ) {
|
|
13175
|
+
this.displaySoftphone();
|
|
13176
|
+
|
|
13177
|
+
if (this.iframe) {
|
|
13178
|
+
this.iframe.contentWindow.postMessage({ type: SDK_CLICK_TO_CALL, number }, '*');
|
|
13179
|
+
}
|
|
13180
|
+
}
|
|
13181
|
+
|
|
13182
|
+
toggleSoftphoneDisplay() {
|
|
13183
|
+
if (this.displayed) {
|
|
13184
|
+
this.hideSoftphone();
|
|
13185
|
+
} else {
|
|
13186
|
+
this.displaySoftphone();
|
|
13187
|
+
}
|
|
13188
|
+
|
|
13189
|
+
this.displayed = !this.displayed;
|
|
13190
|
+
}
|
|
13191
|
+
|
|
13192
|
+
displaySoftphone() {
|
|
13193
|
+
if (!this.iframe) {
|
|
13194
|
+
this._createIframe();
|
|
13195
|
+
}
|
|
13196
|
+
|
|
13197
|
+
if (this.iframe) {
|
|
13198
|
+
this.iframe.style.display = 'block';
|
|
13199
|
+
}
|
|
13200
|
+
}
|
|
13201
|
+
|
|
13202
|
+
hideSoftphone() {
|
|
13203
|
+
if (this.iframe) {
|
|
13204
|
+
this.iframe.style.display = 'none';
|
|
13205
|
+
}
|
|
13206
|
+
}
|
|
13207
|
+
|
|
13208
|
+
_createIframe() {
|
|
13209
|
+
this.iframe = document.createElement('iframe');
|
|
13210
|
+
// $FlowFixMe
|
|
13211
|
+
this.iframe.width = this.width;
|
|
13212
|
+
// $FlowFixMe
|
|
13213
|
+
this.iframe.height = this.height;
|
|
13214
|
+
// $FlowFixMe
|
|
13215
|
+
this.iframe.allow = 'camera *; microphone *; autoplay *; display-capture *';
|
|
13216
|
+
this.iframe.style.position = 'absolute';
|
|
13217
|
+
this.iframe.style.left = '0';
|
|
13218
|
+
this.iframe.style.bottom = '0';
|
|
13219
|
+
this.iframe.style.border = '1px solid #aaa';
|
|
13220
|
+
this.iframe.src = this.url;
|
|
13221
|
+
this.iframe.style.display = 'none';
|
|
13222
|
+
this.iframe.id = 'wazo-softphone';
|
|
13223
|
+
|
|
13224
|
+
// $FlowFixMe
|
|
13225
|
+
document.body.appendChild(this.iframe);
|
|
13226
|
+
}
|
|
13227
|
+
|
|
13228
|
+
_getLinks() {
|
|
13229
|
+
return [].slice.call(document.querySelectorAll('a:not([data-wazo-parsed])'), 0)
|
|
13230
|
+
.filter(link => link.href.indexOf('tel:') === 0 || link.href.indexOf('callto:') === 0);
|
|
13231
|
+
}
|
|
13232
|
+
|
|
13233
|
+
_onLinkClick(e ) {
|
|
13234
|
+
e.preventDefault();
|
|
13235
|
+
const number = e.target.href.split(':')[1];
|
|
13236
|
+
|
|
13237
|
+
this.makeCall(number);
|
|
13238
|
+
}
|
|
13239
|
+
|
|
13240
|
+
_onAuthenticated() {
|
|
13241
|
+
this.parseLinks();
|
|
13242
|
+
}
|
|
13243
|
+
|
|
13244
|
+
_onMessage(event ) {
|
|
13245
|
+
if (!event.data) {
|
|
13246
|
+
return;
|
|
13247
|
+
}
|
|
13248
|
+
|
|
13249
|
+
switch (event.data.type) {
|
|
13250
|
+
case SDK_ON_CALL_MADE:
|
|
13251
|
+
this.onCallMade(event.data.callSession);
|
|
13252
|
+
break;
|
|
13253
|
+
case SDK_CALL_ENDED: {
|
|
13254
|
+
const { callSession, content, direction, userExtension } = event.data;
|
|
13255
|
+
this.onCallEnded(callSession, content, direction, userExtension);
|
|
13256
|
+
break;
|
|
13257
|
+
}
|
|
13258
|
+
case SDK_CALL_INCOMING:
|
|
13259
|
+
this.onCallIncoming(event.data.callSession);
|
|
13260
|
+
break;
|
|
13261
|
+
case SDK_AUTHENTICATED:
|
|
13262
|
+
// $FlowFixMe
|
|
13263
|
+
this._onAuthenticated(event.data.session);
|
|
13264
|
+
this.onAuthenticated(event.data.session);
|
|
13265
|
+
break;
|
|
13266
|
+
}
|
|
13267
|
+
}
|
|
13268
|
+
}
|
|
13269
|
+
|
|
13270
|
+
var Softphone$1 = new Softphone();
|
|
13271
|
+
|
|
13125
13272
|
/* global window */
|
|
13126
13273
|
|
|
13127
13274
|
const Wazo = {
|
|
@@ -13142,6 +13289,7 @@ const Wazo = {
|
|
|
13142
13289
|
loggerFor: IssueReporter$1.loggerFor.bind(IssueReporter$1),
|
|
13143
13290
|
Features: Features$1,
|
|
13144
13291
|
Checker,
|
|
13292
|
+
Softphone: Softphone$1,
|
|
13145
13293
|
|
|
13146
13294
|
// Domain
|
|
13147
13295
|
domain: {
|
package/esm/simple/room/Room.js
CHANGED
|
@@ -13133,6 +13133,153 @@ class Checker {
|
|
|
13133
13133
|
}
|
|
13134
13134
|
}
|
|
13135
13135
|
|
|
13136
|
+
//
|
|
13137
|
+
/* eslint-disable no-unused-vars */
|
|
13138
|
+
/* global window, document */
|
|
13139
|
+
const SDK_CLICK_TO_CALL = 'sdk/CLICK_TO_CALL';
|
|
13140
|
+
const SDK_ON_CALL_MADE = 'sdk/SDK_ON_CALL_MADE';
|
|
13141
|
+
const SDK_CALL_ENDED = 'sdk/ON_CALL_ENDED';
|
|
13142
|
+
const SDK_CALL_INCOMING = 'sdk/SDK_CALL_INCOMING';
|
|
13143
|
+
const SDK_AUTHENTICATED = 'sdk/SDK_AUTHENTICATED';
|
|
13144
|
+
|
|
13145
|
+
class Softphone {
|
|
13146
|
+
url = 'https://softphone.wazo.io';
|
|
13147
|
+
width = 500;
|
|
13148
|
+
height = 600;
|
|
13149
|
+
displayed = false;
|
|
13150
|
+
iframe = null;
|
|
13151
|
+
|
|
13152
|
+
onLinkEnabled(link ) {}
|
|
13153
|
+
|
|
13154
|
+
onCallMade(call ) {}
|
|
13155
|
+
onCallIncoming(call ) {}
|
|
13156
|
+
onCallEnded(call , card , direction , fromExtension ) {}
|
|
13157
|
+
onAuthenticated(session ) {}
|
|
13158
|
+
|
|
13159
|
+
init(url , width , height ) {
|
|
13160
|
+
if (url) {
|
|
13161
|
+
this.url = url;
|
|
13162
|
+
}
|
|
13163
|
+
if (width) {
|
|
13164
|
+
this.width = width;
|
|
13165
|
+
}
|
|
13166
|
+
if (height) {
|
|
13167
|
+
this.height = height;
|
|
13168
|
+
}
|
|
13169
|
+
|
|
13170
|
+
window.addEventListener('message', this._onMessage.bind(this), false);
|
|
13171
|
+
|
|
13172
|
+
this._createIframe();
|
|
13173
|
+
}
|
|
13174
|
+
|
|
13175
|
+
parseLinks() {
|
|
13176
|
+
const links = this._getLinks();
|
|
13177
|
+
|
|
13178
|
+
links.forEach(link => {
|
|
13179
|
+
link.setAttribute('data-wazo-parsed', true);
|
|
13180
|
+
link.addEventListener('click', this._onLinkClick.bind(this));
|
|
13181
|
+
this.onLinkEnabled(link);
|
|
13182
|
+
});
|
|
13183
|
+
}
|
|
13184
|
+
|
|
13185
|
+
makeCall(number ) {
|
|
13186
|
+
this.displaySoftphone();
|
|
13187
|
+
|
|
13188
|
+
if (this.iframe) {
|
|
13189
|
+
this.iframe.contentWindow.postMessage({ type: SDK_CLICK_TO_CALL, number }, '*');
|
|
13190
|
+
}
|
|
13191
|
+
}
|
|
13192
|
+
|
|
13193
|
+
toggleSoftphoneDisplay() {
|
|
13194
|
+
if (this.displayed) {
|
|
13195
|
+
this.hideSoftphone();
|
|
13196
|
+
} else {
|
|
13197
|
+
this.displaySoftphone();
|
|
13198
|
+
}
|
|
13199
|
+
|
|
13200
|
+
this.displayed = !this.displayed;
|
|
13201
|
+
}
|
|
13202
|
+
|
|
13203
|
+
displaySoftphone() {
|
|
13204
|
+
if (!this.iframe) {
|
|
13205
|
+
this._createIframe();
|
|
13206
|
+
}
|
|
13207
|
+
|
|
13208
|
+
if (this.iframe) {
|
|
13209
|
+
this.iframe.style.display = 'block';
|
|
13210
|
+
}
|
|
13211
|
+
}
|
|
13212
|
+
|
|
13213
|
+
hideSoftphone() {
|
|
13214
|
+
if (this.iframe) {
|
|
13215
|
+
this.iframe.style.display = 'none';
|
|
13216
|
+
}
|
|
13217
|
+
}
|
|
13218
|
+
|
|
13219
|
+
_createIframe() {
|
|
13220
|
+
this.iframe = document.createElement('iframe');
|
|
13221
|
+
// $FlowFixMe
|
|
13222
|
+
this.iframe.width = this.width;
|
|
13223
|
+
// $FlowFixMe
|
|
13224
|
+
this.iframe.height = this.height;
|
|
13225
|
+
// $FlowFixMe
|
|
13226
|
+
this.iframe.allow = 'camera *; microphone *; autoplay *; display-capture *';
|
|
13227
|
+
this.iframe.style.position = 'absolute';
|
|
13228
|
+
this.iframe.style.left = '0';
|
|
13229
|
+
this.iframe.style.bottom = '0';
|
|
13230
|
+
this.iframe.style.border = '1px solid #aaa';
|
|
13231
|
+
this.iframe.src = this.url;
|
|
13232
|
+
this.iframe.style.display = 'none';
|
|
13233
|
+
this.iframe.id = 'wazo-softphone';
|
|
13234
|
+
|
|
13235
|
+
// $FlowFixMe
|
|
13236
|
+
document.body.appendChild(this.iframe);
|
|
13237
|
+
}
|
|
13238
|
+
|
|
13239
|
+
_getLinks() {
|
|
13240
|
+
return [].slice.call(document.querySelectorAll('a:not([data-wazo-parsed])'), 0)
|
|
13241
|
+
.filter(link => link.href.indexOf('tel:') === 0 || link.href.indexOf('callto:') === 0);
|
|
13242
|
+
}
|
|
13243
|
+
|
|
13244
|
+
_onLinkClick(e ) {
|
|
13245
|
+
e.preventDefault();
|
|
13246
|
+
const number = e.target.href.split(':')[1];
|
|
13247
|
+
|
|
13248
|
+
this.makeCall(number);
|
|
13249
|
+
}
|
|
13250
|
+
|
|
13251
|
+
_onAuthenticated() {
|
|
13252
|
+
this.parseLinks();
|
|
13253
|
+
}
|
|
13254
|
+
|
|
13255
|
+
_onMessage(event ) {
|
|
13256
|
+
if (!event.data) {
|
|
13257
|
+
return;
|
|
13258
|
+
}
|
|
13259
|
+
|
|
13260
|
+
switch (event.data.type) {
|
|
13261
|
+
case SDK_ON_CALL_MADE:
|
|
13262
|
+
this.onCallMade(event.data.callSession);
|
|
13263
|
+
break;
|
|
13264
|
+
case SDK_CALL_ENDED: {
|
|
13265
|
+
const { callSession, content, direction, userExtension } = event.data;
|
|
13266
|
+
this.onCallEnded(callSession, content, direction, userExtension);
|
|
13267
|
+
break;
|
|
13268
|
+
}
|
|
13269
|
+
case SDK_CALL_INCOMING:
|
|
13270
|
+
this.onCallIncoming(event.data.callSession);
|
|
13271
|
+
break;
|
|
13272
|
+
case SDK_AUTHENTICATED:
|
|
13273
|
+
// $FlowFixMe
|
|
13274
|
+
this._onAuthenticated(event.data.session);
|
|
13275
|
+
this.onAuthenticated(event.data.session);
|
|
13276
|
+
break;
|
|
13277
|
+
}
|
|
13278
|
+
}
|
|
13279
|
+
}
|
|
13280
|
+
|
|
13281
|
+
var Softphone$1 = new Softphone();
|
|
13282
|
+
|
|
13136
13283
|
/* global window */
|
|
13137
13284
|
|
|
13138
13285
|
const Wazo = {
|
|
@@ -13153,6 +13300,7 @@ const Wazo = {
|
|
|
13153
13300
|
loggerFor: IssueReporter$1.loggerFor.bind(IssueReporter$1),
|
|
13154
13301
|
Features: Features$1,
|
|
13155
13302
|
Checker,
|
|
13303
|
+
Softphone: Softphone$1,
|
|
13156
13304
|
|
|
13157
13305
|
// Domain
|
|
13158
13306
|
domain: {
|
|
@@ -13830,6 +13830,153 @@ class Checker {
|
|
|
13830
13830
|
}
|
|
13831
13831
|
}
|
|
13832
13832
|
|
|
13833
|
+
//
|
|
13834
|
+
/* eslint-disable no-unused-vars */
|
|
13835
|
+
/* global window, document */
|
|
13836
|
+
const SDK_CLICK_TO_CALL = 'sdk/CLICK_TO_CALL';
|
|
13837
|
+
const SDK_ON_CALL_MADE = 'sdk/SDK_ON_CALL_MADE';
|
|
13838
|
+
const SDK_CALL_ENDED = 'sdk/ON_CALL_ENDED';
|
|
13839
|
+
const SDK_CALL_INCOMING = 'sdk/SDK_CALL_INCOMING';
|
|
13840
|
+
const SDK_AUTHENTICATED = 'sdk/SDK_AUTHENTICATED';
|
|
13841
|
+
|
|
13842
|
+
class Softphone {
|
|
13843
|
+
url = 'https://softphone.wazo.io';
|
|
13844
|
+
width = 500;
|
|
13845
|
+
height = 600;
|
|
13846
|
+
displayed = false;
|
|
13847
|
+
iframe = null;
|
|
13848
|
+
|
|
13849
|
+
onLinkEnabled(link ) {}
|
|
13850
|
+
|
|
13851
|
+
onCallMade(call ) {}
|
|
13852
|
+
onCallIncoming(call ) {}
|
|
13853
|
+
onCallEnded(call , card , direction , fromExtension ) {}
|
|
13854
|
+
onAuthenticated(session ) {}
|
|
13855
|
+
|
|
13856
|
+
init(url , width , height ) {
|
|
13857
|
+
if (url) {
|
|
13858
|
+
this.url = url;
|
|
13859
|
+
}
|
|
13860
|
+
if (width) {
|
|
13861
|
+
this.width = width;
|
|
13862
|
+
}
|
|
13863
|
+
if (height) {
|
|
13864
|
+
this.height = height;
|
|
13865
|
+
}
|
|
13866
|
+
|
|
13867
|
+
window.addEventListener('message', this._onMessage.bind(this), false);
|
|
13868
|
+
|
|
13869
|
+
this._createIframe();
|
|
13870
|
+
}
|
|
13871
|
+
|
|
13872
|
+
parseLinks() {
|
|
13873
|
+
const links = this._getLinks();
|
|
13874
|
+
|
|
13875
|
+
links.forEach(link => {
|
|
13876
|
+
link.setAttribute('data-wazo-parsed', true);
|
|
13877
|
+
link.addEventListener('click', this._onLinkClick.bind(this));
|
|
13878
|
+
this.onLinkEnabled(link);
|
|
13879
|
+
});
|
|
13880
|
+
}
|
|
13881
|
+
|
|
13882
|
+
makeCall(number ) {
|
|
13883
|
+
this.displaySoftphone();
|
|
13884
|
+
|
|
13885
|
+
if (this.iframe) {
|
|
13886
|
+
this.iframe.contentWindow.postMessage({ type: SDK_CLICK_TO_CALL, number }, '*');
|
|
13887
|
+
}
|
|
13888
|
+
}
|
|
13889
|
+
|
|
13890
|
+
toggleSoftphoneDisplay() {
|
|
13891
|
+
if (this.displayed) {
|
|
13892
|
+
this.hideSoftphone();
|
|
13893
|
+
} else {
|
|
13894
|
+
this.displaySoftphone();
|
|
13895
|
+
}
|
|
13896
|
+
|
|
13897
|
+
this.displayed = !this.displayed;
|
|
13898
|
+
}
|
|
13899
|
+
|
|
13900
|
+
displaySoftphone() {
|
|
13901
|
+
if (!this.iframe) {
|
|
13902
|
+
this._createIframe();
|
|
13903
|
+
}
|
|
13904
|
+
|
|
13905
|
+
if (this.iframe) {
|
|
13906
|
+
this.iframe.style.display = 'block';
|
|
13907
|
+
}
|
|
13908
|
+
}
|
|
13909
|
+
|
|
13910
|
+
hideSoftphone() {
|
|
13911
|
+
if (this.iframe) {
|
|
13912
|
+
this.iframe.style.display = 'none';
|
|
13913
|
+
}
|
|
13914
|
+
}
|
|
13915
|
+
|
|
13916
|
+
_createIframe() {
|
|
13917
|
+
this.iframe = document.createElement('iframe');
|
|
13918
|
+
// $FlowFixMe
|
|
13919
|
+
this.iframe.width = this.width;
|
|
13920
|
+
// $FlowFixMe
|
|
13921
|
+
this.iframe.height = this.height;
|
|
13922
|
+
// $FlowFixMe
|
|
13923
|
+
this.iframe.allow = 'camera *; microphone *; autoplay *; display-capture *';
|
|
13924
|
+
this.iframe.style.position = 'absolute';
|
|
13925
|
+
this.iframe.style.left = '0';
|
|
13926
|
+
this.iframe.style.bottom = '0';
|
|
13927
|
+
this.iframe.style.border = '1px solid #aaa';
|
|
13928
|
+
this.iframe.src = this.url;
|
|
13929
|
+
this.iframe.style.display = 'none';
|
|
13930
|
+
this.iframe.id = 'wazo-softphone';
|
|
13931
|
+
|
|
13932
|
+
// $FlowFixMe
|
|
13933
|
+
document.body.appendChild(this.iframe);
|
|
13934
|
+
}
|
|
13935
|
+
|
|
13936
|
+
_getLinks() {
|
|
13937
|
+
return [].slice.call(document.querySelectorAll('a:not([data-wazo-parsed])'), 0)
|
|
13938
|
+
.filter(link => link.href.indexOf('tel:') === 0 || link.href.indexOf('callto:') === 0);
|
|
13939
|
+
}
|
|
13940
|
+
|
|
13941
|
+
_onLinkClick(e ) {
|
|
13942
|
+
e.preventDefault();
|
|
13943
|
+
const number = e.target.href.split(':')[1];
|
|
13944
|
+
|
|
13945
|
+
this.makeCall(number);
|
|
13946
|
+
}
|
|
13947
|
+
|
|
13948
|
+
_onAuthenticated() {
|
|
13949
|
+
this.parseLinks();
|
|
13950
|
+
}
|
|
13951
|
+
|
|
13952
|
+
_onMessage(event ) {
|
|
13953
|
+
if (!event.data) {
|
|
13954
|
+
return;
|
|
13955
|
+
}
|
|
13956
|
+
|
|
13957
|
+
switch (event.data.type) {
|
|
13958
|
+
case SDK_ON_CALL_MADE:
|
|
13959
|
+
this.onCallMade(event.data.callSession);
|
|
13960
|
+
break;
|
|
13961
|
+
case SDK_CALL_ENDED: {
|
|
13962
|
+
const { callSession, content, direction, userExtension } = event.data;
|
|
13963
|
+
this.onCallEnded(callSession, content, direction, userExtension);
|
|
13964
|
+
break;
|
|
13965
|
+
}
|
|
13966
|
+
case SDK_CALL_INCOMING:
|
|
13967
|
+
this.onCallIncoming(event.data.callSession);
|
|
13968
|
+
break;
|
|
13969
|
+
case SDK_AUTHENTICATED:
|
|
13970
|
+
// $FlowFixMe
|
|
13971
|
+
this._onAuthenticated(event.data.session);
|
|
13972
|
+
this.onAuthenticated(event.data.session);
|
|
13973
|
+
break;
|
|
13974
|
+
}
|
|
13975
|
+
}
|
|
13976
|
+
}
|
|
13977
|
+
|
|
13978
|
+
var Softphone$1 = new Softphone();
|
|
13979
|
+
|
|
13833
13980
|
/* global window */
|
|
13834
13981
|
|
|
13835
13982
|
const Wazo = {
|
|
@@ -13850,6 +13997,7 @@ const Wazo = {
|
|
|
13850
13997
|
loggerFor: IssueReporter$1.loggerFor.bind(IssueReporter$1),
|
|
13851
13998
|
Features: Features$1,
|
|
13852
13999
|
Checker,
|
|
14000
|
+
Softphone: Softphone$1,
|
|
13853
14001
|
|
|
13854
14002
|
// Domain
|
|
13855
14003
|
domain: {
|
|
@@ -13911,6 +13911,153 @@ class Checker {
|
|
|
13911
13911
|
}
|
|
13912
13912
|
}
|
|
13913
13913
|
|
|
13914
|
+
//
|
|
13915
|
+
/* eslint-disable no-unused-vars */
|
|
13916
|
+
/* global window, document */
|
|
13917
|
+
const SDK_CLICK_TO_CALL = 'sdk/CLICK_TO_CALL';
|
|
13918
|
+
const SDK_ON_CALL_MADE = 'sdk/SDK_ON_CALL_MADE';
|
|
13919
|
+
const SDK_CALL_ENDED = 'sdk/ON_CALL_ENDED';
|
|
13920
|
+
const SDK_CALL_INCOMING = 'sdk/SDK_CALL_INCOMING';
|
|
13921
|
+
const SDK_AUTHENTICATED = 'sdk/SDK_AUTHENTICATED';
|
|
13922
|
+
|
|
13923
|
+
class Softphone {
|
|
13924
|
+
url = 'https://softphone.wazo.io';
|
|
13925
|
+
width = 500;
|
|
13926
|
+
height = 600;
|
|
13927
|
+
displayed = false;
|
|
13928
|
+
iframe = null;
|
|
13929
|
+
|
|
13930
|
+
onLinkEnabled(link ) {}
|
|
13931
|
+
|
|
13932
|
+
onCallMade(call ) {}
|
|
13933
|
+
onCallIncoming(call ) {}
|
|
13934
|
+
onCallEnded(call , card , direction , fromExtension ) {}
|
|
13935
|
+
onAuthenticated(session ) {}
|
|
13936
|
+
|
|
13937
|
+
init(url , width , height ) {
|
|
13938
|
+
if (url) {
|
|
13939
|
+
this.url = url;
|
|
13940
|
+
}
|
|
13941
|
+
if (width) {
|
|
13942
|
+
this.width = width;
|
|
13943
|
+
}
|
|
13944
|
+
if (height) {
|
|
13945
|
+
this.height = height;
|
|
13946
|
+
}
|
|
13947
|
+
|
|
13948
|
+
window.addEventListener('message', this._onMessage.bind(this), false);
|
|
13949
|
+
|
|
13950
|
+
this._createIframe();
|
|
13951
|
+
}
|
|
13952
|
+
|
|
13953
|
+
parseLinks() {
|
|
13954
|
+
const links = this._getLinks();
|
|
13955
|
+
|
|
13956
|
+
links.forEach(link => {
|
|
13957
|
+
link.setAttribute('data-wazo-parsed', true);
|
|
13958
|
+
link.addEventListener('click', this._onLinkClick.bind(this));
|
|
13959
|
+
this.onLinkEnabled(link);
|
|
13960
|
+
});
|
|
13961
|
+
}
|
|
13962
|
+
|
|
13963
|
+
makeCall(number ) {
|
|
13964
|
+
this.displaySoftphone();
|
|
13965
|
+
|
|
13966
|
+
if (this.iframe) {
|
|
13967
|
+
this.iframe.contentWindow.postMessage({ type: SDK_CLICK_TO_CALL, number }, '*');
|
|
13968
|
+
}
|
|
13969
|
+
}
|
|
13970
|
+
|
|
13971
|
+
toggleSoftphoneDisplay() {
|
|
13972
|
+
if (this.displayed) {
|
|
13973
|
+
this.hideSoftphone();
|
|
13974
|
+
} else {
|
|
13975
|
+
this.displaySoftphone();
|
|
13976
|
+
}
|
|
13977
|
+
|
|
13978
|
+
this.displayed = !this.displayed;
|
|
13979
|
+
}
|
|
13980
|
+
|
|
13981
|
+
displaySoftphone() {
|
|
13982
|
+
if (!this.iframe) {
|
|
13983
|
+
this._createIframe();
|
|
13984
|
+
}
|
|
13985
|
+
|
|
13986
|
+
if (this.iframe) {
|
|
13987
|
+
this.iframe.style.display = 'block';
|
|
13988
|
+
}
|
|
13989
|
+
}
|
|
13990
|
+
|
|
13991
|
+
hideSoftphone() {
|
|
13992
|
+
if (this.iframe) {
|
|
13993
|
+
this.iframe.style.display = 'none';
|
|
13994
|
+
}
|
|
13995
|
+
}
|
|
13996
|
+
|
|
13997
|
+
_createIframe() {
|
|
13998
|
+
this.iframe = document.createElement('iframe');
|
|
13999
|
+
// $FlowFixMe
|
|
14000
|
+
this.iframe.width = this.width;
|
|
14001
|
+
// $FlowFixMe
|
|
14002
|
+
this.iframe.height = this.height;
|
|
14003
|
+
// $FlowFixMe
|
|
14004
|
+
this.iframe.allow = 'camera *; microphone *; autoplay *; display-capture *';
|
|
14005
|
+
this.iframe.style.position = 'absolute';
|
|
14006
|
+
this.iframe.style.left = '0';
|
|
14007
|
+
this.iframe.style.bottom = '0';
|
|
14008
|
+
this.iframe.style.border = '1px solid #aaa';
|
|
14009
|
+
this.iframe.src = this.url;
|
|
14010
|
+
this.iframe.style.display = 'none';
|
|
14011
|
+
this.iframe.id = 'wazo-softphone';
|
|
14012
|
+
|
|
14013
|
+
// $FlowFixMe
|
|
14014
|
+
document.body.appendChild(this.iframe);
|
|
14015
|
+
}
|
|
14016
|
+
|
|
14017
|
+
_getLinks() {
|
|
14018
|
+
return [].slice.call(document.querySelectorAll('a:not([data-wazo-parsed])'), 0)
|
|
14019
|
+
.filter(link => link.href.indexOf('tel:') === 0 || link.href.indexOf('callto:') === 0);
|
|
14020
|
+
}
|
|
14021
|
+
|
|
14022
|
+
_onLinkClick(e ) {
|
|
14023
|
+
e.preventDefault();
|
|
14024
|
+
const number = e.target.href.split(':')[1];
|
|
14025
|
+
|
|
14026
|
+
this.makeCall(number);
|
|
14027
|
+
}
|
|
14028
|
+
|
|
14029
|
+
_onAuthenticated() {
|
|
14030
|
+
this.parseLinks();
|
|
14031
|
+
}
|
|
14032
|
+
|
|
14033
|
+
_onMessage(event ) {
|
|
14034
|
+
if (!event.data) {
|
|
14035
|
+
return;
|
|
14036
|
+
}
|
|
14037
|
+
|
|
14038
|
+
switch (event.data.type) {
|
|
14039
|
+
case SDK_ON_CALL_MADE:
|
|
14040
|
+
this.onCallMade(event.data.callSession);
|
|
14041
|
+
break;
|
|
14042
|
+
case SDK_CALL_ENDED: {
|
|
14043
|
+
const { callSession, content, direction, userExtension } = event.data;
|
|
14044
|
+
this.onCallEnded(callSession, content, direction, userExtension);
|
|
14045
|
+
break;
|
|
14046
|
+
}
|
|
14047
|
+
case SDK_CALL_INCOMING:
|
|
14048
|
+
this.onCallIncoming(event.data.callSession);
|
|
14049
|
+
break;
|
|
14050
|
+
case SDK_AUTHENTICATED:
|
|
14051
|
+
// $FlowFixMe
|
|
14052
|
+
this._onAuthenticated(event.data.session);
|
|
14053
|
+
this.onAuthenticated(event.data.session);
|
|
14054
|
+
break;
|
|
14055
|
+
}
|
|
14056
|
+
}
|
|
14057
|
+
}
|
|
14058
|
+
|
|
14059
|
+
var Softphone$1 = new Softphone();
|
|
14060
|
+
|
|
13914
14061
|
/* global window */
|
|
13915
14062
|
|
|
13916
14063
|
const Wazo = {
|
|
@@ -13931,6 +14078,7 @@ const Wazo = {
|
|
|
13931
14078
|
loggerFor: IssueReporter$1.loggerFor.bind(IssueReporter$1),
|
|
13932
14079
|
Features: Features$1,
|
|
13933
14080
|
Checker,
|
|
14081
|
+
Softphone: Softphone$1,
|
|
13934
14082
|
|
|
13935
14083
|
// Domain
|
|
13936
14084
|
domain: {
|