pusher-js 8.0.2 → 8.2.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/CHANGELOG.md +9 -0
- package/dist/node/pusher.js +968 -1391
- package/dist/node/pusher.js.map +1 -1
- package/dist/react-native/pusher.js +2 -2
- package/dist/react-native/pusher.js.map +1 -1
- package/dist/web/pusher-with-encryption.js +1003 -1434
- package/dist/web/pusher-with-encryption.js.map +1 -1
- package/dist/web/pusher-with-encryption.min.js +2 -2
- package/dist/web/pusher-with-encryption.min.js.map +1 -1
- package/dist/web/pusher.js +994 -1410
- package/dist/web/pusher.js.map +1 -1
- package/dist/web/pusher.min.js +2 -2
- package/dist/web/pusher.min.js.map +1 -1
- package/dist/worker/pusher-with-encryption.worker.js +968 -1390
- package/dist/worker/pusher-with-encryption.worker.js.map +1 -1
- package/dist/worker/pusher-with-encryption.worker.min.js +2 -2
- package/dist/worker/pusher-with-encryption.worker.min.js.map +1 -1
- package/dist/worker/pusher.worker.js +959 -1366
- package/dist/worker/pusher.worker.js.map +1 -1
- package/dist/worker/pusher.worker.min.js +2 -2
- package/dist/worker/pusher.worker.min.js.map +1 -1
- package/package.json +6 -6
- package/src/runtimes/isomorphic/default_strategy.ts +0 -1
- package/src/runtimes/web/default_strategy.ts +0 -1
- package/tsconfig.json +1 -1
- package/types/src/core/auth/options.d.ts +3 -3
- package/types/src/core/config.d.ts +2 -2
- package/types/src/core/strategies/transport_strategy.d.ts +0 -3
- package/types/src/core/utils/timers/scheduling.d.ts +1 -1
package/dist/web/pusher.js
CHANGED
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
/*!
|
|
2
|
-
* Pusher JavaScript Library v8.0
|
|
2
|
+
* Pusher JavaScript Library v8.2.0
|
|
3
3
|
* https://pusher.com/
|
|
4
4
|
*
|
|
5
5
|
* Copyright 2020, Pusher
|
|
@@ -562,13 +562,13 @@ module.exports = __webpack_require__(3).default;
|
|
|
562
562
|
__webpack_require__.r(__webpack_exports__);
|
|
563
563
|
|
|
564
564
|
// CONCATENATED MODULE: ./src/runtimes/web/dom/script_receiver_factory.ts
|
|
565
|
-
|
|
566
|
-
|
|
565
|
+
class ScriptReceiverFactory {
|
|
566
|
+
constructor(prefix, name) {
|
|
567
567
|
this.lastId = 0;
|
|
568
568
|
this.prefix = prefix;
|
|
569
569
|
this.name = name;
|
|
570
570
|
}
|
|
571
|
-
|
|
571
|
+
create(callback) {
|
|
572
572
|
this.lastId++;
|
|
573
573
|
var number = this.lastId;
|
|
574
574
|
var id = this.prefix + number;
|
|
@@ -582,18 +582,16 @@ var ScriptReceiverFactory = (function () {
|
|
|
582
582
|
};
|
|
583
583
|
this[number] = callbackWrapper;
|
|
584
584
|
return { number: number, id: id, name: name, callback: callbackWrapper };
|
|
585
|
-
}
|
|
586
|
-
|
|
585
|
+
}
|
|
586
|
+
remove(receiver) {
|
|
587
587
|
delete this[receiver.number];
|
|
588
|
-
}
|
|
589
|
-
|
|
590
|
-
}());
|
|
591
|
-
|
|
588
|
+
}
|
|
589
|
+
}
|
|
592
590
|
var ScriptReceivers = new ScriptReceiverFactory('_pusher_script_', 'Pusher.ScriptReceivers');
|
|
593
591
|
|
|
594
592
|
// CONCATENATED MODULE: ./src/core/defaults.ts
|
|
595
593
|
var Defaults = {
|
|
596
|
-
VERSION: "8.0
|
|
594
|
+
VERSION: "8.2.0",
|
|
597
595
|
PROTOCOL: 7,
|
|
598
596
|
wsPort: 80,
|
|
599
597
|
wssPort: 443,
|
|
@@ -625,13 +623,13 @@ var Defaults = {
|
|
|
625
623
|
// CONCATENATED MODULE: ./src/runtimes/web/dom/dependency_loader.ts
|
|
626
624
|
|
|
627
625
|
|
|
628
|
-
|
|
629
|
-
|
|
626
|
+
class dependency_loader_DependencyLoader {
|
|
627
|
+
constructor(options) {
|
|
630
628
|
this.options = options;
|
|
631
629
|
this.receivers = options.receivers || ScriptReceivers;
|
|
632
630
|
this.loading = {};
|
|
633
631
|
}
|
|
634
|
-
|
|
632
|
+
load(name, options, callback) {
|
|
635
633
|
var self = this;
|
|
636
634
|
if (self.loading[name] && self.loading[name].length > 0) {
|
|
637
635
|
self.loading[name].push(callback);
|
|
@@ -656,8 +654,8 @@ var dependency_loader_DependencyLoader = (function () {
|
|
|
656
654
|
});
|
|
657
655
|
request.send(receiver);
|
|
658
656
|
}
|
|
659
|
-
}
|
|
660
|
-
|
|
657
|
+
}
|
|
658
|
+
getRoot(options) {
|
|
661
659
|
var cdn;
|
|
662
660
|
var protocol = runtime.getDocument().location.protocol;
|
|
663
661
|
if ((options && options.useTLS) || protocol === 'https:') {
|
|
@@ -667,20 +665,18 @@ var dependency_loader_DependencyLoader = (function () {
|
|
|
667
665
|
cdn = this.options.cdn_http;
|
|
668
666
|
}
|
|
669
667
|
return cdn.replace(/\/*$/, '') + '/' + this.options.version;
|
|
670
|
-
}
|
|
671
|
-
|
|
668
|
+
}
|
|
669
|
+
getPath(name, options) {
|
|
672
670
|
return this.getRoot(options) + '/' + name + this.options.suffix + '.js';
|
|
673
|
-
}
|
|
674
|
-
|
|
675
|
-
}());
|
|
676
|
-
/* harmony default export */ var dependency_loader = (dependency_loader_DependencyLoader);
|
|
671
|
+
}
|
|
672
|
+
}
|
|
677
673
|
|
|
678
674
|
// CONCATENATED MODULE: ./src/runtimes/web/dom/dependencies.ts
|
|
679
675
|
|
|
680
676
|
|
|
681
677
|
|
|
682
678
|
var DependenciesReceivers = new ScriptReceiverFactory('_pusher_dependencies', 'Pusher.DependenciesReceivers');
|
|
683
|
-
var Dependencies = new
|
|
679
|
+
var Dependencies = new dependency_loader_DependencyLoader({
|
|
684
680
|
cdn_http: defaults.cdn_http,
|
|
685
681
|
cdn_https: defaults.cdn_https,
|
|
686
682
|
version: defaults.VERSION,
|
|
@@ -689,7 +685,7 @@ var Dependencies = new dependency_loader({
|
|
|
689
685
|
});
|
|
690
686
|
|
|
691
687
|
// CONCATENATED MODULE: ./src/core/utils/url_store.ts
|
|
692
|
-
|
|
688
|
+
const urlStore = {
|
|
693
689
|
baseUrl: 'https://pusher.com',
|
|
694
690
|
urls: {
|
|
695
691
|
authenticationEndpoint: {
|
|
@@ -709,12 +705,12 @@ var urlStore = {
|
|
|
709
705
|
}
|
|
710
706
|
}
|
|
711
707
|
};
|
|
712
|
-
|
|
713
|
-
|
|
714
|
-
|
|
708
|
+
const buildLogSuffix = function (key) {
|
|
709
|
+
const urlPrefix = 'See:';
|
|
710
|
+
const urlObj = urlStore.urls[key];
|
|
715
711
|
if (!urlObj)
|
|
716
712
|
return '';
|
|
717
|
-
|
|
713
|
+
let url;
|
|
718
714
|
if (urlObj.fullUrl) {
|
|
719
715
|
url = urlObj.fullUrl;
|
|
720
716
|
}
|
|
@@ -723,9 +719,9 @@ var buildLogSuffix = function (key) {
|
|
|
723
719
|
}
|
|
724
720
|
if (!url)
|
|
725
721
|
return '';
|
|
726
|
-
return urlPrefix
|
|
722
|
+
return `${urlPrefix} ${url}`;
|
|
727
723
|
};
|
|
728
|
-
/* harmony default export */ var url_store = ({ buildLogSuffix
|
|
724
|
+
/* harmony default export */ var url_store = ({ buildLogSuffix });
|
|
729
725
|
|
|
730
726
|
// CONCATENATED MODULE: ./src/core/auth/options.ts
|
|
731
727
|
var AuthRequestType;
|
|
@@ -735,134 +731,76 @@ var AuthRequestType;
|
|
|
735
731
|
})(AuthRequestType || (AuthRequestType = {}));
|
|
736
732
|
|
|
737
733
|
// CONCATENATED MODULE: ./src/core/errors.ts
|
|
738
|
-
|
|
739
|
-
|
|
740
|
-
|
|
741
|
-
|
|
742
|
-
|
|
743
|
-
|
|
744
|
-
|
|
745
|
-
|
|
746
|
-
|
|
747
|
-
|
|
748
|
-
|
|
749
|
-
|
|
750
|
-
|
|
751
|
-
|
|
752
|
-
|
|
753
|
-
|
|
754
|
-
|
|
755
|
-
|
|
756
|
-
|
|
757
|
-
|
|
758
|
-
|
|
759
|
-
|
|
760
|
-
}
|
|
761
|
-
|
|
762
|
-
|
|
763
|
-
|
|
764
|
-
|
|
765
|
-
|
|
766
|
-
|
|
767
|
-
|
|
768
|
-
|
|
769
|
-
|
|
770
|
-
|
|
771
|
-
|
|
772
|
-
|
|
773
|
-
|
|
774
|
-
|
|
775
|
-
|
|
776
|
-
|
|
777
|
-
|
|
778
|
-
|
|
779
|
-
|
|
780
|
-
|
|
781
|
-
|
|
782
|
-
|
|
783
|
-
|
|
784
|
-
|
|
785
|
-
|
|
786
|
-
|
|
787
|
-
|
|
788
|
-
|
|
789
|
-
|
|
790
|
-
|
|
791
|
-
}
|
|
792
|
-
|
|
793
|
-
}(Error));
|
|
794
|
-
|
|
795
|
-
var TransportClosed = (function (_super) {
|
|
796
|
-
__extends(TransportClosed, _super);
|
|
797
|
-
function TransportClosed(msg) {
|
|
798
|
-
var _newTarget = this.constructor;
|
|
799
|
-
var _this = _super.call(this, msg) || this;
|
|
800
|
-
Object.setPrototypeOf(_this, _newTarget.prototype);
|
|
801
|
-
return _this;
|
|
802
|
-
}
|
|
803
|
-
return TransportClosed;
|
|
804
|
-
}(Error));
|
|
805
|
-
|
|
806
|
-
var UnsupportedFeature = (function (_super) {
|
|
807
|
-
__extends(UnsupportedFeature, _super);
|
|
808
|
-
function UnsupportedFeature(msg) {
|
|
809
|
-
var _newTarget = this.constructor;
|
|
810
|
-
var _this = _super.call(this, msg) || this;
|
|
811
|
-
Object.setPrototypeOf(_this, _newTarget.prototype);
|
|
812
|
-
return _this;
|
|
813
|
-
}
|
|
814
|
-
return UnsupportedFeature;
|
|
815
|
-
}(Error));
|
|
816
|
-
|
|
817
|
-
var UnsupportedTransport = (function (_super) {
|
|
818
|
-
__extends(UnsupportedTransport, _super);
|
|
819
|
-
function UnsupportedTransport(msg) {
|
|
820
|
-
var _newTarget = this.constructor;
|
|
821
|
-
var _this = _super.call(this, msg) || this;
|
|
822
|
-
Object.setPrototypeOf(_this, _newTarget.prototype);
|
|
823
|
-
return _this;
|
|
824
|
-
}
|
|
825
|
-
return UnsupportedTransport;
|
|
826
|
-
}(Error));
|
|
827
|
-
|
|
828
|
-
var UnsupportedStrategy = (function (_super) {
|
|
829
|
-
__extends(UnsupportedStrategy, _super);
|
|
830
|
-
function UnsupportedStrategy(msg) {
|
|
831
|
-
var _newTarget = this.constructor;
|
|
832
|
-
var _this = _super.call(this, msg) || this;
|
|
833
|
-
Object.setPrototypeOf(_this, _newTarget.prototype);
|
|
834
|
-
return _this;
|
|
835
|
-
}
|
|
836
|
-
return UnsupportedStrategy;
|
|
837
|
-
}(Error));
|
|
838
|
-
|
|
839
|
-
var HTTPAuthError = (function (_super) {
|
|
840
|
-
__extends(HTTPAuthError, _super);
|
|
841
|
-
function HTTPAuthError(status, msg) {
|
|
842
|
-
var _newTarget = this.constructor;
|
|
843
|
-
var _this = _super.call(this, msg) || this;
|
|
844
|
-
_this.status = status;
|
|
845
|
-
Object.setPrototypeOf(_this, _newTarget.prototype);
|
|
846
|
-
return _this;
|
|
847
|
-
}
|
|
848
|
-
return HTTPAuthError;
|
|
849
|
-
}(Error));
|
|
850
|
-
|
|
734
|
+
class BadEventName extends Error {
|
|
735
|
+
constructor(msg) {
|
|
736
|
+
super(msg);
|
|
737
|
+
Object.setPrototypeOf(this, new.target.prototype);
|
|
738
|
+
}
|
|
739
|
+
}
|
|
740
|
+
class BadChannelName extends Error {
|
|
741
|
+
constructor(msg) {
|
|
742
|
+
super(msg);
|
|
743
|
+
Object.setPrototypeOf(this, new.target.prototype);
|
|
744
|
+
}
|
|
745
|
+
}
|
|
746
|
+
class RequestTimedOut extends Error {
|
|
747
|
+
constructor(msg) {
|
|
748
|
+
super(msg);
|
|
749
|
+
Object.setPrototypeOf(this, new.target.prototype);
|
|
750
|
+
}
|
|
751
|
+
}
|
|
752
|
+
class TransportPriorityTooLow extends Error {
|
|
753
|
+
constructor(msg) {
|
|
754
|
+
super(msg);
|
|
755
|
+
Object.setPrototypeOf(this, new.target.prototype);
|
|
756
|
+
}
|
|
757
|
+
}
|
|
758
|
+
class TransportClosed extends Error {
|
|
759
|
+
constructor(msg) {
|
|
760
|
+
super(msg);
|
|
761
|
+
Object.setPrototypeOf(this, new.target.prototype);
|
|
762
|
+
}
|
|
763
|
+
}
|
|
764
|
+
class UnsupportedFeature extends Error {
|
|
765
|
+
constructor(msg) {
|
|
766
|
+
super(msg);
|
|
767
|
+
Object.setPrototypeOf(this, new.target.prototype);
|
|
768
|
+
}
|
|
769
|
+
}
|
|
770
|
+
class UnsupportedTransport extends Error {
|
|
771
|
+
constructor(msg) {
|
|
772
|
+
super(msg);
|
|
773
|
+
Object.setPrototypeOf(this, new.target.prototype);
|
|
774
|
+
}
|
|
775
|
+
}
|
|
776
|
+
class UnsupportedStrategy extends Error {
|
|
777
|
+
constructor(msg) {
|
|
778
|
+
super(msg);
|
|
779
|
+
Object.setPrototypeOf(this, new.target.prototype);
|
|
780
|
+
}
|
|
781
|
+
}
|
|
782
|
+
class HTTPAuthError extends Error {
|
|
783
|
+
constructor(status, msg) {
|
|
784
|
+
super(msg);
|
|
785
|
+
this.status = status;
|
|
786
|
+
Object.setPrototypeOf(this, new.target.prototype);
|
|
787
|
+
}
|
|
788
|
+
}
|
|
851
789
|
|
|
852
790
|
// CONCATENATED MODULE: ./src/runtimes/isomorphic/auth/xhr_auth.ts
|
|
853
791
|
|
|
854
792
|
|
|
855
793
|
|
|
856
794
|
|
|
857
|
-
|
|
858
|
-
|
|
795
|
+
const ajax = function (context, query, authOptions, authRequestType, callback) {
|
|
796
|
+
const xhr = runtime.createXHR();
|
|
859
797
|
xhr.open('POST', authOptions.endpoint, true);
|
|
860
798
|
xhr.setRequestHeader('Content-Type', 'application/x-www-form-urlencoded');
|
|
861
799
|
for (var headerName in authOptions.headers) {
|
|
862
800
|
xhr.setRequestHeader(headerName, authOptions.headers[headerName]);
|
|
863
801
|
}
|
|
864
802
|
if (authOptions.headersProvider != null) {
|
|
865
|
-
|
|
803
|
+
let dynamicHeaders = authOptions.headersProvider();
|
|
866
804
|
for (var headerName in dynamicHeaders) {
|
|
867
805
|
xhr.setRequestHeader(headerName, dynamicHeaders[headerName]);
|
|
868
806
|
}
|
|
@@ -870,31 +808,31 @@ var ajax = function (context, query, authOptions, authRequestType, callback) {
|
|
|
870
808
|
xhr.onreadystatechange = function () {
|
|
871
809
|
if (xhr.readyState === 4) {
|
|
872
810
|
if (xhr.status === 200) {
|
|
873
|
-
|
|
874
|
-
|
|
811
|
+
let data;
|
|
812
|
+
let parsed = false;
|
|
875
813
|
try {
|
|
876
814
|
data = JSON.parse(xhr.responseText);
|
|
877
815
|
parsed = true;
|
|
878
816
|
}
|
|
879
817
|
catch (e) {
|
|
880
|
-
callback(new HTTPAuthError(200,
|
|
818
|
+
callback(new HTTPAuthError(200, `JSON returned from ${authRequestType.toString()} endpoint was invalid, yet status code was 200. Data was: ${xhr.responseText}`), null);
|
|
881
819
|
}
|
|
882
820
|
if (parsed) {
|
|
883
821
|
callback(null, data);
|
|
884
822
|
}
|
|
885
823
|
}
|
|
886
824
|
else {
|
|
887
|
-
|
|
825
|
+
let suffix = '';
|
|
888
826
|
switch (authRequestType) {
|
|
889
827
|
case AuthRequestType.UserAuthentication:
|
|
890
828
|
suffix = url_store.buildLogSuffix('authenticationEndpoint');
|
|
891
829
|
break;
|
|
892
830
|
case AuthRequestType.ChannelAuthorization:
|
|
893
|
-
suffix =
|
|
831
|
+
suffix = `Clients must be authorized to join private or presence channels. ${url_store.buildLogSuffix('authorizationEndpoint')}`;
|
|
894
832
|
break;
|
|
895
833
|
}
|
|
896
|
-
callback(new HTTPAuthError(xhr.status,
|
|
897
|
-
|
|
834
|
+
callback(new HTTPAuthError(xhr.status, `Unable to retrieve auth string from ${authRequestType.toString()} endpoint - ` +
|
|
835
|
+
`received status: ${xhr.status} from ${authOptions.endpoint}. ${suffix}`), null);
|
|
898
836
|
}
|
|
899
837
|
}
|
|
900
838
|
};
|
|
@@ -945,43 +883,28 @@ var btoa = window.btoa ||
|
|
|
945
883
|
};
|
|
946
884
|
|
|
947
885
|
// CONCATENATED MODULE: ./src/core/utils/timers/abstract_timer.ts
|
|
948
|
-
|
|
949
|
-
|
|
950
|
-
var _this = this;
|
|
886
|
+
class Timer {
|
|
887
|
+
constructor(set, clear, delay, callback) {
|
|
951
888
|
this.clear = clear;
|
|
952
|
-
this.timer = set(
|
|
953
|
-
if (
|
|
954
|
-
|
|
889
|
+
this.timer = set(() => {
|
|
890
|
+
if (this.timer) {
|
|
891
|
+
this.timer = callback(this.timer);
|
|
955
892
|
}
|
|
956
893
|
}, delay);
|
|
957
894
|
}
|
|
958
|
-
|
|
895
|
+
isRunning() {
|
|
959
896
|
return this.timer !== null;
|
|
960
|
-
}
|
|
961
|
-
|
|
897
|
+
}
|
|
898
|
+
ensureAborted() {
|
|
962
899
|
if (this.timer) {
|
|
963
900
|
this.clear(this.timer);
|
|
964
901
|
this.timer = null;
|
|
965
902
|
}
|
|
966
|
-
}
|
|
967
|
-
|
|
968
|
-
}());
|
|
903
|
+
}
|
|
904
|
+
}
|
|
969
905
|
/* harmony default export */ var abstract_timer = (Timer);
|
|
970
906
|
|
|
971
907
|
// CONCATENATED MODULE: ./src/core/utils/timers/index.ts
|
|
972
|
-
var timers_extends = (undefined && undefined.__extends) || (function () {
|
|
973
|
-
var extendStatics = function (d, b) {
|
|
974
|
-
extendStatics = Object.setPrototypeOf ||
|
|
975
|
-
({ __proto__: [] } instanceof Array && function (d, b) { d.__proto__ = b; }) ||
|
|
976
|
-
function (d, b) { for (var p in b) if (b.hasOwnProperty(p)) d[p] = b[p]; };
|
|
977
|
-
return extendStatics(d, b);
|
|
978
|
-
};
|
|
979
|
-
return function (d, b) {
|
|
980
|
-
extendStatics(d, b);
|
|
981
|
-
function __() { this.constructor = d; }
|
|
982
|
-
d.prototype = b === null ? Object.create(b) : (__.prototype = b.prototype, new __());
|
|
983
|
-
};
|
|
984
|
-
})();
|
|
985
908
|
|
|
986
909
|
function timers_clearTimeout(timer) {
|
|
987
910
|
window.clearTimeout(timer);
|
|
@@ -989,33 +912,27 @@ function timers_clearTimeout(timer) {
|
|
|
989
912
|
function timers_clearInterval(timer) {
|
|
990
913
|
window.clearInterval(timer);
|
|
991
914
|
}
|
|
992
|
-
|
|
993
|
-
|
|
994
|
-
|
|
995
|
-
return _super.call(this, setTimeout, timers_clearTimeout, delay, function (timer) {
|
|
915
|
+
class timers_OneOffTimer extends abstract_timer {
|
|
916
|
+
constructor(delay, callback) {
|
|
917
|
+
super(setTimeout, timers_clearTimeout, delay, function (timer) {
|
|
996
918
|
callback();
|
|
997
919
|
return null;
|
|
998
|
-
})
|
|
920
|
+
});
|
|
999
921
|
}
|
|
1000
|
-
|
|
1001
|
-
|
|
1002
|
-
|
|
1003
|
-
|
|
1004
|
-
timers_extends(PeriodicTimer, _super);
|
|
1005
|
-
function PeriodicTimer(delay, callback) {
|
|
1006
|
-
return _super.call(this, setInterval, timers_clearInterval, delay, function (timer) {
|
|
922
|
+
}
|
|
923
|
+
class timers_PeriodicTimer extends abstract_timer {
|
|
924
|
+
constructor(delay, callback) {
|
|
925
|
+
super(setInterval, timers_clearInterval, delay, function (timer) {
|
|
1007
926
|
callback();
|
|
1008
927
|
return timer;
|
|
1009
|
-
})
|
|
928
|
+
});
|
|
1010
929
|
}
|
|
1011
|
-
|
|
1012
|
-
}(abstract_timer));
|
|
1013
|
-
|
|
930
|
+
}
|
|
1014
931
|
|
|
1015
932
|
// CONCATENATED MODULE: ./src/core/util.ts
|
|
1016
933
|
|
|
1017
934
|
var Util = {
|
|
1018
|
-
now
|
|
935
|
+
now() {
|
|
1019
936
|
if (Date.now) {
|
|
1020
937
|
return Date.now();
|
|
1021
938
|
}
|
|
@@ -1023,14 +940,10 @@ var Util = {
|
|
|
1023
940
|
return new Date().valueOf();
|
|
1024
941
|
}
|
|
1025
942
|
},
|
|
1026
|
-
defer
|
|
1027
|
-
return new
|
|
943
|
+
defer(callback) {
|
|
944
|
+
return new timers_OneOffTimer(0, callback);
|
|
1028
945
|
},
|
|
1029
|
-
method
|
|
1030
|
-
var args = [];
|
|
1031
|
-
for (var _i = 1; _i < arguments.length; _i++) {
|
|
1032
|
-
args[_i - 1] = arguments[_i];
|
|
1033
|
-
}
|
|
946
|
+
method(name, ...args) {
|
|
1034
947
|
var boundArguments = Array.prototype.slice.call(arguments, 1);
|
|
1035
948
|
return function (object) {
|
|
1036
949
|
return object[name].apply(object, boundArguments.concat(arguments));
|
|
@@ -1042,11 +955,7 @@ var Util = {
|
|
|
1042
955
|
// CONCATENATED MODULE: ./src/core/utils/collections.ts
|
|
1043
956
|
|
|
1044
957
|
|
|
1045
|
-
function extend(target) {
|
|
1046
|
-
var sources = [];
|
|
1047
|
-
for (var _i = 1; _i < arguments.length; _i++) {
|
|
1048
|
-
sources[_i - 1] = arguments[_i];
|
|
1049
|
-
}
|
|
958
|
+
function extend(target, ...sources) {
|
|
1050
959
|
for (var i = 0; i < sources.length; i++) {
|
|
1051
960
|
var extensions = sources[i];
|
|
1052
961
|
for (var property in extensions) {
|
|
@@ -1240,67 +1149,50 @@ function safeJSONStringify(source) {
|
|
|
1240
1149
|
// CONCATENATED MODULE: ./src/core/logger.ts
|
|
1241
1150
|
|
|
1242
1151
|
|
|
1243
|
-
|
|
1244
|
-
|
|
1245
|
-
this.globalLog =
|
|
1152
|
+
class logger_Logger {
|
|
1153
|
+
constructor() {
|
|
1154
|
+
this.globalLog = (message) => {
|
|
1246
1155
|
if (window.console && window.console.log) {
|
|
1247
1156
|
window.console.log(message);
|
|
1248
1157
|
}
|
|
1249
1158
|
};
|
|
1250
1159
|
}
|
|
1251
|
-
|
|
1252
|
-
var args = [];
|
|
1253
|
-
for (var _i = 0; _i < arguments.length; _i++) {
|
|
1254
|
-
args[_i] = arguments[_i];
|
|
1255
|
-
}
|
|
1160
|
+
debug(...args) {
|
|
1256
1161
|
this.log(this.globalLog, args);
|
|
1257
|
-
}
|
|
1258
|
-
|
|
1259
|
-
var args = [];
|
|
1260
|
-
for (var _i = 0; _i < arguments.length; _i++) {
|
|
1261
|
-
args[_i] = arguments[_i];
|
|
1262
|
-
}
|
|
1162
|
+
}
|
|
1163
|
+
warn(...args) {
|
|
1263
1164
|
this.log(this.globalLogWarn, args);
|
|
1264
|
-
}
|
|
1265
|
-
|
|
1266
|
-
var args = [];
|
|
1267
|
-
for (var _i = 0; _i < arguments.length; _i++) {
|
|
1268
|
-
args[_i] = arguments[_i];
|
|
1269
|
-
}
|
|
1165
|
+
}
|
|
1166
|
+
error(...args) {
|
|
1270
1167
|
this.log(this.globalLogError, args);
|
|
1271
|
-
}
|
|
1272
|
-
|
|
1168
|
+
}
|
|
1169
|
+
globalLogWarn(message) {
|
|
1273
1170
|
if (window.console && window.console.warn) {
|
|
1274
1171
|
window.console.warn(message);
|
|
1275
1172
|
}
|
|
1276
1173
|
else {
|
|
1277
1174
|
this.globalLog(message);
|
|
1278
1175
|
}
|
|
1279
|
-
}
|
|
1280
|
-
|
|
1176
|
+
}
|
|
1177
|
+
globalLogError(message) {
|
|
1281
1178
|
if (window.console && window.console.error) {
|
|
1282
1179
|
window.console.error(message);
|
|
1283
1180
|
}
|
|
1284
1181
|
else {
|
|
1285
1182
|
this.globalLogWarn(message);
|
|
1286
1183
|
}
|
|
1287
|
-
}
|
|
1288
|
-
|
|
1289
|
-
var args = [];
|
|
1290
|
-
for (var _i = 1; _i < arguments.length; _i++) {
|
|
1291
|
-
args[_i - 1] = arguments[_i];
|
|
1292
|
-
}
|
|
1184
|
+
}
|
|
1185
|
+
log(defaultLoggingFunction, ...args) {
|
|
1293
1186
|
var message = stringify.apply(this, arguments);
|
|
1294
1187
|
if (core_pusher.log) {
|
|
1295
1188
|
core_pusher.log(message);
|
|
1296
1189
|
}
|
|
1297
1190
|
else if (core_pusher.logToConsole) {
|
|
1298
|
-
|
|
1191
|
+
const log = defaultLoggingFunction.bind(this);
|
|
1299
1192
|
log(message);
|
|
1300
1193
|
}
|
|
1301
|
-
}
|
|
1302
|
-
|
|
1303
|
-
}());
|
|
1194
|
+
}
|
|
1195
|
+
}
|
|
1304
1196
|
/* harmony default export */ var logger = (new logger_Logger());
|
|
1305
1197
|
|
|
1306
1198
|
// CONCATENATED MODULE: ./src/runtimes/web/auth/jsonp_auth.ts
|
|
@@ -1308,7 +1200,7 @@ var logger_Logger = (function () {
|
|
|
1308
1200
|
var jsonp = function (context, query, authOptions, authRequestType, callback) {
|
|
1309
1201
|
if (authOptions.headers !== undefined ||
|
|
1310
1202
|
authOptions.headersProvider != null) {
|
|
1311
|
-
logger.warn(
|
|
1203
|
+
logger.warn(`To send headers with the ${authRequestType.toString()} request, you must use AJAX, rather than JSONP.`);
|
|
1312
1204
|
}
|
|
1313
1205
|
var callbackName = context.nextAuthCallbackID.toString();
|
|
1314
1206
|
context.nextAuthCallbackID++;
|
|
@@ -1330,11 +1222,11 @@ var jsonp = function (context, query, authOptions, authRequestType, callback) {
|
|
|
1330
1222
|
/* harmony default export */ var jsonp_auth = (jsonp);
|
|
1331
1223
|
|
|
1332
1224
|
// CONCATENATED MODULE: ./src/runtimes/web/dom/script_request.ts
|
|
1333
|
-
|
|
1334
|
-
|
|
1225
|
+
class ScriptRequest {
|
|
1226
|
+
constructor(src) {
|
|
1335
1227
|
this.src = src;
|
|
1336
1228
|
}
|
|
1337
|
-
|
|
1229
|
+
send(receiver) {
|
|
1338
1230
|
var self = this;
|
|
1339
1231
|
var errorString = 'Error loading ' + self.src;
|
|
1340
1232
|
self.script = document.createElement('script');
|
|
@@ -1374,8 +1266,8 @@ var ScriptRequest = (function () {
|
|
|
1374
1266
|
if (self.errorScript) {
|
|
1375
1267
|
head.insertBefore(self.errorScript, self.script.nextSibling);
|
|
1376
1268
|
}
|
|
1377
|
-
}
|
|
1378
|
-
|
|
1269
|
+
}
|
|
1270
|
+
cleanup() {
|
|
1379
1271
|
if (this.script) {
|
|
1380
1272
|
this.script.onload = this.script.onerror = null;
|
|
1381
1273
|
this.script.onreadystatechange = null;
|
|
@@ -1388,20 +1280,18 @@ var ScriptRequest = (function () {
|
|
|
1388
1280
|
}
|
|
1389
1281
|
this.script = null;
|
|
1390
1282
|
this.errorScript = null;
|
|
1391
|
-
}
|
|
1392
|
-
|
|
1393
|
-
}());
|
|
1394
|
-
/* harmony default export */ var script_request = (ScriptRequest);
|
|
1283
|
+
}
|
|
1284
|
+
}
|
|
1395
1285
|
|
|
1396
1286
|
// CONCATENATED MODULE: ./src/runtimes/web/dom/jsonp_request.ts
|
|
1397
1287
|
|
|
1398
1288
|
|
|
1399
|
-
|
|
1400
|
-
|
|
1289
|
+
class jsonp_request_JSONPRequest {
|
|
1290
|
+
constructor(url, data) {
|
|
1401
1291
|
this.url = url;
|
|
1402
1292
|
this.data = data;
|
|
1403
1293
|
}
|
|
1404
|
-
|
|
1294
|
+
send(receiver) {
|
|
1405
1295
|
if (this.request) {
|
|
1406
1296
|
return;
|
|
1407
1297
|
}
|
|
@@ -1409,15 +1299,13 @@ var jsonp_request_JSONPRequest = (function () {
|
|
|
1409
1299
|
var url = this.url + '/' + receiver.number + '?' + query;
|
|
1410
1300
|
this.request = runtime.createScriptRequest(url);
|
|
1411
1301
|
this.request.send(receiver);
|
|
1412
|
-
}
|
|
1413
|
-
|
|
1302
|
+
}
|
|
1303
|
+
cleanup() {
|
|
1414
1304
|
if (this.request) {
|
|
1415
1305
|
this.request.cleanup();
|
|
1416
1306
|
}
|
|
1417
|
-
}
|
|
1418
|
-
|
|
1419
|
-
}());
|
|
1420
|
-
/* harmony default export */ var jsonp_request = (jsonp_request_JSONPRequest);
|
|
1307
|
+
}
|
|
1308
|
+
}
|
|
1421
1309
|
|
|
1422
1310
|
// CONCATENATED MODULE: ./src/runtimes/web/timeline/jsonp_timeline.ts
|
|
1423
1311
|
|
|
@@ -1442,7 +1330,7 @@ var getAgent = function (sender, useTLS) {
|
|
|
1442
1330
|
};
|
|
1443
1331
|
var jsonp_timeline_jsonp = {
|
|
1444
1332
|
name: 'jsonp',
|
|
1445
|
-
getAgent
|
|
1333
|
+
getAgent
|
|
1446
1334
|
};
|
|
1447
1335
|
/* harmony default export */ var jsonp_timeline = (jsonp_timeline_jsonp);
|
|
1448
1336
|
|
|
@@ -1486,14 +1374,14 @@ var sockjs = {
|
|
|
1486
1374
|
|
|
1487
1375
|
// CONCATENATED MODULE: ./src/core/events/callback_registry.ts
|
|
1488
1376
|
|
|
1489
|
-
|
|
1490
|
-
|
|
1377
|
+
class callback_registry_CallbackRegistry {
|
|
1378
|
+
constructor() {
|
|
1491
1379
|
this._callbacks = {};
|
|
1492
1380
|
}
|
|
1493
|
-
|
|
1381
|
+
get(name) {
|
|
1494
1382
|
return this._callbacks[prefix(name)];
|
|
1495
|
-
}
|
|
1496
|
-
|
|
1383
|
+
}
|
|
1384
|
+
add(name, callback, context) {
|
|
1497
1385
|
var prefixedEventName = prefix(name);
|
|
1498
1386
|
this._callbacks[prefixedEventName] =
|
|
1499
1387
|
this._callbacks[prefixedEventName] || [];
|
|
@@ -1501,8 +1389,8 @@ var callback_registry_CallbackRegistry = (function () {
|
|
|
1501
1389
|
fn: callback,
|
|
1502
1390
|
context: context
|
|
1503
1391
|
});
|
|
1504
|
-
}
|
|
1505
|
-
|
|
1392
|
+
}
|
|
1393
|
+
remove(name, callback, context) {
|
|
1506
1394
|
if (!name && !callback && !context) {
|
|
1507
1395
|
this._callbacks = {};
|
|
1508
1396
|
return;
|
|
@@ -1514,8 +1402,8 @@ var callback_registry_CallbackRegistry = (function () {
|
|
|
1514
1402
|
else {
|
|
1515
1403
|
this.removeAllCallbacks(names);
|
|
1516
1404
|
}
|
|
1517
|
-
}
|
|
1518
|
-
|
|
1405
|
+
}
|
|
1406
|
+
removeCallback(names, callback, context) {
|
|
1519
1407
|
apply(names, function (name) {
|
|
1520
1408
|
this._callbacks[name] = filter(this._callbacks[name] || [], function (binding) {
|
|
1521
1409
|
return ((callback && callback !== binding.fn) ||
|
|
@@ -1525,15 +1413,13 @@ var callback_registry_CallbackRegistry = (function () {
|
|
|
1525
1413
|
delete this._callbacks[name];
|
|
1526
1414
|
}
|
|
1527
1415
|
}, this);
|
|
1528
|
-
}
|
|
1529
|
-
|
|
1416
|
+
}
|
|
1417
|
+
removeAllCallbacks(names) {
|
|
1530
1418
|
apply(names, function (name) {
|
|
1531
1419
|
delete this._callbacks[name];
|
|
1532
1420
|
}, this);
|
|
1533
|
-
}
|
|
1534
|
-
|
|
1535
|
-
}());
|
|
1536
|
-
/* harmony default export */ var callback_registry = (callback_registry_CallbackRegistry);
|
|
1421
|
+
}
|
|
1422
|
+
}
|
|
1537
1423
|
function prefix(name) {
|
|
1538
1424
|
return '_' + name;
|
|
1539
1425
|
}
|
|
@@ -1541,38 +1427,38 @@ function prefix(name) {
|
|
|
1541
1427
|
// CONCATENATED MODULE: ./src/core/events/dispatcher.ts
|
|
1542
1428
|
|
|
1543
1429
|
|
|
1544
|
-
|
|
1545
|
-
|
|
1546
|
-
this.callbacks = new
|
|
1430
|
+
class dispatcher_Dispatcher {
|
|
1431
|
+
constructor(failThrough) {
|
|
1432
|
+
this.callbacks = new callback_registry_CallbackRegistry();
|
|
1547
1433
|
this.global_callbacks = [];
|
|
1548
1434
|
this.failThrough = failThrough;
|
|
1549
1435
|
}
|
|
1550
|
-
|
|
1436
|
+
bind(eventName, callback, context) {
|
|
1551
1437
|
this.callbacks.add(eventName, callback, context);
|
|
1552
1438
|
return this;
|
|
1553
|
-
}
|
|
1554
|
-
|
|
1439
|
+
}
|
|
1440
|
+
bind_global(callback) {
|
|
1555
1441
|
this.global_callbacks.push(callback);
|
|
1556
1442
|
return this;
|
|
1557
|
-
}
|
|
1558
|
-
|
|
1443
|
+
}
|
|
1444
|
+
unbind(eventName, callback, context) {
|
|
1559
1445
|
this.callbacks.remove(eventName, callback, context);
|
|
1560
1446
|
return this;
|
|
1561
|
-
}
|
|
1562
|
-
|
|
1447
|
+
}
|
|
1448
|
+
unbind_global(callback) {
|
|
1563
1449
|
if (!callback) {
|
|
1564
1450
|
this.global_callbacks = [];
|
|
1565
1451
|
return this;
|
|
1566
1452
|
}
|
|
1567
|
-
this.global_callbacks = filter(this.global_callbacks || [],
|
|
1453
|
+
this.global_callbacks = filter(this.global_callbacks || [], c => c !== callback);
|
|
1568
1454
|
return this;
|
|
1569
|
-
}
|
|
1570
|
-
|
|
1455
|
+
}
|
|
1456
|
+
unbind_all() {
|
|
1571
1457
|
this.unbind();
|
|
1572
1458
|
this.unbind_global();
|
|
1573
1459
|
return this;
|
|
1574
|
-
}
|
|
1575
|
-
|
|
1460
|
+
}
|
|
1461
|
+
emit(eventName, data, metadata) {
|
|
1576
1462
|
for (var i = 0; i < this.global_callbacks.length; i++) {
|
|
1577
1463
|
this.global_callbacks[i](eventName, data);
|
|
1578
1464
|
}
|
|
@@ -1593,54 +1479,36 @@ var dispatcher_Dispatcher = (function () {
|
|
|
1593
1479
|
this.failThrough(eventName, data);
|
|
1594
1480
|
}
|
|
1595
1481
|
return this;
|
|
1596
|
-
}
|
|
1597
|
-
|
|
1598
|
-
}());
|
|
1599
|
-
/* harmony default export */ var dispatcher = (dispatcher_Dispatcher);
|
|
1482
|
+
}
|
|
1483
|
+
}
|
|
1600
1484
|
|
|
1601
1485
|
// CONCATENATED MODULE: ./src/core/transports/transport_connection.ts
|
|
1602
|
-
var transport_connection_extends = (undefined && undefined.__extends) || (function () {
|
|
1603
|
-
var extendStatics = function (d, b) {
|
|
1604
|
-
extendStatics = Object.setPrototypeOf ||
|
|
1605
|
-
({ __proto__: [] } instanceof Array && function (d, b) { d.__proto__ = b; }) ||
|
|
1606
|
-
function (d, b) { for (var p in b) if (b.hasOwnProperty(p)) d[p] = b[p]; };
|
|
1607
|
-
return extendStatics(d, b);
|
|
1608
|
-
};
|
|
1609
|
-
return function (d, b) {
|
|
1610
|
-
extendStatics(d, b);
|
|
1611
|
-
function __() { this.constructor = d; }
|
|
1612
|
-
d.prototype = b === null ? Object.create(b) : (__.prototype = b.prototype, new __());
|
|
1613
|
-
};
|
|
1614
|
-
})();
|
|
1615
1486
|
|
|
1616
1487
|
|
|
1617
1488
|
|
|
1618
1489
|
|
|
1619
1490
|
|
|
1620
|
-
|
|
1621
|
-
|
|
1622
|
-
|
|
1623
|
-
|
|
1624
|
-
|
|
1625
|
-
|
|
1626
|
-
|
|
1627
|
-
|
|
1628
|
-
|
|
1629
|
-
|
|
1630
|
-
|
|
1631
|
-
|
|
1632
|
-
|
|
1633
|
-
_this.id = _this.timeline.generateUniqueID();
|
|
1634
|
-
return _this;
|
|
1491
|
+
class transport_connection_TransportConnection extends dispatcher_Dispatcher {
|
|
1492
|
+
constructor(hooks, name, priority, key, options) {
|
|
1493
|
+
super();
|
|
1494
|
+
this.initialize = runtime.transportConnectionInitializer;
|
|
1495
|
+
this.hooks = hooks;
|
|
1496
|
+
this.name = name;
|
|
1497
|
+
this.priority = priority;
|
|
1498
|
+
this.key = key;
|
|
1499
|
+
this.options = options;
|
|
1500
|
+
this.state = 'new';
|
|
1501
|
+
this.timeline = options.timeline;
|
|
1502
|
+
this.activityTimeout = options.activityTimeout;
|
|
1503
|
+
this.id = this.timeline.generateUniqueID();
|
|
1635
1504
|
}
|
|
1636
|
-
|
|
1505
|
+
handlesActivityChecks() {
|
|
1637
1506
|
return Boolean(this.hooks.handlesActivityChecks);
|
|
1638
|
-
}
|
|
1639
|
-
|
|
1507
|
+
}
|
|
1508
|
+
supportsPing() {
|
|
1640
1509
|
return Boolean(this.hooks.supportsPing);
|
|
1641
|
-
}
|
|
1642
|
-
|
|
1643
|
-
var _this = this;
|
|
1510
|
+
}
|
|
1511
|
+
connect() {
|
|
1644
1512
|
if (this.socket || this.state !== 'initialized') {
|
|
1645
1513
|
return false;
|
|
1646
1514
|
}
|
|
@@ -1649,18 +1517,18 @@ var transport_connection_TransportConnection = (function (_super) {
|
|
|
1649
1517
|
this.socket = this.hooks.getSocket(url, this.options);
|
|
1650
1518
|
}
|
|
1651
1519
|
catch (e) {
|
|
1652
|
-
util.defer(
|
|
1653
|
-
|
|
1654
|
-
|
|
1520
|
+
util.defer(() => {
|
|
1521
|
+
this.onError(e);
|
|
1522
|
+
this.changeState('closed');
|
|
1655
1523
|
});
|
|
1656
1524
|
return false;
|
|
1657
1525
|
}
|
|
1658
1526
|
this.bindListeners();
|
|
1659
|
-
logger.debug('Connecting', { transport: this.name, url
|
|
1527
|
+
logger.debug('Connecting', { transport: this.name, url });
|
|
1660
1528
|
this.changeState('connecting');
|
|
1661
1529
|
return true;
|
|
1662
|
-
}
|
|
1663
|
-
|
|
1530
|
+
}
|
|
1531
|
+
close() {
|
|
1664
1532
|
if (this.socket) {
|
|
1665
1533
|
this.socket.close();
|
|
1666
1534
|
return true;
|
|
@@ -1668,13 +1536,12 @@ var transport_connection_TransportConnection = (function (_super) {
|
|
|
1668
1536
|
else {
|
|
1669
1537
|
return false;
|
|
1670
1538
|
}
|
|
1671
|
-
}
|
|
1672
|
-
|
|
1673
|
-
var _this = this;
|
|
1539
|
+
}
|
|
1540
|
+
send(data) {
|
|
1674
1541
|
if (this.state === 'open') {
|
|
1675
|
-
util.defer(
|
|
1676
|
-
if (
|
|
1677
|
-
|
|
1542
|
+
util.defer(() => {
|
|
1543
|
+
if (this.socket) {
|
|
1544
|
+
this.socket.send(data);
|
|
1678
1545
|
}
|
|
1679
1546
|
});
|
|
1680
1547
|
return true;
|
|
@@ -1682,24 +1549,24 @@ var transport_connection_TransportConnection = (function (_super) {
|
|
|
1682
1549
|
else {
|
|
1683
1550
|
return false;
|
|
1684
1551
|
}
|
|
1685
|
-
}
|
|
1686
|
-
|
|
1552
|
+
}
|
|
1553
|
+
ping() {
|
|
1687
1554
|
if (this.state === 'open' && this.supportsPing()) {
|
|
1688
1555
|
this.socket.ping();
|
|
1689
1556
|
}
|
|
1690
|
-
}
|
|
1691
|
-
|
|
1557
|
+
}
|
|
1558
|
+
onOpen() {
|
|
1692
1559
|
if (this.hooks.beforeOpen) {
|
|
1693
1560
|
this.hooks.beforeOpen(this.socket, this.hooks.urls.getPath(this.key, this.options));
|
|
1694
1561
|
}
|
|
1695
1562
|
this.changeState('open');
|
|
1696
1563
|
this.socket.onopen = undefined;
|
|
1697
|
-
}
|
|
1698
|
-
|
|
1564
|
+
}
|
|
1565
|
+
onError(error) {
|
|
1699
1566
|
this.emit('error', { type: 'WebSocketError', error: error });
|
|
1700
1567
|
this.timeline.error(this.buildTimelineMessage({ error: error.toString() }));
|
|
1701
|
-
}
|
|
1702
|
-
|
|
1568
|
+
}
|
|
1569
|
+
onClose(closeEvent) {
|
|
1703
1570
|
if (closeEvent) {
|
|
1704
1571
|
this.changeState('closed', {
|
|
1705
1572
|
code: closeEvent.code,
|
|
@@ -1712,34 +1579,33 @@ var transport_connection_TransportConnection = (function (_super) {
|
|
|
1712
1579
|
}
|
|
1713
1580
|
this.unbindListeners();
|
|
1714
1581
|
this.socket = undefined;
|
|
1715
|
-
}
|
|
1716
|
-
|
|
1582
|
+
}
|
|
1583
|
+
onMessage(message) {
|
|
1717
1584
|
this.emit('message', message);
|
|
1718
|
-
}
|
|
1719
|
-
|
|
1585
|
+
}
|
|
1586
|
+
onActivity() {
|
|
1720
1587
|
this.emit('activity');
|
|
1721
|
-
}
|
|
1722
|
-
|
|
1723
|
-
|
|
1724
|
-
|
|
1725
|
-
_this.onOpen();
|
|
1588
|
+
}
|
|
1589
|
+
bindListeners() {
|
|
1590
|
+
this.socket.onopen = () => {
|
|
1591
|
+
this.onOpen();
|
|
1726
1592
|
};
|
|
1727
|
-
this.socket.onerror =
|
|
1728
|
-
|
|
1593
|
+
this.socket.onerror = error => {
|
|
1594
|
+
this.onError(error);
|
|
1729
1595
|
};
|
|
1730
|
-
this.socket.onclose =
|
|
1731
|
-
|
|
1596
|
+
this.socket.onclose = closeEvent => {
|
|
1597
|
+
this.onClose(closeEvent);
|
|
1732
1598
|
};
|
|
1733
|
-
this.socket.onmessage =
|
|
1734
|
-
|
|
1599
|
+
this.socket.onmessage = message => {
|
|
1600
|
+
this.onMessage(message);
|
|
1735
1601
|
};
|
|
1736
1602
|
if (this.supportsPing()) {
|
|
1737
|
-
this.socket.onactivity =
|
|
1738
|
-
|
|
1603
|
+
this.socket.onactivity = () => {
|
|
1604
|
+
this.onActivity();
|
|
1739
1605
|
};
|
|
1740
1606
|
}
|
|
1741
|
-
}
|
|
1742
|
-
|
|
1607
|
+
}
|
|
1608
|
+
unbindListeners() {
|
|
1743
1609
|
if (this.socket) {
|
|
1744
1610
|
this.socket.onopen = undefined;
|
|
1745
1611
|
this.socket.onerror = undefined;
|
|
@@ -1749,44 +1615,40 @@ var transport_connection_TransportConnection = (function (_super) {
|
|
|
1749
1615
|
this.socket.onactivity = undefined;
|
|
1750
1616
|
}
|
|
1751
1617
|
}
|
|
1752
|
-
}
|
|
1753
|
-
|
|
1618
|
+
}
|
|
1619
|
+
changeState(state, params) {
|
|
1754
1620
|
this.state = state;
|
|
1755
1621
|
this.timeline.info(this.buildTimelineMessage({
|
|
1756
1622
|
state: state,
|
|
1757
1623
|
params: params
|
|
1758
1624
|
}));
|
|
1759
1625
|
this.emit(state, params);
|
|
1760
|
-
}
|
|
1761
|
-
|
|
1626
|
+
}
|
|
1627
|
+
buildTimelineMessage(message) {
|
|
1762
1628
|
return extend({ cid: this.id }, message);
|
|
1763
|
-
}
|
|
1764
|
-
|
|
1765
|
-
}(dispatcher));
|
|
1766
|
-
/* harmony default export */ var transport_connection = (transport_connection_TransportConnection);
|
|
1629
|
+
}
|
|
1630
|
+
}
|
|
1767
1631
|
|
|
1768
1632
|
// CONCATENATED MODULE: ./src/core/transports/transport.ts
|
|
1769
1633
|
|
|
1770
|
-
|
|
1771
|
-
|
|
1634
|
+
class transport_Transport {
|
|
1635
|
+
constructor(hooks) {
|
|
1772
1636
|
this.hooks = hooks;
|
|
1773
1637
|
}
|
|
1774
|
-
|
|
1638
|
+
isSupported(environment) {
|
|
1775
1639
|
return this.hooks.isSupported(environment);
|
|
1776
|
-
}
|
|
1777
|
-
|
|
1778
|
-
return new
|
|
1779
|
-
}
|
|
1780
|
-
|
|
1781
|
-
}());
|
|
1782
|
-
/* harmony default export */ var transports_transport = (transport_Transport);
|
|
1640
|
+
}
|
|
1641
|
+
createConnection(name, priority, key, options) {
|
|
1642
|
+
return new transport_connection_TransportConnection(this.hooks, name, priority, key, options);
|
|
1643
|
+
}
|
|
1644
|
+
}
|
|
1783
1645
|
|
|
1784
1646
|
// CONCATENATED MODULE: ./src/runtimes/isomorphic/transports/transports.ts
|
|
1785
1647
|
|
|
1786
1648
|
|
|
1787
1649
|
|
|
1788
1650
|
|
|
1789
|
-
var WSTransport = new
|
|
1651
|
+
var WSTransport = new transport_Transport({
|
|
1790
1652
|
urls: ws,
|
|
1791
1653
|
handlesActivityChecks: false,
|
|
1792
1654
|
supportsPing: false,
|
|
@@ -1823,8 +1685,8 @@ var xhrConfiguration = {
|
|
|
1823
1685
|
return runtime.isXHRSupported();
|
|
1824
1686
|
}
|
|
1825
1687
|
};
|
|
1826
|
-
var XHRStreamingTransport = new
|
|
1827
|
-
var XHRPollingTransport = new
|
|
1688
|
+
var XHRStreamingTransport = new transport_Transport((extend({}, streamingConfiguration, xhrConfiguration)));
|
|
1689
|
+
var XHRPollingTransport = new transport_Transport(extend({}, pollingConfiguration, xhrConfiguration));
|
|
1828
1690
|
var Transports = {
|
|
1829
1691
|
ws: WSTransport,
|
|
1830
1692
|
xhr_streaming: XHRStreamingTransport,
|
|
@@ -1839,7 +1701,7 @@ var Transports = {
|
|
|
1839
1701
|
|
|
1840
1702
|
|
|
1841
1703
|
|
|
1842
|
-
var SockJSTransport = new
|
|
1704
|
+
var SockJSTransport = new transport_Transport({
|
|
1843
1705
|
file: 'sockjs',
|
|
1844
1706
|
urls: sockjs,
|
|
1845
1707
|
handlesActivityChecks: true,
|
|
@@ -1870,33 +1732,19 @@ var xdrConfiguration = {
|
|
|
1870
1732
|
return yes;
|
|
1871
1733
|
}
|
|
1872
1734
|
};
|
|
1873
|
-
var XDRStreamingTransport = new
|
|
1874
|
-
var XDRPollingTransport = new
|
|
1735
|
+
var XDRStreamingTransport = new transport_Transport((extend({}, streamingConfiguration, xdrConfiguration)));
|
|
1736
|
+
var XDRPollingTransport = new transport_Transport(extend({}, pollingConfiguration, xdrConfiguration));
|
|
1875
1737
|
transports.xdr_streaming = XDRStreamingTransport;
|
|
1876
1738
|
transports.xdr_polling = XDRPollingTransport;
|
|
1877
1739
|
transports.sockjs = SockJSTransport;
|
|
1878
1740
|
/* harmony default export */ var transports_transports = (transports);
|
|
1879
1741
|
|
|
1880
1742
|
// CONCATENATED MODULE: ./src/runtimes/web/net_info.ts
|
|
1881
|
-
var net_info_extends = (undefined && undefined.__extends) || (function () {
|
|
1882
|
-
var extendStatics = function (d, b) {
|
|
1883
|
-
extendStatics = Object.setPrototypeOf ||
|
|
1884
|
-
({ __proto__: [] } instanceof Array && function (d, b) { d.__proto__ = b; }) ||
|
|
1885
|
-
function (d, b) { for (var p in b) if (b.hasOwnProperty(p)) d[p] = b[p]; };
|
|
1886
|
-
return extendStatics(d, b);
|
|
1887
|
-
};
|
|
1888
|
-
return function (d, b) {
|
|
1889
|
-
extendStatics(d, b);
|
|
1890
|
-
function __() { this.constructor = d; }
|
|
1891
|
-
d.prototype = b === null ? Object.create(b) : (__.prototype = b.prototype, new __());
|
|
1892
|
-
};
|
|
1893
|
-
})();
|
|
1894
1743
|
|
|
1895
|
-
|
|
1896
|
-
|
|
1897
|
-
|
|
1898
|
-
var
|
|
1899
|
-
var self = _this;
|
|
1744
|
+
class net_info_NetInfo extends dispatcher_Dispatcher {
|
|
1745
|
+
constructor() {
|
|
1746
|
+
super();
|
|
1747
|
+
var self = this;
|
|
1900
1748
|
if (window.addEventListener !== undefined) {
|
|
1901
1749
|
window.addEventListener('online', function () {
|
|
1902
1750
|
self.emit('online');
|
|
@@ -1905,34 +1753,30 @@ var NetInfo = (function (_super) {
|
|
|
1905
1753
|
self.emit('offline');
|
|
1906
1754
|
}, false);
|
|
1907
1755
|
}
|
|
1908
|
-
return _this;
|
|
1909
1756
|
}
|
|
1910
|
-
|
|
1757
|
+
isOnline() {
|
|
1911
1758
|
if (window.navigator.onLine === undefined) {
|
|
1912
1759
|
return true;
|
|
1913
1760
|
}
|
|
1914
1761
|
else {
|
|
1915
1762
|
return window.navigator.onLine;
|
|
1916
1763
|
}
|
|
1917
|
-
}
|
|
1918
|
-
|
|
1919
|
-
|
|
1920
|
-
|
|
1921
|
-
var net_info_Network = new NetInfo();
|
|
1764
|
+
}
|
|
1765
|
+
}
|
|
1766
|
+
var net_info_Network = new net_info_NetInfo();
|
|
1922
1767
|
|
|
1923
1768
|
// CONCATENATED MODULE: ./src/core/transports/assistant_to_the_transport_manager.ts
|
|
1924
1769
|
|
|
1925
1770
|
|
|
1926
|
-
|
|
1927
|
-
|
|
1771
|
+
class assistant_to_the_transport_manager_AssistantToTheTransportManager {
|
|
1772
|
+
constructor(manager, transport, options) {
|
|
1928
1773
|
this.manager = manager;
|
|
1929
1774
|
this.transport = transport;
|
|
1930
1775
|
this.minPingDelay = options.minPingDelay;
|
|
1931
1776
|
this.maxPingDelay = options.maxPingDelay;
|
|
1932
1777
|
this.pingDelay = undefined;
|
|
1933
1778
|
}
|
|
1934
|
-
|
|
1935
|
-
var _this = this;
|
|
1779
|
+
createConnection(name, priority, key, options) {
|
|
1936
1780
|
options = extend({}, options, {
|
|
1937
1781
|
activityTimeout: this.pingDelay
|
|
1938
1782
|
});
|
|
@@ -1943,31 +1787,29 @@ var assistant_to_the_transport_manager_AssistantToTheTransportManager = (functio
|
|
|
1943
1787
|
connection.bind('closed', onClosed);
|
|
1944
1788
|
openTimestamp = util.now();
|
|
1945
1789
|
};
|
|
1946
|
-
var onClosed =
|
|
1790
|
+
var onClosed = closeEvent => {
|
|
1947
1791
|
connection.unbind('closed', onClosed);
|
|
1948
1792
|
if (closeEvent.code === 1002 || closeEvent.code === 1003) {
|
|
1949
|
-
|
|
1793
|
+
this.manager.reportDeath();
|
|
1950
1794
|
}
|
|
1951
1795
|
else if (!closeEvent.wasClean && openTimestamp) {
|
|
1952
1796
|
var lifespan = util.now() - openTimestamp;
|
|
1953
|
-
if (lifespan < 2 *
|
|
1954
|
-
|
|
1955
|
-
|
|
1797
|
+
if (lifespan < 2 * this.maxPingDelay) {
|
|
1798
|
+
this.manager.reportDeath();
|
|
1799
|
+
this.pingDelay = Math.max(lifespan / 2, this.minPingDelay);
|
|
1956
1800
|
}
|
|
1957
1801
|
}
|
|
1958
1802
|
};
|
|
1959
1803
|
connection.bind('open', onOpen);
|
|
1960
1804
|
return connection;
|
|
1961
|
-
}
|
|
1962
|
-
|
|
1805
|
+
}
|
|
1806
|
+
isSupported(environment) {
|
|
1963
1807
|
return this.manager.isAlive() && this.transport.isSupported(environment);
|
|
1964
|
-
}
|
|
1965
|
-
|
|
1966
|
-
}());
|
|
1967
|
-
/* harmony default export */ var assistant_to_the_transport_manager = (assistant_to_the_transport_manager_AssistantToTheTransportManager);
|
|
1808
|
+
}
|
|
1809
|
+
}
|
|
1968
1810
|
|
|
1969
1811
|
// CONCATENATED MODULE: ./src/core/connection/protocol/protocol.ts
|
|
1970
|
-
|
|
1812
|
+
const Protocol = {
|
|
1971
1813
|
decodeMessage: function (messageEvent) {
|
|
1972
1814
|
try {
|
|
1973
1815
|
var messageData = JSON.parse(messageEvent.data);
|
|
@@ -2060,68 +1902,52 @@ var Protocol = {
|
|
|
2060
1902
|
/* harmony default export */ var protocol_protocol = (Protocol);
|
|
2061
1903
|
|
|
2062
1904
|
// CONCATENATED MODULE: ./src/core/connection/connection.ts
|
|
2063
|
-
var connection_extends = (undefined && undefined.__extends) || (function () {
|
|
2064
|
-
var extendStatics = function (d, b) {
|
|
2065
|
-
extendStatics = Object.setPrototypeOf ||
|
|
2066
|
-
({ __proto__: [] } instanceof Array && function (d, b) { d.__proto__ = b; }) ||
|
|
2067
|
-
function (d, b) { for (var p in b) if (b.hasOwnProperty(p)) d[p] = b[p]; };
|
|
2068
|
-
return extendStatics(d, b);
|
|
2069
|
-
};
|
|
2070
|
-
return function (d, b) {
|
|
2071
|
-
extendStatics(d, b);
|
|
2072
|
-
function __() { this.constructor = d; }
|
|
2073
|
-
d.prototype = b === null ? Object.create(b) : (__.prototype = b.prototype, new __());
|
|
2074
|
-
};
|
|
2075
|
-
})();
|
|
2076
1905
|
|
|
2077
1906
|
|
|
2078
1907
|
|
|
2079
1908
|
|
|
2080
|
-
|
|
2081
|
-
|
|
2082
|
-
|
|
2083
|
-
|
|
2084
|
-
|
|
2085
|
-
|
|
2086
|
-
|
|
2087
|
-
_this.bindListeners();
|
|
2088
|
-
return _this;
|
|
1909
|
+
class connection_Connection extends dispatcher_Dispatcher {
|
|
1910
|
+
constructor(id, transport) {
|
|
1911
|
+
super();
|
|
1912
|
+
this.id = id;
|
|
1913
|
+
this.transport = transport;
|
|
1914
|
+
this.activityTimeout = transport.activityTimeout;
|
|
1915
|
+
this.bindListeners();
|
|
2089
1916
|
}
|
|
2090
|
-
|
|
1917
|
+
handlesActivityChecks() {
|
|
2091
1918
|
return this.transport.handlesActivityChecks();
|
|
2092
|
-
}
|
|
2093
|
-
|
|
1919
|
+
}
|
|
1920
|
+
send(data) {
|
|
2094
1921
|
return this.transport.send(data);
|
|
2095
|
-
}
|
|
2096
|
-
|
|
1922
|
+
}
|
|
1923
|
+
send_event(name, data, channel) {
|
|
2097
1924
|
var event = { event: name, data: data };
|
|
2098
1925
|
if (channel) {
|
|
2099
1926
|
event.channel = channel;
|
|
2100
1927
|
}
|
|
2101
1928
|
logger.debug('Event sent', event);
|
|
2102
1929
|
return this.send(protocol_protocol.encodeMessage(event));
|
|
2103
|
-
}
|
|
2104
|
-
|
|
1930
|
+
}
|
|
1931
|
+
ping() {
|
|
2105
1932
|
if (this.transport.supportsPing()) {
|
|
2106
1933
|
this.transport.ping();
|
|
2107
1934
|
}
|
|
2108
1935
|
else {
|
|
2109
1936
|
this.send_event('pusher:ping', {});
|
|
2110
1937
|
}
|
|
2111
|
-
}
|
|
2112
|
-
|
|
1938
|
+
}
|
|
1939
|
+
close() {
|
|
2113
1940
|
this.transport.close();
|
|
2114
|
-
}
|
|
2115
|
-
|
|
2116
|
-
var _this = this;
|
|
1941
|
+
}
|
|
1942
|
+
bindListeners() {
|
|
2117
1943
|
var listeners = {
|
|
2118
|
-
message:
|
|
1944
|
+
message: (messageEvent) => {
|
|
2119
1945
|
var pusherEvent;
|
|
2120
1946
|
try {
|
|
2121
1947
|
pusherEvent = protocol_protocol.decodeMessage(messageEvent);
|
|
2122
1948
|
}
|
|
2123
1949
|
catch (e) {
|
|
2124
|
-
|
|
1950
|
+
this.emit('error', {
|
|
2125
1951
|
type: 'MessageParseError',
|
|
2126
1952
|
error: e,
|
|
2127
1953
|
data: messageEvent.data
|
|
@@ -2131,46 +1957,46 @@ var connection_Connection = (function (_super) {
|
|
|
2131
1957
|
logger.debug('Event recd', pusherEvent);
|
|
2132
1958
|
switch (pusherEvent.event) {
|
|
2133
1959
|
case 'pusher:error':
|
|
2134
|
-
|
|
1960
|
+
this.emit('error', {
|
|
2135
1961
|
type: 'PusherError',
|
|
2136
1962
|
data: pusherEvent.data
|
|
2137
1963
|
});
|
|
2138
1964
|
break;
|
|
2139
1965
|
case 'pusher:ping':
|
|
2140
|
-
|
|
1966
|
+
this.emit('ping');
|
|
2141
1967
|
break;
|
|
2142
1968
|
case 'pusher:pong':
|
|
2143
|
-
|
|
1969
|
+
this.emit('pong');
|
|
2144
1970
|
break;
|
|
2145
1971
|
}
|
|
2146
|
-
|
|
1972
|
+
this.emit('message', pusherEvent);
|
|
2147
1973
|
}
|
|
2148
1974
|
},
|
|
2149
|
-
activity:
|
|
2150
|
-
|
|
1975
|
+
activity: () => {
|
|
1976
|
+
this.emit('activity');
|
|
2151
1977
|
},
|
|
2152
|
-
error:
|
|
2153
|
-
|
|
1978
|
+
error: error => {
|
|
1979
|
+
this.emit('error', error);
|
|
2154
1980
|
},
|
|
2155
|
-
closed:
|
|
1981
|
+
closed: closeEvent => {
|
|
2156
1982
|
unbindListeners();
|
|
2157
1983
|
if (closeEvent && closeEvent.code) {
|
|
2158
|
-
|
|
1984
|
+
this.handleCloseEvent(closeEvent);
|
|
2159
1985
|
}
|
|
2160
|
-
|
|
2161
|
-
|
|
1986
|
+
this.transport = null;
|
|
1987
|
+
this.emit('closed');
|
|
2162
1988
|
}
|
|
2163
1989
|
};
|
|
2164
|
-
var unbindListeners =
|
|
2165
|
-
objectApply(listeners,
|
|
2166
|
-
|
|
1990
|
+
var unbindListeners = () => {
|
|
1991
|
+
objectApply(listeners, (listener, event) => {
|
|
1992
|
+
this.transport.unbind(event, listener);
|
|
2167
1993
|
});
|
|
2168
1994
|
};
|
|
2169
|
-
objectApply(listeners,
|
|
2170
|
-
|
|
1995
|
+
objectApply(listeners, (listener, event) => {
|
|
1996
|
+
this.transport.bind(event, listener);
|
|
2171
1997
|
});
|
|
2172
|
-
}
|
|
2173
|
-
|
|
1998
|
+
}
|
|
1999
|
+
handleCloseEvent(closeEvent) {
|
|
2174
2000
|
var action = protocol_protocol.getCloseAction(closeEvent);
|
|
2175
2001
|
var error = protocol_protocol.getCloseError(closeEvent);
|
|
2176
2002
|
if (error) {
|
|
@@ -2179,136 +2005,114 @@ var connection_Connection = (function (_super) {
|
|
|
2179
2005
|
if (action) {
|
|
2180
2006
|
this.emit(action, { action: action, error: error });
|
|
2181
2007
|
}
|
|
2182
|
-
}
|
|
2183
|
-
|
|
2184
|
-
}(dispatcher));
|
|
2185
|
-
/* harmony default export */ var connection_connection = (connection_Connection);
|
|
2008
|
+
}
|
|
2009
|
+
}
|
|
2186
2010
|
|
|
2187
2011
|
// CONCATENATED MODULE: ./src/core/connection/handshake/index.ts
|
|
2188
2012
|
|
|
2189
2013
|
|
|
2190
2014
|
|
|
2191
|
-
|
|
2192
|
-
|
|
2015
|
+
class handshake_Handshake {
|
|
2016
|
+
constructor(transport, callback) {
|
|
2193
2017
|
this.transport = transport;
|
|
2194
2018
|
this.callback = callback;
|
|
2195
2019
|
this.bindListeners();
|
|
2196
2020
|
}
|
|
2197
|
-
|
|
2021
|
+
close() {
|
|
2198
2022
|
this.unbindListeners();
|
|
2199
2023
|
this.transport.close();
|
|
2200
|
-
}
|
|
2201
|
-
|
|
2202
|
-
|
|
2203
|
-
|
|
2204
|
-
_this.unbindListeners();
|
|
2024
|
+
}
|
|
2025
|
+
bindListeners() {
|
|
2026
|
+
this.onMessage = m => {
|
|
2027
|
+
this.unbindListeners();
|
|
2205
2028
|
var result;
|
|
2206
2029
|
try {
|
|
2207
2030
|
result = protocol_protocol.processHandshake(m);
|
|
2208
2031
|
}
|
|
2209
2032
|
catch (e) {
|
|
2210
|
-
|
|
2211
|
-
|
|
2033
|
+
this.finish('error', { error: e });
|
|
2034
|
+
this.transport.close();
|
|
2212
2035
|
return;
|
|
2213
2036
|
}
|
|
2214
2037
|
if (result.action === 'connected') {
|
|
2215
|
-
|
|
2216
|
-
connection: new
|
|
2038
|
+
this.finish('connected', {
|
|
2039
|
+
connection: new connection_Connection(result.id, this.transport),
|
|
2217
2040
|
activityTimeout: result.activityTimeout
|
|
2218
2041
|
});
|
|
2219
2042
|
}
|
|
2220
2043
|
else {
|
|
2221
|
-
|
|
2222
|
-
|
|
2044
|
+
this.finish(result.action, { error: result.error });
|
|
2045
|
+
this.transport.close();
|
|
2223
2046
|
}
|
|
2224
2047
|
};
|
|
2225
|
-
this.onClosed =
|
|
2226
|
-
|
|
2048
|
+
this.onClosed = closeEvent => {
|
|
2049
|
+
this.unbindListeners();
|
|
2227
2050
|
var action = protocol_protocol.getCloseAction(closeEvent) || 'backoff';
|
|
2228
2051
|
var error = protocol_protocol.getCloseError(closeEvent);
|
|
2229
|
-
|
|
2052
|
+
this.finish(action, { error: error });
|
|
2230
2053
|
};
|
|
2231
2054
|
this.transport.bind('message', this.onMessage);
|
|
2232
2055
|
this.transport.bind('closed', this.onClosed);
|
|
2233
|
-
}
|
|
2234
|
-
|
|
2056
|
+
}
|
|
2057
|
+
unbindListeners() {
|
|
2235
2058
|
this.transport.unbind('message', this.onMessage);
|
|
2236
2059
|
this.transport.unbind('closed', this.onClosed);
|
|
2237
|
-
}
|
|
2238
|
-
|
|
2060
|
+
}
|
|
2061
|
+
finish(action, params) {
|
|
2239
2062
|
this.callback(extend({ transport: this.transport, action: action }, params));
|
|
2240
|
-
}
|
|
2241
|
-
|
|
2242
|
-
}());
|
|
2243
|
-
/* harmony default export */ var connection_handshake = (handshake_Handshake);
|
|
2063
|
+
}
|
|
2064
|
+
}
|
|
2244
2065
|
|
|
2245
2066
|
// CONCATENATED MODULE: ./src/core/timeline/timeline_sender.ts
|
|
2246
2067
|
|
|
2247
|
-
|
|
2248
|
-
|
|
2068
|
+
class timeline_sender_TimelineSender {
|
|
2069
|
+
constructor(timeline, options) {
|
|
2249
2070
|
this.timeline = timeline;
|
|
2250
2071
|
this.options = options || {};
|
|
2251
2072
|
}
|
|
2252
|
-
|
|
2073
|
+
send(useTLS, callback) {
|
|
2253
2074
|
if (this.timeline.isEmpty()) {
|
|
2254
2075
|
return;
|
|
2255
2076
|
}
|
|
2256
2077
|
this.timeline.send(runtime.TimelineTransport.getAgent(this, useTLS), callback);
|
|
2257
|
-
}
|
|
2258
|
-
|
|
2259
|
-
}());
|
|
2260
|
-
/* harmony default export */ var timeline_sender = (timeline_sender_TimelineSender);
|
|
2078
|
+
}
|
|
2079
|
+
}
|
|
2261
2080
|
|
|
2262
2081
|
// CONCATENATED MODULE: ./src/core/channels/channel.ts
|
|
2263
|
-
var channel_extends = (undefined && undefined.__extends) || (function () {
|
|
2264
|
-
var extendStatics = function (d, b) {
|
|
2265
|
-
extendStatics = Object.setPrototypeOf ||
|
|
2266
|
-
({ __proto__: [] } instanceof Array && function (d, b) { d.__proto__ = b; }) ||
|
|
2267
|
-
function (d, b) { for (var p in b) if (b.hasOwnProperty(p)) d[p] = b[p]; };
|
|
2268
|
-
return extendStatics(d, b);
|
|
2269
|
-
};
|
|
2270
|
-
return function (d, b) {
|
|
2271
|
-
extendStatics(d, b);
|
|
2272
|
-
function __() { this.constructor = d; }
|
|
2273
|
-
d.prototype = b === null ? Object.create(b) : (__.prototype = b.prototype, new __());
|
|
2274
|
-
};
|
|
2275
|
-
})();
|
|
2276
2082
|
|
|
2277
2083
|
|
|
2278
2084
|
|
|
2279
2085
|
|
|
2280
2086
|
|
|
2281
|
-
|
|
2282
|
-
|
|
2283
|
-
|
|
2284
|
-
var _this = _super.call(this, function (event, data) {
|
|
2087
|
+
class channel_Channel extends dispatcher_Dispatcher {
|
|
2088
|
+
constructor(name, pusher) {
|
|
2089
|
+
super(function (event, data) {
|
|
2285
2090
|
logger.debug('No callbacks on ' + name + ' for ' + event);
|
|
2286
|
-
})
|
|
2287
|
-
|
|
2288
|
-
|
|
2289
|
-
|
|
2290
|
-
|
|
2291
|
-
|
|
2292
|
-
|
|
2293
|
-
|
|
2294
|
-
Channel.prototype.authorize = function (socketId, callback) {
|
|
2091
|
+
});
|
|
2092
|
+
this.name = name;
|
|
2093
|
+
this.pusher = pusher;
|
|
2094
|
+
this.subscribed = false;
|
|
2095
|
+
this.subscriptionPending = false;
|
|
2096
|
+
this.subscriptionCancelled = false;
|
|
2097
|
+
}
|
|
2098
|
+
authorize(socketId, callback) {
|
|
2295
2099
|
return callback(null, { auth: '' });
|
|
2296
|
-
}
|
|
2297
|
-
|
|
2100
|
+
}
|
|
2101
|
+
trigger(event, data) {
|
|
2298
2102
|
if (event.indexOf('client-') !== 0) {
|
|
2299
2103
|
throw new BadEventName("Event '" + event + "' does not start with 'client-'");
|
|
2300
2104
|
}
|
|
2301
2105
|
if (!this.subscribed) {
|
|
2302
2106
|
var suffix = url_store.buildLogSuffix('triggeringClientEvents');
|
|
2303
|
-
logger.warn(
|
|
2107
|
+
logger.warn(`Client event triggered before channel 'subscription_succeeded' event . ${suffix}`);
|
|
2304
2108
|
}
|
|
2305
2109
|
return this.pusher.send_event(event, data, this.name);
|
|
2306
|
-
}
|
|
2307
|
-
|
|
2110
|
+
}
|
|
2111
|
+
disconnect() {
|
|
2308
2112
|
this.subscribed = false;
|
|
2309
2113
|
this.subscriptionPending = false;
|
|
2310
|
-
}
|
|
2311
|
-
|
|
2114
|
+
}
|
|
2115
|
+
handleEvent(event) {
|
|
2312
2116
|
var eventName = event.event;
|
|
2313
2117
|
var data = event.data;
|
|
2314
2118
|
if (eventName === 'pusher_internal:subscription_succeeded') {
|
|
@@ -2321,8 +2125,8 @@ var channel_Channel = (function (_super) {
|
|
|
2321
2125
|
var metadata = {};
|
|
2322
2126
|
this.emit(eventName, data, metadata);
|
|
2323
2127
|
}
|
|
2324
|
-
}
|
|
2325
|
-
|
|
2128
|
+
}
|
|
2129
|
+
handleSubscriptionSucceededEvent(event) {
|
|
2326
2130
|
this.subscriptionPending = false;
|
|
2327
2131
|
this.subscribed = true;
|
|
2328
2132
|
if (this.subscriptionCancelled) {
|
|
@@ -2331,91 +2135,69 @@ var channel_Channel = (function (_super) {
|
|
|
2331
2135
|
else {
|
|
2332
2136
|
this.emit('pusher:subscription_succeeded', event.data);
|
|
2333
2137
|
}
|
|
2334
|
-
}
|
|
2335
|
-
|
|
2138
|
+
}
|
|
2139
|
+
handleSubscriptionCountEvent(event) {
|
|
2336
2140
|
if (event.data.subscription_count) {
|
|
2337
2141
|
this.subscriptionCount = event.data.subscription_count;
|
|
2338
2142
|
}
|
|
2339
2143
|
this.emit('pusher:subscription_count', event.data);
|
|
2340
|
-
}
|
|
2341
|
-
|
|
2342
|
-
var _this = this;
|
|
2144
|
+
}
|
|
2145
|
+
subscribe() {
|
|
2343
2146
|
if (this.subscribed) {
|
|
2344
2147
|
return;
|
|
2345
2148
|
}
|
|
2346
2149
|
this.subscriptionPending = true;
|
|
2347
2150
|
this.subscriptionCancelled = false;
|
|
2348
|
-
this.authorize(this.pusher.connection.socket_id,
|
|
2151
|
+
this.authorize(this.pusher.connection.socket_id, (error, data) => {
|
|
2349
2152
|
if (error) {
|
|
2350
|
-
|
|
2153
|
+
this.subscriptionPending = false;
|
|
2351
2154
|
logger.error(error.toString());
|
|
2352
|
-
|
|
2155
|
+
this.emit('pusher:subscription_error', Object.assign({}, {
|
|
2353
2156
|
type: 'AuthError',
|
|
2354
2157
|
error: error.message
|
|
2355
2158
|
}, error instanceof HTTPAuthError ? { status: error.status } : {}));
|
|
2356
2159
|
}
|
|
2357
2160
|
else {
|
|
2358
|
-
|
|
2161
|
+
this.pusher.send_event('pusher:subscribe', {
|
|
2359
2162
|
auth: data.auth,
|
|
2360
2163
|
channel_data: data.channel_data,
|
|
2361
|
-
channel:
|
|
2164
|
+
channel: this.name
|
|
2362
2165
|
});
|
|
2363
2166
|
}
|
|
2364
2167
|
});
|
|
2365
|
-
}
|
|
2366
|
-
|
|
2168
|
+
}
|
|
2169
|
+
unsubscribe() {
|
|
2367
2170
|
this.subscribed = false;
|
|
2368
2171
|
this.pusher.send_event('pusher:unsubscribe', {
|
|
2369
2172
|
channel: this.name
|
|
2370
2173
|
});
|
|
2371
|
-
}
|
|
2372
|
-
|
|
2174
|
+
}
|
|
2175
|
+
cancelSubscription() {
|
|
2373
2176
|
this.subscriptionCancelled = true;
|
|
2374
|
-
}
|
|
2375
|
-
|
|
2177
|
+
}
|
|
2178
|
+
reinstateSubscription() {
|
|
2376
2179
|
this.subscriptionCancelled = false;
|
|
2377
|
-
}
|
|
2378
|
-
|
|
2379
|
-
}(dispatcher));
|
|
2380
|
-
/* harmony default export */ var channels_channel = (channel_Channel);
|
|
2180
|
+
}
|
|
2181
|
+
}
|
|
2381
2182
|
|
|
2382
2183
|
// CONCATENATED MODULE: ./src/core/channels/private_channel.ts
|
|
2383
|
-
var private_channel_extends = (undefined && undefined.__extends) || (function () {
|
|
2384
|
-
var extendStatics = function (d, b) {
|
|
2385
|
-
extendStatics = Object.setPrototypeOf ||
|
|
2386
|
-
({ __proto__: [] } instanceof Array && function (d, b) { d.__proto__ = b; }) ||
|
|
2387
|
-
function (d, b) { for (var p in b) if (b.hasOwnProperty(p)) d[p] = b[p]; };
|
|
2388
|
-
return extendStatics(d, b);
|
|
2389
|
-
};
|
|
2390
|
-
return function (d, b) {
|
|
2391
|
-
extendStatics(d, b);
|
|
2392
|
-
function __() { this.constructor = d; }
|
|
2393
|
-
d.prototype = b === null ? Object.create(b) : (__.prototype = b.prototype, new __());
|
|
2394
|
-
};
|
|
2395
|
-
})();
|
|
2396
2184
|
|
|
2397
|
-
|
|
2398
|
-
|
|
2399
|
-
function PrivateChannel() {
|
|
2400
|
-
return _super !== null && _super.apply(this, arguments) || this;
|
|
2401
|
-
}
|
|
2402
|
-
PrivateChannel.prototype.authorize = function (socketId, callback) {
|
|
2185
|
+
class private_channel_PrivateChannel extends channel_Channel {
|
|
2186
|
+
authorize(socketId, callback) {
|
|
2403
2187
|
return this.pusher.config.channelAuthorizer({
|
|
2404
2188
|
channelName: this.name,
|
|
2405
2189
|
socketId: socketId
|
|
2406
2190
|
}, callback);
|
|
2407
|
-
}
|
|
2408
|
-
|
|
2409
|
-
}(channels_channel));
|
|
2410
|
-
/* harmony default export */ var private_channel = (PrivateChannel);
|
|
2191
|
+
}
|
|
2192
|
+
}
|
|
2411
2193
|
|
|
2412
2194
|
// CONCATENATED MODULE: ./src/core/channels/members.ts
|
|
2413
2195
|
|
|
2414
|
-
|
|
2415
|
-
|
|
2196
|
+
class members_Members {
|
|
2197
|
+
constructor() {
|
|
2416
2198
|
this.reset();
|
|
2417
2199
|
}
|
|
2418
|
-
|
|
2200
|
+
get(id) {
|
|
2419
2201
|
if (Object.prototype.hasOwnProperty.call(this.members, id)) {
|
|
2420
2202
|
return {
|
|
2421
2203
|
id: id,
|
|
@@ -2425,60 +2207,44 @@ var members_Members = (function () {
|
|
|
2425
2207
|
else {
|
|
2426
2208
|
return null;
|
|
2427
2209
|
}
|
|
2428
|
-
}
|
|
2429
|
-
|
|
2430
|
-
|
|
2431
|
-
|
|
2432
|
-
callback(_this.get(id));
|
|
2210
|
+
}
|
|
2211
|
+
each(callback) {
|
|
2212
|
+
objectApply(this.members, (member, id) => {
|
|
2213
|
+
callback(this.get(id));
|
|
2433
2214
|
});
|
|
2434
|
-
}
|
|
2435
|
-
|
|
2215
|
+
}
|
|
2216
|
+
setMyID(id) {
|
|
2436
2217
|
this.myID = id;
|
|
2437
|
-
}
|
|
2438
|
-
|
|
2218
|
+
}
|
|
2219
|
+
onSubscription(subscriptionData) {
|
|
2439
2220
|
this.members = subscriptionData.presence.hash;
|
|
2440
2221
|
this.count = subscriptionData.presence.count;
|
|
2441
2222
|
this.me = this.get(this.myID);
|
|
2442
|
-
}
|
|
2443
|
-
|
|
2223
|
+
}
|
|
2224
|
+
addMember(memberData) {
|
|
2444
2225
|
if (this.get(memberData.user_id) === null) {
|
|
2445
2226
|
this.count++;
|
|
2446
2227
|
}
|
|
2447
2228
|
this.members[memberData.user_id] = memberData.user_info;
|
|
2448
2229
|
return this.get(memberData.user_id);
|
|
2449
|
-
}
|
|
2450
|
-
|
|
2230
|
+
}
|
|
2231
|
+
removeMember(memberData) {
|
|
2451
2232
|
var member = this.get(memberData.user_id);
|
|
2452
2233
|
if (member) {
|
|
2453
2234
|
delete this.members[memberData.user_id];
|
|
2454
2235
|
this.count--;
|
|
2455
2236
|
}
|
|
2456
2237
|
return member;
|
|
2457
|
-
}
|
|
2458
|
-
|
|
2238
|
+
}
|
|
2239
|
+
reset() {
|
|
2459
2240
|
this.members = {};
|
|
2460
2241
|
this.count = 0;
|
|
2461
2242
|
this.myID = null;
|
|
2462
2243
|
this.me = null;
|
|
2463
|
-
}
|
|
2464
|
-
|
|
2465
|
-
}());
|
|
2466
|
-
/* harmony default export */ var members = (members_Members);
|
|
2244
|
+
}
|
|
2245
|
+
}
|
|
2467
2246
|
|
|
2468
2247
|
// CONCATENATED MODULE: ./src/core/channels/presence_channel.ts
|
|
2469
|
-
var presence_channel_extends = (undefined && undefined.__extends) || (function () {
|
|
2470
|
-
var extendStatics = function (d, b) {
|
|
2471
|
-
extendStatics = Object.setPrototypeOf ||
|
|
2472
|
-
({ __proto__: [] } instanceof Array && function (d, b) { d.__proto__ = b; }) ||
|
|
2473
|
-
function (d, b) { for (var p in b) if (b.hasOwnProperty(p)) d[p] = b[p]; };
|
|
2474
|
-
return extendStatics(d, b);
|
|
2475
|
-
};
|
|
2476
|
-
return function (d, b) {
|
|
2477
|
-
extendStatics(d, b);
|
|
2478
|
-
function __() { this.constructor = d; }
|
|
2479
|
-
d.prototype = b === null ? Object.create(b) : (__.prototype = b.prototype, new __());
|
|
2480
|
-
};
|
|
2481
|
-
})();
|
|
2482
2248
|
var __awaiter = (undefined && undefined.__awaiter) || function (thisArg, _arguments, P, generator) {
|
|
2483
2249
|
function adopt(value) { return value instanceof P ? value : new P(function (resolve) { resolve(value); }); }
|
|
2484
2250
|
return new (P || (P = Promise))(function (resolve, reject) {
|
|
@@ -2488,80 +2254,42 @@ var __awaiter = (undefined && undefined.__awaiter) || function (thisArg, _argume
|
|
|
2488
2254
|
step((generator = generator.apply(thisArg, _arguments || [])).next());
|
|
2489
2255
|
});
|
|
2490
2256
|
};
|
|
2491
|
-
var __generator = (undefined && undefined.__generator) || function (thisArg, body) {
|
|
2492
|
-
var _ = { label: 0, sent: function() { if (t[0] & 1) throw t[1]; return t[1]; }, trys: [], ops: [] }, f, y, t, g;
|
|
2493
|
-
return g = { next: verb(0), "throw": verb(1), "return": verb(2) }, typeof Symbol === "function" && (g[Symbol.iterator] = function() { return this; }), g;
|
|
2494
|
-
function verb(n) { return function (v) { return step([n, v]); }; }
|
|
2495
|
-
function step(op) {
|
|
2496
|
-
if (f) throw new TypeError("Generator is already executing.");
|
|
2497
|
-
while (_) try {
|
|
2498
|
-
if (f = 1, y && (t = op[0] & 2 ? y["return"] : op[0] ? y["throw"] || ((t = y["return"]) && t.call(y), 0) : y.next) && !(t = t.call(y, op[1])).done) return t;
|
|
2499
|
-
if (y = 0, t) op = [op[0] & 2, t.value];
|
|
2500
|
-
switch (op[0]) {
|
|
2501
|
-
case 0: case 1: t = op; break;
|
|
2502
|
-
case 4: _.label++; return { value: op[1], done: false };
|
|
2503
|
-
case 5: _.label++; y = op[1]; op = [0]; continue;
|
|
2504
|
-
case 7: op = _.ops.pop(); _.trys.pop(); continue;
|
|
2505
|
-
default:
|
|
2506
|
-
if (!(t = _.trys, t = t.length > 0 && t[t.length - 1]) && (op[0] === 6 || op[0] === 2)) { _ = 0; continue; }
|
|
2507
|
-
if (op[0] === 3 && (!t || (op[1] > t[0] && op[1] < t[3]))) { _.label = op[1]; break; }
|
|
2508
|
-
if (op[0] === 6 && _.label < t[1]) { _.label = t[1]; t = op; break; }
|
|
2509
|
-
if (t && _.label < t[2]) { _.label = t[2]; _.ops.push(op); break; }
|
|
2510
|
-
if (t[2]) _.ops.pop();
|
|
2511
|
-
_.trys.pop(); continue;
|
|
2512
|
-
}
|
|
2513
|
-
op = body.call(thisArg, _);
|
|
2514
|
-
} catch (e) { op = [6, e]; y = 0; } finally { f = t = 0; }
|
|
2515
|
-
if (op[0] & 5) throw op[1]; return { value: op[0] ? op[1] : void 0, done: true };
|
|
2516
|
-
}
|
|
2517
|
-
};
|
|
2518
2257
|
|
|
2519
2258
|
|
|
2520
2259
|
|
|
2521
2260
|
|
|
2522
|
-
|
|
2523
|
-
|
|
2524
|
-
|
|
2525
|
-
|
|
2526
|
-
|
|
2527
|
-
|
|
2528
|
-
|
|
2529
|
-
|
|
2530
|
-
|
|
2531
|
-
|
|
2532
|
-
|
|
2533
|
-
|
|
2534
|
-
switch (_a.label) {
|
|
2535
|
-
case 0:
|
|
2536
|
-
if (!!error) return [3, 3];
|
|
2537
|
-
authData = authData;
|
|
2538
|
-
if (!(authData.channel_data != null)) return [3, 1];
|
|
2539
|
-
channelData = JSON.parse(authData.channel_data);
|
|
2540
|
-
this.members.setMyID(channelData.user_id);
|
|
2541
|
-
return [3, 3];
|
|
2542
|
-
case 1: return [4, this.pusher.user.signinDonePromise];
|
|
2543
|
-
case 2:
|
|
2544
|
-
_a.sent();
|
|
2545
|
-
if (this.pusher.user.user_data != null) {
|
|
2546
|
-
this.members.setMyID(this.pusher.user.user_data.id);
|
|
2547
|
-
}
|
|
2548
|
-
else {
|
|
2549
|
-
suffix = url_store.buildLogSuffix('authorizationEndpoint');
|
|
2550
|
-
logger.error("Invalid auth response for channel '" + this.name + "', " +
|
|
2551
|
-
("expected 'channel_data' field. " + suffix + ", ") +
|
|
2552
|
-
"or the user should be signed in.");
|
|
2553
|
-
callback('Invalid auth response');
|
|
2554
|
-
return [2];
|
|
2555
|
-
}
|
|
2556
|
-
_a.label = 3;
|
|
2557
|
-
case 3:
|
|
2558
|
-
callback(error, authData);
|
|
2559
|
-
return [2];
|
|
2261
|
+
class presence_channel_PresenceChannel extends private_channel_PrivateChannel {
|
|
2262
|
+
constructor(name, pusher) {
|
|
2263
|
+
super(name, pusher);
|
|
2264
|
+
this.members = new members_Members();
|
|
2265
|
+
}
|
|
2266
|
+
authorize(socketId, callback) {
|
|
2267
|
+
super.authorize(socketId, (error, authData) => __awaiter(this, void 0, void 0, function* () {
|
|
2268
|
+
if (!error) {
|
|
2269
|
+
authData = authData;
|
|
2270
|
+
if (authData.channel_data != null) {
|
|
2271
|
+
var channelData = JSON.parse(authData.channel_data);
|
|
2272
|
+
this.members.setMyID(channelData.user_id);
|
|
2560
2273
|
}
|
|
2561
|
-
|
|
2562
|
-
|
|
2563
|
-
|
|
2564
|
-
|
|
2274
|
+
else {
|
|
2275
|
+
yield this.pusher.user.signinDonePromise;
|
|
2276
|
+
if (this.pusher.user.user_data != null) {
|
|
2277
|
+
this.members.setMyID(this.pusher.user.user_data.id);
|
|
2278
|
+
}
|
|
2279
|
+
else {
|
|
2280
|
+
let suffix = url_store.buildLogSuffix('authorizationEndpoint');
|
|
2281
|
+
logger.error(`Invalid auth response for channel '${this.name}', ` +
|
|
2282
|
+
`expected 'channel_data' field. ${suffix}, ` +
|
|
2283
|
+
`or the user should be signed in.`);
|
|
2284
|
+
callback('Invalid auth response');
|
|
2285
|
+
return;
|
|
2286
|
+
}
|
|
2287
|
+
}
|
|
2288
|
+
}
|
|
2289
|
+
callback(error, authData);
|
|
2290
|
+
}));
|
|
2291
|
+
}
|
|
2292
|
+
handleEvent(event) {
|
|
2565
2293
|
var eventName = event.event;
|
|
2566
2294
|
if (eventName.indexOf('pusher_internal:') === 0) {
|
|
2567
2295
|
this.handleInternalEvent(event);
|
|
@@ -2574,8 +2302,8 @@ var presence_channel_PresenceChannel = (function (_super) {
|
|
|
2574
2302
|
}
|
|
2575
2303
|
this.emit(eventName, data, metadata);
|
|
2576
2304
|
}
|
|
2577
|
-
}
|
|
2578
|
-
|
|
2305
|
+
}
|
|
2306
|
+
handleInternalEvent(event) {
|
|
2579
2307
|
var eventName = event.event;
|
|
2580
2308
|
var data = event.data;
|
|
2581
2309
|
switch (eventName) {
|
|
@@ -2596,8 +2324,8 @@ var presence_channel_PresenceChannel = (function (_super) {
|
|
|
2596
2324
|
}
|
|
2597
2325
|
break;
|
|
2598
2326
|
}
|
|
2599
|
-
}
|
|
2600
|
-
|
|
2327
|
+
}
|
|
2328
|
+
handleSubscriptionSucceededEvent(event) {
|
|
2601
2329
|
this.subscriptionPending = false;
|
|
2602
2330
|
this.subscribed = true;
|
|
2603
2331
|
if (this.subscriptionCancelled) {
|
|
@@ -2607,14 +2335,12 @@ var presence_channel_PresenceChannel = (function (_super) {
|
|
|
2607
2335
|
this.members.onSubscription(event.data);
|
|
2608
2336
|
this.emit('pusher:subscription_succeeded', this.members);
|
|
2609
2337
|
}
|
|
2610
|
-
}
|
|
2611
|
-
|
|
2338
|
+
}
|
|
2339
|
+
disconnect() {
|
|
2612
2340
|
this.members.reset();
|
|
2613
|
-
|
|
2614
|
-
}
|
|
2615
|
-
|
|
2616
|
-
}(private_channel));
|
|
2617
|
-
/* harmony default export */ var presence_channel = (presence_channel_PresenceChannel);
|
|
2341
|
+
super.disconnect();
|
|
2342
|
+
}
|
|
2343
|
+
}
|
|
2618
2344
|
|
|
2619
2345
|
// EXTERNAL MODULE: ./node_modules/@stablelib/utf8/lib/utf8.js
|
|
2620
2346
|
var utf8 = __webpack_require__(1);
|
|
@@ -2623,64 +2349,47 @@ var utf8 = __webpack_require__(1);
|
|
|
2623
2349
|
var base64 = __webpack_require__(0);
|
|
2624
2350
|
|
|
2625
2351
|
// CONCATENATED MODULE: ./src/core/channels/encrypted_channel.ts
|
|
2626
|
-
var encrypted_channel_extends = (undefined && undefined.__extends) || (function () {
|
|
2627
|
-
var extendStatics = function (d, b) {
|
|
2628
|
-
extendStatics = Object.setPrototypeOf ||
|
|
2629
|
-
({ __proto__: [] } instanceof Array && function (d, b) { d.__proto__ = b; }) ||
|
|
2630
|
-
function (d, b) { for (var p in b) if (b.hasOwnProperty(p)) d[p] = b[p]; };
|
|
2631
|
-
return extendStatics(d, b);
|
|
2632
|
-
};
|
|
2633
|
-
return function (d, b) {
|
|
2634
|
-
extendStatics(d, b);
|
|
2635
|
-
function __() { this.constructor = d; }
|
|
2636
|
-
d.prototype = b === null ? Object.create(b) : (__.prototype = b.prototype, new __());
|
|
2637
|
-
};
|
|
2638
|
-
})();
|
|
2639
2352
|
|
|
2640
2353
|
|
|
2641
2354
|
|
|
2642
2355
|
|
|
2643
2356
|
|
|
2644
|
-
|
|
2645
|
-
|
|
2646
|
-
|
|
2647
|
-
|
|
2648
|
-
|
|
2649
|
-
_this.nacl = nacl;
|
|
2650
|
-
return _this;
|
|
2357
|
+
class encrypted_channel_EncryptedChannel extends private_channel_PrivateChannel {
|
|
2358
|
+
constructor(name, pusher, nacl) {
|
|
2359
|
+
super(name, pusher);
|
|
2360
|
+
this.key = null;
|
|
2361
|
+
this.nacl = nacl;
|
|
2651
2362
|
}
|
|
2652
|
-
|
|
2653
|
-
|
|
2654
|
-
_super.prototype.authorize.call(this, socketId, function (error, authData) {
|
|
2363
|
+
authorize(socketId, callback) {
|
|
2364
|
+
super.authorize(socketId, (error, authData) => {
|
|
2655
2365
|
if (error) {
|
|
2656
2366
|
callback(error, authData);
|
|
2657
2367
|
return;
|
|
2658
2368
|
}
|
|
2659
|
-
|
|
2369
|
+
let sharedSecret = authData['shared_secret'];
|
|
2660
2370
|
if (!sharedSecret) {
|
|
2661
|
-
callback(new Error(
|
|
2371
|
+
callback(new Error(`No shared_secret key in auth payload for encrypted channel: ${this.name}`), null);
|
|
2662
2372
|
return;
|
|
2663
2373
|
}
|
|
2664
|
-
|
|
2374
|
+
this.key = Object(base64["decode"])(sharedSecret);
|
|
2665
2375
|
delete authData['shared_secret'];
|
|
2666
2376
|
callback(null, authData);
|
|
2667
2377
|
});
|
|
2668
|
-
}
|
|
2669
|
-
|
|
2378
|
+
}
|
|
2379
|
+
trigger(event, data) {
|
|
2670
2380
|
throw new UnsupportedFeature('Client events are not currently supported for encrypted channels');
|
|
2671
|
-
}
|
|
2672
|
-
|
|
2381
|
+
}
|
|
2382
|
+
handleEvent(event) {
|
|
2673
2383
|
var eventName = event.event;
|
|
2674
2384
|
var data = event.data;
|
|
2675
2385
|
if (eventName.indexOf('pusher_internal:') === 0 ||
|
|
2676
2386
|
eventName.indexOf('pusher:') === 0) {
|
|
2677
|
-
|
|
2387
|
+
super.handleEvent(event);
|
|
2678
2388
|
return;
|
|
2679
2389
|
}
|
|
2680
2390
|
this.handleEncryptedEvent(eventName, data);
|
|
2681
|
-
}
|
|
2682
|
-
|
|
2683
|
-
var _this = this;
|
|
2391
|
+
}
|
|
2392
|
+
handleEncryptedEvent(event, data) {
|
|
2684
2393
|
if (!this.key) {
|
|
2685
2394
|
logger.debug('Received encrypted event before key has been retrieved from the authEndpoint');
|
|
2686
2395
|
return;
|
|
@@ -2690,98 +2399,81 @@ var encrypted_channel_EncryptedChannel = (function (_super) {
|
|
|
2690
2399
|
data);
|
|
2691
2400
|
return;
|
|
2692
2401
|
}
|
|
2693
|
-
|
|
2402
|
+
let cipherText = Object(base64["decode"])(data.ciphertext);
|
|
2694
2403
|
if (cipherText.length < this.nacl.secretbox.overheadLength) {
|
|
2695
|
-
logger.error(
|
|
2404
|
+
logger.error(`Expected encrypted event ciphertext length to be ${this.nacl.secretbox.overheadLength}, got: ${cipherText.length}`);
|
|
2696
2405
|
return;
|
|
2697
2406
|
}
|
|
2698
|
-
|
|
2407
|
+
let nonce = Object(base64["decode"])(data.nonce);
|
|
2699
2408
|
if (nonce.length < this.nacl.secretbox.nonceLength) {
|
|
2700
|
-
logger.error(
|
|
2409
|
+
logger.error(`Expected encrypted event nonce length to be ${this.nacl.secretbox.nonceLength}, got: ${nonce.length}`);
|
|
2701
2410
|
return;
|
|
2702
2411
|
}
|
|
2703
|
-
|
|
2412
|
+
let bytes = this.nacl.secretbox.open(cipherText, nonce, this.key);
|
|
2704
2413
|
if (bytes === null) {
|
|
2705
2414
|
logger.debug('Failed to decrypt an event, probably because it was encrypted with a different key. Fetching a new key from the authEndpoint...');
|
|
2706
|
-
this.authorize(this.pusher.connection.socket_id,
|
|
2415
|
+
this.authorize(this.pusher.connection.socket_id, (error, authData) => {
|
|
2707
2416
|
if (error) {
|
|
2708
|
-
logger.error(
|
|
2417
|
+
logger.error(`Failed to make a request to the authEndpoint: ${authData}. Unable to fetch new key, so dropping encrypted event`);
|
|
2709
2418
|
return;
|
|
2710
2419
|
}
|
|
2711
|
-
bytes =
|
|
2420
|
+
bytes = this.nacl.secretbox.open(cipherText, nonce, this.key);
|
|
2712
2421
|
if (bytes === null) {
|
|
2713
|
-
logger.error(
|
|
2422
|
+
logger.error(`Failed to decrypt event with new key. Dropping encrypted event`);
|
|
2714
2423
|
return;
|
|
2715
2424
|
}
|
|
2716
|
-
|
|
2425
|
+
this.emit(event, this.getDataToEmit(bytes));
|
|
2717
2426
|
return;
|
|
2718
2427
|
});
|
|
2719
2428
|
return;
|
|
2720
2429
|
}
|
|
2721
2430
|
this.emit(event, this.getDataToEmit(bytes));
|
|
2722
|
-
}
|
|
2723
|
-
|
|
2724
|
-
|
|
2431
|
+
}
|
|
2432
|
+
getDataToEmit(bytes) {
|
|
2433
|
+
let raw = Object(utf8["decode"])(bytes);
|
|
2725
2434
|
try {
|
|
2726
2435
|
return JSON.parse(raw);
|
|
2727
2436
|
}
|
|
2728
2437
|
catch (_a) {
|
|
2729
2438
|
return raw;
|
|
2730
2439
|
}
|
|
2731
|
-
}
|
|
2732
|
-
|
|
2733
|
-
}(private_channel));
|
|
2734
|
-
/* harmony default export */ var encrypted_channel = (encrypted_channel_EncryptedChannel);
|
|
2440
|
+
}
|
|
2441
|
+
}
|
|
2735
2442
|
|
|
2736
2443
|
// CONCATENATED MODULE: ./src/core/connection/connection_manager.ts
|
|
2737
|
-
var connection_manager_extends = (undefined && undefined.__extends) || (function () {
|
|
2738
|
-
var extendStatics = function (d, b) {
|
|
2739
|
-
extendStatics = Object.setPrototypeOf ||
|
|
2740
|
-
({ __proto__: [] } instanceof Array && function (d, b) { d.__proto__ = b; }) ||
|
|
2741
|
-
function (d, b) { for (var p in b) if (b.hasOwnProperty(p)) d[p] = b[p]; };
|
|
2742
|
-
return extendStatics(d, b);
|
|
2743
|
-
};
|
|
2744
|
-
return function (d, b) {
|
|
2745
|
-
extendStatics(d, b);
|
|
2746
|
-
function __() { this.constructor = d; }
|
|
2747
|
-
d.prototype = b === null ? Object.create(b) : (__.prototype = b.prototype, new __());
|
|
2748
|
-
};
|
|
2749
|
-
})();
|
|
2750
2444
|
|
|
2751
2445
|
|
|
2752
2446
|
|
|
2753
2447
|
|
|
2754
2448
|
|
|
2755
|
-
|
|
2756
|
-
|
|
2757
|
-
|
|
2758
|
-
|
|
2759
|
-
|
|
2760
|
-
|
|
2761
|
-
|
|
2762
|
-
|
|
2763
|
-
|
|
2764
|
-
|
|
2765
|
-
|
|
2766
|
-
|
|
2767
|
-
_this.handshakeCallbacks = _this.buildHandshakeCallbacks(_this.errorCallbacks);
|
|
2449
|
+
class connection_manager_ConnectionManager extends dispatcher_Dispatcher {
|
|
2450
|
+
constructor(key, options) {
|
|
2451
|
+
super();
|
|
2452
|
+
this.state = 'initialized';
|
|
2453
|
+
this.connection = null;
|
|
2454
|
+
this.key = key;
|
|
2455
|
+
this.options = options;
|
|
2456
|
+
this.timeline = this.options.timeline;
|
|
2457
|
+
this.usingTLS = this.options.useTLS;
|
|
2458
|
+
this.errorCallbacks = this.buildErrorCallbacks();
|
|
2459
|
+
this.connectionCallbacks = this.buildConnectionCallbacks(this.errorCallbacks);
|
|
2460
|
+
this.handshakeCallbacks = this.buildHandshakeCallbacks(this.errorCallbacks);
|
|
2768
2461
|
var Network = runtime.getNetwork();
|
|
2769
|
-
Network.bind('online',
|
|
2770
|
-
|
|
2771
|
-
if (
|
|
2772
|
-
|
|
2462
|
+
Network.bind('online', () => {
|
|
2463
|
+
this.timeline.info({ netinfo: 'online' });
|
|
2464
|
+
if (this.state === 'connecting' || this.state === 'unavailable') {
|
|
2465
|
+
this.retryIn(0);
|
|
2773
2466
|
}
|
|
2774
2467
|
});
|
|
2775
|
-
Network.bind('offline',
|
|
2776
|
-
|
|
2777
|
-
if (
|
|
2778
|
-
|
|
2468
|
+
Network.bind('offline', () => {
|
|
2469
|
+
this.timeline.info({ netinfo: 'offline' });
|
|
2470
|
+
if (this.connection) {
|
|
2471
|
+
this.sendActivityCheck();
|
|
2779
2472
|
}
|
|
2780
2473
|
});
|
|
2781
|
-
|
|
2782
|
-
return _this;
|
|
2474
|
+
this.updateStrategy();
|
|
2783
2475
|
}
|
|
2784
|
-
|
|
2476
|
+
connect() {
|
|
2785
2477
|
if (this.connection || this.runner) {
|
|
2786
2478
|
return;
|
|
2787
2479
|
}
|
|
@@ -2792,59 +2484,58 @@ var connection_manager_ConnectionManager = (function (_super) {
|
|
|
2792
2484
|
this.updateState('connecting');
|
|
2793
2485
|
this.startConnecting();
|
|
2794
2486
|
this.setUnavailableTimer();
|
|
2795
|
-
}
|
|
2796
|
-
|
|
2487
|
+
}
|
|
2488
|
+
send(data) {
|
|
2797
2489
|
if (this.connection) {
|
|
2798
2490
|
return this.connection.send(data);
|
|
2799
2491
|
}
|
|
2800
2492
|
else {
|
|
2801
2493
|
return false;
|
|
2802
2494
|
}
|
|
2803
|
-
}
|
|
2804
|
-
|
|
2495
|
+
}
|
|
2496
|
+
send_event(name, data, channel) {
|
|
2805
2497
|
if (this.connection) {
|
|
2806
2498
|
return this.connection.send_event(name, data, channel);
|
|
2807
2499
|
}
|
|
2808
2500
|
else {
|
|
2809
2501
|
return false;
|
|
2810
2502
|
}
|
|
2811
|
-
}
|
|
2812
|
-
|
|
2503
|
+
}
|
|
2504
|
+
disconnect() {
|
|
2813
2505
|
this.disconnectInternally();
|
|
2814
2506
|
this.updateState('disconnected');
|
|
2815
|
-
}
|
|
2816
|
-
|
|
2507
|
+
}
|
|
2508
|
+
isUsingTLS() {
|
|
2817
2509
|
return this.usingTLS;
|
|
2818
|
-
}
|
|
2819
|
-
|
|
2820
|
-
var
|
|
2821
|
-
var callback = function (error, handshake) {
|
|
2510
|
+
}
|
|
2511
|
+
startConnecting() {
|
|
2512
|
+
var callback = (error, handshake) => {
|
|
2822
2513
|
if (error) {
|
|
2823
|
-
|
|
2514
|
+
this.runner = this.strategy.connect(0, callback);
|
|
2824
2515
|
}
|
|
2825
2516
|
else {
|
|
2826
2517
|
if (handshake.action === 'error') {
|
|
2827
|
-
|
|
2518
|
+
this.emit('error', {
|
|
2828
2519
|
type: 'HandshakeError',
|
|
2829
2520
|
error: handshake.error
|
|
2830
2521
|
});
|
|
2831
|
-
|
|
2522
|
+
this.timeline.error({ handshakeError: handshake.error });
|
|
2832
2523
|
}
|
|
2833
2524
|
else {
|
|
2834
|
-
|
|
2835
|
-
|
|
2525
|
+
this.abortConnecting();
|
|
2526
|
+
this.handshakeCallbacks[handshake.action](handshake);
|
|
2836
2527
|
}
|
|
2837
2528
|
}
|
|
2838
2529
|
};
|
|
2839
2530
|
this.runner = this.strategy.connect(0, callback);
|
|
2840
|
-
}
|
|
2841
|
-
|
|
2531
|
+
}
|
|
2532
|
+
abortConnecting() {
|
|
2842
2533
|
if (this.runner) {
|
|
2843
2534
|
this.runner.abort();
|
|
2844
2535
|
this.runner = null;
|
|
2845
2536
|
}
|
|
2846
|
-
}
|
|
2847
|
-
|
|
2537
|
+
}
|
|
2538
|
+
disconnectInternally() {
|
|
2848
2539
|
this.abortConnecting();
|
|
2849
2540
|
this.clearRetryTimer();
|
|
2850
2541
|
this.clearUnavailableTimer();
|
|
@@ -2852,136 +2543,129 @@ var connection_manager_ConnectionManager = (function (_super) {
|
|
|
2852
2543
|
var connection = this.abandonConnection();
|
|
2853
2544
|
connection.close();
|
|
2854
2545
|
}
|
|
2855
|
-
}
|
|
2856
|
-
|
|
2546
|
+
}
|
|
2547
|
+
updateStrategy() {
|
|
2857
2548
|
this.strategy = this.options.getStrategy({
|
|
2858
2549
|
key: this.key,
|
|
2859
2550
|
timeline: this.timeline,
|
|
2860
2551
|
useTLS: this.usingTLS
|
|
2861
2552
|
});
|
|
2862
|
-
}
|
|
2863
|
-
|
|
2864
|
-
var _this = this;
|
|
2553
|
+
}
|
|
2554
|
+
retryIn(delay) {
|
|
2865
2555
|
this.timeline.info({ action: 'retry', delay: delay });
|
|
2866
2556
|
if (delay > 0) {
|
|
2867
2557
|
this.emit('connecting_in', Math.round(delay / 1000));
|
|
2868
2558
|
}
|
|
2869
|
-
this.retryTimer = new
|
|
2870
|
-
|
|
2871
|
-
|
|
2559
|
+
this.retryTimer = new timers_OneOffTimer(delay || 0, () => {
|
|
2560
|
+
this.disconnectInternally();
|
|
2561
|
+
this.connect();
|
|
2872
2562
|
});
|
|
2873
|
-
}
|
|
2874
|
-
|
|
2563
|
+
}
|
|
2564
|
+
clearRetryTimer() {
|
|
2875
2565
|
if (this.retryTimer) {
|
|
2876
2566
|
this.retryTimer.ensureAborted();
|
|
2877
2567
|
this.retryTimer = null;
|
|
2878
2568
|
}
|
|
2879
|
-
}
|
|
2880
|
-
|
|
2881
|
-
|
|
2882
|
-
|
|
2883
|
-
_this.updateState('unavailable');
|
|
2569
|
+
}
|
|
2570
|
+
setUnavailableTimer() {
|
|
2571
|
+
this.unavailableTimer = new timers_OneOffTimer(this.options.unavailableTimeout, () => {
|
|
2572
|
+
this.updateState('unavailable');
|
|
2884
2573
|
});
|
|
2885
|
-
}
|
|
2886
|
-
|
|
2574
|
+
}
|
|
2575
|
+
clearUnavailableTimer() {
|
|
2887
2576
|
if (this.unavailableTimer) {
|
|
2888
2577
|
this.unavailableTimer.ensureAborted();
|
|
2889
2578
|
}
|
|
2890
|
-
}
|
|
2891
|
-
|
|
2892
|
-
var _this = this;
|
|
2579
|
+
}
|
|
2580
|
+
sendActivityCheck() {
|
|
2893
2581
|
this.stopActivityCheck();
|
|
2894
2582
|
this.connection.ping();
|
|
2895
|
-
this.activityTimer = new
|
|
2896
|
-
|
|
2897
|
-
|
|
2583
|
+
this.activityTimer = new timers_OneOffTimer(this.options.pongTimeout, () => {
|
|
2584
|
+
this.timeline.error({ pong_timed_out: this.options.pongTimeout });
|
|
2585
|
+
this.retryIn(0);
|
|
2898
2586
|
});
|
|
2899
|
-
}
|
|
2900
|
-
|
|
2901
|
-
var _this = this;
|
|
2587
|
+
}
|
|
2588
|
+
resetActivityCheck() {
|
|
2902
2589
|
this.stopActivityCheck();
|
|
2903
2590
|
if (this.connection && !this.connection.handlesActivityChecks()) {
|
|
2904
|
-
this.activityTimer = new
|
|
2905
|
-
|
|
2591
|
+
this.activityTimer = new timers_OneOffTimer(this.activityTimeout, () => {
|
|
2592
|
+
this.sendActivityCheck();
|
|
2906
2593
|
});
|
|
2907
2594
|
}
|
|
2908
|
-
}
|
|
2909
|
-
|
|
2595
|
+
}
|
|
2596
|
+
stopActivityCheck() {
|
|
2910
2597
|
if (this.activityTimer) {
|
|
2911
2598
|
this.activityTimer.ensureAborted();
|
|
2912
2599
|
}
|
|
2913
|
-
}
|
|
2914
|
-
|
|
2915
|
-
var _this = this;
|
|
2600
|
+
}
|
|
2601
|
+
buildConnectionCallbacks(errorCallbacks) {
|
|
2916
2602
|
return extend({}, errorCallbacks, {
|
|
2917
|
-
message:
|
|
2918
|
-
|
|
2919
|
-
|
|
2603
|
+
message: message => {
|
|
2604
|
+
this.resetActivityCheck();
|
|
2605
|
+
this.emit('message', message);
|
|
2920
2606
|
},
|
|
2921
|
-
ping:
|
|
2922
|
-
|
|
2607
|
+
ping: () => {
|
|
2608
|
+
this.send_event('pusher:pong', {});
|
|
2923
2609
|
},
|
|
2924
|
-
activity:
|
|
2925
|
-
|
|
2610
|
+
activity: () => {
|
|
2611
|
+
this.resetActivityCheck();
|
|
2926
2612
|
},
|
|
2927
|
-
error:
|
|
2928
|
-
|
|
2613
|
+
error: error => {
|
|
2614
|
+
this.emit('error', error);
|
|
2929
2615
|
},
|
|
2930
|
-
closed:
|
|
2931
|
-
|
|
2932
|
-
if (
|
|
2933
|
-
|
|
2616
|
+
closed: () => {
|
|
2617
|
+
this.abandonConnection();
|
|
2618
|
+
if (this.shouldRetry()) {
|
|
2619
|
+
this.retryIn(1000);
|
|
2934
2620
|
}
|
|
2935
2621
|
}
|
|
2936
2622
|
});
|
|
2937
|
-
}
|
|
2938
|
-
|
|
2939
|
-
var _this = this;
|
|
2623
|
+
}
|
|
2624
|
+
buildHandshakeCallbacks(errorCallbacks) {
|
|
2940
2625
|
return extend({}, errorCallbacks, {
|
|
2941
|
-
connected:
|
|
2942
|
-
|
|
2943
|
-
|
|
2944
|
-
|
|
2945
|
-
|
|
2946
|
-
|
|
2626
|
+
connected: (handshake) => {
|
|
2627
|
+
this.activityTimeout = Math.min(this.options.activityTimeout, handshake.activityTimeout, handshake.connection.activityTimeout || Infinity);
|
|
2628
|
+
this.clearUnavailableTimer();
|
|
2629
|
+
this.setConnection(handshake.connection);
|
|
2630
|
+
this.socket_id = this.connection.id;
|
|
2631
|
+
this.updateState('connected', { socket_id: this.socket_id });
|
|
2947
2632
|
}
|
|
2948
2633
|
});
|
|
2949
|
-
}
|
|
2950
|
-
|
|
2951
|
-
|
|
2952
|
-
|
|
2953
|
-
return function (result) {
|
|
2634
|
+
}
|
|
2635
|
+
buildErrorCallbacks() {
|
|
2636
|
+
let withErrorEmitted = callback => {
|
|
2637
|
+
return (result) => {
|
|
2954
2638
|
if (result.error) {
|
|
2955
|
-
|
|
2639
|
+
this.emit('error', { type: 'WebSocketError', error: result.error });
|
|
2956
2640
|
}
|
|
2957
2641
|
callback(result);
|
|
2958
2642
|
};
|
|
2959
2643
|
};
|
|
2960
2644
|
return {
|
|
2961
|
-
tls_only: withErrorEmitted(
|
|
2962
|
-
|
|
2963
|
-
|
|
2964
|
-
|
|
2645
|
+
tls_only: withErrorEmitted(() => {
|
|
2646
|
+
this.usingTLS = true;
|
|
2647
|
+
this.updateStrategy();
|
|
2648
|
+
this.retryIn(0);
|
|
2965
2649
|
}),
|
|
2966
|
-
refused: withErrorEmitted(
|
|
2967
|
-
|
|
2650
|
+
refused: withErrorEmitted(() => {
|
|
2651
|
+
this.disconnect();
|
|
2968
2652
|
}),
|
|
2969
|
-
backoff: withErrorEmitted(
|
|
2970
|
-
|
|
2653
|
+
backoff: withErrorEmitted(() => {
|
|
2654
|
+
this.retryIn(1000);
|
|
2971
2655
|
}),
|
|
2972
|
-
retry: withErrorEmitted(
|
|
2973
|
-
|
|
2656
|
+
retry: withErrorEmitted(() => {
|
|
2657
|
+
this.retryIn(0);
|
|
2974
2658
|
})
|
|
2975
2659
|
};
|
|
2976
|
-
}
|
|
2977
|
-
|
|
2660
|
+
}
|
|
2661
|
+
setConnection(connection) {
|
|
2978
2662
|
this.connection = connection;
|
|
2979
2663
|
for (var event in this.connectionCallbacks) {
|
|
2980
2664
|
this.connection.bind(event, this.connectionCallbacks[event]);
|
|
2981
2665
|
}
|
|
2982
2666
|
this.resetActivityCheck();
|
|
2983
|
-
}
|
|
2984
|
-
|
|
2667
|
+
}
|
|
2668
|
+
abandonConnection() {
|
|
2985
2669
|
if (!this.connection) {
|
|
2986
2670
|
return;
|
|
2987
2671
|
}
|
|
@@ -2992,8 +2676,8 @@ var connection_manager_ConnectionManager = (function (_super) {
|
|
|
2992
2676
|
var connection = this.connection;
|
|
2993
2677
|
this.connection = null;
|
|
2994
2678
|
return connection;
|
|
2995
|
-
}
|
|
2996
|
-
|
|
2679
|
+
}
|
|
2680
|
+
updateState(newState, data) {
|
|
2997
2681
|
var previousState = this.state;
|
|
2998
2682
|
this.state = newState;
|
|
2999
2683
|
if (previousState !== newState) {
|
|
@@ -3006,56 +2690,52 @@ var connection_manager_ConnectionManager = (function (_super) {
|
|
|
3006
2690
|
this.emit('state_change', { previous: previousState, current: newState });
|
|
3007
2691
|
this.emit(newState, data);
|
|
3008
2692
|
}
|
|
3009
|
-
}
|
|
3010
|
-
|
|
2693
|
+
}
|
|
2694
|
+
shouldRetry() {
|
|
3011
2695
|
return this.state === 'connecting' || this.state === 'connected';
|
|
3012
|
-
}
|
|
3013
|
-
|
|
3014
|
-
}(dispatcher));
|
|
3015
|
-
/* harmony default export */ var connection_manager = (connection_manager_ConnectionManager);
|
|
2696
|
+
}
|
|
2697
|
+
}
|
|
3016
2698
|
|
|
3017
2699
|
// CONCATENATED MODULE: ./src/core/channels/channels.ts
|
|
3018
2700
|
|
|
3019
2701
|
|
|
3020
2702
|
|
|
3021
2703
|
|
|
3022
|
-
|
|
3023
|
-
|
|
2704
|
+
class channels_Channels {
|
|
2705
|
+
constructor() {
|
|
3024
2706
|
this.channels = {};
|
|
3025
2707
|
}
|
|
3026
|
-
|
|
2708
|
+
add(name, pusher) {
|
|
3027
2709
|
if (!this.channels[name]) {
|
|
3028
2710
|
this.channels[name] = createChannel(name, pusher);
|
|
3029
2711
|
}
|
|
3030
2712
|
return this.channels[name];
|
|
3031
|
-
}
|
|
3032
|
-
|
|
2713
|
+
}
|
|
2714
|
+
all() {
|
|
3033
2715
|
return values(this.channels);
|
|
3034
|
-
}
|
|
3035
|
-
|
|
2716
|
+
}
|
|
2717
|
+
find(name) {
|
|
3036
2718
|
return this.channels[name];
|
|
3037
|
-
}
|
|
3038
|
-
|
|
2719
|
+
}
|
|
2720
|
+
remove(name) {
|
|
3039
2721
|
var channel = this.channels[name];
|
|
3040
2722
|
delete this.channels[name];
|
|
3041
2723
|
return channel;
|
|
3042
|
-
}
|
|
3043
|
-
|
|
2724
|
+
}
|
|
2725
|
+
disconnect() {
|
|
3044
2726
|
objectApply(this.channels, function (channel) {
|
|
3045
2727
|
channel.disconnect();
|
|
3046
2728
|
});
|
|
3047
|
-
}
|
|
3048
|
-
|
|
3049
|
-
}());
|
|
3050
|
-
/* harmony default export */ var channels = (channels_Channels);
|
|
2729
|
+
}
|
|
2730
|
+
}
|
|
3051
2731
|
function createChannel(name, pusher) {
|
|
3052
2732
|
if (name.indexOf('private-encrypted-') === 0) {
|
|
3053
2733
|
if (pusher.config.nacl) {
|
|
3054
2734
|
return factory.createEncryptedChannel(name, pusher, pusher.config.nacl);
|
|
3055
2735
|
}
|
|
3056
|
-
|
|
3057
|
-
|
|
3058
|
-
throw new UnsupportedFeature(errMsg
|
|
2736
|
+
let errMsg = 'Tried to subscribe to a private-encrypted- channel but no nacl implementation available';
|
|
2737
|
+
let suffix = url_store.buildLogSuffix('encryptedChannelSupport');
|
|
2738
|
+
throw new UnsupportedFeature(`${errMsg}. ${suffix}`);
|
|
3059
2739
|
}
|
|
3060
2740
|
else if (name.indexOf('private-') === 0) {
|
|
3061
2741
|
return factory.createPrivateChannel(name, pusher);
|
|
@@ -3082,97 +2762,94 @@ function createChannel(name, pusher) {
|
|
|
3082
2762
|
|
|
3083
2763
|
|
|
3084
2764
|
var Factory = {
|
|
3085
|
-
createChannels
|
|
3086
|
-
return new
|
|
2765
|
+
createChannels() {
|
|
2766
|
+
return new channels_Channels();
|
|
3087
2767
|
},
|
|
3088
|
-
createConnectionManager
|
|
3089
|
-
return new
|
|
2768
|
+
createConnectionManager(key, options) {
|
|
2769
|
+
return new connection_manager_ConnectionManager(key, options);
|
|
3090
2770
|
},
|
|
3091
|
-
createChannel
|
|
3092
|
-
return new
|
|
2771
|
+
createChannel(name, pusher) {
|
|
2772
|
+
return new channel_Channel(name, pusher);
|
|
3093
2773
|
},
|
|
3094
|
-
createPrivateChannel
|
|
3095
|
-
return new
|
|
2774
|
+
createPrivateChannel(name, pusher) {
|
|
2775
|
+
return new private_channel_PrivateChannel(name, pusher);
|
|
3096
2776
|
},
|
|
3097
|
-
createPresenceChannel
|
|
3098
|
-
return new
|
|
2777
|
+
createPresenceChannel(name, pusher) {
|
|
2778
|
+
return new presence_channel_PresenceChannel(name, pusher);
|
|
3099
2779
|
},
|
|
3100
|
-
createEncryptedChannel
|
|
3101
|
-
return new
|
|
2780
|
+
createEncryptedChannel(name, pusher, nacl) {
|
|
2781
|
+
return new encrypted_channel_EncryptedChannel(name, pusher, nacl);
|
|
3102
2782
|
},
|
|
3103
|
-
createTimelineSender
|
|
3104
|
-
return new
|
|
2783
|
+
createTimelineSender(timeline, options) {
|
|
2784
|
+
return new timeline_sender_TimelineSender(timeline, options);
|
|
3105
2785
|
},
|
|
3106
|
-
createHandshake
|
|
3107
|
-
return new
|
|
2786
|
+
createHandshake(transport, callback) {
|
|
2787
|
+
return new handshake_Handshake(transport, callback);
|
|
3108
2788
|
},
|
|
3109
|
-
createAssistantToTheTransportManager
|
|
3110
|
-
return new
|
|
2789
|
+
createAssistantToTheTransportManager(manager, transport, options) {
|
|
2790
|
+
return new assistant_to_the_transport_manager_AssistantToTheTransportManager(manager, transport, options);
|
|
3111
2791
|
}
|
|
3112
2792
|
};
|
|
3113
2793
|
/* harmony default export */ var factory = (Factory);
|
|
3114
2794
|
|
|
3115
2795
|
// CONCATENATED MODULE: ./src/core/transports/transport_manager.ts
|
|
3116
2796
|
|
|
3117
|
-
|
|
3118
|
-
|
|
2797
|
+
class transport_manager_TransportManager {
|
|
2798
|
+
constructor(options) {
|
|
3119
2799
|
this.options = options || {};
|
|
3120
2800
|
this.livesLeft = this.options.lives || Infinity;
|
|
3121
2801
|
}
|
|
3122
|
-
|
|
2802
|
+
getAssistant(transport) {
|
|
3123
2803
|
return factory.createAssistantToTheTransportManager(this, transport, {
|
|
3124
2804
|
minPingDelay: this.options.minPingDelay,
|
|
3125
2805
|
maxPingDelay: this.options.maxPingDelay
|
|
3126
2806
|
});
|
|
3127
|
-
}
|
|
3128
|
-
|
|
2807
|
+
}
|
|
2808
|
+
isAlive() {
|
|
3129
2809
|
return this.livesLeft > 0;
|
|
3130
|
-
}
|
|
3131
|
-
|
|
2810
|
+
}
|
|
2811
|
+
reportDeath() {
|
|
3132
2812
|
this.livesLeft -= 1;
|
|
3133
|
-
}
|
|
3134
|
-
|
|
3135
|
-
}());
|
|
3136
|
-
/* harmony default export */ var transport_manager = (transport_manager_TransportManager);
|
|
2813
|
+
}
|
|
2814
|
+
}
|
|
3137
2815
|
|
|
3138
2816
|
// CONCATENATED MODULE: ./src/core/strategies/sequential_strategy.ts
|
|
3139
2817
|
|
|
3140
2818
|
|
|
3141
2819
|
|
|
3142
|
-
|
|
3143
|
-
|
|
2820
|
+
class sequential_strategy_SequentialStrategy {
|
|
2821
|
+
constructor(strategies, options) {
|
|
3144
2822
|
this.strategies = strategies;
|
|
3145
2823
|
this.loop = Boolean(options.loop);
|
|
3146
2824
|
this.failFast = Boolean(options.failFast);
|
|
3147
2825
|
this.timeout = options.timeout;
|
|
3148
2826
|
this.timeoutLimit = options.timeoutLimit;
|
|
3149
2827
|
}
|
|
3150
|
-
|
|
2828
|
+
isSupported() {
|
|
3151
2829
|
return any(this.strategies, util.method('isSupported'));
|
|
3152
|
-
}
|
|
3153
|
-
|
|
3154
|
-
var _this = this;
|
|
2830
|
+
}
|
|
2831
|
+
connect(minPriority, callback) {
|
|
3155
2832
|
var strategies = this.strategies;
|
|
3156
2833
|
var current = 0;
|
|
3157
2834
|
var timeout = this.timeout;
|
|
3158
2835
|
var runner = null;
|
|
3159
|
-
var tryNextStrategy =
|
|
2836
|
+
var tryNextStrategy = (error, handshake) => {
|
|
3160
2837
|
if (handshake) {
|
|
3161
2838
|
callback(null, handshake);
|
|
3162
2839
|
}
|
|
3163
2840
|
else {
|
|
3164
2841
|
current = current + 1;
|
|
3165
|
-
if (
|
|
2842
|
+
if (this.loop) {
|
|
3166
2843
|
current = current % strategies.length;
|
|
3167
2844
|
}
|
|
3168
2845
|
if (current < strategies.length) {
|
|
3169
2846
|
if (timeout) {
|
|
3170
2847
|
timeout = timeout * 2;
|
|
3171
|
-
if (
|
|
3172
|
-
timeout = Math.min(timeout,
|
|
2848
|
+
if (this.timeoutLimit) {
|
|
2849
|
+
timeout = Math.min(timeout, this.timeoutLimit);
|
|
3173
2850
|
}
|
|
3174
2851
|
}
|
|
3175
|
-
runner =
|
|
2852
|
+
runner = this.tryStrategy(strategies[current], minPriority, { timeout, failFast: this.failFast }, tryNextStrategy);
|
|
3176
2853
|
}
|
|
3177
2854
|
else {
|
|
3178
2855
|
callback(true);
|
|
@@ -3191,12 +2868,12 @@ var sequential_strategy_SequentialStrategy = (function () {
|
|
|
3191
2868
|
}
|
|
3192
2869
|
}
|
|
3193
2870
|
};
|
|
3194
|
-
}
|
|
3195
|
-
|
|
2871
|
+
}
|
|
2872
|
+
tryStrategy(strategy, minPriority, options, callback) {
|
|
3196
2873
|
var timer = null;
|
|
3197
2874
|
var runner = null;
|
|
3198
2875
|
if (options.timeout > 0) {
|
|
3199
|
-
timer = new
|
|
2876
|
+
timer = new timers_OneOffTimer(options.timeout, function () {
|
|
3200
2877
|
runner.abort();
|
|
3201
2878
|
callback(true);
|
|
3202
2879
|
});
|
|
@@ -3221,22 +2898,20 @@ var sequential_strategy_SequentialStrategy = (function () {
|
|
|
3221
2898
|
runner.forceMinPriority(p);
|
|
3222
2899
|
}
|
|
3223
2900
|
};
|
|
3224
|
-
}
|
|
3225
|
-
|
|
3226
|
-
}());
|
|
3227
|
-
/* harmony default export */ var sequential_strategy = (sequential_strategy_SequentialStrategy);
|
|
2901
|
+
}
|
|
2902
|
+
}
|
|
3228
2903
|
|
|
3229
2904
|
// CONCATENATED MODULE: ./src/core/strategies/best_connected_ever_strategy.ts
|
|
3230
2905
|
|
|
3231
2906
|
|
|
3232
|
-
|
|
3233
|
-
|
|
2907
|
+
class best_connected_ever_strategy_BestConnectedEverStrategy {
|
|
2908
|
+
constructor(strategies) {
|
|
3234
2909
|
this.strategies = strategies;
|
|
3235
2910
|
}
|
|
3236
|
-
|
|
2911
|
+
isSupported() {
|
|
3237
2912
|
return any(this.strategies, util.method('isSupported'));
|
|
3238
|
-
}
|
|
3239
|
-
|
|
2913
|
+
}
|
|
2914
|
+
connect(minPriority, callback) {
|
|
3240
2915
|
return connect(this.strategies, minPriority, function (i, runners) {
|
|
3241
2916
|
return function (error, handshake) {
|
|
3242
2917
|
runners[i].error = error;
|
|
@@ -3252,10 +2927,8 @@ var best_connected_ever_strategy_BestConnectedEverStrategy = (function () {
|
|
|
3252
2927
|
callback(null, handshake);
|
|
3253
2928
|
};
|
|
3254
2929
|
});
|
|
3255
|
-
}
|
|
3256
|
-
|
|
3257
|
-
}());
|
|
3258
|
-
/* harmony default export */ var best_connected_ever_strategy = (best_connected_ever_strategy_BestConnectedEverStrategy);
|
|
2930
|
+
}
|
|
2931
|
+
}
|
|
3259
2932
|
function connect(strategies, minPriority, callbackBuilder) {
|
|
3260
2933
|
var runners = map(strategies, function (strategy, i, _, rs) {
|
|
3261
2934
|
return strategy.connect(minPriority, callbackBuilder(i, rs));
|
|
@@ -3288,18 +2961,18 @@ function abortRunner(runner) {
|
|
|
3288
2961
|
|
|
3289
2962
|
|
|
3290
2963
|
|
|
3291
|
-
|
|
3292
|
-
|
|
2964
|
+
class cached_strategy_CachedStrategy {
|
|
2965
|
+
constructor(strategy, transports, options) {
|
|
3293
2966
|
this.strategy = strategy;
|
|
3294
2967
|
this.transports = transports;
|
|
3295
2968
|
this.ttl = options.ttl || 1800 * 1000;
|
|
3296
2969
|
this.usingTLS = options.useTLS;
|
|
3297
2970
|
this.timeline = options.timeline;
|
|
3298
2971
|
}
|
|
3299
|
-
|
|
2972
|
+
isSupported() {
|
|
3300
2973
|
return this.strategy.isSupported();
|
|
3301
|
-
}
|
|
3302
|
-
|
|
2974
|
+
}
|
|
2975
|
+
connect(minPriority, callback) {
|
|
3303
2976
|
var usingTLS = this.usingTLS;
|
|
3304
2977
|
var info = fetchTransportCache(usingTLS);
|
|
3305
2978
|
var strategies = [this.strategy];
|
|
@@ -3311,7 +2984,7 @@ var cached_strategy_CachedStrategy = (function () {
|
|
|
3311
2984
|
transport: info.transport,
|
|
3312
2985
|
latency: info.latency
|
|
3313
2986
|
});
|
|
3314
|
-
strategies.push(new
|
|
2987
|
+
strategies.push(new sequential_strategy_SequentialStrategy([transport], {
|
|
3315
2988
|
timeout: info.latency * 2 + 1000,
|
|
3316
2989
|
failFast: true
|
|
3317
2990
|
}));
|
|
@@ -3347,10 +3020,8 @@ var cached_strategy_CachedStrategy = (function () {
|
|
|
3347
3020
|
}
|
|
3348
3021
|
}
|
|
3349
3022
|
};
|
|
3350
|
-
}
|
|
3351
|
-
|
|
3352
|
-
}());
|
|
3353
|
-
/* harmony default export */ var cached_strategy = (cached_strategy_CachedStrategy);
|
|
3023
|
+
}
|
|
3024
|
+
}
|
|
3354
3025
|
function getTransportCacheKey(usingTLS) {
|
|
3355
3026
|
return 'pusherTransport' + (usingTLS ? 'TLS' : 'NonTLS');
|
|
3356
3027
|
}
|
|
@@ -3396,19 +3067,18 @@ function flushTransportCache(usingTLS) {
|
|
|
3396
3067
|
|
|
3397
3068
|
// CONCATENATED MODULE: ./src/core/strategies/delayed_strategy.ts
|
|
3398
3069
|
|
|
3399
|
-
|
|
3400
|
-
|
|
3401
|
-
var number = _a.delay;
|
|
3070
|
+
class delayed_strategy_DelayedStrategy {
|
|
3071
|
+
constructor(strategy, { delay: number }) {
|
|
3402
3072
|
this.strategy = strategy;
|
|
3403
3073
|
this.options = { delay: number };
|
|
3404
3074
|
}
|
|
3405
|
-
|
|
3075
|
+
isSupported() {
|
|
3406
3076
|
return this.strategy.isSupported();
|
|
3407
|
-
}
|
|
3408
|
-
|
|
3077
|
+
}
|
|
3078
|
+
connect(minPriority, callback) {
|
|
3409
3079
|
var strategy = this.strategy;
|
|
3410
3080
|
var runner;
|
|
3411
|
-
var timer = new
|
|
3081
|
+
var timer = new timers_OneOffTimer(this.options.delay, function () {
|
|
3412
3082
|
runner = strategy.connect(minPriority, callback);
|
|
3413
3083
|
});
|
|
3414
3084
|
return {
|
|
@@ -3425,39 +3095,35 @@ var delayed_strategy_DelayedStrategy = (function () {
|
|
|
3425
3095
|
}
|
|
3426
3096
|
}
|
|
3427
3097
|
};
|
|
3428
|
-
}
|
|
3429
|
-
|
|
3430
|
-
}());
|
|
3431
|
-
/* harmony default export */ var delayed_strategy = (delayed_strategy_DelayedStrategy);
|
|
3098
|
+
}
|
|
3099
|
+
}
|
|
3432
3100
|
|
|
3433
3101
|
// CONCATENATED MODULE: ./src/core/strategies/if_strategy.ts
|
|
3434
|
-
|
|
3435
|
-
|
|
3102
|
+
class IfStrategy {
|
|
3103
|
+
constructor(test, trueBranch, falseBranch) {
|
|
3436
3104
|
this.test = test;
|
|
3437
3105
|
this.trueBranch = trueBranch;
|
|
3438
3106
|
this.falseBranch = falseBranch;
|
|
3439
3107
|
}
|
|
3440
|
-
|
|
3108
|
+
isSupported() {
|
|
3441
3109
|
var branch = this.test() ? this.trueBranch : this.falseBranch;
|
|
3442
3110
|
return branch.isSupported();
|
|
3443
|
-
}
|
|
3444
|
-
|
|
3111
|
+
}
|
|
3112
|
+
connect(minPriority, callback) {
|
|
3445
3113
|
var branch = this.test() ? this.trueBranch : this.falseBranch;
|
|
3446
3114
|
return branch.connect(minPriority, callback);
|
|
3447
|
-
}
|
|
3448
|
-
|
|
3449
|
-
}());
|
|
3450
|
-
/* harmony default export */ var if_strategy = (IfStrategy);
|
|
3115
|
+
}
|
|
3116
|
+
}
|
|
3451
3117
|
|
|
3452
3118
|
// CONCATENATED MODULE: ./src/core/strategies/first_connected_strategy.ts
|
|
3453
|
-
|
|
3454
|
-
|
|
3119
|
+
class FirstConnectedStrategy {
|
|
3120
|
+
constructor(strategy) {
|
|
3455
3121
|
this.strategy = strategy;
|
|
3456
3122
|
}
|
|
3457
|
-
|
|
3123
|
+
isSupported() {
|
|
3458
3124
|
return this.strategy.isSupported();
|
|
3459
|
-
}
|
|
3460
|
-
|
|
3125
|
+
}
|
|
3126
|
+
connect(minPriority, callback) {
|
|
3461
3127
|
var runner = this.strategy.connect(minPriority, function (error, handshake) {
|
|
3462
3128
|
if (handshake) {
|
|
3463
3129
|
runner.abort();
|
|
@@ -3465,10 +3131,8 @@ var FirstConnectedStrategy = (function () {
|
|
|
3465
3131
|
callback(error, handshake);
|
|
3466
3132
|
});
|
|
3467
3133
|
return runner;
|
|
3468
|
-
}
|
|
3469
|
-
|
|
3470
|
-
}());
|
|
3471
|
-
/* harmony default export */ var first_connected_strategy = (FirstConnectedStrategy);
|
|
3134
|
+
}
|
|
3135
|
+
}
|
|
3472
3136
|
|
|
3473
3137
|
// CONCATENATED MODULE: ./src/runtimes/web/default_strategy.ts
|
|
3474
3138
|
|
|
@@ -3508,12 +3172,11 @@ var getDefaultStrategy = function (config, baseOptions, defineTransport) {
|
|
|
3508
3172
|
timeout: 15000,
|
|
3509
3173
|
timeoutLimit: 60000
|
|
3510
3174
|
};
|
|
3511
|
-
var ws_manager = new
|
|
3512
|
-
lives: 2,
|
|
3175
|
+
var ws_manager = new transport_manager_TransportManager({
|
|
3513
3176
|
minPingDelay: 10000,
|
|
3514
3177
|
maxPingDelay: config.activityTimeout
|
|
3515
3178
|
});
|
|
3516
|
-
var streaming_manager = new
|
|
3179
|
+
var streaming_manager = new transport_manager_TransportManager({
|
|
3517
3180
|
lives: 2,
|
|
3518
3181
|
minPingDelay: 10000,
|
|
3519
3182
|
maxPingDelay: config.activityTimeout
|
|
@@ -3525,37 +3188,37 @@ var getDefaultStrategy = function (config, baseOptions, defineTransport) {
|
|
|
3525
3188
|
var xdr_streaming_transport = defineTransportStrategy('xdr_streaming', 'xdr_streaming', 1, sockjs_options, streaming_manager);
|
|
3526
3189
|
var xhr_polling_transport = defineTransportStrategy('xhr_polling', 'xhr_polling', 1, sockjs_options);
|
|
3527
3190
|
var xdr_polling_transport = defineTransportStrategy('xdr_polling', 'xdr_polling', 1, sockjs_options);
|
|
3528
|
-
var ws_loop = new
|
|
3529
|
-
var wss_loop = new
|
|
3530
|
-
var sockjs_loop = new
|
|
3531
|
-
var streaming_loop = new
|
|
3532
|
-
new
|
|
3191
|
+
var ws_loop = new sequential_strategy_SequentialStrategy([ws_transport], timeouts);
|
|
3192
|
+
var wss_loop = new sequential_strategy_SequentialStrategy([wss_transport], timeouts);
|
|
3193
|
+
var sockjs_loop = new sequential_strategy_SequentialStrategy([sockjs_transport], timeouts);
|
|
3194
|
+
var streaming_loop = new sequential_strategy_SequentialStrategy([
|
|
3195
|
+
new IfStrategy(testSupportsStrategy(xhr_streaming_transport), xhr_streaming_transport, xdr_streaming_transport)
|
|
3533
3196
|
], timeouts);
|
|
3534
|
-
var polling_loop = new
|
|
3535
|
-
new
|
|
3197
|
+
var polling_loop = new sequential_strategy_SequentialStrategy([
|
|
3198
|
+
new IfStrategy(testSupportsStrategy(xhr_polling_transport), xhr_polling_transport, xdr_polling_transport)
|
|
3536
3199
|
], timeouts);
|
|
3537
|
-
var http_loop = new
|
|
3538
|
-
new
|
|
3200
|
+
var http_loop = new sequential_strategy_SequentialStrategy([
|
|
3201
|
+
new IfStrategy(testSupportsStrategy(streaming_loop), new best_connected_ever_strategy_BestConnectedEverStrategy([
|
|
3539
3202
|
streaming_loop,
|
|
3540
|
-
new
|
|
3203
|
+
new delayed_strategy_DelayedStrategy(polling_loop, { delay: 4000 })
|
|
3541
3204
|
]), polling_loop)
|
|
3542
3205
|
], timeouts);
|
|
3543
|
-
var http_fallback_loop = new
|
|
3206
|
+
var http_fallback_loop = new IfStrategy(testSupportsStrategy(http_loop), http_loop, sockjs_loop);
|
|
3544
3207
|
var wsStrategy;
|
|
3545
3208
|
if (baseOptions.useTLS) {
|
|
3546
|
-
wsStrategy = new
|
|
3209
|
+
wsStrategy = new best_connected_ever_strategy_BestConnectedEverStrategy([
|
|
3547
3210
|
ws_loop,
|
|
3548
|
-
new
|
|
3211
|
+
new delayed_strategy_DelayedStrategy(http_fallback_loop, { delay: 2000 })
|
|
3549
3212
|
]);
|
|
3550
3213
|
}
|
|
3551
3214
|
else {
|
|
3552
|
-
wsStrategy = new
|
|
3215
|
+
wsStrategy = new best_connected_ever_strategy_BestConnectedEverStrategy([
|
|
3553
3216
|
ws_loop,
|
|
3554
|
-
new
|
|
3555
|
-
new
|
|
3217
|
+
new delayed_strategy_DelayedStrategy(wss_loop, { delay: 2000 }),
|
|
3218
|
+
new delayed_strategy_DelayedStrategy(http_fallback_loop, { delay: 5000 })
|
|
3556
3219
|
]);
|
|
3557
3220
|
}
|
|
3558
|
-
return new
|
|
3221
|
+
return new cached_strategy_CachedStrategy(new FirstConnectedStrategy(new IfStrategy(testSupportsStrategy(ws_transport), wsStrategy, http_fallback_loop)), definedTransports, {
|
|
3559
3222
|
ttl: 1800000,
|
|
3560
3223
|
timeline: baseOptions.timeline,
|
|
3561
3224
|
useTLS: baseOptions.useTLS
|
|
@@ -3629,37 +3292,21 @@ var http_xdomain_request_hooks = {
|
|
|
3629
3292
|
/* harmony default export */ var http_xdomain_request = (http_xdomain_request_hooks);
|
|
3630
3293
|
|
|
3631
3294
|
// CONCATENATED MODULE: ./src/core/http/http_request.ts
|
|
3632
|
-
var http_request_extends = (undefined && undefined.__extends) || (function () {
|
|
3633
|
-
var extendStatics = function (d, b) {
|
|
3634
|
-
extendStatics = Object.setPrototypeOf ||
|
|
3635
|
-
({ __proto__: [] } instanceof Array && function (d, b) { d.__proto__ = b; }) ||
|
|
3636
|
-
function (d, b) { for (var p in b) if (b.hasOwnProperty(p)) d[p] = b[p]; };
|
|
3637
|
-
return extendStatics(d, b);
|
|
3638
|
-
};
|
|
3639
|
-
return function (d, b) {
|
|
3640
|
-
extendStatics(d, b);
|
|
3641
|
-
function __() { this.constructor = d; }
|
|
3642
|
-
d.prototype = b === null ? Object.create(b) : (__.prototype = b.prototype, new __());
|
|
3643
|
-
};
|
|
3644
|
-
})();
|
|
3645
3295
|
|
|
3646
3296
|
|
|
3647
|
-
|
|
3648
|
-
|
|
3649
|
-
|
|
3650
|
-
|
|
3651
|
-
|
|
3652
|
-
|
|
3653
|
-
|
|
3654
|
-
_this.url = url;
|
|
3655
|
-
return _this;
|
|
3297
|
+
const MAX_BUFFER_LENGTH = 256 * 1024;
|
|
3298
|
+
class http_request_HTTPRequest extends dispatcher_Dispatcher {
|
|
3299
|
+
constructor(hooks, method, url) {
|
|
3300
|
+
super();
|
|
3301
|
+
this.hooks = hooks;
|
|
3302
|
+
this.method = method;
|
|
3303
|
+
this.url = url;
|
|
3656
3304
|
}
|
|
3657
|
-
|
|
3658
|
-
var _this = this;
|
|
3305
|
+
start(payload) {
|
|
3659
3306
|
this.position = 0;
|
|
3660
3307
|
this.xhr = this.hooks.getRequest(this);
|
|
3661
|
-
this.unloader =
|
|
3662
|
-
|
|
3308
|
+
this.unloader = () => {
|
|
3309
|
+
this.close();
|
|
3663
3310
|
};
|
|
3664
3311
|
runtime.addUnloadListener(this.unloader);
|
|
3665
3312
|
this.xhr.open(this.method, this.url, true);
|
|
@@ -3667,8 +3314,8 @@ var http_request_HTTPRequest = (function (_super) {
|
|
|
3667
3314
|
this.xhr.setRequestHeader('Content-Type', 'application/json');
|
|
3668
3315
|
}
|
|
3669
3316
|
this.xhr.send(payload);
|
|
3670
|
-
}
|
|
3671
|
-
|
|
3317
|
+
}
|
|
3318
|
+
close() {
|
|
3672
3319
|
if (this.unloader) {
|
|
3673
3320
|
runtime.removeUnloadListener(this.unloader);
|
|
3674
3321
|
this.unloader = null;
|
|
@@ -3677,8 +3324,8 @@ var http_request_HTTPRequest = (function (_super) {
|
|
|
3677
3324
|
this.hooks.abortRequest(this.xhr);
|
|
3678
3325
|
this.xhr = null;
|
|
3679
3326
|
}
|
|
3680
|
-
}
|
|
3681
|
-
|
|
3327
|
+
}
|
|
3328
|
+
onChunk(status, data) {
|
|
3682
3329
|
while (true) {
|
|
3683
3330
|
var chunk = this.advanceBuffer(data);
|
|
3684
3331
|
if (chunk) {
|
|
@@ -3691,8 +3338,8 @@ var http_request_HTTPRequest = (function (_super) {
|
|
|
3691
3338
|
if (this.isBufferTooLong(data)) {
|
|
3692
3339
|
this.emit('buffer_too_long');
|
|
3693
3340
|
}
|
|
3694
|
-
}
|
|
3695
|
-
|
|
3341
|
+
}
|
|
3342
|
+
advanceBuffer(buffer) {
|
|
3696
3343
|
var unreadData = buffer.slice(this.position);
|
|
3697
3344
|
var endOfLinePosition = unreadData.indexOf('\n');
|
|
3698
3345
|
if (endOfLinePosition !== -1) {
|
|
@@ -3702,13 +3349,11 @@ var http_request_HTTPRequest = (function (_super) {
|
|
|
3702
3349
|
else {
|
|
3703
3350
|
return null;
|
|
3704
3351
|
}
|
|
3705
|
-
}
|
|
3706
|
-
|
|
3352
|
+
}
|
|
3353
|
+
isBufferTooLong(buffer) {
|
|
3707
3354
|
return this.position === buffer.length && buffer.length > MAX_BUFFER_LENGTH;
|
|
3708
|
-
}
|
|
3709
|
-
|
|
3710
|
-
}(dispatcher));
|
|
3711
|
-
/* harmony default export */ var http_request = (http_request_HTTPRequest);
|
|
3355
|
+
}
|
|
3356
|
+
}
|
|
3712
3357
|
|
|
3713
3358
|
// CONCATENATED MODULE: ./src/core/http/state.ts
|
|
3714
3359
|
var State;
|
|
@@ -3724,24 +3369,24 @@ var State;
|
|
|
3724
3369
|
|
|
3725
3370
|
|
|
3726
3371
|
var autoIncrement = 1;
|
|
3727
|
-
|
|
3728
|
-
|
|
3372
|
+
class http_socket_HTTPSocket {
|
|
3373
|
+
constructor(hooks, url) {
|
|
3729
3374
|
this.hooks = hooks;
|
|
3730
3375
|
this.session = randomNumber(1000) + '/' + randomString(8);
|
|
3731
3376
|
this.location = getLocation(url);
|
|
3732
3377
|
this.readyState = state.CONNECTING;
|
|
3733
3378
|
this.openStream();
|
|
3734
3379
|
}
|
|
3735
|
-
|
|
3380
|
+
send(payload) {
|
|
3736
3381
|
return this.sendRaw(JSON.stringify([payload]));
|
|
3737
|
-
}
|
|
3738
|
-
|
|
3382
|
+
}
|
|
3383
|
+
ping() {
|
|
3739
3384
|
this.hooks.sendHeartbeat(this);
|
|
3740
|
-
}
|
|
3741
|
-
|
|
3385
|
+
}
|
|
3386
|
+
close(code, reason) {
|
|
3742
3387
|
this.onClose(code, reason, true);
|
|
3743
|
-
}
|
|
3744
|
-
|
|
3388
|
+
}
|
|
3389
|
+
sendRaw(payload) {
|
|
3745
3390
|
if (this.readyState === state.OPEN) {
|
|
3746
3391
|
try {
|
|
3747
3392
|
runtime.createSocketRequest('POST', getUniqueURL(getSendURL(this.location, this.session))).start(payload);
|
|
@@ -3754,12 +3399,12 @@ var http_socket_HTTPSocket = (function () {
|
|
|
3754
3399
|
else {
|
|
3755
3400
|
return false;
|
|
3756
3401
|
}
|
|
3757
|
-
}
|
|
3758
|
-
|
|
3402
|
+
}
|
|
3403
|
+
reconnect() {
|
|
3759
3404
|
this.closeStream();
|
|
3760
3405
|
this.openStream();
|
|
3761
|
-
}
|
|
3762
|
-
|
|
3406
|
+
}
|
|
3407
|
+
onClose(code, reason, wasClean) {
|
|
3763
3408
|
this.closeStream();
|
|
3764
3409
|
this.readyState = state.CLOSED;
|
|
3765
3410
|
if (this.onclose) {
|
|
@@ -3769,8 +3414,8 @@ var http_socket_HTTPSocket = (function () {
|
|
|
3769
3414
|
wasClean: wasClean
|
|
3770
3415
|
});
|
|
3771
3416
|
}
|
|
3772
|
-
}
|
|
3773
|
-
|
|
3417
|
+
}
|
|
3418
|
+
onChunk(chunk) {
|
|
3774
3419
|
if (chunk.status !== 200) {
|
|
3775
3420
|
return;
|
|
3776
3421
|
}
|
|
@@ -3802,8 +3447,8 @@ var http_socket_HTTPSocket = (function () {
|
|
|
3802
3447
|
this.onClose(payload[0], payload[1], true);
|
|
3803
3448
|
break;
|
|
3804
3449
|
}
|
|
3805
|
-
}
|
|
3806
|
-
|
|
3450
|
+
}
|
|
3451
|
+
onOpen(options) {
|
|
3807
3452
|
if (this.readyState === state.CONNECTING) {
|
|
3808
3453
|
if (options && options.hostname) {
|
|
3809
3454
|
this.location.base = replaceHost(this.location.base, options.hostname);
|
|
@@ -3816,53 +3461,51 @@ var http_socket_HTTPSocket = (function () {
|
|
|
3816
3461
|
else {
|
|
3817
3462
|
this.onClose(1006, 'Server lost session', true);
|
|
3818
3463
|
}
|
|
3819
|
-
}
|
|
3820
|
-
|
|
3464
|
+
}
|
|
3465
|
+
onEvent(event) {
|
|
3821
3466
|
if (this.readyState === state.OPEN && this.onmessage) {
|
|
3822
3467
|
this.onmessage({ data: event });
|
|
3823
3468
|
}
|
|
3824
|
-
}
|
|
3825
|
-
|
|
3469
|
+
}
|
|
3470
|
+
onActivity() {
|
|
3826
3471
|
if (this.onactivity) {
|
|
3827
3472
|
this.onactivity();
|
|
3828
3473
|
}
|
|
3829
|
-
}
|
|
3830
|
-
|
|
3474
|
+
}
|
|
3475
|
+
onError(error) {
|
|
3831
3476
|
if (this.onerror) {
|
|
3832
3477
|
this.onerror(error);
|
|
3833
3478
|
}
|
|
3834
|
-
}
|
|
3835
|
-
|
|
3836
|
-
var _this = this;
|
|
3479
|
+
}
|
|
3480
|
+
openStream() {
|
|
3837
3481
|
this.stream = runtime.createSocketRequest('POST', getUniqueURL(this.hooks.getReceiveURL(this.location, this.session)));
|
|
3838
|
-
this.stream.bind('chunk',
|
|
3839
|
-
|
|
3482
|
+
this.stream.bind('chunk', chunk => {
|
|
3483
|
+
this.onChunk(chunk);
|
|
3840
3484
|
});
|
|
3841
|
-
this.stream.bind('finished',
|
|
3842
|
-
|
|
3485
|
+
this.stream.bind('finished', status => {
|
|
3486
|
+
this.hooks.onFinished(this, status);
|
|
3843
3487
|
});
|
|
3844
|
-
this.stream.bind('buffer_too_long',
|
|
3845
|
-
|
|
3488
|
+
this.stream.bind('buffer_too_long', () => {
|
|
3489
|
+
this.reconnect();
|
|
3846
3490
|
});
|
|
3847
3491
|
try {
|
|
3848
3492
|
this.stream.start();
|
|
3849
3493
|
}
|
|
3850
3494
|
catch (error) {
|
|
3851
|
-
util.defer(
|
|
3852
|
-
|
|
3853
|
-
|
|
3495
|
+
util.defer(() => {
|
|
3496
|
+
this.onError(error);
|
|
3497
|
+
this.onClose(1006, 'Could not start streaming', false);
|
|
3854
3498
|
});
|
|
3855
3499
|
}
|
|
3856
|
-
}
|
|
3857
|
-
|
|
3500
|
+
}
|
|
3501
|
+
closeStream() {
|
|
3858
3502
|
if (this.stream) {
|
|
3859
3503
|
this.stream.unbind_all();
|
|
3860
3504
|
this.stream.close();
|
|
3861
3505
|
this.stream = null;
|
|
3862
3506
|
}
|
|
3863
|
-
}
|
|
3864
|
-
|
|
3865
|
-
}());
|
|
3507
|
+
}
|
|
3508
|
+
}
|
|
3866
3509
|
function getLocation(url) {
|
|
3867
3510
|
var parts = /([^\?]*)\/*(\??.*)/.exec(url);
|
|
3868
3511
|
return {
|
|
@@ -3969,20 +3612,20 @@ var http_xhr_request_hooks = {
|
|
|
3969
3612
|
|
|
3970
3613
|
|
|
3971
3614
|
var HTTP = {
|
|
3972
|
-
createStreamingSocket
|
|
3615
|
+
createStreamingSocket(url) {
|
|
3973
3616
|
return this.createSocket(http_streaming_socket, url);
|
|
3974
3617
|
},
|
|
3975
|
-
createPollingSocket
|
|
3618
|
+
createPollingSocket(url) {
|
|
3976
3619
|
return this.createSocket(http_polling_socket, url);
|
|
3977
3620
|
},
|
|
3978
|
-
createSocket
|
|
3621
|
+
createSocket(hooks, url) {
|
|
3979
3622
|
return new http_socket(hooks, url);
|
|
3980
3623
|
},
|
|
3981
|
-
createXHR
|
|
3624
|
+
createXHR(method, url) {
|
|
3982
3625
|
return this.createRequest(http_xhr_request, method, url);
|
|
3983
3626
|
},
|
|
3984
|
-
createRequest
|
|
3985
|
-
return new
|
|
3627
|
+
createRequest(hooks, method, url) {
|
|
3628
|
+
return new http_request_HTTPRequest(hooks, method, url);
|
|
3986
3629
|
}
|
|
3987
3630
|
};
|
|
3988
3631
|
/* harmony default export */ var http_http = (HTTP);
|
|
@@ -4018,17 +3661,16 @@ var Runtime = {
|
|
|
4018
3661
|
transportConnectionInitializer: transport_connection_initializer,
|
|
4019
3662
|
HTTPFactory: web_http_http,
|
|
4020
3663
|
TimelineTransport: jsonp_timeline,
|
|
4021
|
-
getXHRAPI
|
|
3664
|
+
getXHRAPI() {
|
|
4022
3665
|
return window.XMLHttpRequest;
|
|
4023
3666
|
},
|
|
4024
|
-
getWebSocketAPI
|
|
3667
|
+
getWebSocketAPI() {
|
|
4025
3668
|
return window.WebSocket || window.MozWebSocket;
|
|
4026
3669
|
},
|
|
4027
|
-
setup
|
|
4028
|
-
var _this = this;
|
|
3670
|
+
setup(PusherClass) {
|
|
4029
3671
|
window.Pusher = PusherClass;
|
|
4030
|
-
var initializeOnDocumentBody =
|
|
4031
|
-
|
|
3672
|
+
var initializeOnDocumentBody = () => {
|
|
3673
|
+
this.onDocumentBody(PusherClass.ready);
|
|
4032
3674
|
};
|
|
4033
3675
|
if (!window.JSON) {
|
|
4034
3676
|
Dependencies.load('json2', {}, initializeOnDocumentBody);
|
|
@@ -4037,33 +3679,32 @@ var Runtime = {
|
|
|
4037
3679
|
initializeOnDocumentBody();
|
|
4038
3680
|
}
|
|
4039
3681
|
},
|
|
4040
|
-
getDocument
|
|
3682
|
+
getDocument() {
|
|
4041
3683
|
return document;
|
|
4042
3684
|
},
|
|
4043
|
-
getProtocol
|
|
3685
|
+
getProtocol() {
|
|
4044
3686
|
return this.getDocument().location.protocol;
|
|
4045
3687
|
},
|
|
4046
|
-
getAuthorizers
|
|
3688
|
+
getAuthorizers() {
|
|
4047
3689
|
return { ajax: xhr_auth, jsonp: jsonp_auth };
|
|
4048
3690
|
},
|
|
4049
|
-
onDocumentBody
|
|
4050
|
-
var _this = this;
|
|
3691
|
+
onDocumentBody(callback) {
|
|
4051
3692
|
if (document.body) {
|
|
4052
3693
|
callback();
|
|
4053
3694
|
}
|
|
4054
3695
|
else {
|
|
4055
|
-
setTimeout(
|
|
4056
|
-
|
|
3696
|
+
setTimeout(() => {
|
|
3697
|
+
this.onDocumentBody(callback);
|
|
4057
3698
|
}, 0);
|
|
4058
3699
|
}
|
|
4059
3700
|
},
|
|
4060
|
-
createJSONPRequest
|
|
4061
|
-
return new
|
|
3701
|
+
createJSONPRequest(url, data) {
|
|
3702
|
+
return new jsonp_request_JSONPRequest(url, data);
|
|
4062
3703
|
},
|
|
4063
|
-
createScriptRequest
|
|
4064
|
-
return new
|
|
3704
|
+
createScriptRequest(src) {
|
|
3705
|
+
return new ScriptRequest(src);
|
|
4065
3706
|
},
|
|
4066
|
-
getLocalStorage
|
|
3707
|
+
getLocalStorage() {
|
|
4067
3708
|
try {
|
|
4068
3709
|
return window.localStorage;
|
|
4069
3710
|
}
|
|
@@ -4071,7 +3712,7 @@ var Runtime = {
|
|
|
4071
3712
|
return undefined;
|
|
4072
3713
|
}
|
|
4073
3714
|
},
|
|
4074
|
-
createXHR
|
|
3715
|
+
createXHR() {
|
|
4075
3716
|
if (this.getXHRAPI()) {
|
|
4076
3717
|
return this.createXMLHttpRequest();
|
|
4077
3718
|
}
|
|
@@ -4079,21 +3720,21 @@ var Runtime = {
|
|
|
4079
3720
|
return this.createMicrosoftXHR();
|
|
4080
3721
|
}
|
|
4081
3722
|
},
|
|
4082
|
-
createXMLHttpRequest
|
|
3723
|
+
createXMLHttpRequest() {
|
|
4083
3724
|
var Constructor = this.getXHRAPI();
|
|
4084
3725
|
return new Constructor();
|
|
4085
3726
|
},
|
|
4086
|
-
createMicrosoftXHR
|
|
3727
|
+
createMicrosoftXHR() {
|
|
4087
3728
|
return new ActiveXObject('Microsoft.XMLHTTP');
|
|
4088
3729
|
},
|
|
4089
|
-
getNetwork
|
|
3730
|
+
getNetwork() {
|
|
4090
3731
|
return net_info_Network;
|
|
4091
3732
|
},
|
|
4092
|
-
createWebSocket
|
|
3733
|
+
createWebSocket(url) {
|
|
4093
3734
|
var Constructor = this.getWebSocketAPI();
|
|
4094
3735
|
return new Constructor(url);
|
|
4095
3736
|
},
|
|
4096
|
-
createSocketRequest
|
|
3737
|
+
createSocketRequest(method, url) {
|
|
4097
3738
|
if (this.isXHRSupported()) {
|
|
4098
3739
|
return this.HTTPFactory.createXHR(method, url);
|
|
4099
3740
|
}
|
|
@@ -4104,16 +3745,16 @@ var Runtime = {
|
|
|
4104
3745
|
throw 'Cross-origin HTTP requests are not supported';
|
|
4105
3746
|
}
|
|
4106
3747
|
},
|
|
4107
|
-
isXHRSupported
|
|
3748
|
+
isXHRSupported() {
|
|
4108
3749
|
var Constructor = this.getXHRAPI();
|
|
4109
3750
|
return (Boolean(Constructor) && new Constructor().withCredentials !== undefined);
|
|
4110
3751
|
},
|
|
4111
|
-
isXDRSupported
|
|
3752
|
+
isXDRSupported(useTLS) {
|
|
4112
3753
|
var protocol = useTLS ? 'https:' : 'http:';
|
|
4113
3754
|
var documentProtocol = this.getProtocol();
|
|
4114
3755
|
return (Boolean(window['XDomainRequest']) && documentProtocol === protocol);
|
|
4115
3756
|
},
|
|
4116
|
-
addUnloadListener
|
|
3757
|
+
addUnloadListener(listener) {
|
|
4117
3758
|
if (window.addEventListener !== undefined) {
|
|
4118
3759
|
window.addEventListener('unload', listener, false);
|
|
4119
3760
|
}
|
|
@@ -4121,7 +3762,7 @@ var Runtime = {
|
|
|
4121
3762
|
window.attachEvent('onunload', listener);
|
|
4122
3763
|
}
|
|
4123
3764
|
},
|
|
4124
|
-
removeUnloadListener
|
|
3765
|
+
removeUnloadListener(listener) {
|
|
4125
3766
|
if (window.addEventListener !== undefined) {
|
|
4126
3767
|
window.removeEventListener('unload', listener, false);
|
|
4127
3768
|
}
|
|
@@ -4129,10 +3770,10 @@ var Runtime = {
|
|
|
4129
3770
|
window.detachEvent('onunload', listener);
|
|
4130
3771
|
}
|
|
4131
3772
|
},
|
|
4132
|
-
randomInt
|
|
4133
|
-
|
|
4134
|
-
|
|
4135
|
-
|
|
3773
|
+
randomInt(max) {
|
|
3774
|
+
const random = function () {
|
|
3775
|
+
const crypto = window.crypto || window['msCrypto'];
|
|
3776
|
+
const random = crypto.getRandomValues(new Uint32Array(1))[0];
|
|
4136
3777
|
return random / Math.pow(2, 32);
|
|
4137
3778
|
};
|
|
4138
3779
|
return Math.floor(random() * max);
|
|
@@ -4153,8 +3794,8 @@ var TimelineLevel;
|
|
|
4153
3794
|
|
|
4154
3795
|
|
|
4155
3796
|
|
|
4156
|
-
|
|
4157
|
-
|
|
3797
|
+
class timeline_Timeline {
|
|
3798
|
+
constructor(key, session, options) {
|
|
4158
3799
|
this.key = key;
|
|
4159
3800
|
this.session = session;
|
|
4160
3801
|
this.events = [];
|
|
@@ -4162,28 +3803,27 @@ var timeline_Timeline = (function () {
|
|
|
4162
3803
|
this.sent = 0;
|
|
4163
3804
|
this.uniqueID = 0;
|
|
4164
3805
|
}
|
|
4165
|
-
|
|
3806
|
+
log(level, event) {
|
|
4166
3807
|
if (level <= this.options.level) {
|
|
4167
3808
|
this.events.push(extend({}, event, { timestamp: util.now() }));
|
|
4168
3809
|
if (this.options.limit && this.events.length > this.options.limit) {
|
|
4169
3810
|
this.events.shift();
|
|
4170
3811
|
}
|
|
4171
3812
|
}
|
|
4172
|
-
}
|
|
4173
|
-
|
|
3813
|
+
}
|
|
3814
|
+
error(event) {
|
|
4174
3815
|
this.log(timeline_level.ERROR, event);
|
|
4175
|
-
}
|
|
4176
|
-
|
|
3816
|
+
}
|
|
3817
|
+
info(event) {
|
|
4177
3818
|
this.log(timeline_level.INFO, event);
|
|
4178
|
-
}
|
|
4179
|
-
|
|
3819
|
+
}
|
|
3820
|
+
debug(event) {
|
|
4180
3821
|
this.log(timeline_level.DEBUG, event);
|
|
4181
|
-
}
|
|
4182
|
-
|
|
3822
|
+
}
|
|
3823
|
+
isEmpty() {
|
|
4183
3824
|
return this.events.length === 0;
|
|
4184
|
-
}
|
|
4185
|
-
|
|
4186
|
-
var _this = this;
|
|
3825
|
+
}
|
|
3826
|
+
send(sendfn, callback) {
|
|
4187
3827
|
var data = extend({
|
|
4188
3828
|
session: this.session,
|
|
4189
3829
|
bundle: this.sent + 1,
|
|
@@ -4195,43 +3835,40 @@ var timeline_Timeline = (function () {
|
|
|
4195
3835
|
timeline: this.events
|
|
4196
3836
|
}, this.options.params);
|
|
4197
3837
|
this.events = [];
|
|
4198
|
-
sendfn(data,
|
|
3838
|
+
sendfn(data, (error, result) => {
|
|
4199
3839
|
if (!error) {
|
|
4200
|
-
|
|
3840
|
+
this.sent++;
|
|
4201
3841
|
}
|
|
4202
3842
|
if (callback) {
|
|
4203
3843
|
callback(error, result);
|
|
4204
3844
|
}
|
|
4205
3845
|
});
|
|
4206
3846
|
return true;
|
|
4207
|
-
}
|
|
4208
|
-
|
|
3847
|
+
}
|
|
3848
|
+
generateUniqueID() {
|
|
4209
3849
|
this.uniqueID++;
|
|
4210
3850
|
return this.uniqueID;
|
|
4211
|
-
}
|
|
4212
|
-
|
|
4213
|
-
}());
|
|
4214
|
-
/* harmony default export */ var timeline_timeline = (timeline_Timeline);
|
|
3851
|
+
}
|
|
3852
|
+
}
|
|
4215
3853
|
|
|
4216
3854
|
// CONCATENATED MODULE: ./src/core/strategies/transport_strategy.ts
|
|
4217
3855
|
|
|
4218
3856
|
|
|
4219
3857
|
|
|
4220
3858
|
|
|
4221
|
-
|
|
4222
|
-
|
|
3859
|
+
class transport_strategy_TransportStrategy {
|
|
3860
|
+
constructor(name, priority, transport, options) {
|
|
4223
3861
|
this.name = name;
|
|
4224
3862
|
this.priority = priority;
|
|
4225
3863
|
this.transport = transport;
|
|
4226
3864
|
this.options = options || {};
|
|
4227
3865
|
}
|
|
4228
|
-
|
|
3866
|
+
isSupported() {
|
|
4229
3867
|
return this.transport.isSupported({
|
|
4230
3868
|
useTLS: this.options.useTLS
|
|
4231
3869
|
});
|
|
4232
|
-
}
|
|
4233
|
-
|
|
4234
|
-
var _this = this;
|
|
3870
|
+
}
|
|
3871
|
+
connect(minPriority, callback) {
|
|
4235
3872
|
if (!this.isSupported()) {
|
|
4236
3873
|
return failAttempt(new UnsupportedStrategy(), callback);
|
|
4237
3874
|
}
|
|
@@ -4274,7 +3911,7 @@ var transport_strategy_TransportStrategy = (function () {
|
|
|
4274
3911
|
transport.bind('closed', onClosed);
|
|
4275
3912
|
transport.initialize();
|
|
4276
3913
|
return {
|
|
4277
|
-
abort:
|
|
3914
|
+
abort: () => {
|
|
4278
3915
|
if (connected) {
|
|
4279
3916
|
return;
|
|
4280
3917
|
}
|
|
@@ -4286,11 +3923,11 @@ var transport_strategy_TransportStrategy = (function () {
|
|
|
4286
3923
|
transport.close();
|
|
4287
3924
|
}
|
|
4288
3925
|
},
|
|
4289
|
-
forceMinPriority:
|
|
3926
|
+
forceMinPriority: p => {
|
|
4290
3927
|
if (connected) {
|
|
4291
3928
|
return;
|
|
4292
3929
|
}
|
|
4293
|
-
if (
|
|
3930
|
+
if (this.priority < p) {
|
|
4294
3931
|
if (handshake) {
|
|
4295
3932
|
handshake.close();
|
|
4296
3933
|
}
|
|
@@ -4300,10 +3937,8 @@ var transport_strategy_TransportStrategy = (function () {
|
|
|
4300
3937
|
}
|
|
4301
3938
|
}
|
|
4302
3939
|
};
|
|
4303
|
-
}
|
|
4304
|
-
|
|
4305
|
-
}());
|
|
4306
|
-
/* harmony default export */ var transport_strategy = (transport_strategy_TransportStrategy);
|
|
3940
|
+
}
|
|
3941
|
+
}
|
|
4307
3942
|
function failAttempt(error, callback) {
|
|
4308
3943
|
util.defer(function () {
|
|
4309
3944
|
callback(error);
|
|
@@ -4320,7 +3955,7 @@ function failAttempt(error, callback) {
|
|
|
4320
3955
|
|
|
4321
3956
|
|
|
4322
3957
|
|
|
4323
|
-
|
|
3958
|
+
const { Transports: strategy_builder_Transports } = runtime;
|
|
4324
3959
|
var strategy_builder_defineTransport = function (config, name, type, priority, options, manager) {
|
|
4325
3960
|
var transportClass = strategy_builder_Transports[type];
|
|
4326
3961
|
if (!transportClass) {
|
|
@@ -4333,7 +3968,7 @@ var strategy_builder_defineTransport = function (config, name, type, priority, o
|
|
|
4333
3968
|
var transport;
|
|
4334
3969
|
if (enabled) {
|
|
4335
3970
|
options = Object.assign({ ignoreNullOrigin: config.ignoreNullOrigin }, options);
|
|
4336
|
-
transport = new
|
|
3971
|
+
transport = new transport_strategy_TransportStrategy(name, priority, manager ? manager.getAssistant(transportClass) : transportClass, options);
|
|
4337
3972
|
}
|
|
4338
3973
|
else {
|
|
4339
3974
|
transport = strategy_builder_UnsupportedStrategy;
|
|
@@ -4374,7 +4009,7 @@ function validateOptions(options) {
|
|
|
4374
4009
|
// CONCATENATED MODULE: ./src/core/auth/user_authenticator.ts
|
|
4375
4010
|
|
|
4376
4011
|
|
|
4377
|
-
|
|
4012
|
+
const composeChannelQuery = (params, authOptions) => {
|
|
4378
4013
|
var query = 'socket_id=' + encodeURIComponent(params.socketId);
|
|
4379
4014
|
for (var key in authOptions.params) {
|
|
4380
4015
|
query +=
|
|
@@ -4384,7 +4019,7 @@ var composeChannelQuery = function (params, authOptions) {
|
|
|
4384
4019
|
encodeURIComponent(authOptions.params[key]);
|
|
4385
4020
|
}
|
|
4386
4021
|
if (authOptions.paramsProvider != null) {
|
|
4387
|
-
|
|
4022
|
+
let dynamicParams = authOptions.paramsProvider();
|
|
4388
4023
|
for (var key in dynamicParams) {
|
|
4389
4024
|
query +=
|
|
4390
4025
|
'&' +
|
|
@@ -4395,12 +4030,12 @@ var composeChannelQuery = function (params, authOptions) {
|
|
|
4395
4030
|
}
|
|
4396
4031
|
return query;
|
|
4397
4032
|
};
|
|
4398
|
-
|
|
4033
|
+
const UserAuthenticator = (authOptions) => {
|
|
4399
4034
|
if (typeof runtime.getAuthorizers()[authOptions.transport] === 'undefined') {
|
|
4400
|
-
throw
|
|
4035
|
+
throw `'${authOptions.transport}' is not a recognized auth transport`;
|
|
4401
4036
|
}
|
|
4402
|
-
return
|
|
4403
|
-
|
|
4037
|
+
return (params, callback) => {
|
|
4038
|
+
const query = composeChannelQuery(params, authOptions);
|
|
4404
4039
|
runtime.getAuthorizers()[authOptions.transport](runtime, query, authOptions, AuthRequestType.UserAuthentication, callback);
|
|
4405
4040
|
};
|
|
4406
4041
|
};
|
|
@@ -4409,7 +4044,7 @@ var UserAuthenticator = function (authOptions) {
|
|
|
4409
4044
|
// CONCATENATED MODULE: ./src/core/auth/channel_authorizer.ts
|
|
4410
4045
|
|
|
4411
4046
|
|
|
4412
|
-
|
|
4047
|
+
const channel_authorizer_composeChannelQuery = (params, authOptions) => {
|
|
4413
4048
|
var query = 'socket_id=' + encodeURIComponent(params.socketId);
|
|
4414
4049
|
query += '&channel_name=' + encodeURIComponent(params.channelName);
|
|
4415
4050
|
for (var key in authOptions.params) {
|
|
@@ -4420,7 +4055,7 @@ var channel_authorizer_composeChannelQuery = function (params, authOptions) {
|
|
|
4420
4055
|
encodeURIComponent(authOptions.params[key]);
|
|
4421
4056
|
}
|
|
4422
4057
|
if (authOptions.paramsProvider != null) {
|
|
4423
|
-
|
|
4058
|
+
let dynamicParams = authOptions.paramsProvider();
|
|
4424
4059
|
for (var key in dynamicParams) {
|
|
4425
4060
|
query +=
|
|
4426
4061
|
'&' +
|
|
@@ -4431,20 +4066,20 @@ var channel_authorizer_composeChannelQuery = function (params, authOptions) {
|
|
|
4431
4066
|
}
|
|
4432
4067
|
return query;
|
|
4433
4068
|
};
|
|
4434
|
-
|
|
4069
|
+
const ChannelAuthorizer = (authOptions) => {
|
|
4435
4070
|
if (typeof runtime.getAuthorizers()[authOptions.transport] === 'undefined') {
|
|
4436
|
-
throw
|
|
4071
|
+
throw `'${authOptions.transport}' is not a recognized auth transport`;
|
|
4437
4072
|
}
|
|
4438
|
-
return
|
|
4439
|
-
|
|
4073
|
+
return (params, callback) => {
|
|
4074
|
+
const query = channel_authorizer_composeChannelQuery(params, authOptions);
|
|
4440
4075
|
runtime.getAuthorizers()[authOptions.transport](runtime, query, authOptions, AuthRequestType.ChannelAuthorization, callback);
|
|
4441
4076
|
};
|
|
4442
4077
|
};
|
|
4443
4078
|
/* harmony default export */ var channel_authorizer = (ChannelAuthorizer);
|
|
4444
4079
|
|
|
4445
4080
|
// CONCATENATED MODULE: ./src/core/auth/deprecated_channel_authorizer.ts
|
|
4446
|
-
|
|
4447
|
-
|
|
4081
|
+
const ChannelAuthorizerProxy = (pusher, authOptions, channelAuthorizerGenerator) => {
|
|
4082
|
+
const deprecatedAuthorizerOptions = {
|
|
4448
4083
|
authTransport: authOptions.transport,
|
|
4449
4084
|
authEndpoint: authOptions.endpoint,
|
|
4450
4085
|
auth: {
|
|
@@ -4452,32 +4087,21 @@ var ChannelAuthorizerProxy = function (pusher, authOptions, channelAuthorizerGen
|
|
|
4452
4087
|
headers: authOptions.headers
|
|
4453
4088
|
}
|
|
4454
4089
|
};
|
|
4455
|
-
return
|
|
4456
|
-
|
|
4457
|
-
|
|
4090
|
+
return (params, callback) => {
|
|
4091
|
+
const channel = pusher.channel(params.channelName);
|
|
4092
|
+
const channelAuthorizer = channelAuthorizerGenerator(channel, deprecatedAuthorizerOptions);
|
|
4458
4093
|
channelAuthorizer.authorize(params.socketId, callback);
|
|
4459
4094
|
};
|
|
4460
4095
|
};
|
|
4461
4096
|
|
|
4462
4097
|
// CONCATENATED MODULE: ./src/core/config.ts
|
|
4463
|
-
var __assign = (undefined && undefined.__assign) || function () {
|
|
4464
|
-
__assign = Object.assign || function(t) {
|
|
4465
|
-
for (var s, i = 1, n = arguments.length; i < n; i++) {
|
|
4466
|
-
s = arguments[i];
|
|
4467
|
-
for (var p in s) if (Object.prototype.hasOwnProperty.call(s, p))
|
|
4468
|
-
t[p] = s[p];
|
|
4469
|
-
}
|
|
4470
|
-
return t;
|
|
4471
|
-
};
|
|
4472
|
-
return __assign.apply(this, arguments);
|
|
4473
|
-
};
|
|
4474
4098
|
|
|
4475
4099
|
|
|
4476
4100
|
|
|
4477
4101
|
|
|
4478
4102
|
|
|
4479
4103
|
function getConfig(opts, pusher) {
|
|
4480
|
-
|
|
4104
|
+
let config = {
|
|
4481
4105
|
activityTimeout: opts.activityTimeout || defaults.activityTimeout,
|
|
4482
4106
|
cluster: opts.cluster,
|
|
4483
4107
|
httpPath: opts.httpPath || defaults.httpPath,
|
|
@@ -4514,7 +4138,7 @@ function getHttpHost(opts) {
|
|
|
4514
4138
|
return opts.httpHost;
|
|
4515
4139
|
}
|
|
4516
4140
|
if (opts.cluster) {
|
|
4517
|
-
return
|
|
4141
|
+
return `sockjs-${opts.cluster}.pusher.com`;
|
|
4518
4142
|
}
|
|
4519
4143
|
return defaults.httpHost;
|
|
4520
4144
|
}
|
|
@@ -4525,7 +4149,7 @@ function getWebsocketHost(opts) {
|
|
|
4525
4149
|
return getWebsocketHostFromCluster(opts.cluster);
|
|
4526
4150
|
}
|
|
4527
4151
|
function getWebsocketHostFromCluster(cluster) {
|
|
4528
|
-
return
|
|
4152
|
+
return `ws-${cluster}.pusher.com`;
|
|
4529
4153
|
}
|
|
4530
4154
|
function shouldUseTLS(opts) {
|
|
4531
4155
|
if (runtime.getProtocol() === 'https:') {
|
|
@@ -4546,7 +4170,7 @@ function getEnableStatsConfig(opts) {
|
|
|
4546
4170
|
return false;
|
|
4547
4171
|
}
|
|
4548
4172
|
function buildUserAuthenticator(opts) {
|
|
4549
|
-
|
|
4173
|
+
const userAuthentication = Object.assign(Object.assign({}, defaults.userAuthentication), opts.userAuthentication);
|
|
4550
4174
|
if ('customHandler' in userAuthentication &&
|
|
4551
4175
|
userAuthentication['customHandler'] != null) {
|
|
4552
4176
|
return userAuthentication['customHandler'];
|
|
@@ -4554,9 +4178,9 @@ function buildUserAuthenticator(opts) {
|
|
|
4554
4178
|
return user_authenticator(userAuthentication);
|
|
4555
4179
|
}
|
|
4556
4180
|
function buildChannelAuth(opts, pusher) {
|
|
4557
|
-
|
|
4181
|
+
let channelAuthorization;
|
|
4558
4182
|
if ('channelAuthorization' in opts) {
|
|
4559
|
-
channelAuthorization =
|
|
4183
|
+
channelAuthorization = Object.assign(Object.assign({}, defaults.channelAuthorization), opts.channelAuthorization);
|
|
4560
4184
|
}
|
|
4561
4185
|
else {
|
|
4562
4186
|
channelAuthorization = {
|
|
@@ -4575,7 +4199,7 @@ function buildChannelAuth(opts, pusher) {
|
|
|
4575
4199
|
return channelAuthorization;
|
|
4576
4200
|
}
|
|
4577
4201
|
function buildChannelAuthorizer(opts, pusher) {
|
|
4578
|
-
|
|
4202
|
+
const channelAuthorization = buildChannelAuth(opts, pusher);
|
|
4579
4203
|
if ('customHandler' in channelAuthorization &&
|
|
4580
4204
|
channelAuthorization['customHandler'] != null) {
|
|
4581
4205
|
return channelAuthorization['customHandler'];
|
|
@@ -4584,134 +4208,99 @@ function buildChannelAuthorizer(opts, pusher) {
|
|
|
4584
4208
|
}
|
|
4585
4209
|
|
|
4586
4210
|
// CONCATENATED MODULE: ./src/core/watchlist.ts
|
|
4587
|
-
var watchlist_extends = (undefined && undefined.__extends) || (function () {
|
|
4588
|
-
var extendStatics = function (d, b) {
|
|
4589
|
-
extendStatics = Object.setPrototypeOf ||
|
|
4590
|
-
({ __proto__: [] } instanceof Array && function (d, b) { d.__proto__ = b; }) ||
|
|
4591
|
-
function (d, b) { for (var p in b) if (b.hasOwnProperty(p)) d[p] = b[p]; };
|
|
4592
|
-
return extendStatics(d, b);
|
|
4593
|
-
};
|
|
4594
|
-
return function (d, b) {
|
|
4595
|
-
extendStatics(d, b);
|
|
4596
|
-
function __() { this.constructor = d; }
|
|
4597
|
-
d.prototype = b === null ? Object.create(b) : (__.prototype = b.prototype, new __());
|
|
4598
|
-
};
|
|
4599
|
-
})();
|
|
4600
4211
|
|
|
4601
4212
|
|
|
4602
|
-
|
|
4603
|
-
|
|
4604
|
-
|
|
4605
|
-
|
|
4606
|
-
logger.debug("No callbacks on watchlist events for " + eventName);
|
|
4607
|
-
}) || this;
|
|
4608
|
-
_this.pusher = pusher;
|
|
4609
|
-
_this.bindWatchlistInternalEvent();
|
|
4610
|
-
return _this;
|
|
4611
|
-
}
|
|
4612
|
-
WatchlistFacade.prototype.handleEvent = function (pusherEvent) {
|
|
4613
|
-
var _this = this;
|
|
4614
|
-
pusherEvent.data.events.forEach(function (watchlistEvent) {
|
|
4615
|
-
_this.emit(watchlistEvent.name, watchlistEvent);
|
|
4213
|
+
class watchlist_WatchlistFacade extends dispatcher_Dispatcher {
|
|
4214
|
+
constructor(pusher) {
|
|
4215
|
+
super(function (eventName, data) {
|
|
4216
|
+
logger.debug(`No callbacks on watchlist events for ${eventName}`);
|
|
4616
4217
|
});
|
|
4617
|
-
|
|
4618
|
-
|
|
4619
|
-
|
|
4620
|
-
|
|
4218
|
+
this.pusher = pusher;
|
|
4219
|
+
this.bindWatchlistInternalEvent();
|
|
4220
|
+
}
|
|
4221
|
+
handleEvent(pusherEvent) {
|
|
4222
|
+
pusherEvent.data.events.forEach(watchlistEvent => {
|
|
4223
|
+
this.emit(watchlistEvent.name, watchlistEvent);
|
|
4224
|
+
});
|
|
4225
|
+
}
|
|
4226
|
+
bindWatchlistInternalEvent() {
|
|
4227
|
+
this.pusher.connection.bind('message', pusherEvent => {
|
|
4621
4228
|
var eventName = pusherEvent.event;
|
|
4622
4229
|
if (eventName === 'pusher_internal:watchlist_events') {
|
|
4623
|
-
|
|
4230
|
+
this.handleEvent(pusherEvent);
|
|
4624
4231
|
}
|
|
4625
4232
|
});
|
|
4626
|
-
}
|
|
4627
|
-
|
|
4628
|
-
}(dispatcher));
|
|
4629
|
-
/* harmony default export */ var watchlist = (watchlist_WatchlistFacade);
|
|
4233
|
+
}
|
|
4234
|
+
}
|
|
4630
4235
|
|
|
4631
4236
|
// CONCATENATED MODULE: ./src/core/utils/flat_promise.ts
|
|
4632
4237
|
function flatPromise() {
|
|
4633
|
-
|
|
4634
|
-
|
|
4238
|
+
let resolve, reject;
|
|
4239
|
+
const promise = new Promise((res, rej) => {
|
|
4635
4240
|
resolve = res;
|
|
4636
4241
|
reject = rej;
|
|
4637
4242
|
});
|
|
4638
|
-
return { promise
|
|
4243
|
+
return { promise, resolve, reject };
|
|
4639
4244
|
}
|
|
4640
4245
|
/* harmony default export */ var flat_promise = (flatPromise);
|
|
4641
4246
|
|
|
4642
4247
|
// CONCATENATED MODULE: ./src/core/user.ts
|
|
4643
|
-
var user_extends = (undefined && undefined.__extends) || (function () {
|
|
4644
|
-
var extendStatics = function (d, b) {
|
|
4645
|
-
extendStatics = Object.setPrototypeOf ||
|
|
4646
|
-
({ __proto__: [] } instanceof Array && function (d, b) { d.__proto__ = b; }) ||
|
|
4647
|
-
function (d, b) { for (var p in b) if (b.hasOwnProperty(p)) d[p] = b[p]; };
|
|
4648
|
-
return extendStatics(d, b);
|
|
4649
|
-
};
|
|
4650
|
-
return function (d, b) {
|
|
4651
|
-
extendStatics(d, b);
|
|
4652
|
-
function __() { this.constructor = d; }
|
|
4653
|
-
d.prototype = b === null ? Object.create(b) : (__.prototype = b.prototype, new __());
|
|
4654
|
-
};
|
|
4655
|
-
})();
|
|
4656
4248
|
|
|
4657
4249
|
|
|
4658
4250
|
|
|
4659
4251
|
|
|
4660
4252
|
|
|
4661
|
-
|
|
4662
|
-
|
|
4663
|
-
|
|
4664
|
-
var _this = _super.call(this, function (eventName, data) {
|
|
4253
|
+
class user_UserFacade extends dispatcher_Dispatcher {
|
|
4254
|
+
constructor(pusher) {
|
|
4255
|
+
super(function (eventName, data) {
|
|
4665
4256
|
logger.debug('No callbacks on user for ' + eventName);
|
|
4666
|
-
})
|
|
4667
|
-
|
|
4668
|
-
|
|
4669
|
-
|
|
4670
|
-
|
|
4671
|
-
|
|
4672
|
-
|
|
4257
|
+
});
|
|
4258
|
+
this.signin_requested = false;
|
|
4259
|
+
this.user_data = null;
|
|
4260
|
+
this.serverToUserChannel = null;
|
|
4261
|
+
this.signinDonePromise = null;
|
|
4262
|
+
this._signinDoneResolve = null;
|
|
4263
|
+
this._onAuthorize = (err, authData) => {
|
|
4673
4264
|
if (err) {
|
|
4674
|
-
logger.warn(
|
|
4675
|
-
|
|
4265
|
+
logger.warn(`Error during signin: ${err}`);
|
|
4266
|
+
this._cleanup();
|
|
4676
4267
|
return;
|
|
4677
4268
|
}
|
|
4678
|
-
|
|
4269
|
+
this.pusher.send_event('pusher:signin', {
|
|
4679
4270
|
auth: authData.auth,
|
|
4680
4271
|
user_data: authData.user_data
|
|
4681
4272
|
});
|
|
4682
4273
|
};
|
|
4683
|
-
|
|
4684
|
-
|
|
4685
|
-
var previous = _a.previous, current = _a.current;
|
|
4274
|
+
this.pusher = pusher;
|
|
4275
|
+
this.pusher.connection.bind('state_change', ({ previous, current }) => {
|
|
4686
4276
|
if (previous !== 'connected' && current === 'connected') {
|
|
4687
|
-
|
|
4277
|
+
this._signin();
|
|
4688
4278
|
}
|
|
4689
4279
|
if (previous === 'connected' && current !== 'connected') {
|
|
4690
|
-
|
|
4691
|
-
|
|
4280
|
+
this._cleanup();
|
|
4281
|
+
this._newSigninPromiseIfNeeded();
|
|
4692
4282
|
}
|
|
4693
4283
|
});
|
|
4694
|
-
|
|
4695
|
-
|
|
4284
|
+
this.watchlist = new watchlist_WatchlistFacade(pusher);
|
|
4285
|
+
this.pusher.connection.bind('message', event => {
|
|
4696
4286
|
var eventName = event.event;
|
|
4697
4287
|
if (eventName === 'pusher:signin_success') {
|
|
4698
|
-
|
|
4288
|
+
this._onSigninSuccess(event.data);
|
|
4699
4289
|
}
|
|
4700
|
-
if (
|
|
4701
|
-
|
|
4702
|
-
|
|
4290
|
+
if (this.serverToUserChannel &&
|
|
4291
|
+
this.serverToUserChannel.name === event.channel) {
|
|
4292
|
+
this.serverToUserChannel.handleEvent(event);
|
|
4703
4293
|
}
|
|
4704
4294
|
});
|
|
4705
|
-
return _this;
|
|
4706
4295
|
}
|
|
4707
|
-
|
|
4296
|
+
signin() {
|
|
4708
4297
|
if (this.signin_requested) {
|
|
4709
4298
|
return;
|
|
4710
4299
|
}
|
|
4711
4300
|
this.signin_requested = true;
|
|
4712
4301
|
this._signin();
|
|
4713
|
-
}
|
|
4714
|
-
|
|
4302
|
+
}
|
|
4303
|
+
_signin() {
|
|
4715
4304
|
if (!this.signin_requested) {
|
|
4716
4305
|
return;
|
|
4717
4306
|
}
|
|
@@ -4722,46 +4311,45 @@ var user_UserFacade = (function (_super) {
|
|
|
4722
4311
|
this.pusher.config.userAuthenticator({
|
|
4723
4312
|
socketId: this.pusher.connection.socket_id
|
|
4724
4313
|
}, this._onAuthorize);
|
|
4725
|
-
}
|
|
4726
|
-
|
|
4314
|
+
}
|
|
4315
|
+
_onSigninSuccess(data) {
|
|
4727
4316
|
try {
|
|
4728
4317
|
this.user_data = JSON.parse(data.user_data);
|
|
4729
4318
|
}
|
|
4730
4319
|
catch (e) {
|
|
4731
|
-
logger.error(
|
|
4320
|
+
logger.error(`Failed parsing user data after signin: ${data.user_data}`);
|
|
4732
4321
|
this._cleanup();
|
|
4733
4322
|
return;
|
|
4734
4323
|
}
|
|
4735
4324
|
if (typeof this.user_data.id !== 'string' || this.user_data.id === '') {
|
|
4736
|
-
logger.error(
|
|
4325
|
+
logger.error(`user_data doesn't contain an id. user_data: ${this.user_data}`);
|
|
4737
4326
|
this._cleanup();
|
|
4738
4327
|
return;
|
|
4739
4328
|
}
|
|
4740
4329
|
this._signinDoneResolve();
|
|
4741
4330
|
this._subscribeChannels();
|
|
4742
|
-
}
|
|
4743
|
-
|
|
4744
|
-
|
|
4745
|
-
var ensure_subscribed = function (channel) {
|
|
4331
|
+
}
|
|
4332
|
+
_subscribeChannels() {
|
|
4333
|
+
const ensure_subscribed = channel => {
|
|
4746
4334
|
if (channel.subscriptionPending && channel.subscriptionCancelled) {
|
|
4747
4335
|
channel.reinstateSubscription();
|
|
4748
4336
|
}
|
|
4749
4337
|
else if (!channel.subscriptionPending &&
|
|
4750
|
-
|
|
4338
|
+
this.pusher.connection.state === 'connected') {
|
|
4751
4339
|
channel.subscribe();
|
|
4752
4340
|
}
|
|
4753
4341
|
};
|
|
4754
|
-
this.serverToUserChannel = new
|
|
4755
|
-
this.serverToUserChannel.bind_global(
|
|
4342
|
+
this.serverToUserChannel = new channel_Channel(`#server-to-user-${this.user_data.id}`, this.pusher);
|
|
4343
|
+
this.serverToUserChannel.bind_global((eventName, data) => {
|
|
4756
4344
|
if (eventName.indexOf('pusher_internal:') === 0 ||
|
|
4757
4345
|
eventName.indexOf('pusher:') === 0) {
|
|
4758
4346
|
return;
|
|
4759
4347
|
}
|
|
4760
|
-
|
|
4348
|
+
this.emit(eventName, data);
|
|
4761
4349
|
});
|
|
4762
4350
|
ensure_subscribed(this.serverToUserChannel);
|
|
4763
|
-
}
|
|
4764
|
-
|
|
4351
|
+
}
|
|
4352
|
+
_cleanup() {
|
|
4765
4353
|
this.user_data = null;
|
|
4766
4354
|
if (this.serverToUserChannel) {
|
|
4767
4355
|
this.serverToUserChannel.unbind_all();
|
|
@@ -4771,26 +4359,24 @@ var user_UserFacade = (function (_super) {
|
|
|
4771
4359
|
if (this.signin_requested) {
|
|
4772
4360
|
this._signinDoneResolve();
|
|
4773
4361
|
}
|
|
4774
|
-
}
|
|
4775
|
-
|
|
4362
|
+
}
|
|
4363
|
+
_newSigninPromiseIfNeeded() {
|
|
4776
4364
|
if (!this.signin_requested) {
|
|
4777
4365
|
return;
|
|
4778
4366
|
}
|
|
4779
4367
|
if (this.signinDonePromise && !this.signinDonePromise.done) {
|
|
4780
4368
|
return;
|
|
4781
4369
|
}
|
|
4782
|
-
|
|
4370
|
+
const { promise, resolve, reject: _ } = flat_promise();
|
|
4783
4371
|
promise.done = false;
|
|
4784
|
-
|
|
4372
|
+
const setDone = () => {
|
|
4785
4373
|
promise.done = true;
|
|
4786
4374
|
};
|
|
4787
|
-
promise.then(setDone)
|
|
4375
|
+
promise.then(setDone).catch(setDone);
|
|
4788
4376
|
this.signinDonePromise = promise;
|
|
4789
4377
|
this._signinDoneResolve = resolve;
|
|
4790
|
-
}
|
|
4791
|
-
|
|
4792
|
-
}(dispatcher));
|
|
4793
|
-
/* harmony default export */ var user = (user_UserFacade);
|
|
4378
|
+
}
|
|
4379
|
+
}
|
|
4794
4380
|
|
|
4795
4381
|
// CONCATENATED MODULE: ./src/core/pusher.ts
|
|
4796
4382
|
|
|
@@ -4806,19 +4392,29 @@ var user_UserFacade = (function (_super) {
|
|
|
4806
4392
|
|
|
4807
4393
|
|
|
4808
4394
|
|
|
4809
|
-
|
|
4810
|
-
|
|
4811
|
-
|
|
4395
|
+
class pusher_Pusher {
|
|
4396
|
+
static ready() {
|
|
4397
|
+
pusher_Pusher.isReady = true;
|
|
4398
|
+
for (var i = 0, l = pusher_Pusher.instances.length; i < l; i++) {
|
|
4399
|
+
pusher_Pusher.instances[i].connect();
|
|
4400
|
+
}
|
|
4401
|
+
}
|
|
4402
|
+
static getClientFeatures() {
|
|
4403
|
+
return keys(filterObject({ ws: runtime.Transports.ws }, function (t) {
|
|
4404
|
+
return t.isSupported({});
|
|
4405
|
+
}));
|
|
4406
|
+
}
|
|
4407
|
+
constructor(app_key, options) {
|
|
4812
4408
|
checkAppKey(app_key);
|
|
4813
4409
|
validateOptions(options);
|
|
4814
4410
|
this.key = app_key;
|
|
4815
4411
|
this.config = getConfig(options, this);
|
|
4816
4412
|
this.channels = factory.createChannels();
|
|
4817
|
-
this.global_emitter = new
|
|
4413
|
+
this.global_emitter = new dispatcher_Dispatcher();
|
|
4818
4414
|
this.sessionID = runtime.randomInt(1000000000);
|
|
4819
|
-
this.timeline = new
|
|
4415
|
+
this.timeline = new timeline_Timeline(this.key, this.sessionID, {
|
|
4820
4416
|
cluster: this.config.cluster,
|
|
4821
|
-
features:
|
|
4417
|
+
features: pusher_Pusher.getClientFeatures(),
|
|
4822
4418
|
params: this.config.timelineParams || {},
|
|
4823
4419
|
limit: 50,
|
|
4824
4420
|
level: timeline_level.INFO,
|
|
@@ -4830,8 +4426,8 @@ var pusher_Pusher = (function () {
|
|
|
4830
4426
|
path: '/timeline/v2/' + runtime.TimelineTransport.name
|
|
4831
4427
|
});
|
|
4832
4428
|
}
|
|
4833
|
-
var getStrategy =
|
|
4834
|
-
return runtime.getDefaultStrategy(
|
|
4429
|
+
var getStrategy = (options) => {
|
|
4430
|
+
return runtime.getDefaultStrategy(this.config, options, strategy_builder_defineTransport);
|
|
4835
4431
|
};
|
|
4836
4432
|
this.connection = factory.createConnectionManager(this.key, {
|
|
4837
4433
|
getStrategy: getStrategy,
|
|
@@ -4841,106 +4437,95 @@ var pusher_Pusher = (function () {
|
|
|
4841
4437
|
unavailableTimeout: this.config.unavailableTimeout,
|
|
4842
4438
|
useTLS: Boolean(this.config.useTLS)
|
|
4843
4439
|
});
|
|
4844
|
-
this.connection.bind('connected',
|
|
4845
|
-
|
|
4846
|
-
if (
|
|
4847
|
-
|
|
4440
|
+
this.connection.bind('connected', () => {
|
|
4441
|
+
this.subscribeAll();
|
|
4442
|
+
if (this.timelineSender) {
|
|
4443
|
+
this.timelineSender.send(this.connection.isUsingTLS());
|
|
4848
4444
|
}
|
|
4849
4445
|
});
|
|
4850
|
-
this.connection.bind('message',
|
|
4446
|
+
this.connection.bind('message', event => {
|
|
4851
4447
|
var eventName = event.event;
|
|
4852
4448
|
var internal = eventName.indexOf('pusher_internal:') === 0;
|
|
4853
4449
|
if (event.channel) {
|
|
4854
|
-
var channel =
|
|
4450
|
+
var channel = this.channel(event.channel);
|
|
4855
4451
|
if (channel) {
|
|
4856
4452
|
channel.handleEvent(event);
|
|
4857
4453
|
}
|
|
4858
4454
|
}
|
|
4859
4455
|
if (!internal) {
|
|
4860
|
-
|
|
4456
|
+
this.global_emitter.emit(event.event, event.data);
|
|
4861
4457
|
}
|
|
4862
4458
|
});
|
|
4863
|
-
this.connection.bind('connecting',
|
|
4864
|
-
|
|
4459
|
+
this.connection.bind('connecting', () => {
|
|
4460
|
+
this.channels.disconnect();
|
|
4865
4461
|
});
|
|
4866
|
-
this.connection.bind('disconnected',
|
|
4867
|
-
|
|
4462
|
+
this.connection.bind('disconnected', () => {
|
|
4463
|
+
this.channels.disconnect();
|
|
4868
4464
|
});
|
|
4869
|
-
this.connection.bind('error',
|
|
4465
|
+
this.connection.bind('error', err => {
|
|
4870
4466
|
logger.warn(err);
|
|
4871
4467
|
});
|
|
4872
|
-
|
|
4873
|
-
this.timeline.info({ instances:
|
|
4874
|
-
this.user = new
|
|
4875
|
-
if (
|
|
4468
|
+
pusher_Pusher.instances.push(this);
|
|
4469
|
+
this.timeline.info({ instances: pusher_Pusher.instances.length });
|
|
4470
|
+
this.user = new user_UserFacade(this);
|
|
4471
|
+
if (pusher_Pusher.isReady) {
|
|
4876
4472
|
this.connect();
|
|
4877
4473
|
}
|
|
4878
4474
|
}
|
|
4879
|
-
|
|
4880
|
-
Pusher.isReady = true;
|
|
4881
|
-
for (var i = 0, l = Pusher.instances.length; i < l; i++) {
|
|
4882
|
-
Pusher.instances[i].connect();
|
|
4883
|
-
}
|
|
4884
|
-
};
|
|
4885
|
-
Pusher.getClientFeatures = function () {
|
|
4886
|
-
return keys(filterObject({ ws: runtime.Transports.ws }, function (t) {
|
|
4887
|
-
return t.isSupported({});
|
|
4888
|
-
}));
|
|
4889
|
-
};
|
|
4890
|
-
Pusher.prototype.channel = function (name) {
|
|
4475
|
+
channel(name) {
|
|
4891
4476
|
return this.channels.find(name);
|
|
4892
|
-
}
|
|
4893
|
-
|
|
4477
|
+
}
|
|
4478
|
+
allChannels() {
|
|
4894
4479
|
return this.channels.all();
|
|
4895
|
-
}
|
|
4896
|
-
|
|
4480
|
+
}
|
|
4481
|
+
connect() {
|
|
4897
4482
|
this.connection.connect();
|
|
4898
4483
|
if (this.timelineSender) {
|
|
4899
4484
|
if (!this.timelineSenderTimer) {
|
|
4900
4485
|
var usingTLS = this.connection.isUsingTLS();
|
|
4901
4486
|
var timelineSender = this.timelineSender;
|
|
4902
|
-
this.timelineSenderTimer = new
|
|
4487
|
+
this.timelineSenderTimer = new timers_PeriodicTimer(60000, function () {
|
|
4903
4488
|
timelineSender.send(usingTLS);
|
|
4904
4489
|
});
|
|
4905
4490
|
}
|
|
4906
4491
|
}
|
|
4907
|
-
}
|
|
4908
|
-
|
|
4492
|
+
}
|
|
4493
|
+
disconnect() {
|
|
4909
4494
|
this.connection.disconnect();
|
|
4910
4495
|
if (this.timelineSenderTimer) {
|
|
4911
4496
|
this.timelineSenderTimer.ensureAborted();
|
|
4912
4497
|
this.timelineSenderTimer = null;
|
|
4913
4498
|
}
|
|
4914
|
-
}
|
|
4915
|
-
|
|
4499
|
+
}
|
|
4500
|
+
bind(event_name, callback, context) {
|
|
4916
4501
|
this.global_emitter.bind(event_name, callback, context);
|
|
4917
4502
|
return this;
|
|
4918
|
-
}
|
|
4919
|
-
|
|
4503
|
+
}
|
|
4504
|
+
unbind(event_name, callback, context) {
|
|
4920
4505
|
this.global_emitter.unbind(event_name, callback, context);
|
|
4921
4506
|
return this;
|
|
4922
|
-
}
|
|
4923
|
-
|
|
4507
|
+
}
|
|
4508
|
+
bind_global(callback) {
|
|
4924
4509
|
this.global_emitter.bind_global(callback);
|
|
4925
4510
|
return this;
|
|
4926
|
-
}
|
|
4927
|
-
|
|
4511
|
+
}
|
|
4512
|
+
unbind_global(callback) {
|
|
4928
4513
|
this.global_emitter.unbind_global(callback);
|
|
4929
4514
|
return this;
|
|
4930
|
-
}
|
|
4931
|
-
|
|
4515
|
+
}
|
|
4516
|
+
unbind_all(callback) {
|
|
4932
4517
|
this.global_emitter.unbind_all();
|
|
4933
4518
|
return this;
|
|
4934
|
-
}
|
|
4935
|
-
|
|
4519
|
+
}
|
|
4520
|
+
subscribeAll() {
|
|
4936
4521
|
var channelName;
|
|
4937
4522
|
for (channelName in this.channels.channels) {
|
|
4938
4523
|
if (this.channels.channels.hasOwnProperty(channelName)) {
|
|
4939
4524
|
this.subscribe(channelName);
|
|
4940
4525
|
}
|
|
4941
4526
|
}
|
|
4942
|
-
}
|
|
4943
|
-
|
|
4527
|
+
}
|
|
4528
|
+
subscribe(channel_name) {
|
|
4944
4529
|
var channel = this.channels.add(channel_name, this);
|
|
4945
4530
|
if (channel.subscriptionPending && channel.subscriptionCancelled) {
|
|
4946
4531
|
channel.reinstateSubscription();
|
|
@@ -4950,8 +4535,8 @@ var pusher_Pusher = (function () {
|
|
|
4950
4535
|
channel.subscribe();
|
|
4951
4536
|
}
|
|
4952
4537
|
return channel;
|
|
4953
|
-
}
|
|
4954
|
-
|
|
4538
|
+
}
|
|
4539
|
+
unsubscribe(channel_name) {
|
|
4955
4540
|
var channel = this.channels.find(channel_name);
|
|
4956
4541
|
if (channel && channel.subscriptionPending) {
|
|
4957
4542
|
channel.cancelSubscription();
|
|
@@ -4962,25 +4547,24 @@ var pusher_Pusher = (function () {
|
|
|
4962
4547
|
channel.unsubscribe();
|
|
4963
4548
|
}
|
|
4964
4549
|
}
|
|
4965
|
-
}
|
|
4966
|
-
|
|
4550
|
+
}
|
|
4551
|
+
send_event(event_name, data, channel) {
|
|
4967
4552
|
return this.connection.send_event(event_name, data, channel);
|
|
4968
|
-
}
|
|
4969
|
-
|
|
4553
|
+
}
|
|
4554
|
+
shouldUseTLS() {
|
|
4970
4555
|
return this.config.useTLS;
|
|
4971
|
-
}
|
|
4972
|
-
|
|
4556
|
+
}
|
|
4557
|
+
signin() {
|
|
4973
4558
|
this.user.signin();
|
|
4974
|
-
}
|
|
4975
|
-
|
|
4976
|
-
|
|
4977
|
-
|
|
4978
|
-
|
|
4979
|
-
|
|
4980
|
-
|
|
4981
|
-
|
|
4982
|
-
|
|
4983
|
-
}());
|
|
4559
|
+
}
|
|
4560
|
+
}
|
|
4561
|
+
pusher_Pusher.instances = [];
|
|
4562
|
+
pusher_Pusher.isReady = false;
|
|
4563
|
+
pusher_Pusher.logToConsole = false;
|
|
4564
|
+
pusher_Pusher.Runtime = runtime;
|
|
4565
|
+
pusher_Pusher.ScriptReceivers = runtime.ScriptReceivers;
|
|
4566
|
+
pusher_Pusher.DependenciesReceivers = runtime.DependenciesReceivers;
|
|
4567
|
+
pusher_Pusher.auth_callbacks = runtime.auth_callbacks;
|
|
4984
4568
|
/* harmony default export */ var core_pusher = __webpack_exports__["default"] = (pusher_Pusher);
|
|
4985
4569
|
function checkAppKey(key) {
|
|
4986
4570
|
if (key === null || key === undefined) {
|