@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
|
@@ -13661,6 +13661,153 @@ class Checker {
|
|
|
13661
13661
|
}
|
|
13662
13662
|
}
|
|
13663
13663
|
|
|
13664
|
+
//
|
|
13665
|
+
/* eslint-disable no-unused-vars */
|
|
13666
|
+
/* global window, document */
|
|
13667
|
+
const SDK_CLICK_TO_CALL = 'sdk/CLICK_TO_CALL';
|
|
13668
|
+
const SDK_ON_CALL_MADE = 'sdk/SDK_ON_CALL_MADE';
|
|
13669
|
+
const SDK_CALL_ENDED = 'sdk/ON_CALL_ENDED';
|
|
13670
|
+
const SDK_CALL_INCOMING = 'sdk/SDK_CALL_INCOMING';
|
|
13671
|
+
const SDK_AUTHENTICATED = 'sdk/SDK_AUTHENTICATED';
|
|
13672
|
+
|
|
13673
|
+
class Softphone {
|
|
13674
|
+
url = 'https://softphone.wazo.io';
|
|
13675
|
+
width = 500;
|
|
13676
|
+
height = 600;
|
|
13677
|
+
displayed = false;
|
|
13678
|
+
iframe = null;
|
|
13679
|
+
|
|
13680
|
+
onLinkEnabled(link ) {}
|
|
13681
|
+
|
|
13682
|
+
onCallMade(call ) {}
|
|
13683
|
+
onCallIncoming(call ) {}
|
|
13684
|
+
onCallEnded(call , card , direction , fromExtension ) {}
|
|
13685
|
+
onAuthenticated(session ) {}
|
|
13686
|
+
|
|
13687
|
+
init(url , width , height ) {
|
|
13688
|
+
if (url) {
|
|
13689
|
+
this.url = url;
|
|
13690
|
+
}
|
|
13691
|
+
if (width) {
|
|
13692
|
+
this.width = width;
|
|
13693
|
+
}
|
|
13694
|
+
if (height) {
|
|
13695
|
+
this.height = height;
|
|
13696
|
+
}
|
|
13697
|
+
|
|
13698
|
+
window.addEventListener('message', this._onMessage.bind(this), false);
|
|
13699
|
+
|
|
13700
|
+
this._createIframe();
|
|
13701
|
+
}
|
|
13702
|
+
|
|
13703
|
+
parseLinks() {
|
|
13704
|
+
const links = this._getLinks();
|
|
13705
|
+
|
|
13706
|
+
links.forEach(link => {
|
|
13707
|
+
link.setAttribute('data-wazo-parsed', true);
|
|
13708
|
+
link.addEventListener('click', this._onLinkClick.bind(this));
|
|
13709
|
+
this.onLinkEnabled(link);
|
|
13710
|
+
});
|
|
13711
|
+
}
|
|
13712
|
+
|
|
13713
|
+
makeCall(number ) {
|
|
13714
|
+
this.displaySoftphone();
|
|
13715
|
+
|
|
13716
|
+
if (this.iframe) {
|
|
13717
|
+
this.iframe.contentWindow.postMessage({ type: SDK_CLICK_TO_CALL, number }, '*');
|
|
13718
|
+
}
|
|
13719
|
+
}
|
|
13720
|
+
|
|
13721
|
+
toggleSoftphoneDisplay() {
|
|
13722
|
+
if (this.displayed) {
|
|
13723
|
+
this.hideSoftphone();
|
|
13724
|
+
} else {
|
|
13725
|
+
this.displaySoftphone();
|
|
13726
|
+
}
|
|
13727
|
+
|
|
13728
|
+
this.displayed = !this.displayed;
|
|
13729
|
+
}
|
|
13730
|
+
|
|
13731
|
+
displaySoftphone() {
|
|
13732
|
+
if (!this.iframe) {
|
|
13733
|
+
this._createIframe();
|
|
13734
|
+
}
|
|
13735
|
+
|
|
13736
|
+
if (this.iframe) {
|
|
13737
|
+
this.iframe.style.display = 'block';
|
|
13738
|
+
}
|
|
13739
|
+
}
|
|
13740
|
+
|
|
13741
|
+
hideSoftphone() {
|
|
13742
|
+
if (this.iframe) {
|
|
13743
|
+
this.iframe.style.display = 'none';
|
|
13744
|
+
}
|
|
13745
|
+
}
|
|
13746
|
+
|
|
13747
|
+
_createIframe() {
|
|
13748
|
+
this.iframe = document.createElement('iframe');
|
|
13749
|
+
// $FlowFixMe
|
|
13750
|
+
this.iframe.width = this.width;
|
|
13751
|
+
// $FlowFixMe
|
|
13752
|
+
this.iframe.height = this.height;
|
|
13753
|
+
// $FlowFixMe
|
|
13754
|
+
this.iframe.allow = 'camera *; microphone *; autoplay *; display-capture *';
|
|
13755
|
+
this.iframe.style.position = 'absolute';
|
|
13756
|
+
this.iframe.style.left = '0';
|
|
13757
|
+
this.iframe.style.bottom = '0';
|
|
13758
|
+
this.iframe.style.border = '1px solid #aaa';
|
|
13759
|
+
this.iframe.src = this.url;
|
|
13760
|
+
this.iframe.style.display = 'none';
|
|
13761
|
+
this.iframe.id = 'wazo-softphone';
|
|
13762
|
+
|
|
13763
|
+
// $FlowFixMe
|
|
13764
|
+
document.body.appendChild(this.iframe);
|
|
13765
|
+
}
|
|
13766
|
+
|
|
13767
|
+
_getLinks() {
|
|
13768
|
+
return [].slice.call(document.querySelectorAll('a:not([data-wazo-parsed])'), 0)
|
|
13769
|
+
.filter(link => link.href.indexOf('tel:') === 0 || link.href.indexOf('callto:') === 0);
|
|
13770
|
+
}
|
|
13771
|
+
|
|
13772
|
+
_onLinkClick(e ) {
|
|
13773
|
+
e.preventDefault();
|
|
13774
|
+
const number = e.target.href.split(':')[1];
|
|
13775
|
+
|
|
13776
|
+
this.makeCall(number);
|
|
13777
|
+
}
|
|
13778
|
+
|
|
13779
|
+
_onAuthenticated() {
|
|
13780
|
+
this.parseLinks();
|
|
13781
|
+
}
|
|
13782
|
+
|
|
13783
|
+
_onMessage(event ) {
|
|
13784
|
+
if (!event.data) {
|
|
13785
|
+
return;
|
|
13786
|
+
}
|
|
13787
|
+
|
|
13788
|
+
switch (event.data.type) {
|
|
13789
|
+
case SDK_ON_CALL_MADE:
|
|
13790
|
+
this.onCallMade(event.data.callSession);
|
|
13791
|
+
break;
|
|
13792
|
+
case SDK_CALL_ENDED: {
|
|
13793
|
+
const { callSession, content, direction, userExtension } = event.data;
|
|
13794
|
+
this.onCallEnded(callSession, content, direction, userExtension);
|
|
13795
|
+
break;
|
|
13796
|
+
}
|
|
13797
|
+
case SDK_CALL_INCOMING:
|
|
13798
|
+
this.onCallIncoming(event.data.callSession);
|
|
13799
|
+
break;
|
|
13800
|
+
case SDK_AUTHENTICATED:
|
|
13801
|
+
// $FlowFixMe
|
|
13802
|
+
this._onAuthenticated(event.data.session);
|
|
13803
|
+
this.onAuthenticated(event.data.session);
|
|
13804
|
+
break;
|
|
13805
|
+
}
|
|
13806
|
+
}
|
|
13807
|
+
}
|
|
13808
|
+
|
|
13809
|
+
var Softphone$1 = new Softphone();
|
|
13810
|
+
|
|
13664
13811
|
/* global window */
|
|
13665
13812
|
|
|
13666
13813
|
const Wazo = {
|
|
@@ -13681,6 +13828,7 @@ const Wazo = {
|
|
|
13681
13828
|
loggerFor: IssueReporter$1.loggerFor.bind(IssueReporter$1),
|
|
13682
13829
|
Features: Features$1,
|
|
13683
13830
|
Checker,
|
|
13831
|
+
Softphone: Softphone$1,
|
|
13684
13832
|
|
|
13685
13833
|
// Domain
|
|
13686
13834
|
domain: {
|
package/lib/simple/Phone.js
CHANGED
|
@@ -13569,6 +13569,153 @@ class Checker {
|
|
|
13569
13569
|
}
|
|
13570
13570
|
}
|
|
13571
13571
|
|
|
13572
|
+
//
|
|
13573
|
+
/* eslint-disable no-unused-vars */
|
|
13574
|
+
/* global window, document */
|
|
13575
|
+
const SDK_CLICK_TO_CALL = 'sdk/CLICK_TO_CALL';
|
|
13576
|
+
const SDK_ON_CALL_MADE = 'sdk/SDK_ON_CALL_MADE';
|
|
13577
|
+
const SDK_CALL_ENDED = 'sdk/ON_CALL_ENDED';
|
|
13578
|
+
const SDK_CALL_INCOMING = 'sdk/SDK_CALL_INCOMING';
|
|
13579
|
+
const SDK_AUTHENTICATED = 'sdk/SDK_AUTHENTICATED';
|
|
13580
|
+
|
|
13581
|
+
class Softphone {
|
|
13582
|
+
url = 'https://softphone.wazo.io';
|
|
13583
|
+
width = 500;
|
|
13584
|
+
height = 600;
|
|
13585
|
+
displayed = false;
|
|
13586
|
+
iframe = null;
|
|
13587
|
+
|
|
13588
|
+
onLinkEnabled(link ) {}
|
|
13589
|
+
|
|
13590
|
+
onCallMade(call ) {}
|
|
13591
|
+
onCallIncoming(call ) {}
|
|
13592
|
+
onCallEnded(call , card , direction , fromExtension ) {}
|
|
13593
|
+
onAuthenticated(session ) {}
|
|
13594
|
+
|
|
13595
|
+
init(url , width , height ) {
|
|
13596
|
+
if (url) {
|
|
13597
|
+
this.url = url;
|
|
13598
|
+
}
|
|
13599
|
+
if (width) {
|
|
13600
|
+
this.width = width;
|
|
13601
|
+
}
|
|
13602
|
+
if (height) {
|
|
13603
|
+
this.height = height;
|
|
13604
|
+
}
|
|
13605
|
+
|
|
13606
|
+
window.addEventListener('message', this._onMessage.bind(this), false);
|
|
13607
|
+
|
|
13608
|
+
this._createIframe();
|
|
13609
|
+
}
|
|
13610
|
+
|
|
13611
|
+
parseLinks() {
|
|
13612
|
+
const links = this._getLinks();
|
|
13613
|
+
|
|
13614
|
+
links.forEach(link => {
|
|
13615
|
+
link.setAttribute('data-wazo-parsed', true);
|
|
13616
|
+
link.addEventListener('click', this._onLinkClick.bind(this));
|
|
13617
|
+
this.onLinkEnabled(link);
|
|
13618
|
+
});
|
|
13619
|
+
}
|
|
13620
|
+
|
|
13621
|
+
makeCall(number ) {
|
|
13622
|
+
this.displaySoftphone();
|
|
13623
|
+
|
|
13624
|
+
if (this.iframe) {
|
|
13625
|
+
this.iframe.contentWindow.postMessage({ type: SDK_CLICK_TO_CALL, number }, '*');
|
|
13626
|
+
}
|
|
13627
|
+
}
|
|
13628
|
+
|
|
13629
|
+
toggleSoftphoneDisplay() {
|
|
13630
|
+
if (this.displayed) {
|
|
13631
|
+
this.hideSoftphone();
|
|
13632
|
+
} else {
|
|
13633
|
+
this.displaySoftphone();
|
|
13634
|
+
}
|
|
13635
|
+
|
|
13636
|
+
this.displayed = !this.displayed;
|
|
13637
|
+
}
|
|
13638
|
+
|
|
13639
|
+
displaySoftphone() {
|
|
13640
|
+
if (!this.iframe) {
|
|
13641
|
+
this._createIframe();
|
|
13642
|
+
}
|
|
13643
|
+
|
|
13644
|
+
if (this.iframe) {
|
|
13645
|
+
this.iframe.style.display = 'block';
|
|
13646
|
+
}
|
|
13647
|
+
}
|
|
13648
|
+
|
|
13649
|
+
hideSoftphone() {
|
|
13650
|
+
if (this.iframe) {
|
|
13651
|
+
this.iframe.style.display = 'none';
|
|
13652
|
+
}
|
|
13653
|
+
}
|
|
13654
|
+
|
|
13655
|
+
_createIframe() {
|
|
13656
|
+
this.iframe = document.createElement('iframe');
|
|
13657
|
+
// $FlowFixMe
|
|
13658
|
+
this.iframe.width = this.width;
|
|
13659
|
+
// $FlowFixMe
|
|
13660
|
+
this.iframe.height = this.height;
|
|
13661
|
+
// $FlowFixMe
|
|
13662
|
+
this.iframe.allow = 'camera *; microphone *; autoplay *; display-capture *';
|
|
13663
|
+
this.iframe.style.position = 'absolute';
|
|
13664
|
+
this.iframe.style.left = '0';
|
|
13665
|
+
this.iframe.style.bottom = '0';
|
|
13666
|
+
this.iframe.style.border = '1px solid #aaa';
|
|
13667
|
+
this.iframe.src = this.url;
|
|
13668
|
+
this.iframe.style.display = 'none';
|
|
13669
|
+
this.iframe.id = 'wazo-softphone';
|
|
13670
|
+
|
|
13671
|
+
// $FlowFixMe
|
|
13672
|
+
document.body.appendChild(this.iframe);
|
|
13673
|
+
}
|
|
13674
|
+
|
|
13675
|
+
_getLinks() {
|
|
13676
|
+
return [].slice.call(document.querySelectorAll('a:not([data-wazo-parsed])'), 0)
|
|
13677
|
+
.filter(link => link.href.indexOf('tel:') === 0 || link.href.indexOf('callto:') === 0);
|
|
13678
|
+
}
|
|
13679
|
+
|
|
13680
|
+
_onLinkClick(e ) {
|
|
13681
|
+
e.preventDefault();
|
|
13682
|
+
const number = e.target.href.split(':')[1];
|
|
13683
|
+
|
|
13684
|
+
this.makeCall(number);
|
|
13685
|
+
}
|
|
13686
|
+
|
|
13687
|
+
_onAuthenticated() {
|
|
13688
|
+
this.parseLinks();
|
|
13689
|
+
}
|
|
13690
|
+
|
|
13691
|
+
_onMessage(event ) {
|
|
13692
|
+
if (!event.data) {
|
|
13693
|
+
return;
|
|
13694
|
+
}
|
|
13695
|
+
|
|
13696
|
+
switch (event.data.type) {
|
|
13697
|
+
case SDK_ON_CALL_MADE:
|
|
13698
|
+
this.onCallMade(event.data.callSession);
|
|
13699
|
+
break;
|
|
13700
|
+
case SDK_CALL_ENDED: {
|
|
13701
|
+
const { callSession, content, direction, userExtension } = event.data;
|
|
13702
|
+
this.onCallEnded(callSession, content, direction, userExtension);
|
|
13703
|
+
break;
|
|
13704
|
+
}
|
|
13705
|
+
case SDK_CALL_INCOMING:
|
|
13706
|
+
this.onCallIncoming(event.data.callSession);
|
|
13707
|
+
break;
|
|
13708
|
+
case SDK_AUTHENTICATED:
|
|
13709
|
+
// $FlowFixMe
|
|
13710
|
+
this._onAuthenticated(event.data.session);
|
|
13711
|
+
this.onAuthenticated(event.data.session);
|
|
13712
|
+
break;
|
|
13713
|
+
}
|
|
13714
|
+
}
|
|
13715
|
+
}
|
|
13716
|
+
|
|
13717
|
+
var Softphone$1 = new Softphone();
|
|
13718
|
+
|
|
13572
13719
|
/* global window */
|
|
13573
13720
|
|
|
13574
13721
|
const Wazo = {
|
|
@@ -13589,6 +13736,7 @@ const Wazo = {
|
|
|
13589
13736
|
loggerFor: IssueReporter$1.loggerFor.bind(IssueReporter$1),
|
|
13590
13737
|
Features: Features$1,
|
|
13591
13738
|
Checker,
|
|
13739
|
+
Softphone: Softphone$1,
|
|
13592
13740
|
|
|
13593
13741
|
// Domain
|
|
13594
13742
|
domain: {
|
|
@@ -0,0 +1,150 @@
|
|
|
1
|
+
'use strict';
|
|
2
|
+
|
|
3
|
+
//
|
|
4
|
+
/* eslint-disable no-unused-vars */
|
|
5
|
+
/* global window, document */
|
|
6
|
+
const SDK_CLICK_TO_CALL = 'sdk/CLICK_TO_CALL';
|
|
7
|
+
const SDK_ON_CALL_MADE = 'sdk/SDK_ON_CALL_MADE';
|
|
8
|
+
const SDK_CALL_ENDED = 'sdk/ON_CALL_ENDED';
|
|
9
|
+
const SDK_CALL_INCOMING = 'sdk/SDK_CALL_INCOMING';
|
|
10
|
+
const SDK_AUTHENTICATED = 'sdk/SDK_AUTHENTICATED';
|
|
11
|
+
|
|
12
|
+
class Softphone {
|
|
13
|
+
url = 'https://softphone.wazo.io';
|
|
14
|
+
width = 500;
|
|
15
|
+
height = 600;
|
|
16
|
+
displayed = false;
|
|
17
|
+
iframe = null;
|
|
18
|
+
|
|
19
|
+
onLinkEnabled(link ) {}
|
|
20
|
+
|
|
21
|
+
onCallMade(call ) {}
|
|
22
|
+
onCallIncoming(call ) {}
|
|
23
|
+
onCallEnded(call , card , direction , fromExtension ) {}
|
|
24
|
+
onAuthenticated(session ) {}
|
|
25
|
+
|
|
26
|
+
init(url , width , height ) {
|
|
27
|
+
if (url) {
|
|
28
|
+
this.url = url;
|
|
29
|
+
}
|
|
30
|
+
if (width) {
|
|
31
|
+
this.width = width;
|
|
32
|
+
}
|
|
33
|
+
if (height) {
|
|
34
|
+
this.height = height;
|
|
35
|
+
}
|
|
36
|
+
|
|
37
|
+
window.addEventListener('message', this._onMessage.bind(this), false);
|
|
38
|
+
|
|
39
|
+
this._createIframe();
|
|
40
|
+
}
|
|
41
|
+
|
|
42
|
+
parseLinks() {
|
|
43
|
+
const links = this._getLinks();
|
|
44
|
+
|
|
45
|
+
links.forEach(link => {
|
|
46
|
+
link.setAttribute('data-wazo-parsed', true);
|
|
47
|
+
link.addEventListener('click', this._onLinkClick.bind(this));
|
|
48
|
+
this.onLinkEnabled(link);
|
|
49
|
+
});
|
|
50
|
+
}
|
|
51
|
+
|
|
52
|
+
makeCall(number ) {
|
|
53
|
+
this.displaySoftphone();
|
|
54
|
+
|
|
55
|
+
if (this.iframe) {
|
|
56
|
+
this.iframe.contentWindow.postMessage({ type: SDK_CLICK_TO_CALL, number }, '*');
|
|
57
|
+
}
|
|
58
|
+
}
|
|
59
|
+
|
|
60
|
+
toggleSoftphoneDisplay() {
|
|
61
|
+
if (this.displayed) {
|
|
62
|
+
this.hideSoftphone();
|
|
63
|
+
} else {
|
|
64
|
+
this.displaySoftphone();
|
|
65
|
+
}
|
|
66
|
+
|
|
67
|
+
this.displayed = !this.displayed;
|
|
68
|
+
}
|
|
69
|
+
|
|
70
|
+
displaySoftphone() {
|
|
71
|
+
if (!this.iframe) {
|
|
72
|
+
this._createIframe();
|
|
73
|
+
}
|
|
74
|
+
|
|
75
|
+
if (this.iframe) {
|
|
76
|
+
this.iframe.style.display = 'block';
|
|
77
|
+
}
|
|
78
|
+
}
|
|
79
|
+
|
|
80
|
+
hideSoftphone() {
|
|
81
|
+
if (this.iframe) {
|
|
82
|
+
this.iframe.style.display = 'none';
|
|
83
|
+
}
|
|
84
|
+
}
|
|
85
|
+
|
|
86
|
+
_createIframe() {
|
|
87
|
+
this.iframe = document.createElement('iframe');
|
|
88
|
+
// $FlowFixMe
|
|
89
|
+
this.iframe.width = this.width;
|
|
90
|
+
// $FlowFixMe
|
|
91
|
+
this.iframe.height = this.height;
|
|
92
|
+
// $FlowFixMe
|
|
93
|
+
this.iframe.allow = 'camera *; microphone *; autoplay *; display-capture *';
|
|
94
|
+
this.iframe.style.position = 'absolute';
|
|
95
|
+
this.iframe.style.left = '0';
|
|
96
|
+
this.iframe.style.bottom = '0';
|
|
97
|
+
this.iframe.style.border = '1px solid #aaa';
|
|
98
|
+
this.iframe.src = this.url;
|
|
99
|
+
this.iframe.style.display = 'none';
|
|
100
|
+
this.iframe.id = 'wazo-softphone';
|
|
101
|
+
|
|
102
|
+
// $FlowFixMe
|
|
103
|
+
document.body.appendChild(this.iframe);
|
|
104
|
+
}
|
|
105
|
+
|
|
106
|
+
_getLinks() {
|
|
107
|
+
return [].slice.call(document.querySelectorAll('a:not([data-wazo-parsed])'), 0)
|
|
108
|
+
.filter(link => link.href.indexOf('tel:') === 0 || link.href.indexOf('callto:') === 0);
|
|
109
|
+
}
|
|
110
|
+
|
|
111
|
+
_onLinkClick(e ) {
|
|
112
|
+
e.preventDefault();
|
|
113
|
+
const number = e.target.href.split(':')[1];
|
|
114
|
+
|
|
115
|
+
this.makeCall(number);
|
|
116
|
+
}
|
|
117
|
+
|
|
118
|
+
_onAuthenticated() {
|
|
119
|
+
this.parseLinks();
|
|
120
|
+
}
|
|
121
|
+
|
|
122
|
+
_onMessage(event ) {
|
|
123
|
+
if (!event.data) {
|
|
124
|
+
return;
|
|
125
|
+
}
|
|
126
|
+
|
|
127
|
+
switch (event.data.type) {
|
|
128
|
+
case SDK_ON_CALL_MADE:
|
|
129
|
+
this.onCallMade(event.data.callSession);
|
|
130
|
+
break;
|
|
131
|
+
case SDK_CALL_ENDED: {
|
|
132
|
+
const { callSession, content, direction, userExtension } = event.data;
|
|
133
|
+
this.onCallEnded(callSession, content, direction, userExtension);
|
|
134
|
+
break;
|
|
135
|
+
}
|
|
136
|
+
case SDK_CALL_INCOMING:
|
|
137
|
+
this.onCallIncoming(event.data.callSession);
|
|
138
|
+
break;
|
|
139
|
+
case SDK_AUTHENTICATED:
|
|
140
|
+
// $FlowFixMe
|
|
141
|
+
this._onAuthenticated(event.data.session);
|
|
142
|
+
this.onAuthenticated(event.data.session);
|
|
143
|
+
break;
|
|
144
|
+
}
|
|
145
|
+
}
|
|
146
|
+
}
|
|
147
|
+
|
|
148
|
+
var Softphone$1 = new Softphone();
|
|
149
|
+
|
|
150
|
+
module.exports = Softphone$1;
|
package/lib/simple/index.js
CHANGED
|
@@ -13979,6 +13979,153 @@ class Checker {
|
|
|
13979
13979
|
}
|
|
13980
13980
|
}
|
|
13981
13981
|
|
|
13982
|
+
//
|
|
13983
|
+
/* eslint-disable no-unused-vars */
|
|
13984
|
+
/* global window, document */
|
|
13985
|
+
const SDK_CLICK_TO_CALL = 'sdk/CLICK_TO_CALL';
|
|
13986
|
+
const SDK_ON_CALL_MADE = 'sdk/SDK_ON_CALL_MADE';
|
|
13987
|
+
const SDK_CALL_ENDED = 'sdk/ON_CALL_ENDED';
|
|
13988
|
+
const SDK_CALL_INCOMING = 'sdk/SDK_CALL_INCOMING';
|
|
13989
|
+
const SDK_AUTHENTICATED = 'sdk/SDK_AUTHENTICATED';
|
|
13990
|
+
|
|
13991
|
+
class Softphone {
|
|
13992
|
+
url = 'https://softphone.wazo.io';
|
|
13993
|
+
width = 500;
|
|
13994
|
+
height = 600;
|
|
13995
|
+
displayed = false;
|
|
13996
|
+
iframe = null;
|
|
13997
|
+
|
|
13998
|
+
onLinkEnabled(link ) {}
|
|
13999
|
+
|
|
14000
|
+
onCallMade(call ) {}
|
|
14001
|
+
onCallIncoming(call ) {}
|
|
14002
|
+
onCallEnded(call , card , direction , fromExtension ) {}
|
|
14003
|
+
onAuthenticated(session ) {}
|
|
14004
|
+
|
|
14005
|
+
init(url , width , height ) {
|
|
14006
|
+
if (url) {
|
|
14007
|
+
this.url = url;
|
|
14008
|
+
}
|
|
14009
|
+
if (width) {
|
|
14010
|
+
this.width = width;
|
|
14011
|
+
}
|
|
14012
|
+
if (height) {
|
|
14013
|
+
this.height = height;
|
|
14014
|
+
}
|
|
14015
|
+
|
|
14016
|
+
window.addEventListener('message', this._onMessage.bind(this), false);
|
|
14017
|
+
|
|
14018
|
+
this._createIframe();
|
|
14019
|
+
}
|
|
14020
|
+
|
|
14021
|
+
parseLinks() {
|
|
14022
|
+
const links = this._getLinks();
|
|
14023
|
+
|
|
14024
|
+
links.forEach(link => {
|
|
14025
|
+
link.setAttribute('data-wazo-parsed', true);
|
|
14026
|
+
link.addEventListener('click', this._onLinkClick.bind(this));
|
|
14027
|
+
this.onLinkEnabled(link);
|
|
14028
|
+
});
|
|
14029
|
+
}
|
|
14030
|
+
|
|
14031
|
+
makeCall(number ) {
|
|
14032
|
+
this.displaySoftphone();
|
|
14033
|
+
|
|
14034
|
+
if (this.iframe) {
|
|
14035
|
+
this.iframe.contentWindow.postMessage({ type: SDK_CLICK_TO_CALL, number }, '*');
|
|
14036
|
+
}
|
|
14037
|
+
}
|
|
14038
|
+
|
|
14039
|
+
toggleSoftphoneDisplay() {
|
|
14040
|
+
if (this.displayed) {
|
|
14041
|
+
this.hideSoftphone();
|
|
14042
|
+
} else {
|
|
14043
|
+
this.displaySoftphone();
|
|
14044
|
+
}
|
|
14045
|
+
|
|
14046
|
+
this.displayed = !this.displayed;
|
|
14047
|
+
}
|
|
14048
|
+
|
|
14049
|
+
displaySoftphone() {
|
|
14050
|
+
if (!this.iframe) {
|
|
14051
|
+
this._createIframe();
|
|
14052
|
+
}
|
|
14053
|
+
|
|
14054
|
+
if (this.iframe) {
|
|
14055
|
+
this.iframe.style.display = 'block';
|
|
14056
|
+
}
|
|
14057
|
+
}
|
|
14058
|
+
|
|
14059
|
+
hideSoftphone() {
|
|
14060
|
+
if (this.iframe) {
|
|
14061
|
+
this.iframe.style.display = 'none';
|
|
14062
|
+
}
|
|
14063
|
+
}
|
|
14064
|
+
|
|
14065
|
+
_createIframe() {
|
|
14066
|
+
this.iframe = document.createElement('iframe');
|
|
14067
|
+
// $FlowFixMe
|
|
14068
|
+
this.iframe.width = this.width;
|
|
14069
|
+
// $FlowFixMe
|
|
14070
|
+
this.iframe.height = this.height;
|
|
14071
|
+
// $FlowFixMe
|
|
14072
|
+
this.iframe.allow = 'camera *; microphone *; autoplay *; display-capture *';
|
|
14073
|
+
this.iframe.style.position = 'absolute';
|
|
14074
|
+
this.iframe.style.left = '0';
|
|
14075
|
+
this.iframe.style.bottom = '0';
|
|
14076
|
+
this.iframe.style.border = '1px solid #aaa';
|
|
14077
|
+
this.iframe.src = this.url;
|
|
14078
|
+
this.iframe.style.display = 'none';
|
|
14079
|
+
this.iframe.id = 'wazo-softphone';
|
|
14080
|
+
|
|
14081
|
+
// $FlowFixMe
|
|
14082
|
+
document.body.appendChild(this.iframe);
|
|
14083
|
+
}
|
|
14084
|
+
|
|
14085
|
+
_getLinks() {
|
|
14086
|
+
return [].slice.call(document.querySelectorAll('a:not([data-wazo-parsed])'), 0)
|
|
14087
|
+
.filter(link => link.href.indexOf('tel:') === 0 || link.href.indexOf('callto:') === 0);
|
|
14088
|
+
}
|
|
14089
|
+
|
|
14090
|
+
_onLinkClick(e ) {
|
|
14091
|
+
e.preventDefault();
|
|
14092
|
+
const number = e.target.href.split(':')[1];
|
|
14093
|
+
|
|
14094
|
+
this.makeCall(number);
|
|
14095
|
+
}
|
|
14096
|
+
|
|
14097
|
+
_onAuthenticated() {
|
|
14098
|
+
this.parseLinks();
|
|
14099
|
+
}
|
|
14100
|
+
|
|
14101
|
+
_onMessage(event ) {
|
|
14102
|
+
if (!event.data) {
|
|
14103
|
+
return;
|
|
14104
|
+
}
|
|
14105
|
+
|
|
14106
|
+
switch (event.data.type) {
|
|
14107
|
+
case SDK_ON_CALL_MADE:
|
|
14108
|
+
this.onCallMade(event.data.callSession);
|
|
14109
|
+
break;
|
|
14110
|
+
case SDK_CALL_ENDED: {
|
|
14111
|
+
const { callSession, content, direction, userExtension } = event.data;
|
|
14112
|
+
this.onCallEnded(callSession, content, direction, userExtension);
|
|
14113
|
+
break;
|
|
14114
|
+
}
|
|
14115
|
+
case SDK_CALL_INCOMING:
|
|
14116
|
+
this.onCallIncoming(event.data.callSession);
|
|
14117
|
+
break;
|
|
14118
|
+
case SDK_AUTHENTICATED:
|
|
14119
|
+
// $FlowFixMe
|
|
14120
|
+
this._onAuthenticated(event.data.session);
|
|
14121
|
+
this.onAuthenticated(event.data.session);
|
|
14122
|
+
break;
|
|
14123
|
+
}
|
|
14124
|
+
}
|
|
14125
|
+
}
|
|
14126
|
+
|
|
14127
|
+
var Softphone$1 = new Softphone();
|
|
14128
|
+
|
|
13982
14129
|
/* global window */
|
|
13983
14130
|
|
|
13984
14131
|
const Wazo = {
|
|
@@ -13999,6 +14146,7 @@ const Wazo = {
|
|
|
13999
14146
|
loggerFor: IssueReporter$1.loggerFor.bind(IssueReporter$1),
|
|
14000
14147
|
Features: Features$1,
|
|
14001
14148
|
Checker,
|
|
14149
|
+
Softphone: Softphone$1,
|
|
14002
14150
|
|
|
14003
14151
|
// Domain
|
|
14004
14152
|
domain: {
|