@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
|
@@ -12848,6 +12848,153 @@ class Checker {
|
|
|
12848
12848
|
}
|
|
12849
12849
|
}
|
|
12850
12850
|
|
|
12851
|
+
//
|
|
12852
|
+
/* eslint-disable no-unused-vars */
|
|
12853
|
+
/* global window, document */
|
|
12854
|
+
const SDK_CLICK_TO_CALL = 'sdk/CLICK_TO_CALL';
|
|
12855
|
+
const SDK_ON_CALL_MADE = 'sdk/SDK_ON_CALL_MADE';
|
|
12856
|
+
const SDK_CALL_ENDED = 'sdk/ON_CALL_ENDED';
|
|
12857
|
+
const SDK_CALL_INCOMING = 'sdk/SDK_CALL_INCOMING';
|
|
12858
|
+
const SDK_AUTHENTICATED = 'sdk/SDK_AUTHENTICATED';
|
|
12859
|
+
|
|
12860
|
+
class Softphone {
|
|
12861
|
+
url = 'https://softphone.wazo.io';
|
|
12862
|
+
width = 500;
|
|
12863
|
+
height = 600;
|
|
12864
|
+
displayed = false;
|
|
12865
|
+
iframe = null;
|
|
12866
|
+
|
|
12867
|
+
onLinkEnabled(link ) {}
|
|
12868
|
+
|
|
12869
|
+
onCallMade(call ) {}
|
|
12870
|
+
onCallIncoming(call ) {}
|
|
12871
|
+
onCallEnded(call , card , direction , fromExtension ) {}
|
|
12872
|
+
onAuthenticated(session ) {}
|
|
12873
|
+
|
|
12874
|
+
init(url , width , height ) {
|
|
12875
|
+
if (url) {
|
|
12876
|
+
this.url = url;
|
|
12877
|
+
}
|
|
12878
|
+
if (width) {
|
|
12879
|
+
this.width = width;
|
|
12880
|
+
}
|
|
12881
|
+
if (height) {
|
|
12882
|
+
this.height = height;
|
|
12883
|
+
}
|
|
12884
|
+
|
|
12885
|
+
window.addEventListener('message', this._onMessage.bind(this), false);
|
|
12886
|
+
|
|
12887
|
+
this._createIframe();
|
|
12888
|
+
}
|
|
12889
|
+
|
|
12890
|
+
parseLinks() {
|
|
12891
|
+
const links = this._getLinks();
|
|
12892
|
+
|
|
12893
|
+
links.forEach(link => {
|
|
12894
|
+
link.setAttribute('data-wazo-parsed', true);
|
|
12895
|
+
link.addEventListener('click', this._onLinkClick.bind(this));
|
|
12896
|
+
this.onLinkEnabled(link);
|
|
12897
|
+
});
|
|
12898
|
+
}
|
|
12899
|
+
|
|
12900
|
+
makeCall(number ) {
|
|
12901
|
+
this.displaySoftphone();
|
|
12902
|
+
|
|
12903
|
+
if (this.iframe) {
|
|
12904
|
+
this.iframe.contentWindow.postMessage({ type: SDK_CLICK_TO_CALL, number }, '*');
|
|
12905
|
+
}
|
|
12906
|
+
}
|
|
12907
|
+
|
|
12908
|
+
toggleSoftphoneDisplay() {
|
|
12909
|
+
if (this.displayed) {
|
|
12910
|
+
this.hideSoftphone();
|
|
12911
|
+
} else {
|
|
12912
|
+
this.displaySoftphone();
|
|
12913
|
+
}
|
|
12914
|
+
|
|
12915
|
+
this.displayed = !this.displayed;
|
|
12916
|
+
}
|
|
12917
|
+
|
|
12918
|
+
displaySoftphone() {
|
|
12919
|
+
if (!this.iframe) {
|
|
12920
|
+
this._createIframe();
|
|
12921
|
+
}
|
|
12922
|
+
|
|
12923
|
+
if (this.iframe) {
|
|
12924
|
+
this.iframe.style.display = 'block';
|
|
12925
|
+
}
|
|
12926
|
+
}
|
|
12927
|
+
|
|
12928
|
+
hideSoftphone() {
|
|
12929
|
+
if (this.iframe) {
|
|
12930
|
+
this.iframe.style.display = 'none';
|
|
12931
|
+
}
|
|
12932
|
+
}
|
|
12933
|
+
|
|
12934
|
+
_createIframe() {
|
|
12935
|
+
this.iframe = document.createElement('iframe');
|
|
12936
|
+
// $FlowFixMe
|
|
12937
|
+
this.iframe.width = this.width;
|
|
12938
|
+
// $FlowFixMe
|
|
12939
|
+
this.iframe.height = this.height;
|
|
12940
|
+
// $FlowFixMe
|
|
12941
|
+
this.iframe.allow = 'camera *; microphone *; autoplay *; display-capture *';
|
|
12942
|
+
this.iframe.style.position = 'absolute';
|
|
12943
|
+
this.iframe.style.left = '0';
|
|
12944
|
+
this.iframe.style.bottom = '0';
|
|
12945
|
+
this.iframe.style.border = '1px solid #aaa';
|
|
12946
|
+
this.iframe.src = this.url;
|
|
12947
|
+
this.iframe.style.display = 'none';
|
|
12948
|
+
this.iframe.id = 'wazo-softphone';
|
|
12949
|
+
|
|
12950
|
+
// $FlowFixMe
|
|
12951
|
+
document.body.appendChild(this.iframe);
|
|
12952
|
+
}
|
|
12953
|
+
|
|
12954
|
+
_getLinks() {
|
|
12955
|
+
return [].slice.call(document.querySelectorAll('a:not([data-wazo-parsed])'), 0)
|
|
12956
|
+
.filter(link => link.href.indexOf('tel:') === 0 || link.href.indexOf('callto:') === 0);
|
|
12957
|
+
}
|
|
12958
|
+
|
|
12959
|
+
_onLinkClick(e ) {
|
|
12960
|
+
e.preventDefault();
|
|
12961
|
+
const number = e.target.href.split(':')[1];
|
|
12962
|
+
|
|
12963
|
+
this.makeCall(number);
|
|
12964
|
+
}
|
|
12965
|
+
|
|
12966
|
+
_onAuthenticated() {
|
|
12967
|
+
this.parseLinks();
|
|
12968
|
+
}
|
|
12969
|
+
|
|
12970
|
+
_onMessage(event ) {
|
|
12971
|
+
if (!event.data) {
|
|
12972
|
+
return;
|
|
12973
|
+
}
|
|
12974
|
+
|
|
12975
|
+
switch (event.data.type) {
|
|
12976
|
+
case SDK_ON_CALL_MADE:
|
|
12977
|
+
this.onCallMade(event.data.callSession);
|
|
12978
|
+
break;
|
|
12979
|
+
case SDK_CALL_ENDED: {
|
|
12980
|
+
const { callSession, content, direction, userExtension } = event.data;
|
|
12981
|
+
this.onCallEnded(callSession, content, direction, userExtension);
|
|
12982
|
+
break;
|
|
12983
|
+
}
|
|
12984
|
+
case SDK_CALL_INCOMING:
|
|
12985
|
+
this.onCallIncoming(event.data.callSession);
|
|
12986
|
+
break;
|
|
12987
|
+
case SDK_AUTHENTICATED:
|
|
12988
|
+
// $FlowFixMe
|
|
12989
|
+
this._onAuthenticated(event.data.session);
|
|
12990
|
+
this.onAuthenticated(event.data.session);
|
|
12991
|
+
break;
|
|
12992
|
+
}
|
|
12993
|
+
}
|
|
12994
|
+
}
|
|
12995
|
+
|
|
12996
|
+
var Softphone$1 = new Softphone();
|
|
12997
|
+
|
|
12851
12998
|
/* global window */
|
|
12852
12999
|
|
|
12853
13000
|
const Wazo = {
|
|
@@ -12868,6 +13015,7 @@ const Wazo = {
|
|
|
12868
13015
|
loggerFor: IssueReporter$1.loggerFor.bind(IssueReporter$1),
|
|
12869
13016
|
Features: Features$1,
|
|
12870
13017
|
Checker,
|
|
13018
|
+
Softphone: Softphone$1,
|
|
12871
13019
|
|
|
12872
13020
|
// Domain
|
|
12873
13021
|
domain: {
|
|
@@ -12853,6 +12853,153 @@ class Checker {
|
|
|
12853
12853
|
}
|
|
12854
12854
|
}
|
|
12855
12855
|
|
|
12856
|
+
//
|
|
12857
|
+
/* eslint-disable no-unused-vars */
|
|
12858
|
+
/* global window, document */
|
|
12859
|
+
const SDK_CLICK_TO_CALL = 'sdk/CLICK_TO_CALL';
|
|
12860
|
+
const SDK_ON_CALL_MADE = 'sdk/SDK_ON_CALL_MADE';
|
|
12861
|
+
const SDK_CALL_ENDED = 'sdk/ON_CALL_ENDED';
|
|
12862
|
+
const SDK_CALL_INCOMING = 'sdk/SDK_CALL_INCOMING';
|
|
12863
|
+
const SDK_AUTHENTICATED = 'sdk/SDK_AUTHENTICATED';
|
|
12864
|
+
|
|
12865
|
+
class Softphone {
|
|
12866
|
+
url = 'https://softphone.wazo.io';
|
|
12867
|
+
width = 500;
|
|
12868
|
+
height = 600;
|
|
12869
|
+
displayed = false;
|
|
12870
|
+
iframe = null;
|
|
12871
|
+
|
|
12872
|
+
onLinkEnabled(link ) {}
|
|
12873
|
+
|
|
12874
|
+
onCallMade(call ) {}
|
|
12875
|
+
onCallIncoming(call ) {}
|
|
12876
|
+
onCallEnded(call , card , direction , fromExtension ) {}
|
|
12877
|
+
onAuthenticated(session ) {}
|
|
12878
|
+
|
|
12879
|
+
init(url , width , height ) {
|
|
12880
|
+
if (url) {
|
|
12881
|
+
this.url = url;
|
|
12882
|
+
}
|
|
12883
|
+
if (width) {
|
|
12884
|
+
this.width = width;
|
|
12885
|
+
}
|
|
12886
|
+
if (height) {
|
|
12887
|
+
this.height = height;
|
|
12888
|
+
}
|
|
12889
|
+
|
|
12890
|
+
window.addEventListener('message', this._onMessage.bind(this), false);
|
|
12891
|
+
|
|
12892
|
+
this._createIframe();
|
|
12893
|
+
}
|
|
12894
|
+
|
|
12895
|
+
parseLinks() {
|
|
12896
|
+
const links = this._getLinks();
|
|
12897
|
+
|
|
12898
|
+
links.forEach(link => {
|
|
12899
|
+
link.setAttribute('data-wazo-parsed', true);
|
|
12900
|
+
link.addEventListener('click', this._onLinkClick.bind(this));
|
|
12901
|
+
this.onLinkEnabled(link);
|
|
12902
|
+
});
|
|
12903
|
+
}
|
|
12904
|
+
|
|
12905
|
+
makeCall(number ) {
|
|
12906
|
+
this.displaySoftphone();
|
|
12907
|
+
|
|
12908
|
+
if (this.iframe) {
|
|
12909
|
+
this.iframe.contentWindow.postMessage({ type: SDK_CLICK_TO_CALL, number }, '*');
|
|
12910
|
+
}
|
|
12911
|
+
}
|
|
12912
|
+
|
|
12913
|
+
toggleSoftphoneDisplay() {
|
|
12914
|
+
if (this.displayed) {
|
|
12915
|
+
this.hideSoftphone();
|
|
12916
|
+
} else {
|
|
12917
|
+
this.displaySoftphone();
|
|
12918
|
+
}
|
|
12919
|
+
|
|
12920
|
+
this.displayed = !this.displayed;
|
|
12921
|
+
}
|
|
12922
|
+
|
|
12923
|
+
displaySoftphone() {
|
|
12924
|
+
if (!this.iframe) {
|
|
12925
|
+
this._createIframe();
|
|
12926
|
+
}
|
|
12927
|
+
|
|
12928
|
+
if (this.iframe) {
|
|
12929
|
+
this.iframe.style.display = 'block';
|
|
12930
|
+
}
|
|
12931
|
+
}
|
|
12932
|
+
|
|
12933
|
+
hideSoftphone() {
|
|
12934
|
+
if (this.iframe) {
|
|
12935
|
+
this.iframe.style.display = 'none';
|
|
12936
|
+
}
|
|
12937
|
+
}
|
|
12938
|
+
|
|
12939
|
+
_createIframe() {
|
|
12940
|
+
this.iframe = document.createElement('iframe');
|
|
12941
|
+
// $FlowFixMe
|
|
12942
|
+
this.iframe.width = this.width;
|
|
12943
|
+
// $FlowFixMe
|
|
12944
|
+
this.iframe.height = this.height;
|
|
12945
|
+
// $FlowFixMe
|
|
12946
|
+
this.iframe.allow = 'camera *; microphone *; autoplay *; display-capture *';
|
|
12947
|
+
this.iframe.style.position = 'absolute';
|
|
12948
|
+
this.iframe.style.left = '0';
|
|
12949
|
+
this.iframe.style.bottom = '0';
|
|
12950
|
+
this.iframe.style.border = '1px solid #aaa';
|
|
12951
|
+
this.iframe.src = this.url;
|
|
12952
|
+
this.iframe.style.display = 'none';
|
|
12953
|
+
this.iframe.id = 'wazo-softphone';
|
|
12954
|
+
|
|
12955
|
+
// $FlowFixMe
|
|
12956
|
+
document.body.appendChild(this.iframe);
|
|
12957
|
+
}
|
|
12958
|
+
|
|
12959
|
+
_getLinks() {
|
|
12960
|
+
return [].slice.call(document.querySelectorAll('a:not([data-wazo-parsed])'), 0)
|
|
12961
|
+
.filter(link => link.href.indexOf('tel:') === 0 || link.href.indexOf('callto:') === 0);
|
|
12962
|
+
}
|
|
12963
|
+
|
|
12964
|
+
_onLinkClick(e ) {
|
|
12965
|
+
e.preventDefault();
|
|
12966
|
+
const number = e.target.href.split(':')[1];
|
|
12967
|
+
|
|
12968
|
+
this.makeCall(number);
|
|
12969
|
+
}
|
|
12970
|
+
|
|
12971
|
+
_onAuthenticated() {
|
|
12972
|
+
this.parseLinks();
|
|
12973
|
+
}
|
|
12974
|
+
|
|
12975
|
+
_onMessage(event ) {
|
|
12976
|
+
if (!event.data) {
|
|
12977
|
+
return;
|
|
12978
|
+
}
|
|
12979
|
+
|
|
12980
|
+
switch (event.data.type) {
|
|
12981
|
+
case SDK_ON_CALL_MADE:
|
|
12982
|
+
this.onCallMade(event.data.callSession);
|
|
12983
|
+
break;
|
|
12984
|
+
case SDK_CALL_ENDED: {
|
|
12985
|
+
const { callSession, content, direction, userExtension } = event.data;
|
|
12986
|
+
this.onCallEnded(callSession, content, direction, userExtension);
|
|
12987
|
+
break;
|
|
12988
|
+
}
|
|
12989
|
+
case SDK_CALL_INCOMING:
|
|
12990
|
+
this.onCallIncoming(event.data.callSession);
|
|
12991
|
+
break;
|
|
12992
|
+
case SDK_AUTHENTICATED:
|
|
12993
|
+
// $FlowFixMe
|
|
12994
|
+
this._onAuthenticated(event.data.session);
|
|
12995
|
+
this.onAuthenticated(event.data.session);
|
|
12996
|
+
break;
|
|
12997
|
+
}
|
|
12998
|
+
}
|
|
12999
|
+
}
|
|
13000
|
+
|
|
13001
|
+
var Softphone$1 = new Softphone();
|
|
13002
|
+
|
|
12856
13003
|
/* global window */
|
|
12857
13004
|
|
|
12858
13005
|
const Wazo = {
|
|
@@ -12873,6 +13020,7 @@ const Wazo = {
|
|
|
12873
13020
|
loggerFor: IssueReporter$1.loggerFor.bind(IssueReporter$1),
|
|
12874
13021
|
Features: Features$1,
|
|
12875
13022
|
Checker,
|
|
13023
|
+
Softphone: Softphone$1,
|
|
12876
13024
|
|
|
12877
13025
|
// Domain
|
|
12878
13026
|
domain: {
|
|
@@ -13132,6 +13132,153 @@ class Checker {
|
|
|
13132
13132
|
}
|
|
13133
13133
|
}
|
|
13134
13134
|
|
|
13135
|
+
//
|
|
13136
|
+
/* eslint-disable no-unused-vars */
|
|
13137
|
+
/* global window, document */
|
|
13138
|
+
const SDK_CLICK_TO_CALL = 'sdk/CLICK_TO_CALL';
|
|
13139
|
+
const SDK_ON_CALL_MADE = 'sdk/SDK_ON_CALL_MADE';
|
|
13140
|
+
const SDK_CALL_ENDED = 'sdk/ON_CALL_ENDED';
|
|
13141
|
+
const SDK_CALL_INCOMING = 'sdk/SDK_CALL_INCOMING';
|
|
13142
|
+
const SDK_AUTHENTICATED = 'sdk/SDK_AUTHENTICATED';
|
|
13143
|
+
|
|
13144
|
+
class Softphone {
|
|
13145
|
+
url = 'https://softphone.wazo.io';
|
|
13146
|
+
width = 500;
|
|
13147
|
+
height = 600;
|
|
13148
|
+
displayed = false;
|
|
13149
|
+
iframe = null;
|
|
13150
|
+
|
|
13151
|
+
onLinkEnabled(link ) {}
|
|
13152
|
+
|
|
13153
|
+
onCallMade(call ) {}
|
|
13154
|
+
onCallIncoming(call ) {}
|
|
13155
|
+
onCallEnded(call , card , direction , fromExtension ) {}
|
|
13156
|
+
onAuthenticated(session ) {}
|
|
13157
|
+
|
|
13158
|
+
init(url , width , height ) {
|
|
13159
|
+
if (url) {
|
|
13160
|
+
this.url = url;
|
|
13161
|
+
}
|
|
13162
|
+
if (width) {
|
|
13163
|
+
this.width = width;
|
|
13164
|
+
}
|
|
13165
|
+
if (height) {
|
|
13166
|
+
this.height = height;
|
|
13167
|
+
}
|
|
13168
|
+
|
|
13169
|
+
window.addEventListener('message', this._onMessage.bind(this), false);
|
|
13170
|
+
|
|
13171
|
+
this._createIframe();
|
|
13172
|
+
}
|
|
13173
|
+
|
|
13174
|
+
parseLinks() {
|
|
13175
|
+
const links = this._getLinks();
|
|
13176
|
+
|
|
13177
|
+
links.forEach(link => {
|
|
13178
|
+
link.setAttribute('data-wazo-parsed', true);
|
|
13179
|
+
link.addEventListener('click', this._onLinkClick.bind(this));
|
|
13180
|
+
this.onLinkEnabled(link);
|
|
13181
|
+
});
|
|
13182
|
+
}
|
|
13183
|
+
|
|
13184
|
+
makeCall(number ) {
|
|
13185
|
+
this.displaySoftphone();
|
|
13186
|
+
|
|
13187
|
+
if (this.iframe) {
|
|
13188
|
+
this.iframe.contentWindow.postMessage({ type: SDK_CLICK_TO_CALL, number }, '*');
|
|
13189
|
+
}
|
|
13190
|
+
}
|
|
13191
|
+
|
|
13192
|
+
toggleSoftphoneDisplay() {
|
|
13193
|
+
if (this.displayed) {
|
|
13194
|
+
this.hideSoftphone();
|
|
13195
|
+
} else {
|
|
13196
|
+
this.displaySoftphone();
|
|
13197
|
+
}
|
|
13198
|
+
|
|
13199
|
+
this.displayed = !this.displayed;
|
|
13200
|
+
}
|
|
13201
|
+
|
|
13202
|
+
displaySoftphone() {
|
|
13203
|
+
if (!this.iframe) {
|
|
13204
|
+
this._createIframe();
|
|
13205
|
+
}
|
|
13206
|
+
|
|
13207
|
+
if (this.iframe) {
|
|
13208
|
+
this.iframe.style.display = 'block';
|
|
13209
|
+
}
|
|
13210
|
+
}
|
|
13211
|
+
|
|
13212
|
+
hideSoftphone() {
|
|
13213
|
+
if (this.iframe) {
|
|
13214
|
+
this.iframe.style.display = 'none';
|
|
13215
|
+
}
|
|
13216
|
+
}
|
|
13217
|
+
|
|
13218
|
+
_createIframe() {
|
|
13219
|
+
this.iframe = document.createElement('iframe');
|
|
13220
|
+
// $FlowFixMe
|
|
13221
|
+
this.iframe.width = this.width;
|
|
13222
|
+
// $FlowFixMe
|
|
13223
|
+
this.iframe.height = this.height;
|
|
13224
|
+
// $FlowFixMe
|
|
13225
|
+
this.iframe.allow = 'camera *; microphone *; autoplay *; display-capture *';
|
|
13226
|
+
this.iframe.style.position = 'absolute';
|
|
13227
|
+
this.iframe.style.left = '0';
|
|
13228
|
+
this.iframe.style.bottom = '0';
|
|
13229
|
+
this.iframe.style.border = '1px solid #aaa';
|
|
13230
|
+
this.iframe.src = this.url;
|
|
13231
|
+
this.iframe.style.display = 'none';
|
|
13232
|
+
this.iframe.id = 'wazo-softphone';
|
|
13233
|
+
|
|
13234
|
+
// $FlowFixMe
|
|
13235
|
+
document.body.appendChild(this.iframe);
|
|
13236
|
+
}
|
|
13237
|
+
|
|
13238
|
+
_getLinks() {
|
|
13239
|
+
return [].slice.call(document.querySelectorAll('a:not([data-wazo-parsed])'), 0)
|
|
13240
|
+
.filter(link => link.href.indexOf('tel:') === 0 || link.href.indexOf('callto:') === 0);
|
|
13241
|
+
}
|
|
13242
|
+
|
|
13243
|
+
_onLinkClick(e ) {
|
|
13244
|
+
e.preventDefault();
|
|
13245
|
+
const number = e.target.href.split(':')[1];
|
|
13246
|
+
|
|
13247
|
+
this.makeCall(number);
|
|
13248
|
+
}
|
|
13249
|
+
|
|
13250
|
+
_onAuthenticated() {
|
|
13251
|
+
this.parseLinks();
|
|
13252
|
+
}
|
|
13253
|
+
|
|
13254
|
+
_onMessage(event ) {
|
|
13255
|
+
if (!event.data) {
|
|
13256
|
+
return;
|
|
13257
|
+
}
|
|
13258
|
+
|
|
13259
|
+
switch (event.data.type) {
|
|
13260
|
+
case SDK_ON_CALL_MADE:
|
|
13261
|
+
this.onCallMade(event.data.callSession);
|
|
13262
|
+
break;
|
|
13263
|
+
case SDK_CALL_ENDED: {
|
|
13264
|
+
const { callSession, content, direction, userExtension } = event.data;
|
|
13265
|
+
this.onCallEnded(callSession, content, direction, userExtension);
|
|
13266
|
+
break;
|
|
13267
|
+
}
|
|
13268
|
+
case SDK_CALL_INCOMING:
|
|
13269
|
+
this.onCallIncoming(event.data.callSession);
|
|
13270
|
+
break;
|
|
13271
|
+
case SDK_AUTHENTICATED:
|
|
13272
|
+
// $FlowFixMe
|
|
13273
|
+
this._onAuthenticated(event.data.session);
|
|
13274
|
+
this.onAuthenticated(event.data.session);
|
|
13275
|
+
break;
|
|
13276
|
+
}
|
|
13277
|
+
}
|
|
13278
|
+
}
|
|
13279
|
+
|
|
13280
|
+
var Softphone$1 = new Softphone();
|
|
13281
|
+
|
|
13135
13282
|
/* global window */
|
|
13136
13283
|
|
|
13137
13284
|
const Wazo = {
|
|
@@ -13152,6 +13299,7 @@ const Wazo = {
|
|
|
13152
13299
|
loggerFor: IssueReporter$1.loggerFor.bind(IssueReporter$1),
|
|
13153
13300
|
Features: Features$1,
|
|
13154
13301
|
Checker,
|
|
13302
|
+
Softphone: Softphone$1,
|
|
13155
13303
|
|
|
13156
13304
|
// Domain
|
|
13157
13305
|
domain: {
|
package/lib/simple/room/Room.js
CHANGED
|
@@ -13145,6 +13145,153 @@ class Checker {
|
|
|
13145
13145
|
}
|
|
13146
13146
|
}
|
|
13147
13147
|
|
|
13148
|
+
//
|
|
13149
|
+
/* eslint-disable no-unused-vars */
|
|
13150
|
+
/* global window, document */
|
|
13151
|
+
const SDK_CLICK_TO_CALL = 'sdk/CLICK_TO_CALL';
|
|
13152
|
+
const SDK_ON_CALL_MADE = 'sdk/SDK_ON_CALL_MADE';
|
|
13153
|
+
const SDK_CALL_ENDED = 'sdk/ON_CALL_ENDED';
|
|
13154
|
+
const SDK_CALL_INCOMING = 'sdk/SDK_CALL_INCOMING';
|
|
13155
|
+
const SDK_AUTHENTICATED = 'sdk/SDK_AUTHENTICATED';
|
|
13156
|
+
|
|
13157
|
+
class Softphone {
|
|
13158
|
+
url = 'https://softphone.wazo.io';
|
|
13159
|
+
width = 500;
|
|
13160
|
+
height = 600;
|
|
13161
|
+
displayed = false;
|
|
13162
|
+
iframe = null;
|
|
13163
|
+
|
|
13164
|
+
onLinkEnabled(link ) {}
|
|
13165
|
+
|
|
13166
|
+
onCallMade(call ) {}
|
|
13167
|
+
onCallIncoming(call ) {}
|
|
13168
|
+
onCallEnded(call , card , direction , fromExtension ) {}
|
|
13169
|
+
onAuthenticated(session ) {}
|
|
13170
|
+
|
|
13171
|
+
init(url , width , height ) {
|
|
13172
|
+
if (url) {
|
|
13173
|
+
this.url = url;
|
|
13174
|
+
}
|
|
13175
|
+
if (width) {
|
|
13176
|
+
this.width = width;
|
|
13177
|
+
}
|
|
13178
|
+
if (height) {
|
|
13179
|
+
this.height = height;
|
|
13180
|
+
}
|
|
13181
|
+
|
|
13182
|
+
window.addEventListener('message', this._onMessage.bind(this), false);
|
|
13183
|
+
|
|
13184
|
+
this._createIframe();
|
|
13185
|
+
}
|
|
13186
|
+
|
|
13187
|
+
parseLinks() {
|
|
13188
|
+
const links = this._getLinks();
|
|
13189
|
+
|
|
13190
|
+
links.forEach(link => {
|
|
13191
|
+
link.setAttribute('data-wazo-parsed', true);
|
|
13192
|
+
link.addEventListener('click', this._onLinkClick.bind(this));
|
|
13193
|
+
this.onLinkEnabled(link);
|
|
13194
|
+
});
|
|
13195
|
+
}
|
|
13196
|
+
|
|
13197
|
+
makeCall(number ) {
|
|
13198
|
+
this.displaySoftphone();
|
|
13199
|
+
|
|
13200
|
+
if (this.iframe) {
|
|
13201
|
+
this.iframe.contentWindow.postMessage({ type: SDK_CLICK_TO_CALL, number }, '*');
|
|
13202
|
+
}
|
|
13203
|
+
}
|
|
13204
|
+
|
|
13205
|
+
toggleSoftphoneDisplay() {
|
|
13206
|
+
if (this.displayed) {
|
|
13207
|
+
this.hideSoftphone();
|
|
13208
|
+
} else {
|
|
13209
|
+
this.displaySoftphone();
|
|
13210
|
+
}
|
|
13211
|
+
|
|
13212
|
+
this.displayed = !this.displayed;
|
|
13213
|
+
}
|
|
13214
|
+
|
|
13215
|
+
displaySoftphone() {
|
|
13216
|
+
if (!this.iframe) {
|
|
13217
|
+
this._createIframe();
|
|
13218
|
+
}
|
|
13219
|
+
|
|
13220
|
+
if (this.iframe) {
|
|
13221
|
+
this.iframe.style.display = 'block';
|
|
13222
|
+
}
|
|
13223
|
+
}
|
|
13224
|
+
|
|
13225
|
+
hideSoftphone() {
|
|
13226
|
+
if (this.iframe) {
|
|
13227
|
+
this.iframe.style.display = 'none';
|
|
13228
|
+
}
|
|
13229
|
+
}
|
|
13230
|
+
|
|
13231
|
+
_createIframe() {
|
|
13232
|
+
this.iframe = document.createElement('iframe');
|
|
13233
|
+
// $FlowFixMe
|
|
13234
|
+
this.iframe.width = this.width;
|
|
13235
|
+
// $FlowFixMe
|
|
13236
|
+
this.iframe.height = this.height;
|
|
13237
|
+
// $FlowFixMe
|
|
13238
|
+
this.iframe.allow = 'camera *; microphone *; autoplay *; display-capture *';
|
|
13239
|
+
this.iframe.style.position = 'absolute';
|
|
13240
|
+
this.iframe.style.left = '0';
|
|
13241
|
+
this.iframe.style.bottom = '0';
|
|
13242
|
+
this.iframe.style.border = '1px solid #aaa';
|
|
13243
|
+
this.iframe.src = this.url;
|
|
13244
|
+
this.iframe.style.display = 'none';
|
|
13245
|
+
this.iframe.id = 'wazo-softphone';
|
|
13246
|
+
|
|
13247
|
+
// $FlowFixMe
|
|
13248
|
+
document.body.appendChild(this.iframe);
|
|
13249
|
+
}
|
|
13250
|
+
|
|
13251
|
+
_getLinks() {
|
|
13252
|
+
return [].slice.call(document.querySelectorAll('a:not([data-wazo-parsed])'), 0)
|
|
13253
|
+
.filter(link => link.href.indexOf('tel:') === 0 || link.href.indexOf('callto:') === 0);
|
|
13254
|
+
}
|
|
13255
|
+
|
|
13256
|
+
_onLinkClick(e ) {
|
|
13257
|
+
e.preventDefault();
|
|
13258
|
+
const number = e.target.href.split(':')[1];
|
|
13259
|
+
|
|
13260
|
+
this.makeCall(number);
|
|
13261
|
+
}
|
|
13262
|
+
|
|
13263
|
+
_onAuthenticated() {
|
|
13264
|
+
this.parseLinks();
|
|
13265
|
+
}
|
|
13266
|
+
|
|
13267
|
+
_onMessage(event ) {
|
|
13268
|
+
if (!event.data) {
|
|
13269
|
+
return;
|
|
13270
|
+
}
|
|
13271
|
+
|
|
13272
|
+
switch (event.data.type) {
|
|
13273
|
+
case SDK_ON_CALL_MADE:
|
|
13274
|
+
this.onCallMade(event.data.callSession);
|
|
13275
|
+
break;
|
|
13276
|
+
case SDK_CALL_ENDED: {
|
|
13277
|
+
const { callSession, content, direction, userExtension } = event.data;
|
|
13278
|
+
this.onCallEnded(callSession, content, direction, userExtension);
|
|
13279
|
+
break;
|
|
13280
|
+
}
|
|
13281
|
+
case SDK_CALL_INCOMING:
|
|
13282
|
+
this.onCallIncoming(event.data.callSession);
|
|
13283
|
+
break;
|
|
13284
|
+
case SDK_AUTHENTICATED:
|
|
13285
|
+
// $FlowFixMe
|
|
13286
|
+
this._onAuthenticated(event.data.session);
|
|
13287
|
+
this.onAuthenticated(event.data.session);
|
|
13288
|
+
break;
|
|
13289
|
+
}
|
|
13290
|
+
}
|
|
13291
|
+
}
|
|
13292
|
+
|
|
13293
|
+
var Softphone$1 = new Softphone();
|
|
13294
|
+
|
|
13148
13295
|
/* global window */
|
|
13149
13296
|
|
|
13150
13297
|
const Wazo = {
|
|
@@ -13165,6 +13312,7 @@ const Wazo = {
|
|
|
13165
13312
|
loggerFor: IssueReporter$1.loggerFor.bind(IssueReporter$1),
|
|
13166
13313
|
Features: Features$1,
|
|
13167
13314
|
Checker,
|
|
13315
|
+
Softphone: Softphone$1,
|
|
13168
13316
|
|
|
13169
13317
|
// Domain
|
|
13170
13318
|
domain: {
|