@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.
@@ -13969,6 +13969,153 @@ class Checker {
13969
13969
  }
13970
13970
  }
13971
13971
 
13972
+ //
13973
+ /* eslint-disable no-unused-vars */
13974
+ /* global window, document */
13975
+ const SDK_CLICK_TO_CALL = 'sdk/CLICK_TO_CALL';
13976
+ const SDK_ON_CALL_MADE = 'sdk/SDK_ON_CALL_MADE';
13977
+ const SDK_CALL_ENDED = 'sdk/ON_CALL_ENDED';
13978
+ const SDK_CALL_INCOMING = 'sdk/SDK_CALL_INCOMING';
13979
+ const SDK_AUTHENTICATED = 'sdk/SDK_AUTHENTICATED';
13980
+
13981
+ class Softphone {
13982
+ url = 'https://softphone.wazo.io';
13983
+ width = 500;
13984
+ height = 600;
13985
+ displayed = false;
13986
+ iframe = null;
13987
+
13988
+ onLinkEnabled(link ) {}
13989
+
13990
+ onCallMade(call ) {}
13991
+ onCallIncoming(call ) {}
13992
+ onCallEnded(call , card , direction , fromExtension ) {}
13993
+ onAuthenticated(session ) {}
13994
+
13995
+ init(url , width , height ) {
13996
+ if (url) {
13997
+ this.url = url;
13998
+ }
13999
+ if (width) {
14000
+ this.width = width;
14001
+ }
14002
+ if (height) {
14003
+ this.height = height;
14004
+ }
14005
+
14006
+ window.addEventListener('message', this._onMessage.bind(this), false);
14007
+
14008
+ this._createIframe();
14009
+ }
14010
+
14011
+ parseLinks() {
14012
+ const links = this._getLinks();
14013
+
14014
+ links.forEach(link => {
14015
+ link.setAttribute('data-wazo-parsed', true);
14016
+ link.addEventListener('click', this._onLinkClick.bind(this));
14017
+ this.onLinkEnabled(link);
14018
+ });
14019
+ }
14020
+
14021
+ makeCall(number ) {
14022
+ this.displaySoftphone();
14023
+
14024
+ if (this.iframe) {
14025
+ this.iframe.contentWindow.postMessage({ type: SDK_CLICK_TO_CALL, number }, '*');
14026
+ }
14027
+ }
14028
+
14029
+ toggleSoftphoneDisplay() {
14030
+ if (this.displayed) {
14031
+ this.hideSoftphone();
14032
+ } else {
14033
+ this.displaySoftphone();
14034
+ }
14035
+
14036
+ this.displayed = !this.displayed;
14037
+ }
14038
+
14039
+ displaySoftphone() {
14040
+ if (!this.iframe) {
14041
+ this._createIframe();
14042
+ }
14043
+
14044
+ if (this.iframe) {
14045
+ this.iframe.style.display = 'block';
14046
+ }
14047
+ }
14048
+
14049
+ hideSoftphone() {
14050
+ if (this.iframe) {
14051
+ this.iframe.style.display = 'none';
14052
+ }
14053
+ }
14054
+
14055
+ _createIframe() {
14056
+ this.iframe = document.createElement('iframe');
14057
+ // $FlowFixMe
14058
+ this.iframe.width = this.width;
14059
+ // $FlowFixMe
14060
+ this.iframe.height = this.height;
14061
+ // $FlowFixMe
14062
+ this.iframe.allow = 'camera *; microphone *; autoplay *; display-capture *';
14063
+ this.iframe.style.position = 'absolute';
14064
+ this.iframe.style.left = '0';
14065
+ this.iframe.style.bottom = '0';
14066
+ this.iframe.style.border = '1px solid #aaa';
14067
+ this.iframe.src = this.url;
14068
+ this.iframe.style.display = 'none';
14069
+ this.iframe.id = 'wazo-softphone';
14070
+
14071
+ // $FlowFixMe
14072
+ document.body.appendChild(this.iframe);
14073
+ }
14074
+
14075
+ _getLinks() {
14076
+ return [].slice.call(document.querySelectorAll('a:not([data-wazo-parsed])'), 0)
14077
+ .filter(link => link.href.indexOf('tel:') === 0 || link.href.indexOf('callto:') === 0);
14078
+ }
14079
+
14080
+ _onLinkClick(e ) {
14081
+ e.preventDefault();
14082
+ const number = e.target.href.split(':')[1];
14083
+
14084
+ this.makeCall(number);
14085
+ }
14086
+
14087
+ _onAuthenticated() {
14088
+ this.parseLinks();
14089
+ }
14090
+
14091
+ _onMessage(event ) {
14092
+ if (!event.data) {
14093
+ return;
14094
+ }
14095
+
14096
+ switch (event.data.type) {
14097
+ case SDK_ON_CALL_MADE:
14098
+ this.onCallMade(event.data.callSession);
14099
+ break;
14100
+ case SDK_CALL_ENDED: {
14101
+ const { callSession, content, direction, userExtension } = event.data;
14102
+ this.onCallEnded(callSession, content, direction, userExtension);
14103
+ break;
14104
+ }
14105
+ case SDK_CALL_INCOMING:
14106
+ this.onCallIncoming(event.data.callSession);
14107
+ break;
14108
+ case SDK_AUTHENTICATED:
14109
+ // $FlowFixMe
14110
+ this._onAuthenticated(event.data.session);
14111
+ this.onAuthenticated(event.data.session);
14112
+ break;
14113
+ }
14114
+ }
14115
+ }
14116
+
14117
+ var Softphone$1 = new Softphone();
14118
+
13972
14119
  /* global window */
13973
14120
 
13974
14121
  const Wazo = {
@@ -13989,6 +14136,7 @@ const Wazo = {
13989
14136
  loggerFor: IssueReporter$1.loggerFor.bind(IssueReporter$1),
13990
14137
  Features: Features$1,
13991
14138
  Checker,
14139
+ Softphone: Softphone$1,
13992
14140
 
13993
14141
  // Domain
13994
14142
  domain: {
@@ -13953,6 +13953,153 @@ class Checker {
13953
13953
  }
13954
13954
  }
13955
13955
 
13956
+ //
13957
+ /* eslint-disable no-unused-vars */
13958
+ /* global window, document */
13959
+ const SDK_CLICK_TO_CALL = 'sdk/CLICK_TO_CALL';
13960
+ const SDK_ON_CALL_MADE = 'sdk/SDK_ON_CALL_MADE';
13961
+ const SDK_CALL_ENDED = 'sdk/ON_CALL_ENDED';
13962
+ const SDK_CALL_INCOMING = 'sdk/SDK_CALL_INCOMING';
13963
+ const SDK_AUTHENTICATED = 'sdk/SDK_AUTHENTICATED';
13964
+
13965
+ class Softphone {
13966
+ url = 'https://softphone.wazo.io';
13967
+ width = 500;
13968
+ height = 600;
13969
+ displayed = false;
13970
+ iframe = null;
13971
+
13972
+ onLinkEnabled(link ) {}
13973
+
13974
+ onCallMade(call ) {}
13975
+ onCallIncoming(call ) {}
13976
+ onCallEnded(call , card , direction , fromExtension ) {}
13977
+ onAuthenticated(session ) {}
13978
+
13979
+ init(url , width , height ) {
13980
+ if (url) {
13981
+ this.url = url;
13982
+ }
13983
+ if (width) {
13984
+ this.width = width;
13985
+ }
13986
+ if (height) {
13987
+ this.height = height;
13988
+ }
13989
+
13990
+ window.addEventListener('message', this._onMessage.bind(this), false);
13991
+
13992
+ this._createIframe();
13993
+ }
13994
+
13995
+ parseLinks() {
13996
+ const links = this._getLinks();
13997
+
13998
+ links.forEach(link => {
13999
+ link.setAttribute('data-wazo-parsed', true);
14000
+ link.addEventListener('click', this._onLinkClick.bind(this));
14001
+ this.onLinkEnabled(link);
14002
+ });
14003
+ }
14004
+
14005
+ makeCall(number ) {
14006
+ this.displaySoftphone();
14007
+
14008
+ if (this.iframe) {
14009
+ this.iframe.contentWindow.postMessage({ type: SDK_CLICK_TO_CALL, number }, '*');
14010
+ }
14011
+ }
14012
+
14013
+ toggleSoftphoneDisplay() {
14014
+ if (this.displayed) {
14015
+ this.hideSoftphone();
14016
+ } else {
14017
+ this.displaySoftphone();
14018
+ }
14019
+
14020
+ this.displayed = !this.displayed;
14021
+ }
14022
+
14023
+ displaySoftphone() {
14024
+ if (!this.iframe) {
14025
+ this._createIframe();
14026
+ }
14027
+
14028
+ if (this.iframe) {
14029
+ this.iframe.style.display = 'block';
14030
+ }
14031
+ }
14032
+
14033
+ hideSoftphone() {
14034
+ if (this.iframe) {
14035
+ this.iframe.style.display = 'none';
14036
+ }
14037
+ }
14038
+
14039
+ _createIframe() {
14040
+ this.iframe = document.createElement('iframe');
14041
+ // $FlowFixMe
14042
+ this.iframe.width = this.width;
14043
+ // $FlowFixMe
14044
+ this.iframe.height = this.height;
14045
+ // $FlowFixMe
14046
+ this.iframe.allow = 'camera *; microphone *; autoplay *; display-capture *';
14047
+ this.iframe.style.position = 'absolute';
14048
+ this.iframe.style.left = '0';
14049
+ this.iframe.style.bottom = '0';
14050
+ this.iframe.style.border = '1px solid #aaa';
14051
+ this.iframe.src = this.url;
14052
+ this.iframe.style.display = 'none';
14053
+ this.iframe.id = 'wazo-softphone';
14054
+
14055
+ // $FlowFixMe
14056
+ document.body.appendChild(this.iframe);
14057
+ }
14058
+
14059
+ _getLinks() {
14060
+ return [].slice.call(document.querySelectorAll('a:not([data-wazo-parsed])'), 0)
14061
+ .filter(link => link.href.indexOf('tel:') === 0 || link.href.indexOf('callto:') === 0);
14062
+ }
14063
+
14064
+ _onLinkClick(e ) {
14065
+ e.preventDefault();
14066
+ const number = e.target.href.split(':')[1];
14067
+
14068
+ this.makeCall(number);
14069
+ }
14070
+
14071
+ _onAuthenticated() {
14072
+ this.parseLinks();
14073
+ }
14074
+
14075
+ _onMessage(event ) {
14076
+ if (!event.data) {
14077
+ return;
14078
+ }
14079
+
14080
+ switch (event.data.type) {
14081
+ case SDK_ON_CALL_MADE:
14082
+ this.onCallMade(event.data.callSession);
14083
+ break;
14084
+ case SDK_CALL_ENDED: {
14085
+ const { callSession, content, direction, userExtension } = event.data;
14086
+ this.onCallEnded(callSession, content, direction, userExtension);
14087
+ break;
14088
+ }
14089
+ case SDK_CALL_INCOMING:
14090
+ this.onCallIncoming(event.data.callSession);
14091
+ break;
14092
+ case SDK_AUTHENTICATED:
14093
+ // $FlowFixMe
14094
+ this._onAuthenticated(event.data.session);
14095
+ this.onAuthenticated(event.data.session);
14096
+ break;
14097
+ }
14098
+ }
14099
+ }
14100
+
14101
+ var Softphone$1 = new Softphone();
14102
+
13956
14103
  /* global window */
13957
14104
 
13958
14105
  const Wazo = {
@@ -13973,6 +14120,7 @@ const Wazo = {
13973
14120
  loggerFor: IssueReporter$1.loggerFor.bind(IssueReporter$1),
13974
14121
  Features: Features$1,
13975
14122
  Checker,
14123
+ Softphone: Softphone$1,
13976
14124
 
13977
14125
  // Domain
13978
14126
  domain: {
package/lib/index.js CHANGED
@@ -14118,6 +14118,153 @@ const createLocalVideoStream = async (options ) => createLocalStream('vid
14118
14118
 
14119
14119
  const createLocalAudioStream = async (options ) => createLocalStream('audio', options);
14120
14120
 
14121
+ //
14122
+ /* eslint-disable no-unused-vars */
14123
+ /* global window, document */
14124
+ const SDK_CLICK_TO_CALL = 'sdk/CLICK_TO_CALL';
14125
+ const SDK_ON_CALL_MADE = 'sdk/SDK_ON_CALL_MADE';
14126
+ const SDK_CALL_ENDED = 'sdk/ON_CALL_ENDED';
14127
+ const SDK_CALL_INCOMING = 'sdk/SDK_CALL_INCOMING';
14128
+ const SDK_AUTHENTICATED = 'sdk/SDK_AUTHENTICATED';
14129
+
14130
+ class Softphone {
14131
+ url = 'https://softphone.wazo.io';
14132
+ width = 500;
14133
+ height = 600;
14134
+ displayed = false;
14135
+ iframe = null;
14136
+
14137
+ onLinkEnabled(link ) {}
14138
+
14139
+ onCallMade(call ) {}
14140
+ onCallIncoming(call ) {}
14141
+ onCallEnded(call , card , direction , fromExtension ) {}
14142
+ onAuthenticated(session ) {}
14143
+
14144
+ init(url , width , height ) {
14145
+ if (url) {
14146
+ this.url = url;
14147
+ }
14148
+ if (width) {
14149
+ this.width = width;
14150
+ }
14151
+ if (height) {
14152
+ this.height = height;
14153
+ }
14154
+
14155
+ window.addEventListener('message', this._onMessage.bind(this), false);
14156
+
14157
+ this._createIframe();
14158
+ }
14159
+
14160
+ parseLinks() {
14161
+ const links = this._getLinks();
14162
+
14163
+ links.forEach(link => {
14164
+ link.setAttribute('data-wazo-parsed', true);
14165
+ link.addEventListener('click', this._onLinkClick.bind(this));
14166
+ this.onLinkEnabled(link);
14167
+ });
14168
+ }
14169
+
14170
+ makeCall(number ) {
14171
+ this.displaySoftphone();
14172
+
14173
+ if (this.iframe) {
14174
+ this.iframe.contentWindow.postMessage({ type: SDK_CLICK_TO_CALL, number }, '*');
14175
+ }
14176
+ }
14177
+
14178
+ toggleSoftphoneDisplay() {
14179
+ if (this.displayed) {
14180
+ this.hideSoftphone();
14181
+ } else {
14182
+ this.displaySoftphone();
14183
+ }
14184
+
14185
+ this.displayed = !this.displayed;
14186
+ }
14187
+
14188
+ displaySoftphone() {
14189
+ if (!this.iframe) {
14190
+ this._createIframe();
14191
+ }
14192
+
14193
+ if (this.iframe) {
14194
+ this.iframe.style.display = 'block';
14195
+ }
14196
+ }
14197
+
14198
+ hideSoftphone() {
14199
+ if (this.iframe) {
14200
+ this.iframe.style.display = 'none';
14201
+ }
14202
+ }
14203
+
14204
+ _createIframe() {
14205
+ this.iframe = document.createElement('iframe');
14206
+ // $FlowFixMe
14207
+ this.iframe.width = this.width;
14208
+ // $FlowFixMe
14209
+ this.iframe.height = this.height;
14210
+ // $FlowFixMe
14211
+ this.iframe.allow = 'camera *; microphone *; autoplay *; display-capture *';
14212
+ this.iframe.style.position = 'absolute';
14213
+ this.iframe.style.left = '0';
14214
+ this.iframe.style.bottom = '0';
14215
+ this.iframe.style.border = '1px solid #aaa';
14216
+ this.iframe.src = this.url;
14217
+ this.iframe.style.display = 'none';
14218
+ this.iframe.id = 'wazo-softphone';
14219
+
14220
+ // $FlowFixMe
14221
+ document.body.appendChild(this.iframe);
14222
+ }
14223
+
14224
+ _getLinks() {
14225
+ return [].slice.call(document.querySelectorAll('a:not([data-wazo-parsed])'), 0)
14226
+ .filter(link => link.href.indexOf('tel:') === 0 || link.href.indexOf('callto:') === 0);
14227
+ }
14228
+
14229
+ _onLinkClick(e ) {
14230
+ e.preventDefault();
14231
+ const number = e.target.href.split(':')[1];
14232
+
14233
+ this.makeCall(number);
14234
+ }
14235
+
14236
+ _onAuthenticated() {
14237
+ this.parseLinks();
14238
+ }
14239
+
14240
+ _onMessage(event ) {
14241
+ if (!event.data) {
14242
+ return;
14243
+ }
14244
+
14245
+ switch (event.data.type) {
14246
+ case SDK_ON_CALL_MADE:
14247
+ this.onCallMade(event.data.callSession);
14248
+ break;
14249
+ case SDK_CALL_ENDED: {
14250
+ const { callSession, content, direction, userExtension } = event.data;
14251
+ this.onCallEnded(callSession, content, direction, userExtension);
14252
+ break;
14253
+ }
14254
+ case SDK_CALL_INCOMING:
14255
+ this.onCallIncoming(event.data.callSession);
14256
+ break;
14257
+ case SDK_AUTHENTICATED:
14258
+ // $FlowFixMe
14259
+ this._onAuthenticated(event.data.session);
14260
+ this.onAuthenticated(event.data.session);
14261
+ break;
14262
+ }
14263
+ }
14264
+ }
14265
+
14266
+ var Softphone$1 = new Softphone();
14267
+
14121
14268
  /* global window */
14122
14269
 
14123
14270
  const Wazo = {
@@ -14138,6 +14285,7 @@ const Wazo = {
14138
14285
  loggerFor: IssueReporter$1.loggerFor.bind(IssueReporter$1),
14139
14286
  Features: Features$1,
14140
14287
  Checker,
14288
+ Softphone: Softphone$1,
14141
14289
 
14142
14290
  // Domain
14143
14291
  domain: {
@@ -13680,6 +13680,153 @@ class Checker {
13680
13680
  }
13681
13681
  }
13682
13682
 
13683
+ //
13684
+ /* eslint-disable no-unused-vars */
13685
+ /* global window, document */
13686
+ const SDK_CLICK_TO_CALL = 'sdk/CLICK_TO_CALL';
13687
+ const SDK_ON_CALL_MADE = 'sdk/SDK_ON_CALL_MADE';
13688
+ const SDK_CALL_ENDED = 'sdk/ON_CALL_ENDED';
13689
+ const SDK_CALL_INCOMING = 'sdk/SDK_CALL_INCOMING';
13690
+ const SDK_AUTHENTICATED = 'sdk/SDK_AUTHENTICATED';
13691
+
13692
+ class Softphone {
13693
+ url = 'https://softphone.wazo.io';
13694
+ width = 500;
13695
+ height = 600;
13696
+ displayed = false;
13697
+ iframe = null;
13698
+
13699
+ onLinkEnabled(link ) {}
13700
+
13701
+ onCallMade(call ) {}
13702
+ onCallIncoming(call ) {}
13703
+ onCallEnded(call , card , direction , fromExtension ) {}
13704
+ onAuthenticated(session ) {}
13705
+
13706
+ init(url , width , height ) {
13707
+ if (url) {
13708
+ this.url = url;
13709
+ }
13710
+ if (width) {
13711
+ this.width = width;
13712
+ }
13713
+ if (height) {
13714
+ this.height = height;
13715
+ }
13716
+
13717
+ window.addEventListener('message', this._onMessage.bind(this), false);
13718
+
13719
+ this._createIframe();
13720
+ }
13721
+
13722
+ parseLinks() {
13723
+ const links = this._getLinks();
13724
+
13725
+ links.forEach(link => {
13726
+ link.setAttribute('data-wazo-parsed', true);
13727
+ link.addEventListener('click', this._onLinkClick.bind(this));
13728
+ this.onLinkEnabled(link);
13729
+ });
13730
+ }
13731
+
13732
+ makeCall(number ) {
13733
+ this.displaySoftphone();
13734
+
13735
+ if (this.iframe) {
13736
+ this.iframe.contentWindow.postMessage({ type: SDK_CLICK_TO_CALL, number }, '*');
13737
+ }
13738
+ }
13739
+
13740
+ toggleSoftphoneDisplay() {
13741
+ if (this.displayed) {
13742
+ this.hideSoftphone();
13743
+ } else {
13744
+ this.displaySoftphone();
13745
+ }
13746
+
13747
+ this.displayed = !this.displayed;
13748
+ }
13749
+
13750
+ displaySoftphone() {
13751
+ if (!this.iframe) {
13752
+ this._createIframe();
13753
+ }
13754
+
13755
+ if (this.iframe) {
13756
+ this.iframe.style.display = 'block';
13757
+ }
13758
+ }
13759
+
13760
+ hideSoftphone() {
13761
+ if (this.iframe) {
13762
+ this.iframe.style.display = 'none';
13763
+ }
13764
+ }
13765
+
13766
+ _createIframe() {
13767
+ this.iframe = document.createElement('iframe');
13768
+ // $FlowFixMe
13769
+ this.iframe.width = this.width;
13770
+ // $FlowFixMe
13771
+ this.iframe.height = this.height;
13772
+ // $FlowFixMe
13773
+ this.iframe.allow = 'camera *; microphone *; autoplay *; display-capture *';
13774
+ this.iframe.style.position = 'absolute';
13775
+ this.iframe.style.left = '0';
13776
+ this.iframe.style.bottom = '0';
13777
+ this.iframe.style.border = '1px solid #aaa';
13778
+ this.iframe.src = this.url;
13779
+ this.iframe.style.display = 'none';
13780
+ this.iframe.id = 'wazo-softphone';
13781
+
13782
+ // $FlowFixMe
13783
+ document.body.appendChild(this.iframe);
13784
+ }
13785
+
13786
+ _getLinks() {
13787
+ return [].slice.call(document.querySelectorAll('a:not([data-wazo-parsed])'), 0)
13788
+ .filter(link => link.href.indexOf('tel:') === 0 || link.href.indexOf('callto:') === 0);
13789
+ }
13790
+
13791
+ _onLinkClick(e ) {
13792
+ e.preventDefault();
13793
+ const number = e.target.href.split(':')[1];
13794
+
13795
+ this.makeCall(number);
13796
+ }
13797
+
13798
+ _onAuthenticated() {
13799
+ this.parseLinks();
13800
+ }
13801
+
13802
+ _onMessage(event ) {
13803
+ if (!event.data) {
13804
+ return;
13805
+ }
13806
+
13807
+ switch (event.data.type) {
13808
+ case SDK_ON_CALL_MADE:
13809
+ this.onCallMade(event.data.callSession);
13810
+ break;
13811
+ case SDK_CALL_ENDED: {
13812
+ const { callSession, content, direction, userExtension } = event.data;
13813
+ this.onCallEnded(callSession, content, direction, userExtension);
13814
+ break;
13815
+ }
13816
+ case SDK_CALL_INCOMING:
13817
+ this.onCallIncoming(event.data.callSession);
13818
+ break;
13819
+ case SDK_AUTHENTICATED:
13820
+ // $FlowFixMe
13821
+ this._onAuthenticated(event.data.session);
13822
+ this.onAuthenticated(event.data.session);
13823
+ break;
13824
+ }
13825
+ }
13826
+ }
13827
+
13828
+ var Softphone$1 = new Softphone();
13829
+
13683
13830
  /* global window */
13684
13831
 
13685
13832
  const Wazo = {
@@ -13700,6 +13847,7 @@ const Wazo = {
13700
13847
  loggerFor: IssueReporter$1.loggerFor.bind(IssueReporter$1),
13701
13848
  Features: Features$1,
13702
13849
  Checker,
13850
+ Softphone: Softphone$1,
13703
13851
 
13704
13852
  // Domain
13705
13853
  domain: {