/
pubnub.js
6830 lines (5471 loc) · 198 KB
/
pubnub.js
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
299
300
301
302
303
304
305
306
307
308
309
310
311
312
313
314
315
316
317
318
319
320
321
322
323
324
325
326
327
328
329
330
331
332
333
334
335
336
337
338
339
340
341
342
343
344
345
346
347
348
349
350
351
352
353
354
355
356
357
358
359
360
361
362
363
364
365
366
367
368
369
370
371
372
373
374
375
376
377
378
379
380
381
382
383
384
385
386
387
388
389
390
391
392
393
394
395
396
397
398
399
400
401
402
403
404
405
406
407
408
409
410
411
412
413
414
415
416
417
418
419
420
421
422
423
424
425
426
427
428
429
430
431
432
433
434
435
436
437
438
439
440
441
442
443
444
445
446
447
448
449
450
451
452
453
454
455
456
457
458
459
460
461
462
463
464
465
466
467
468
469
470
471
472
473
474
475
476
477
478
479
480
481
482
483
484
485
486
487
488
489
490
491
492
493
494
495
496
497
498
499
500
501
502
503
504
505
506
507
508
509
510
511
512
513
514
515
516
517
518
519
520
521
522
523
524
525
526
527
528
529
530
531
532
533
534
535
536
537
538
539
540
541
542
543
544
545
546
547
548
549
550
551
552
553
554
555
556
557
558
559
560
561
562
563
564
565
566
567
568
569
570
571
572
573
574
575
576
577
578
579
580
581
582
583
584
585
586
587
588
589
590
591
592
593
594
595
596
597
598
599
600
601
602
603
604
605
606
607
608
609
610
611
612
613
614
615
616
617
618
619
620
621
622
623
624
625
626
627
628
629
630
631
632
633
634
635
636
637
638
639
640
641
642
643
644
645
646
647
648
649
650
651
652
653
654
655
656
657
658
659
660
661
662
663
664
665
666
667
668
669
670
671
672
673
674
675
676
677
678
679
680
681
682
683
684
685
686
687
688
689
690
691
692
693
694
695
696
697
698
699
700
701
702
703
704
705
706
707
708
709
710
711
712
713
714
715
716
717
718
719
720
721
722
723
724
725
726
727
728
729
730
731
732
733
734
735
736
737
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
794
795
796
797
798
799
800
801
802
803
804
805
806
807
808
809
810
811
812
813
814
815
816
817
818
819
820
821
822
823
824
825
826
827
828
829
830
831
832
833
834
835
836
837
838
839
840
841
842
843
844
845
846
847
848
849
850
851
852
853
854
855
856
857
858
859
860
861
862
863
864
865
866
867
868
869
870
871
872
873
874
875
876
877
878
879
880
881
882
883
884
885
886
887
888
889
890
891
892
893
894
895
896
897
898
899
900
901
902
903
904
905
906
907
908
909
910
911
912
913
914
915
916
917
918
919
920
921
922
923
924
925
926
927
928
929
930
931
932
933
934
935
936
937
938
939
940
941
942
943
944
945
946
947
948
949
950
951
952
953
954
955
956
957
958
959
960
961
962
963
964
965
966
967
968
969
970
971
972
973
974
975
976
977
978
979
980
981
982
983
984
985
986
987
988
989
990
991
992
993
994
995
996
997
998
999
1000
/*! 4.21.5 / Consumer */
(function webpackUniversalModuleDefinition(root, factory) {
if(typeof exports === 'object' && typeof module === 'object')
module.exports = factory();
else if(typeof define === 'function' && define.amd)
define([], factory);
else if(typeof exports === 'object')
exports["PubNub"] = factory();
else
root["PubNub"] = factory();
})(this, function() {
return /******/ (function(modules) { // webpackBootstrap
/******/ // The module cache
/******/ var installedModules = {};
/******/ // The require function
/******/ function __webpack_require__(moduleId) {
/******/ // Check if module is in cache
/******/ if(installedModules[moduleId])
/******/ return installedModules[moduleId].exports;
/******/ // Create a new module (and put it into the cache)
/******/ var module = installedModules[moduleId] = {
/******/ exports: {},
/******/ id: moduleId,
/******/ loaded: false
/******/ };
/******/ // Execute the module function
/******/ modules[moduleId].call(module.exports, module, module.exports, __webpack_require__);
/******/ // Flag the module as loaded
/******/ module.loaded = true;
/******/ // Return the exports of the module
/******/ return module.exports;
/******/ }
/******/ // expose the modules object (__webpack_modules__)
/******/ __webpack_require__.m = modules;
/******/ // expose the module cache
/******/ __webpack_require__.c = installedModules;
/******/ // __webpack_public_path__
/******/ __webpack_require__.p = "";
/******/ // Load entry module and return exports
/******/ return __webpack_require__(0);
/******/ })
/************************************************************************/
/******/ ([
/* 0 */
/***/ (function(module, exports, __webpack_require__) {
'use strict';
Object.defineProperty(exports, "__esModule", {
value: true
});
var _pubnubCommon = __webpack_require__(1);
var _pubnubCommon2 = _interopRequireDefault(_pubnubCommon);
var _networking = __webpack_require__(39);
var _networking2 = _interopRequireDefault(_networking);
var _web = __webpack_require__(40);
var _web2 = _interopRequireDefault(_web);
var _webNode = __webpack_require__(41);
var _flow_interfaces = __webpack_require__(5);
function _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { default: obj }; }
function _classCallCheck(instance, Constructor) { if (!(instance instanceof Constructor)) { throw new TypeError("Cannot call a class as a function"); } }
function _possibleConstructorReturn(self, call) { if (!self) { throw new ReferenceError("this hasn't been initialised - super() hasn't been called"); } return call && (typeof call === "object" || typeof call === "function") ? call : self; }
function _inherits(subClass, superClass) { if (typeof superClass !== "function" && superClass !== null) { throw new TypeError("Super expression must either be null or a function, not " + typeof superClass); } subClass.prototype = Object.create(superClass && superClass.prototype, { constructor: { value: subClass, enumerable: false, writable: true, configurable: true } }); if (superClass) Object.setPrototypeOf ? Object.setPrototypeOf(subClass, superClass) : subClass.__proto__ = superClass; }
function sendBeacon(url) {
if (navigator && navigator.sendBeacon) {
navigator.sendBeacon(url);
} else {
return false;
}
}
var _class = function (_PubNubCore) {
_inherits(_class, _PubNubCore);
function _class(setup) {
_classCallCheck(this, _class);
var _setup$listenToBrowse = setup.listenToBrowserNetworkEvents,
listenToBrowserNetworkEvents = _setup$listenToBrowse === undefined ? true : _setup$listenToBrowse;
setup.db = _web2.default;
setup.sdkFamily = 'Web';
setup.networking = new _networking2.default({ del: _webNode.del, get: _webNode.get, post: _webNode.post, sendBeacon: sendBeacon });
var _this = _possibleConstructorReturn(this, (_class.__proto__ || Object.getPrototypeOf(_class)).call(this, setup));
if (listenToBrowserNetworkEvents) {
window.addEventListener('offline', function () {
_this.networkDownDetected();
});
window.addEventListener('online', function () {
_this.networkUpDetected();
});
}
return _this;
}
return _class;
}(_pubnubCommon2.default);
exports.default = _class;
module.exports = exports['default'];
/***/ }),
/* 1 */
/***/ (function(module, exports, __webpack_require__) {
'use strict';
Object.defineProperty(exports, "__esModule", {
value: true
});
var _createClass = function () { function defineProperties(target, props) { for (var i = 0; i < props.length; i++) { var descriptor = props[i]; descriptor.enumerable = descriptor.enumerable || false; descriptor.configurable = true; if ("value" in descriptor) descriptor.writable = true; Object.defineProperty(target, descriptor.key, descriptor); } } return function (Constructor, protoProps, staticProps) { if (protoProps) defineProperties(Constructor.prototype, protoProps); if (staticProps) defineProperties(Constructor, staticProps); return Constructor; }; }();
var _config = __webpack_require__(2);
var _config2 = _interopRequireDefault(_config);
var _index = __webpack_require__(6);
var _index2 = _interopRequireDefault(_index);
var _subscription_manager = __webpack_require__(8);
var _subscription_manager2 = _interopRequireDefault(_subscription_manager);
var _listener_manager = __webpack_require__(9);
var _listener_manager2 = _interopRequireDefault(_listener_manager);
var _endpoint = __webpack_require__(16);
var _endpoint2 = _interopRequireDefault(_endpoint);
var _add_channels = __webpack_require__(17);
var addChannelsChannelGroupConfig = _interopRequireWildcard(_add_channels);
var _remove_channels = __webpack_require__(18);
var removeChannelsChannelGroupConfig = _interopRequireWildcard(_remove_channels);
var _delete_group = __webpack_require__(19);
var deleteChannelGroupConfig = _interopRequireWildcard(_delete_group);
var _list_groups = __webpack_require__(20);
var listChannelGroupsConfig = _interopRequireWildcard(_list_groups);
var _list_channels = __webpack_require__(21);
var listChannelsInChannelGroupConfig = _interopRequireWildcard(_list_channels);
var _add_push_channels = __webpack_require__(22);
var addPushChannelsConfig = _interopRequireWildcard(_add_push_channels);
var _remove_push_channels = __webpack_require__(23);
var removePushChannelsConfig = _interopRequireWildcard(_remove_push_channels);
var _list_push_channels = __webpack_require__(24);
var listPushChannelsConfig = _interopRequireWildcard(_list_push_channels);
var _remove_device = __webpack_require__(25);
var removeDevicePushConfig = _interopRequireWildcard(_remove_device);
var _leave = __webpack_require__(26);
var presenceLeaveEndpointConfig = _interopRequireWildcard(_leave);
var _where_now = __webpack_require__(27);
var presenceWhereNowEndpointConfig = _interopRequireWildcard(_where_now);
var _heartbeat = __webpack_require__(28);
var presenceHeartbeatEndpointConfig = _interopRequireWildcard(_heartbeat);
var _get_state = __webpack_require__(29);
var presenceGetStateConfig = _interopRequireWildcard(_get_state);
var _set_state = __webpack_require__(30);
var presenceSetStateConfig = _interopRequireWildcard(_set_state);
var _here_now = __webpack_require__(31);
var presenceHereNowConfig = _interopRequireWildcard(_here_now);
var _audit = __webpack_require__(32);
var auditEndpointConfig = _interopRequireWildcard(_audit);
var _grant = __webpack_require__(33);
var grantEndpointConfig = _interopRequireWildcard(_grant);
var _publish = __webpack_require__(34);
var publishEndpointConfig = _interopRequireWildcard(_publish);
var _get_history = __webpack_require__(35);
var historyEndpointConfig = _interopRequireWildcard(_get_history);
var _delete_messages = __webpack_require__(36);
var deleteMessagesEndpointConfig = _interopRequireWildcard(_delete_messages);
var _fetch_messages = __webpack_require__(37);
var fetchMessagesEndpointConfig = _interopRequireWildcard(_fetch_messages);
var _time = __webpack_require__(12);
var timeEndpointConfig = _interopRequireWildcard(_time);
var _subscribe = __webpack_require__(38);
var subscribeEndpointConfig = _interopRequireWildcard(_subscribe);
var _operations = __webpack_require__(13);
var _operations2 = _interopRequireDefault(_operations);
var _categories = __webpack_require__(10);
var _categories2 = _interopRequireDefault(_categories);
var _flow_interfaces = __webpack_require__(5);
var _uuid = __webpack_require__(3);
var _uuid2 = _interopRequireDefault(_uuid);
function _interopRequireWildcard(obj) { if (obj && obj.__esModule) { return obj; } else { var newObj = {}; if (obj != null) { for (var key in obj) { if (Object.prototype.hasOwnProperty.call(obj, key)) newObj[key] = obj[key]; } } newObj.default = obj; return newObj; } }
function _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { default: obj }; }
function _classCallCheck(instance, Constructor) { if (!(instance instanceof Constructor)) { throw new TypeError("Cannot call a class as a function"); } }
var _class = function () {
function _class(setup) {
var _this = this;
_classCallCheck(this, _class);
var db = setup.db,
networking = setup.networking;
var config = this._config = new _config2.default({ setup: setup, db: db });
var crypto = new _index2.default({ config: config });
networking.init(config);
var modules = { config: config, networking: networking, crypto: crypto };
var timeEndpoint = _endpoint2.default.bind(this, modules, timeEndpointConfig);
var leaveEndpoint = _endpoint2.default.bind(this, modules, presenceLeaveEndpointConfig);
var heartbeatEndpoint = _endpoint2.default.bind(this, modules, presenceHeartbeatEndpointConfig);
var setStateEndpoint = _endpoint2.default.bind(this, modules, presenceSetStateConfig);
var subscribeEndpoint = _endpoint2.default.bind(this, modules, subscribeEndpointConfig);
var listenerManager = this._listenerManager = new _listener_manager2.default();
var subscriptionManager = new _subscription_manager2.default({
timeEndpoint: timeEndpoint,
leaveEndpoint: leaveEndpoint,
heartbeatEndpoint: heartbeatEndpoint,
setStateEndpoint: setStateEndpoint,
subscribeEndpoint: subscribeEndpoint,
crypto: modules.crypto,
config: modules.config,
listenerManager: listenerManager
});
this.addListener = listenerManager.addListener.bind(listenerManager);
this.removeListener = listenerManager.removeListener.bind(listenerManager);
this.removeAllListeners = listenerManager.removeAllListeners.bind(listenerManager);
this.channelGroups = {
listGroups: _endpoint2.default.bind(this, modules, listChannelGroupsConfig),
listChannels: _endpoint2.default.bind(this, modules, listChannelsInChannelGroupConfig),
addChannels: _endpoint2.default.bind(this, modules, addChannelsChannelGroupConfig),
removeChannels: _endpoint2.default.bind(this, modules, removeChannelsChannelGroupConfig),
deleteGroup: _endpoint2.default.bind(this, modules, deleteChannelGroupConfig)
};
this.push = {
addChannels: _endpoint2.default.bind(this, modules, addPushChannelsConfig),
removeChannels: _endpoint2.default.bind(this, modules, removePushChannelsConfig),
deleteDevice: _endpoint2.default.bind(this, modules, removeDevicePushConfig),
listChannels: _endpoint2.default.bind(this, modules, listPushChannelsConfig)
};
this.hereNow = _endpoint2.default.bind(this, modules, presenceHereNowConfig);
this.whereNow = _endpoint2.default.bind(this, modules, presenceWhereNowEndpointConfig);
this.getState = _endpoint2.default.bind(this, modules, presenceGetStateConfig);
this.setState = subscriptionManager.adaptStateChange.bind(subscriptionManager);
this.grant = _endpoint2.default.bind(this, modules, grantEndpointConfig);
this.audit = _endpoint2.default.bind(this, modules, auditEndpointConfig);
this.publish = _endpoint2.default.bind(this, modules, publishEndpointConfig);
this.fire = function (args, callback) {
args.replicate = false;
args.storeInHistory = false;
return _this.publish(args, callback);
};
this.history = _endpoint2.default.bind(this, modules, historyEndpointConfig);
this.deleteMessages = _endpoint2.default.bind(this, modules, deleteMessagesEndpointConfig);
this.fetchMessages = _endpoint2.default.bind(this, modules, fetchMessagesEndpointConfig);
this.time = timeEndpoint;
this.subscribe = subscriptionManager.adaptSubscribeChange.bind(subscriptionManager);
this.presence = subscriptionManager.adaptPresenceChange.bind(subscriptionManager);
this.unsubscribe = subscriptionManager.adaptUnsubscribeChange.bind(subscriptionManager);
this.disconnect = subscriptionManager.disconnect.bind(subscriptionManager);
this.reconnect = subscriptionManager.reconnect.bind(subscriptionManager);
this.destroy = function (isOffline) {
subscriptionManager.unsubscribeAll(isOffline);
subscriptionManager.disconnect();
};
this.stop = this.destroy;
this.unsubscribeAll = subscriptionManager.unsubscribeAll.bind(subscriptionManager);
this.getSubscribedChannels = subscriptionManager.getSubscribedChannels.bind(subscriptionManager);
this.getSubscribedChannelGroups = subscriptionManager.getSubscribedChannelGroups.bind(subscriptionManager);
this.encrypt = crypto.encrypt.bind(crypto);
this.decrypt = crypto.decrypt.bind(crypto);
this.getAuthKey = modules.config.getAuthKey.bind(modules.config);
this.setAuthKey = modules.config.setAuthKey.bind(modules.config);
this.setCipherKey = modules.config.setCipherKey.bind(modules.config);
this.getUUID = modules.config.getUUID.bind(modules.config);
this.setUUID = modules.config.setUUID.bind(modules.config);
this.getFilterExpression = modules.config.getFilterExpression.bind(modules.config);
this.setFilterExpression = modules.config.setFilterExpression.bind(modules.config);
this.setHeartbeatInterval = modules.config.setHeartbeatInterval.bind(modules.config);
if (networking.hasModule('proxy')) {
this.setProxy = function (proxy) {
modules.config.setProxy(proxy);
_this.reconnect();
};
}
}
_createClass(_class, [{
key: 'getVersion',
value: function getVersion() {
return this._config.getVersion();
}
}, {
key: 'networkDownDetected',
value: function networkDownDetected() {
this._listenerManager.announceNetworkDown();
if (this._config.restore) {
this.disconnect();
} else {
this.destroy(true);
}
}
}, {
key: 'networkUpDetected',
value: function networkUpDetected() {
this._listenerManager.announceNetworkUp();
this.reconnect();
}
}], [{
key: 'generateUUID',
value: function generateUUID() {
return _uuid2.default.createUUID();
}
}]);
return _class;
}();
_class.OPERATIONS = _operations2.default;
_class.CATEGORIES = _categories2.default;
exports.default = _class;
module.exports = exports['default'];
/***/ }),
/* 2 */
/***/ (function(module, exports, __webpack_require__) {
'use strict';
Object.defineProperty(exports, "__esModule", {
value: true
});
var _createClass = function () { function defineProperties(target, props) { for (var i = 0; i < props.length; i++) { var descriptor = props[i]; descriptor.enumerable = descriptor.enumerable || false; descriptor.configurable = true; if ("value" in descriptor) descriptor.writable = true; Object.defineProperty(target, descriptor.key, descriptor); } } return function (Constructor, protoProps, staticProps) { if (protoProps) defineProperties(Constructor.prototype, protoProps); if (staticProps) defineProperties(Constructor, staticProps); return Constructor; }; }();
var _uuid = __webpack_require__(3);
var _uuid2 = _interopRequireDefault(_uuid);
var _flow_interfaces = __webpack_require__(5);
function _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { default: obj }; }
function _classCallCheck(instance, Constructor) { if (!(instance instanceof Constructor)) { throw new TypeError("Cannot call a class as a function"); } }
var _class = function () {
function _class(_ref) {
var setup = _ref.setup,
db = _ref.db;
_classCallCheck(this, _class);
this._db = db;
this.instanceId = 'pn-' + _uuid2.default.createUUID();
this.secretKey = setup.secretKey || setup.secret_key;
this.subscribeKey = setup.subscribeKey || setup.subscribe_key;
this.publishKey = setup.publishKey || setup.publish_key;
this.sdkName = setup.sdkName;
this.sdkFamily = setup.sdkFamily;
this.partnerId = setup.partnerId;
this.setAuthKey(setup.authKey);
this.setCipherKey(setup.cipherKey);
this.setFilterExpression(setup.filterExpression);
this.origin = setup.origin || 'pubsub.pndsn.com';
this.secure = setup.ssl || false;
this.restore = setup.restore || false;
this.proxy = setup.proxy;
this.keepAlive = setup.keepAlive;
this.keepAliveSettings = setup.keepAliveSettings;
this.autoNetworkDetection = setup.autoNetworkDetection || false;
this.dedupeOnSubscribe = setup.dedupeOnSubscribe || false;
this.maximumCacheSize = setup.maximumCacheSize || 100;
this.customEncrypt = setup.customEncrypt;
this.customDecrypt = setup.customDecrypt;
if (typeof location !== 'undefined' && location.protocol === 'https:') {
this.secure = true;
}
this.logVerbosity = setup.logVerbosity || false;
this.suppressLeaveEvents = setup.suppressLeaveEvents || false;
this.announceFailedHeartbeats = setup.announceFailedHeartbeats || true;
this.announceSuccessfulHeartbeats = setup.announceSuccessfulHeartbeats || false;
this.useInstanceId = setup.useInstanceId || false;
this.useRequestId = setup.useRequestId || false;
this.requestMessageCountThreshold = setup.requestMessageCountThreshold;
this.setTransactionTimeout(setup.transactionalRequestTimeout || 15 * 1000);
this.setSubscribeTimeout(setup.subscribeRequestTimeout || 310 * 1000);
this.setSendBeaconConfig(setup.useSendBeacon || true);
this.setPresenceTimeout(setup.presenceTimeout || 300);
if (setup.heartbeatInterval != null) {
this.setHeartbeatInterval(setup.heartbeatInterval);
}
this.setUUID(this._decideUUID(setup.uuid));
}
_createClass(_class, [{
key: 'getAuthKey',
value: function getAuthKey() {
return this.authKey;
}
}, {
key: 'setAuthKey',
value: function setAuthKey(val) {
this.authKey = val;return this;
}
}, {
key: 'setCipherKey',
value: function setCipherKey(val) {
this.cipherKey = val;return this;
}
}, {
key: 'getUUID',
value: function getUUID() {
return this.UUID;
}
}, {
key: 'setUUID',
value: function setUUID(val) {
if (this._db && this._db.set) this._db.set(this.subscribeKey + 'uuid', val);
this.UUID = val;
return this;
}
}, {
key: 'getFilterExpression',
value: function getFilterExpression() {
return this.filterExpression;
}
}, {
key: 'setFilterExpression',
value: function setFilterExpression(val) {
this.filterExpression = val;return this;
}
}, {
key: 'getPresenceTimeout',
value: function getPresenceTimeout() {
return this._presenceTimeout;
}
}, {
key: 'setPresenceTimeout',
value: function setPresenceTimeout(val) {
this._presenceTimeout = val;
this.setHeartbeatInterval(this._presenceTimeout / 2 - 1);
return this;
}
}, {
key: 'setProxy',
value: function setProxy(proxy) {
this.proxy = proxy;
}
}, {
key: 'getHeartbeatInterval',
value: function getHeartbeatInterval() {
return this._heartbeatInterval;
}
}, {
key: 'setHeartbeatInterval',
value: function setHeartbeatInterval(val) {
this._heartbeatInterval = val;return this;
}
}, {
key: 'getSubscribeTimeout',
value: function getSubscribeTimeout() {
return this._subscribeRequestTimeout;
}
}, {
key: 'setSubscribeTimeout',
value: function setSubscribeTimeout(val) {
this._subscribeRequestTimeout = val;return this;
}
}, {
key: 'getTransactionTimeout',
value: function getTransactionTimeout() {
return this._transactionalRequestTimeout;
}
}, {
key: 'setTransactionTimeout',
value: function setTransactionTimeout(val) {
this._transactionalRequestTimeout = val;return this;
}
}, {
key: 'isSendBeaconEnabled',
value: function isSendBeaconEnabled() {
return this._useSendBeacon;
}
}, {
key: 'setSendBeaconConfig',
value: function setSendBeaconConfig(val) {
this._useSendBeacon = val;return this;
}
}, {
key: 'getVersion',
value: function getVersion() {
return '4.21.5';
}
}, {
key: '_decideUUID',
value: function _decideUUID(providedUUID) {
if (providedUUID) {
return providedUUID;
}
if (this._db && this._db.get && this._db.get(this.subscribeKey + 'uuid')) {
return this._db.get(this.subscribeKey + 'uuid');
}
return 'pn-' + _uuid2.default.createUUID();
}
}]);
return _class;
}();
exports.default = _class;
module.exports = exports['default'];
/***/ }),
/* 3 */
/***/ (function(module, exports, __webpack_require__) {
'use strict';
Object.defineProperty(exports, "__esModule", {
value: true
});
var _lilUuid = __webpack_require__(4);
var _lilUuid2 = _interopRequireDefault(_lilUuid);
function _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { default: obj }; }
exports.default = {
createUUID: function createUUID() {
if (_lilUuid2.default.uuid) {
return _lilUuid2.default.uuid();
} else {
return (0, _lilUuid2.default)();
}
}
};
module.exports = exports['default'];
/***/ }),
/* 4 */
/***/ (function(module, exports, __webpack_require__) {
var __WEBPACK_AMD_DEFINE_FACTORY__, __WEBPACK_AMD_DEFINE_ARRAY__, __WEBPACK_AMD_DEFINE_RESULT__;/*! lil-uuid - v0.1 - MIT License - https://github.com/lil-js/uuid */
(function (root, factory) {
if (true) {
!(__WEBPACK_AMD_DEFINE_ARRAY__ = [exports], __WEBPACK_AMD_DEFINE_FACTORY__ = (factory), __WEBPACK_AMD_DEFINE_RESULT__ = (typeof __WEBPACK_AMD_DEFINE_FACTORY__ === 'function' ? (__WEBPACK_AMD_DEFINE_FACTORY__.apply(exports, __WEBPACK_AMD_DEFINE_ARRAY__)) : __WEBPACK_AMD_DEFINE_FACTORY__), __WEBPACK_AMD_DEFINE_RESULT__ !== undefined && (module.exports = __WEBPACK_AMD_DEFINE_RESULT__))
} else if (typeof exports === 'object') {
factory(exports)
if (typeof module === 'object' && module !== null) {
module.exports = exports.uuid
}
} else {
factory((root.lil = root.lil || {}))
}
}(this, function (exports) {
var VERSION = '0.1.0'
var uuidRegex = {
'3': /^[0-9A-F]{8}-[0-9A-F]{4}-3[0-9A-F]{3}-[0-9A-F]{4}-[0-9A-F]{12}$/i,
'4': /^[0-9A-F]{8}-[0-9A-F]{4}-4[0-9A-F]{3}-[89AB][0-9A-F]{3}-[0-9A-F]{12}$/i,
'5': /^[0-9A-F]{8}-[0-9A-F]{4}-5[0-9A-F]{3}-[89AB][0-9A-F]{3}-[0-9A-F]{12}$/i,
all: /^[0-9A-F]{8}-[0-9A-F]{4}-[0-9A-F]{4}-[0-9A-F]{4}-[0-9A-F]{12}$/i
}
function uuid() {
var uuid = '', i, random
for (i = 0; i < 32; i++) {
random = Math.random() * 16 | 0;
if (i === 8 || i === 12 || i === 16 || i === 20) uuid += '-'
uuid += (i === 12 ? 4 : (i === 16 ? (random & 3 | 8) : random)).toString(16)
}
return uuid
}
function isUUID(str, version) {
var pattern = uuidRegex[version || 'all']
return pattern && pattern.test(str) || false
}
uuid.isUUID = isUUID
uuid.VERSION = VERSION
exports.uuid = uuid
exports.isUUID = isUUID
}));
/***/ }),
/* 5 */
/***/ (function(module, exports) {
'use strict';
module.exports = {};
/***/ }),
/* 6 */
/***/ (function(module, exports, __webpack_require__) {
'use strict';
Object.defineProperty(exports, "__esModule", {
value: true
});
var _createClass = function () { function defineProperties(target, props) { for (var i = 0; i < props.length; i++) { var descriptor = props[i]; descriptor.enumerable = descriptor.enumerable || false; descriptor.configurable = true; if ("value" in descriptor) descriptor.writable = true; Object.defineProperty(target, descriptor.key, descriptor); } } return function (Constructor, protoProps, staticProps) { if (protoProps) defineProperties(Constructor.prototype, protoProps); if (staticProps) defineProperties(Constructor, staticProps); return Constructor; }; }();
var _config = __webpack_require__(2);
var _config2 = _interopRequireDefault(_config);
var _hmacSha = __webpack_require__(7);
var _hmacSha2 = _interopRequireDefault(_hmacSha);
function _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { default: obj }; }
function _classCallCheck(instance, Constructor) { if (!(instance instanceof Constructor)) { throw new TypeError("Cannot call a class as a function"); } }
var _class = function () {
function _class(_ref) {
var config = _ref.config;
_classCallCheck(this, _class);
this._config = config;
this._iv = '0123456789012345';
this._allowedKeyEncodings = ['hex', 'utf8', 'base64', 'binary'];
this._allowedKeyLengths = [128, 256];
this._allowedModes = ['ecb', 'cbc'];
this._defaultOptions = {
encryptKey: true,
keyEncoding: 'utf8',
keyLength: 256,
mode: 'cbc'
};
}
_createClass(_class, [{
key: 'HMACSHA256',
value: function HMACSHA256(data) {
var hash = _hmacSha2.default.HmacSHA256(data, this._config.secretKey);
return hash.toString(_hmacSha2.default.enc.Base64);
}
}, {
key: 'SHA256',
value: function SHA256(s) {
return _hmacSha2.default.SHA256(s).toString(_hmacSha2.default.enc.Hex);
}
}, {
key: '_parseOptions',
value: function _parseOptions(incomingOptions) {
var options = incomingOptions || {};
if (!options.hasOwnProperty('encryptKey')) options.encryptKey = this._defaultOptions.encryptKey;
if (!options.hasOwnProperty('keyEncoding')) options.keyEncoding = this._defaultOptions.keyEncoding;
if (!options.hasOwnProperty('keyLength')) options.keyLength = this._defaultOptions.keyLength;
if (!options.hasOwnProperty('mode')) options.mode = this._defaultOptions.mode;
if (this._allowedKeyEncodings.indexOf(options.keyEncoding.toLowerCase()) === -1) {
options.keyEncoding = this._defaultOptions.keyEncoding;
}
if (this._allowedKeyLengths.indexOf(parseInt(options.keyLength, 10)) === -1) {
options.keyLength = this._defaultOptions.keyLength;
}
if (this._allowedModes.indexOf(options.mode.toLowerCase()) === -1) {
options.mode = this._defaultOptions.mode;
}
return options;
}
}, {
key: '_decodeKey',
value: function _decodeKey(key, options) {
if (options.keyEncoding === 'base64') {
return _hmacSha2.default.enc.Base64.parse(key);
} else if (options.keyEncoding === 'hex') {
return _hmacSha2.default.enc.Hex.parse(key);
} else {
return key;
}
}
}, {
key: '_getPaddedKey',
value: function _getPaddedKey(key, options) {
key = this._decodeKey(key, options);
if (options.encryptKey) {
return _hmacSha2.default.enc.Utf8.parse(this.SHA256(key).slice(0, 32));
} else {
return key;
}
}
}, {
key: '_getMode',
value: function _getMode(options) {
if (options.mode === 'ecb') {
return _hmacSha2.default.mode.ECB;
} else {
return _hmacSha2.default.mode.CBC;
}
}
}, {
key: '_getIV',
value: function _getIV(options) {
return options.mode === 'cbc' ? _hmacSha2.default.enc.Utf8.parse(this._iv) : null;
}
}, {
key: 'encrypt',
value: function encrypt(data, customCipherKey, options) {
if (this._config.customEncrypt) {
return this._config.customEncrypt(data);
} else {
return this.pnEncrypt(data, customCipherKey, options);
}
}
}, {
key: 'decrypt',
value: function decrypt(data, customCipherKey, options) {
if (this._config.customDecrypt) {
return this._config.customDecrypt(data);
} else {
return this.pnDecrypt(data, customCipherKey, options);
}
}
}, {
key: 'pnEncrypt',
value: function pnEncrypt(data, customCipherKey, options) {
if (!customCipherKey && !this._config.cipherKey) return data;
options = this._parseOptions(options);
var iv = this._getIV(options);
var mode = this._getMode(options);
var cipherKey = this._getPaddedKey(customCipherKey || this._config.cipherKey, options);
var encryptedHexArray = _hmacSha2.default.AES.encrypt(data, cipherKey, { iv: iv, mode: mode }).ciphertext;
var base64Encrypted = encryptedHexArray.toString(_hmacSha2.default.enc.Base64);
return base64Encrypted || data;
}
}, {
key: 'pnDecrypt',
value: function pnDecrypt(data, customCipherKey, options) {
if (!customCipherKey && !this._config.cipherKey) return data;
options = this._parseOptions(options);
var iv = this._getIV(options);
var mode = this._getMode(options);
var cipherKey = this._getPaddedKey(customCipherKey || this._config.cipherKey, options);
try {
var ciphertext = _hmacSha2.default.enc.Base64.parse(data);
var plainJSON = _hmacSha2.default.AES.decrypt({ ciphertext: ciphertext }, cipherKey, { iv: iv, mode: mode }).toString(_hmacSha2.default.enc.Utf8);
var plaintext = JSON.parse(plainJSON);
return plaintext;
} catch (e) {
return null;
}
}
}]);
return _class;
}();
exports.default = _class;
module.exports = exports['default'];
/***/ }),
/* 7 */
/***/ (function(module, exports) {
"use strict";
var CryptoJS = CryptoJS || function (h, s) {
var f = {},
g = f.lib = {},
q = function q() {},
m = g.Base = { extend: function extend(a) {
q.prototype = this;var c = new q();a && c.mixIn(a);c.hasOwnProperty("init") || (c.init = function () {
c.$super.init.apply(this, arguments);
});c.init.prototype = c;c.$super = this;return c;
}, create: function create() {
var a = this.extend();a.init.apply(a, arguments);return a;
}, init: function init() {}, mixIn: function mixIn(a) {
for (var c in a) {
a.hasOwnProperty(c) && (this[c] = a[c]);
}a.hasOwnProperty("toString") && (this.toString = a.toString);
}, clone: function clone() {
return this.init.prototype.extend(this);
} },
r = g.WordArray = m.extend({ init: function init(a, c) {
a = this.words = a || [];this.sigBytes = c != s ? c : 4 * a.length;
}, toString: function toString(a) {
return (a || k).stringify(this);
}, concat: function concat(a) {
var c = this.words,
d = a.words,
b = this.sigBytes;a = a.sigBytes;this.clamp();if (b % 4) for (var e = 0; e < a; e++) {
c[b + e >>> 2] |= (d[e >>> 2] >>> 24 - 8 * (e % 4) & 255) << 24 - 8 * ((b + e) % 4);
} else if (65535 < d.length) for (e = 0; e < a; e += 4) {
c[b + e >>> 2] = d[e >>> 2];
} else c.push.apply(c, d);this.sigBytes += a;return this;
}, clamp: function clamp() {
var a = this.words,
c = this.sigBytes;a[c >>> 2] &= 4294967295 << 32 - 8 * (c % 4);a.length = h.ceil(c / 4);
}, clone: function clone() {
var a = m.clone.call(this);a.words = this.words.slice(0);return a;
}, random: function random(a) {
for (var c = [], d = 0; d < a; d += 4) {
c.push(4294967296 * h.random() | 0);
}return new r.init(c, a);
} }),
l = f.enc = {},
k = l.Hex = { stringify: function stringify(a) {
var c = a.words;a = a.sigBytes;for (var d = [], b = 0; b < a; b++) {
var e = c[b >>> 2] >>> 24 - 8 * (b % 4) & 255;d.push((e >>> 4).toString(16));d.push((e & 15).toString(16));
}return d.join("");
}, parse: function parse(a) {
for (var c = a.length, d = [], b = 0; b < c; b += 2) {
d[b >>> 3] |= parseInt(a.substr(b, 2), 16) << 24 - 4 * (b % 8);
}return new r.init(d, c / 2);
} },
n = l.Latin1 = { stringify: function stringify(a) {
var c = a.words;a = a.sigBytes;for (var d = [], b = 0; b < a; b++) {
d.push(String.fromCharCode(c[b >>> 2] >>> 24 - 8 * (b % 4) & 255));
}return d.join("");
}, parse: function parse(a) {
for (var c = a.length, d = [], b = 0; b < c; b++) {
d[b >>> 2] |= (a.charCodeAt(b) & 255) << 24 - 8 * (b % 4);
}return new r.init(d, c);
} },
j = l.Utf8 = { stringify: function stringify(a) {
try {
return decodeURIComponent(escape(n.stringify(a)));
} catch (c) {
throw Error("Malformed UTF-8 data");
}
}, parse: function parse(a) {
return n.parse(unescape(encodeURIComponent(a)));
} },
u = g.BufferedBlockAlgorithm = m.extend({ reset: function reset() {
this._data = new r.init();this._nDataBytes = 0;
}, _append: function _append(a) {
"string" == typeof a && (a = j.parse(a));this._data.concat(a);this._nDataBytes += a.sigBytes;
}, _process: function _process(a) {
var c = this._data,
d = c.words,
b = c.sigBytes,
e = this.blockSize,
f = b / (4 * e),
f = a ? h.ceil(f) : h.max((f | 0) - this._minBufferSize, 0);a = f * e;b = h.min(4 * a, b);if (a) {
for (var g = 0; g < a; g += e) {
this._doProcessBlock(d, g);
}g = d.splice(0, a);c.sigBytes -= b;
}return new r.init(g, b);
}, clone: function clone() {
var a = m.clone.call(this);
a._data = this._data.clone();return a;
}, _minBufferSize: 0 });g.Hasher = u.extend({ cfg: m.extend(), init: function init(a) {
this.cfg = this.cfg.extend(a);this.reset();
}, reset: function reset() {
u.reset.call(this);this._doReset();
}, update: function update(a) {
this._append(a);this._process();return this;
}, finalize: function finalize(a) {
a && this._append(a);return this._doFinalize();
}, blockSize: 16, _createHelper: function _createHelper(a) {
return function (c, d) {
return new a.init(d).finalize(c);
};
}, _createHmacHelper: function _createHmacHelper(a) {
return function (c, d) {
return new t.HMAC.init(a, d).finalize(c);
};
} });var t = f.algo = {};return f;
}(Math);
(function (h) {
for (var s = CryptoJS, f = s.lib, g = f.WordArray, q = f.Hasher, f = s.algo, m = [], r = [], l = function l(a) {
return 4294967296 * (a - (a | 0)) | 0;
}, k = 2, n = 0; 64 > n;) {